:root {
  --bg-0: #0b0e12;
  --bg-1: #101826;
  --bg-2: #121e2f;
  --accent: #22d3ee;
  --accent-strong: #06b6d4;
  --accent-soft: #0ea5e9;
  --card: rgba(15, 23, 42, 0.6);
  --stroke: rgba(148, 163, 184, 0.15);
  --sidebar: rgba(8, 12, 20, 0.95);
  --topbar: rgba(10, 16, 26, 0.95);
}

body {
  font-family: "Roboto", sans-serif;
  background: radial-gradient(circle at 10% 10%, rgba(34, 211, 238, 0.15), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.2), transparent 35%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  color: #e2e8f0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(14, 165, 233, 0.12), transparent 40%);
  pointer-events: none;
  z-index: -1;
}

.glass {
  background: var(--card);
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 35px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(12px);
}

.text-gradient {
  background: linear-gradient(135deg, #22d3ee, #38bdf8, #a5f3fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.glow {
  box-shadow: 0 0 25px rgba(34, 211, 238, 0.4);
}

.nav-active {
  background: rgba(14, 165, 233, 0.15);
  border-left: 3px solid var(--accent);
}

.chart-wrap {
  height: 16rem;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.design-element {
  position: absolute;
  border: 1px dashed rgba(148, 163, 184, 0.6);
  padding: 6px;
  cursor: move;
  user-select: none;
}

.design-element.selected {
  border-color: rgba(34, 211, 238, 0.9);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.25);
}

.design-text-input {
  position: absolute;
  z-index: 20;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(34, 211, 238, 0.5);
  color: #e2e8f0;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 16px;
}

.design-layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.6);
}

.design-layer-item.active {
  border-color: rgba(34, 211, 238, 0.7);
  background: rgba(14, 165, 233, 0.15);
}

.design-stage {
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 20px 20px;
}

.crop-stage {
  background: rgba(2, 6, 12, 0.7);
}

.design-guide {
  position: absolute;
  background: rgba(34, 211, 238, 0.7);
  pointer-events: none;
  z-index: 15;
}

.design-guide.h {
  height: 1px;
  width: 100%;
}

.design-guide.v {
  width: 1px;
  height: 100%;
}

.design-rotate-handle {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #0f172a;
  cursor: grab;
}

.design-rotate-line {
  position: absolute;
  top: -22px;
  left: 50%;
  width: 2px;
  height: 18px;
  background: rgba(56, 189, 248, 0.8);
  transform: translateX(-50%);
}

.design-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #22d3ee;
  border-radius: 50%;
  border: 2px solid #0f172a;
}

.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-n { top: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-e { top: 50%; right: -6px; transform: translateY(-50%); cursor: ew-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.handle-s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-w { top: 50%; left: -6px; transform: translateY(-50%); cursor: ew-resize; }

.crop-frame {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(34, 211, 238, 0.6);
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(4, 8, 14, 0.45);
}

#cropCanvas,
#bgCanvas {
  display: block;
  transform-origin: top left;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 72px 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
}

.app-topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--topbar);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
}

.app-sidebar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
  overflow-y: auto;
}

.app-main {
  grid-area: main;
  padding: 28px 32px 40px;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 72px auto;
    grid-template-areas:
      "topbar"
      "main";
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    height: 100vh;
    width: min(82vw, 320px);
    z-index: 60;
    border-right: 1px solid var(--stroke);
    border-bottom: none;
    transition: left 0.25s ease;
  }

  .app-main {
    padding: 24px;
  }

  body.sidebar-open .app-sidebar {
    left: 0;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.7);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}
