* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column; /* stack top bar + app */
}

/* ================= TOP BAR ================= */
#topBar {
  height: 32px;
  background: linear-gradient(145deg,#f0f0f0,#e5e5e5);
  display: flex;
  align-items: center;
  padding: 0 12px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.15), 0 0 0 1px rgba(255,255,255,0.05) inset;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
}

#topBar .menu {
  display: flex;
  gap: 12px;
}

#topBar .menu-item {
  position: relative;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}

#topBar .menu-item:hover {
  background: rgba(33,150,243,0.1);
}

#topBar .menu-item .dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 120px;
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-radius: 4px;
  z-index: 1001;
  flex-direction: column;
}

#topBar .menu-item:hover .dropdown {
  display: flex;
}

#topBar .dropdown div {
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.12s;
}

#topBar .dropdown div:hover {
  background: rgba(33,150,243,0.1);
}

/* Project Modal */
#projectModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  font-weight: 500;
}

/* App layout */
#app {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Tools panel */
#tools {
  width: 60px;
  background: #2f2f2f;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool {
  background: linear-gradient(145deg,#4d4d4d,#3c3c3c);
  color: white;
  border: none;
  padding: 10px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.18s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.tool.active {
  background: linear-gradient(145deg,#4fc3f7,#2196f3);
  box-shadow: 0 4px 10px rgba(33,150,243,0.4);
}
.tool:hover { transform: scale(1.08); }

/* Main layout */
#main {
  flex: 1;
  display: flex;
  overflow: hidden;
}
#left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Canvas */
#canvas-wrap {
  flex: 1;
  background: #888;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px;
}
#canvas-transform { transform-origin: 0 0; }
canvas {
  background: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  border-radius: 6px;
}

/* Timeline */
#timeline-wrap {
  height: 210px;
  background: linear-gradient(to top, #f8f8f8, #e8e8e8);
  border-top: 1px solid #bbb;
  display: flex;
  flex-direction: column;
}
#timeline {
  flex: 1;
  overflow-x: auto;
  white-space: nowrap;
  padding: 4px 2px;
}
.timeline-row { display: flex; min-width: max-content; margin-bottom: 3px; }
.layer-name {
  width: 120px;
  background: #e0e0e0;
  padding: 5px;
  border-radius: 5px 0 0 5px;
  user-select: none;
  font-weight: 600;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1);
}

.frame {
  width: 36px;
  height: 28px;
  border-radius: 6px;
  margin-left: 2px;
  border: 1px solid #aaa;
  transition: all 0.12s ease;
  cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}
.frame.key {
  background: #fff;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}
.frame.hold { background: #d2d2d2; }
.frame.empty { background: #bbb; }
.frame.active { outline: 2px solid #2196f3; outline-offset: -2px; }
.frame:hover { transform: scale(1.08); border-color: #999; }

/* Right panel */
#right-panel {
  width: 210px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #bbb;
  background: #fafafa;
}
#properties-panel, #layers-panel {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}
.layer-item {
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 3px;
  cursor: pointer;
  transition: all 0.12s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}
.layer-item.active { background: #2196f3; color: white; box-shadow: 0 2px 6px rgba(33,150,243,0.3); }
.layer-item:hover { background: #d4eaff; }

.layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  cursor: pointer;
}

.layer-item span {
  flex: 1;
}

.layer-item {
  user-select: none;
}

/* Context menu */
#frameMenu {
  position: absolute;
  background: #2c2c2c;
  color: #f2f2f2;
  display: none;
  z-index: 10000;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
#frameMenu div {
  padding: 7px 14px;
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.12s ease;
}
#frameMenu div:hover { background: #444; }

#canvas-wrap {
  overflow: hidden;
}

#canvas-transform {
  will-change: transform;
}
.frame.preview {
    outline: 2px dashed #00f;
}
.shape-grid {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  gap: 8px;
  margin-top: 8px;
}

.shape-option {
  width: 48px;
  height: 48px;
  border: 2px solid #444;
  border-radius: 6px;
  cursor: pointer;
  background: #222;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shape-option.active {
  border-color: #4da3ff;
  background: #2a3a4a;
}
