/* ==========================================================================
   NOVA PhotoStudio Pro — design system
   Dark-first, high-density, keyboard-aware. Two themes, no external fonts.
   ========================================================================== */

:root {
  --bg: #07080c;
  --bg-1: #0b0d13;
  --bg-2: #10131b;
  --bg-3: #151925;
  --bg-4: #1b2030;
  --panel: #0d1017;
  --panel-2: #12151f;
  --line: rgba(150, 170, 210, 0.11);
  --line-strong: rgba(160, 180, 220, 0.2);
  --text: #edf1fa;
  --text-2: #a7b1c7;
  --text-3: #6f7a91;
  --accent: #8b7cff;
  --accent-2: #45d6ff;
  --accent-soft: rgba(139, 124, 255, 0.16);
  --accent-line: rgba(139, 124, 255, 0.42);
  --success: #37d39b;
  --warn: #ffc857;
  --danger: #ff5c72;
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
  --shadow-md: 0 14px 40px -16px rgba(0, 0, 0, 0.7);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  --radius-xs: 7px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --checker: repeating-conic-gradient(#20232c 0% 25%, #171a22 0% 50%) 50% / 16px 16px;
}

[data-theme="light"] {
  --bg: #eef1f7;
  --bg-1: #f6f8fc;
  --bg-2: #ffffff;
  --bg-3: #f0f3f9;
  --bg-4: #e7ebf3;
  --panel: #ffffff;
  --panel-2: #f7f9fd;
  --line: rgba(18, 30, 55, 0.1);
  --line-strong: rgba(18, 30, 55, 0.18);
  --text: #111828;
  --text-2: #4b566e;
  --text-3: #7b869d;
  --accent: #5b48e8;
  --accent-2: #0d9fc4;
  --accent-soft: rgba(91, 72, 232, 0.1);
  --accent-line: rgba(91, 72, 232, 0.3);
  --shadow-lg: 0 30px 70px -26px rgba(24, 36, 66, 0.35);
  --shadow-md: 0 14px 34px -18px rgba(24, 36, 66, 0.3);
  --shadow-sm: 0 3px 10px rgba(24, 36, 66, 0.09);
  --checker: repeating-conic-gradient(#e6eaf3 0% 25%, #f7f9fd 0% 50%) 50% / 16px 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overflow: hidden; }

#app { height: 100%; }
#app.app { height: 100%; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent-soft); color: var(--text); }

h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.icon-wrap { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon { display: block; }

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-2);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 6px;
  padding: 3px 6px;
  white-space: nowrap;
}

.dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--text-3); display: inline-block; flex: none;
}

.panel-hint {
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.55;
  padding: 10px 2px 2px;
}

.is-hidden { display: none !important; }

/* Scrollbars ------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); background-clip: padding-box; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  font-weight: 560;
  font-size: 13px;
  letter-spacing: -0.01em;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.1s var(--ease), box-shadow 0.16s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-4); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; pointer-events: none; }
.btn--sm { height: 31px; padding: 0 11px; font-size: 12px; gap: 6px; }
.btn--block { width: 100%; height: 44px; }
.btn--primary {
  background: linear-gradient(180deg, #9b8dff, #7564f2);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: 0 8px 22px -10px rgba(117, 100, 242, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn--primary:hover { background: linear-gradient(180deg, #a89bff, #8272f6); }
[data-theme="light"] .btn--primary { color: #fff; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn--ghost:hover { background: var(--bg-3); color: var(--text); }
.btn--danger { background: rgba(255, 92, 114, 0.12); border-color: rgba(255, 92, 114, 0.35); color: #ff8b9b; }
.btn--danger:hover { background: rgba(255, 92, 114, 0.2); }

.iconbtn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s;
}
.iconbtn:hover { background: var(--bg-3); color: var(--text); border-color: var(--line); }
.iconbtn:disabled { opacity: 0.32; pointer-events: none; }
.iconbtn--danger:hover { color: var(--danger); border-color: rgba(255, 92, 114, 0.3); background: rgba(255, 92, 114, 0.08); }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 520;
  transition: all 0.15s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--line-strong); background: var(--bg-3); }
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: #c9c2ff;
}
[data-theme="light"] .chip.is-active { color: var(--accent); }
.chip:disabled { opacity: 0.36; pointer-events: none; }
.chip--icon { width: 30px; padding: 0; }
.chip-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(7, 9, 14, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e6ebf7;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}
.badge--soft { background: rgba(7, 9, 14, 0.5); border-color: rgba(255, 255, 255, 0.12); color: #cdd6e8; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border-radius: 99px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 550;
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
}
.eyebrow__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(55, 211, 155, 0.14);
  animation: pulse 2.6s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(55, 211, 155, 0.14); }
  50% { box-shadow: 0 0 0 7px rgba(55, 211, 155, 0.04); }
}

/* ==========================================================================
   Forms
   ========================================================================== */

.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  outline: none;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent-line);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input--search { padding-left: 34px; background-image: none; max-width: 230px; }
.textarea { height: auto; padding: 10px 11px; line-height: 1.5; resize: vertical; min-height: 76px; font-size: 13px; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='m1 1 4 4 4-4' fill='none' stroke='%23808aa0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
  cursor: pointer;
}

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field__label {
  font-size: 10.5px;
  font-weight: 620;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.field--grow { flex: 1; min-width: 0; }
.field-row { display: flex; align-items: flex-end; gap: 10px; }
.field-row__spacer { flex: 1; }

.range-row {
  display: grid;
  grid-template-columns: 68px 1fr 52px;
  align-items: center;
  gap: 10px;
  margin: 7px 0;
}
.range-row__label { font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
.range-row__value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.range-row__input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  outline: none;
}
.range-row__input::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-line), var(--line-strong));
}
.range-row__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s var(--ease);
}
.range-row__input::-webkit-slider-thumb:hover { transform: scale(1.14); }
.range-row__input::-moz-range-track { height: 3px; border-radius: 99px; background: var(--line-strong); }
.range-row__input::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
}
.range-row__input:disabled { opacity: 0.4; }

.color-input {
  -webkit-appearance: none;
  appearance: none;
  width: 38px; height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
.color-input::-webkit-color-swatch-wrapper { padding: 3px; }
.color-input::-webkit-color-swatch { border: none; border-radius: 5px; }
.color-input::-moz-color-swatch { border: none; border-radius: 5px; }
.color-input--wide { width: 100%; height: 34px; }
.color-field { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--bg-1);
  border: 1px solid var(--line);
}
.segmented--wide { display: flex; width: 100%; }
.segmented__item {
  flex: 1;
  height: 28px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 560;
  border-radius: 7px;
  white-space: nowrap;
  transition: all 0.15s var(--ease);
}
.segmented__item:hover { color: var(--text); }
.segmented__item.is-active {
  background: var(--bg-4);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.segmented-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.segmented-row .range-row__label { width: 68px; flex: none; }

.lock-toggle {
  width: 34px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--text-3);
  flex: none;
}
.lock-toggle.is-active { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-soft); }

.size-row { display: flex; align-items: flex-end; gap: 9px; margin-bottom: 14px; }
.size-row__x { color: var(--text-3); padding-bottom: 9px; font-size: 12px; }
.resize-readout { font-family: var(--mono); font-size: 11px; color: var(--text-3); white-space: nowrap; padding-bottom: 9px; }

.anchor-grid {
  display: grid;
  grid-template-columns: repeat(3, 26px);
  grid-auto-rows: 26px;
  gap: 3px;
  margin: 8px 0 4px;
}
.anchor-grid__cell {
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  transition: all 0.14s var(--ease);
}
.anchor-grid__cell:hover { border-color: var(--line-strong); }
.anchor-grid__cell.is-active { background: var(--accent-soft); border-color: var(--accent-line); box-shadow: inset 0 0 0 1px var(--accent-line); }

/* ==========================================================================
   Boot / fatal / loading
   ========================================================================== */

.boot, .fatal, .studio-loading {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(139, 124, 255, 0.14), transparent 65%),
    var(--bg);
}

.boot__mark { animation: float 4s ease-in-out infinite; filter: drop-shadow(0 18px 34px rgba(139, 124, 255, 0.35)); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.boot__text { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.boot__text strong { font-size: 16px; font-weight: 650; letter-spacing: -0.015em; }
.boot__text span { color: var(--text-3); font-size: 12.5px; }
.boot__bar {
  width: 190px; height: 3px; border-radius: 99px;
  background: var(--bg-4); overflow: hidden; position: relative;
}
.boot__bar i {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  animation: bootbar 1.5s infinite;
}
@keyframes bootbar { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.noscript {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); color: var(--text); font-size: 15px; padding: 30px; text-align: center;
}

.fatal__card {
  width: min(520px, calc(100vw - 40px));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 40px 34px;
  border-radius: var(--radius-xl);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.fatal__mark {
  width: 60px; height: 60px; border-radius: 18px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: 4px;
}
.fatal__card h1 { font-size: 21px; letter-spacing: -0.02em; }
.fatal__card p { color: var(--text-2); font-size: 13.5px; line-height: 1.6; max-width: 400px; }
.fatal__actions { display: flex; gap: 9px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.fatal__hint { color: var(--text-3); font-size: 11.5px; line-height: 1.6; margin-top: 8px; max-width: 380px; }

.studio-loading { gap: 10px; }
.studio-loading__mark {
  width: 62px; height: 62px; border-radius: 19px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 8px;
  animation: float 3.6s ease-in-out infinite;
}
.studio-loading strong { font-size: 15px; }
.studio-loading span { color: var(--text-3); font-size: 12.5px; }
.studio-loading__bar { width: 220px; height: 3px; border-radius: 99px; background: var(--bg-4); overflow: hidden; margin-top: 8px; position: relative; }
.studio-loading__bar i {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  animation: bootbar 1.6s infinite;
}

/* ==========================================================================
   Auth
   ========================================================================== */

.auth-root { height: 100%; overflow: auto; background: var(--bg); }
.auth {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 700px at 88% 10%, rgba(69, 214, 255, 0.09), transparent 62%),
    radial-gradient(900px 700px at 6% 92%, rgba(139, 124, 255, 0.12), transparent 60%),
    var(--bg);
}
.auth__top {
  display: flex; align-items: center;
  padding: 20px 28px;
  flex: none;
}
.auth__top-tag {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 11px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.04em;
}
.auth__main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(380px, 460px) 1fr;
  align-items: center;
  gap: clamp(30px, 6vw, 90px);
  padding: 24px clamp(24px, 6vw, 90px) 40px;
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
}
.auth__card {
  padding: clamp(26px, 3.4vw, 44px);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.026), transparent 42%), var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.auth__card::after {
  content: "";
  position: absolute; inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139, 124, 255, 0.6), transparent);
}
.auth__brand { display: flex; align-items: center; gap: 9px; margin-bottom: 34px; }
.auth__head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 26px; }
.auth__head h1 { font-size: clamp(24px, 2.6vw, 32px); letter-spacing: -0.035em; line-height: 1.1; font-weight: 680; }
.auth__head p { color: var(--text-2); font-size: 13.5px; line-height: 1.65; max-width: 340px; }
.auth__form { display: flex; flex-direction: column; gap: 15px; }
.auth__form .btn { margin-top: 6px; }
.auth__error {
  display: none;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 92, 114, 0.09);
  border: 1px solid rgba(255, 92, 114, 0.3);
  color: #ff96a5;
  font-size: 12.5px;
  line-height: 1.5;
}
.auth__error.is-visible { display: block; animation: shake 0.34s var(--ease); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.auth__notes {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 24px; padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.5;
}
.auth__switch-row {
  display: flex; justify-content: center;
  margin-top: 16px;
}
.auth__switch {
  background: none; border: none; padding: 6px 8px; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 13px; font-weight: 560;
}
.auth__switch:hover { text-decoration: underline; }
.auth__art { position: relative; display: flex; flex-direction: column; align-items: center; gap: 30px; }
.auth__orb { position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; }
.auth__orb--a { width: 340px; height: 340px; background: rgba(139, 124, 255, 0.32); top: -60px; left: -40px; }
.auth__orb--b { width: 300px; height: 300px; background: rgba(69, 214, 255, 0.2); bottom: -60px; right: -20px; }
.auth__frame {
  position: relative;
  width: min(100%, 560px);
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: perspective(1400px) rotateY(-7deg) rotateX(2deg);
}
.auth__frame-bar {
  height: 34px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 13px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.auth__frame-bar i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.auth__frame-bar i:first-child { background: #ff5f57; opacity: 0.6; }
.auth__frame-canvas {
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(400px 260px at 30% 30%, rgba(139, 124, 255, 0.34), transparent 65%),
    radial-gradient(360px 240px at 75% 70%, rgba(69, 214, 255, 0.2), transparent 62%),
    var(--checker);
  position: relative;
}
.auth__chip {
  position: absolute;
  padding: 8px 13px;
  border-radius: 9px;
  background: rgba(10, 12, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #dfe6f5;
  font-size: 11.5px;
  font-weight: 560;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}
.auth__chip--a { top: 18%; left: 12%; }
.auth__chip--b { top: 44%; left: 38%; border-color: var(--accent-line); color: #cfc7ff; }
.auth__chip--c { top: 66%; left: 20%; }
.auth__caption { text-align: center; display: flex; flex-direction: column; gap: 5px; position: relative; }
.auth__caption strong { font-size: 13px; font-weight: 620; }
.auth__caption span { color: var(--text-3); font-size: 12px; }
.auth__foot {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px 28px 24px;
  color: var(--text-3);
  font-size: 11px;
  flex: none;
}

@media (max-width: 980px) {
  .auth__main { grid-template-columns: 1fr; max-width: 500px; }
  .auth__art { display: none; }
}

/* ==========================================================================
   Library
   ========================================================================== */

.library { height: 100%; overflow-y: auto; background: var(--bg); }
.library__nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  height: 62px; padding: 0 clamp(18px, 3vw, 40px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.library__nav-tag {
  font-size: 11px;
  color: var(--text-3);
  border-left: 1px solid var(--line);
  padding-left: 14px;
  letter-spacing: 0.02em;
}
.topbar__spacer { flex: 1; }

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  background: transparent; border: none; padding: 0;
  color: var(--text);
}
.brand__name { font-size: 14.5px; font-weight: 650; letter-spacing: -0.02em; }
.brand__badge {
  font-size: 8.5px; font-weight: 750;
  letter-spacing: 0.1em;
  padding: 3px 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: #c3baff;
  border: 1px solid var(--accent-line);
}
[data-theme="light"] .brand__badge { color: var(--accent); }
.brand--library .icon-wrap { filter: drop-shadow(0 4px 10px rgba(139, 124, 255, 0.35)); }

.user-chip {
  display: inline-flex; align-items: center; gap: 9px;
  height: 38px; padding: 0 10px 0 5px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--text);
  transition: border-color 0.15s;
}
.user-chip:hover { border-color: var(--line-strong); }
.user-chip__meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.user-chip__meta strong { font-size: 11.5px; font-weight: 600; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip__meta span { font-size: 9.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.user-chip > .icon-wrap:last-child { color: var(--text-3); }

.avatar {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: linear-gradient(140deg, var(--accent), #5b48e8);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
  padding: 0;
}

.library__main {
  max-width: 1480px;
  margin: 0 auto;
  padding: clamp(26px, 4vw, 54px) clamp(18px, 3vw, 40px) 40px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.library__hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 440px);
  gap: clamp(20px, 4vw, 60px);
  align-items: center;
}
.library__hero-copy { display: flex; flex-direction: column; gap: 16px; max-width: 620px; }
.library__title {
  font-size: clamp(32px, 4.6vw, 54px);
  line-height: 1.02;
  letter-spacing: -0.045em;
  font-weight: 680;
  display: flex; gap: 12px; flex-wrap: wrap;
}
.library__title em {
  font-style: normal;
  background: linear-gradient(100deg, #b3a8ff 10%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.library__lede { color: var(--text-2); font-size: clamp(13px, 1.2vw, 15px); line-height: 1.65; max-width: 500px; }
.library__hero-actions { display: flex; gap: 9px; margin-top: 6px; flex-wrap: wrap; }

.library__hero-art { position: relative; height: 250px; display: grid; place-items: center; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); }
.orb--a { width: 230px; height: 230px; background: rgba(139, 124, 255, 0.26); top: 0; right: 40px; }
.orb--b { width: 200px; height: 200px; background: rgba(69, 214, 255, 0.16); bottom: 0; left: 30px; }
.hero-frame {
  position: relative;
  width: min(100%, 400px);
  border-radius: 15px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: perspective(1200px) rotateY(-8deg) rotateX(3deg);
}
.hero-frame__bar {
  height: 27px; display: flex; align-items: center; gap: 5px; padding: 0 10px;
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.hero-frame__bar i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.hero-frame__canvas { aspect-ratio: 16 / 9; position: relative; background: var(--checker); overflow: hidden; }
.hero-frame__canvas::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(320px 210px at 28% 32%, rgba(139, 124, 255, 0.5), transparent 66%),
              radial-gradient(280px 200px at 76% 70%, rgba(69, 214, 255, 0.3), transparent 64%);
}
.hero-frame__layer {
  position: absolute; border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(3px);
}
.hero-frame__layer--a { inset: 16% 22% 46% 14%; background: rgba(255, 255, 255, 0.06); }
.hero-frame__layer--b { inset: 46% 14% 18% 30%; background: rgba(139, 124, 255, 0.1); border-color: var(--accent-line); }
.hero-frame__layer--c { inset: 32% 40% 40% 52%; background: rgba(69, 214, 255, 0.08); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  transition: border-color 0.18s, transform 0.18s var(--ease);
}
.stat-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat-card__icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: #b9b0ff;
  flex: none;
}
[data-theme="light"] .stat-card__icon { color: var(--accent); }
.stat-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-card__label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); font-weight: 600; }
.stat-card__value { font-size: 21px; letter-spacing: -0.03em; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-card__sub { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.library__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 26px;
  align-items: start;
}
.library__content { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-head__title { display: flex; align-items: baseline; gap: 10px; }
.section-head__title h2 { font-size: 18px; letter-spacing: -0.025em; font-weight: 640; }
.section-count { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.section-head__tools { display: flex; align-items: center; gap: 8px; }
.section-head__tools .select { width: 130px; height: 34px; }
.section-head__tools .input--search { height: 34px; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.project-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  transition: border-color 0.18s, transform 0.18s var(--ease), box-shadow 0.18s;
  cursor: pointer;
}
.project-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.project-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--checker);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.project-card__thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.project-card__thumb--empty { display: grid; place-items: center; color: var(--text-3); }
.project-card__star {
  position: absolute; top: 8px; right: 8px;
  width: 27px; height: 27px;
  display: grid; place-items: center;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 9, 14, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  backdrop-filter: blur(8px);
}
.project-card:hover .project-card__star, .project-card__star.is-on { opacity: 1; }
.project-card__star.is-on { color: var(--warn); }
.project-card__badges { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 5px; }
.project-card__body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 7px; }
.project-card__title-row { display: flex; align-items: center; gap: 6px; }
.project-card__title {
  font-size: 13px; font-weight: 580; letter-spacing: -0.01em;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-card__more {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border: none; border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  flex: none;
}
.project-card__more:hover { background: var(--bg-3); color: var(--text); }
.project-card__meta { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 10.5px; font-variant-numeric: tabular-nums; }

.empty-library {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 60px 24px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line-strong);
  background: linear-gradient(180deg, rgba(139, 124, 255, 0.04), transparent);
  text-align: center;
}
.empty-library__icon {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: 4px;
}
.empty-library h3 { font-size: 17px; letter-spacing: -0.02em; }
.empty-library p { color: var(--text-2); font-size: 12.5px; line-height: 1.6; max-width: 400px; }
.empty-library .btn { margin-top: 10px; }

.library__rail { display: flex; flex-direction: column; gap: 13px; position: sticky; top: 78px; }
.rail-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.rail-card__head { display: flex; align-items: center; justify-content: space-between; color: var(--text-3); }
.rail-card__head h3 { font-size: 11px; font-weight: 640; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-2); }
.rail-card--note { background: linear-gradient(180deg, var(--accent-soft), transparent 70%), var(--panel); }
.rail-card--note p { color: var(--text-2); font-size: 11.5px; line-height: 1.6; }
.rail-list { display: flex; flex-direction: column; gap: 3px; }
.rail-row {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 6px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 11.5px;
  transition: background 0.14s;
  min-width: 0;
}
.rail-row:hover { background: var(--bg-3); text-decoration: none; }
.rail-row__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: none; }
.rail-row__thumb { width: 34px; height: 34px; border-radius: 7px; object-fit: cover; border: 1px solid var(--line); flex: none; background: var(--checker); }
.rail-row__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.rail-row__body strong { font-size: 11.5px; font-weight: 560; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-row__body span { font-size: 10px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-row__time { font-size: 9.5px; color: var(--text-3); white-space: nowrap; flex: none; }
.rail-row--export > .icon-wrap { color: var(--text-3); }
.rail-empty { color: var(--text-3); font-size: 11.5px; line-height: 1.55; padding: 4px 2px; }

.library__foot {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 8px 0 0;
  color: var(--text-3);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

@media (max-width: 1200px) {
  .library__body { grid-template-columns: minmax(0, 1fr) 280px; }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1020px) {
  .library__hero { grid-template-columns: 1fr; }
  .library__hero-art { display: none; }
  .library__body { grid-template-columns: 1fr; }
  .library__rail { position: static; display: grid; grid-template-columns: 1fr 1fr; }
  .rail-card--note { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .library__nav { gap: 8px; }
  .library__nav-tag { display: none; }
  .user-chip__meta { display: none; }
  .library__rail { grid-template-columns: 1fr; }
  .section-head__tools { width: 100%; }
  .section-head__tools .input--search { max-width: none; flex: 1; }
  .project-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ==========================================================================
   Studio shell
   ========================================================================== */

.studio-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.topbar {
  flex: none;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__left { flex: 1; }
.topbar__divider { width: 1px; height: 20px; background: var(--line); margin: 0 2px; flex: none; }
.doc-title-wrap { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding-right: 10px; }
.doc-title {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: -6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 580;
  letter-spacing: -0.01em;
  max-width: 320px;
  min-width: 90px;
  width: 100%;
}
.doc-title:hover { border-color: var(--line); }
.doc-title:focus { outline: none; border-color: var(--accent-line); background: var(--bg-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.save-state { font-size: 9.5px; color: var(--text-3); padding-left: 2px; letter-spacing: 0.02em; }
.save-state.is-saving { color: var(--accent-2); }
.save-state.is-dirty { color: var(--warn); }
.save-state.is-saved { color: var(--text-3); }

.cluster {
  display: flex; align-items: center; gap: 2px;
  padding: 2px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.cluster .iconbtn { width: 28px; height: 28px; }
.zoom-btn {
  height: 28px; min-width: 52px;
  padding: 0 6px;
  border: none; background: transparent;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 10.5px;
  border-radius: 6px;
}
.zoom-btn:hover { background: var(--bg-3); color: var(--text); }

.studio__body { flex: 1; display: flex; min-height: 0; }

.toolrail {
  flex: none;
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 18px;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
}
.toolrail__sep { width: 22px; height: 1px; background: var(--line); margin: 5px 0; flex: none; }
.toolbtn {
  position: relative;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: all 0.15s var(--ease);
  flex: none;
}
.toolbtn:hover { background: var(--bg-3); color: var(--text); border-color: var(--line); }
.toolbtn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: #c9c1ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
[data-theme="light"] .toolbtn.is-active { color: var(--accent); }
.toolbtn__key {
  position: absolute; right: 3px; bottom: 2px;
  font-family: var(--mono);
  font-size: 7.5px;
  color: var(--text-3);
  opacity: 0.75;
  pointer-events: none;
}
.toolbtn.is-active .toolbtn__key { color: var(--accent-2); }

.studio__center { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.optionsbar {
  flex: none;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.optionsbar::-webkit-scrollbar { display: none; }
.opt-group {
  display: flex; align-items: center; gap: 8px;
  padding: 0 9px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  flex: none;
  white-space: nowrap;
}
.opt-group--end { border: none; background: transparent; padding: 0 0 0 8px; margin-left: auto; }
.opt { display: flex; align-items: center; gap: 7px; }
.opt__label { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.opt__range { -webkit-appearance: none; appearance: none; width: 76px; height: 18px; background: transparent; }
.opt__range::-webkit-slider-runnable-track { height: 2px; border-radius: 99px; background: var(--line-strong); }
.opt__range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4.5px;
  border-radius: 50%; background: #fff; border: 2px solid var(--accent);
}
.opt__range::-moz-range-track { height: 2px; background: var(--line-strong); }
.opt__range::-moz-range-thumb { width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.opt__value { font-family: var(--mono); font-size: 10px; color: var(--text-2); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.opt__caption { font-size: 10.5px; color: var(--text-3); }
.opt__swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line-strong); flex: none; }
.opt__arrow { color: var(--text-3); font-size: 10px; }

.viewport {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
  background:
    radial-gradient(900px 520px at 50% 42%, rgba(139, 124, 255, 0.055), transparent 70%),
    var(--bg);
  outline: none;
  touch-action: none;
}
.viewport::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(150, 170, 210, 0.12) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.35;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at 50% 50%, #000 30%, transparent 78%);
}
.viewport[data-tool="hand"] { cursor: grab; }
.viewport[data-tool="hand"]:active { cursor: grabbing; }
.viewport.is-panning { cursor: grabbing !important; }
.viewport[data-tool="zoom"] { cursor: zoom-in; }
.viewport[data-tool="move"] { cursor: move; }
.viewport[data-tool="eyedropper"] { cursor: crosshair; }
.viewport[data-tool="text"] { cursor: text; }
.viewport[data-tool="brush"], .viewport[data-tool="eraser"], .viewport[data-tool="fill"],
.viewport[data-tool="gradient"], .viewport[data-tool="shape"], .viewport[data-tool="select-rect"],
.viewport[data-tool="select-ellipse"], .viewport[data-tool="lasso"], .viewport[data-tool="wand"],
.viewport[data-tool="crop"] { cursor: crosshair; }

.stage { transform-origin: center center; will-change: transform; }
.artboard {
  position: relative;
  background: var(--checker);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 30px 80px -20px rgba(0, 0, 0, 0.85);
}
[data-theme="light"] .artboard { box-shadow: 0 0 0 1px rgba(18, 30, 55, 0.14), 0 24px 60px -24px rgba(24, 36, 66, 0.4); }
.artboard__canvas, .artboard__overlay { position: absolute; inset: 0; display: block; }
.artboard__canvas { image-rendering: auto; }
.artboard__overlay { pointer-events: none; }

.zoom-pill {
  position: absolute;
  right: 14px; bottom: 14px;
  height: 24px;
  padding: 0 9px;
  display: inline-flex; align-items: center;
  border-radius: 99px;
  background: color-mix(in srgb, var(--bg-1) 86%, transparent);
  border: 1px solid var(--line);
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 10px;
  backdrop-filter: blur(10px);
  pointer-events: none;
  letter-spacing: 0.02em;
}

.dropzone {
  position: absolute;
  inset: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--accent-line);
  background: rgba(139, 124, 255, 0.07);
  color: #c8c1ff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s;
  backdrop-filter: blur(2px);
  z-index: 5;
}
.dropzone.is-visible { opacity: 1; }

.statusbar {
  flex: none;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--text-3);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}
.statusbar__item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.statusbar__item strong { color: var(--text-2); font-weight: 580; }
.statusbar__hint { color: var(--text-3); }
.statusbar__right { margin-left: auto; }

@media (max-width: 1080px) {
  .topbar .brand__name { display: none; }
  .doc-title { max-width: 190px; }
}
@media (max-width: 900px) {
  .studio__body { flex-direction: column; }
  .toolrail {
    width: 100%; height: 50px;
    flex-direction: row; justify-content: flex-start;
    padding: 6px 8px; gap: 2px;
    border-right: none; border-bottom: 1px solid var(--line);
    overflow-x: auto; overflow-y: hidden;
  }
  .toolrail__sep { width: 1px; height: 22px; margin: 0 4px; }
  .toolbtn { width: 34px; height: 34px; }
  .studio__center { flex: 1; min-height: 0; }
  .inspector {
    width: 100% !important;
    height: 38vh;
    border-left: none !important;
    border-top: 1px solid var(--line);
  }
  .inspector__body { padding-bottom: 10px; }
  .statusbar { font-size: 9.5px; gap: 9px; }
  .statusbar__hint { display: none; }
}
@media (max-width: 640px) {
  .topbar { height: 50px; gap: 6px; }
  .topbar .cluster--zoom, .topbar .brand { display: none; }
  .optionsbar { height: 42px; }
  .doc-title { max-width: 130px; }
  .zoom-pill { display: none; }
  .inspector { height: 42vh; }
}

/* ==========================================================================
   Inspector
   ========================================================================== */

.inspector {
  flex: none;
  width: 336px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.inspector__tabs {
  flex: none;
  display: flex;
  align-items: stretch;
  gap: 1px;
  padding: 7px 8px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.tab {
  flex: 1;
  position: relative;
  height: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 560;
  border-radius: 8px 8px 0 0;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text-2); background: var(--bg-2); }
.tab.is-active { color: var(--text); }
.tab.is-active::after {
  content: "";
  position: absolute; left: 9px; right: 9px; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
}
.tab__badge {
  min-width: 0;
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--text-3);
  opacity: 0.8;
}
.tab__badge:empty { display: none; }
.tab.is-active .tab__badge { color: var(--accent-2); }

.inspector__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.panel-eyebrow { display: block; font-size: 9px; font-weight: 650; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
.panel-title { font-size: 14px; font-weight: 620; letter-spacing: -0.015em; }
.panel-meta { font-family: var(--mono); font-size: 9.5px; color: var(--text-3); text-align: right; }

.layer-list { display: flex; flex-direction: column; gap: 1px; }
.layer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 46px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
  outline: none;
  user-select: none;
}
.layer-row:hover { background: var(--bg-2); }
.layer-row.is-active { background: var(--accent-soft); border-color: var(--accent-line); }
.layer-row.is-hidden .layer-row__thumb, .layer-row.is-hidden .layer-row__label { opacity: 0.42; }
.layer-row.is-dragging { opacity: 0.45; }
.layer-row.is-drop-target { box-shadow: inset 0 2px 0 var(--accent-2); }
.layer-row__toggle {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: none; border-radius: 5px;
  background: transparent;
  color: var(--text-3);
  flex: none;
}
.layer-row__toggle:hover { background: var(--bg-4); color: var(--text); }
.layer-row.is-hidden .layer-row__toggle { color: var(--warn); }
.layer-row.is-locked .layer-row__toggle:last-of-type { color: var(--danger); }
.layer-row__thumbwrap {
  width: 34px; height: 34px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--checker);
  flex: none;
}
.layer-row__thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.layer-row__label { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.layer-row__name { font-size: 11.5px; font-weight: 540; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row__meta { font-size: 9px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.layer-actions { display: flex; align-items: center; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.layer-actions .btn { padding: 0 8px; }

.dock {
  flex: none;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dock__colors { display: flex; align-items: center; gap: 10px; }
.dock__stack { position: relative; width: 46px; height: 34px; flex: none; }
.swatch-input {
  position: absolute;
  width: 28px; height: 28px;
  padding: 0;
  border-radius: 7px;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  background: transparent;
  z-index: 2;
}
.swatch-input--back { right: 0; bottom: 0; z-index: 1; border-color: rgba(255, 255, 255, 0.16); }
.swatch-input::-webkit-color-swatch-wrapper { padding: 0; }
.swatch-input::-webkit-color-swatch { border: none; }
.swatch-input::-moz-color-swatch { border: none; }
.dock__meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.dock__meta strong { font-size: 10.5px; font-weight: 620; }
.dock__meta span { font-size: 9px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock__actions { display: flex; gap: 2px; }
.dock__mini {
  width: 25px; height: 25px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--text-3);
}
.dock__mini:hover { color: var(--text); border-color: var(--line-strong); }
.dock__recent { display: flex; gap: 5px; flex-wrap: wrap; }
.recent-swatch {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  background: var(--swatch, #fff);
  padding: 0;
  transition: transform 0.12s var(--ease);
}
.recent-swatch:hover { transform: scale(1.14); }

.action-card {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.12s var(--ease);
}
.action-card:hover { border-color: var(--line-strong); background: var(--bg-3); transform: translateY(-1px); }
.action-card__icon {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: #bdb4ff; flex: none;
}
[data-theme="light"] .action-card__icon { color: var(--accent); }
.action-card__label { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.action-card__label strong { font-size: 12px; font-weight: 600; }
.action-card__label span { font-size: 10px; color: var(--text-3); line-height: 1.45; }
.action-card__go { color: var(--text-3); flex: none; }
.action-card--accent {
  border-color: var(--accent-line);
  background: linear-gradient(120deg, var(--accent-soft), transparent 60%), var(--bg-2);
}
.action-card--accent .action-card__icon { background: linear-gradient(140deg, var(--accent), #5b48e8); color: #fff; }

.histogram-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  padding: 10px;
  display: flex; flex-direction: column; gap: 7px;
}
.histogram-card__head { display: flex; align-items: center; justify-content: space-between; }
.histogram { width: 100%; height: 76px; display: block; border-radius: 6px; background: var(--bg-1); }
.histogram-card__scale { display: flex; justify-content: space-between; font-size: 8.5px; color: var(--text-3); letter-spacing: 0.04em; text-transform: uppercase; }

.group-label {
  display: flex; align-items: center; gap: 9px;
  margin: 8px 0 1px;
  font-size: 9.5px; font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-3);
}
.group-label__rule { flex: 1; height: 1px; background: var(--line); }

.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.filter-card {
  display: flex; align-items: center; gap: 7px;
  height: 38px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 10.5px;
  text-align: left;
  transition: all 0.14s var(--ease);
  min-width: 0;
}
.filter-card:hover { border-color: var(--accent-line); background: var(--bg-3); color: var(--text); }
.filter-card__icon { color: var(--text-3); flex: none; display: inline-flex; }
.filter-card:hover .filter-card__icon { color: var(--accent-2); }
.filter-card__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.history-list { display: flex; flex-direction: column; gap: 1px; }
.history-row {
  display: flex; align-items: center; gap: 8px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  text-align: left;
  transition: background 0.13s;
}
.history-row:hover { background: var(--bg-2); }
.history-row__icon { color: var(--text-3); flex: none; display: inline-flex; }
.history-row__label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row__time { font-family: var(--mono); font-size: 9px; color: var(--text-3); flex: none; }
.history-row.is-current { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.history-row.is-current .history-row__icon { color: var(--accent-2); }
.history-row.is-future { opacity: 0.42; }
.history-row.is-future:hover { opacity: 0.7; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 6px; }
.stat {
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.stat span { font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-3); }
.stat strong { font-family: var(--mono); font-size: 10.5px; font-weight: 520; color: var(--text-2); }

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 34px 18px;
  text-align: center;
  color: var(--text-3);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
}
.empty-state .icon-wrap { color: var(--accent); opacity: 0.8; }
.empty-state strong { color: var(--text-2); font-size: 12px; font-weight: 580; }
.empty-state span { font-size: 10.5px; line-height: 1.55; max-width: 220px; }

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 4, 7, 0.66);
  backdrop-filter: blur(7px);
  opacity: 0;
  transition: opacity 0.16s var(--ease);
  overflow-y: auto;
}
.modal-backdrop.is-open { opacity: 1; }
[data-theme="light"] .modal-backdrop { background: rgba(30, 42, 70, 0.34); }

.modal {
  width: 100%;
  max-width: 560px;
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(0.985);
  transition: transform 0.18s var(--ease);
  overflow: hidden;
}
.modal-backdrop.is-open .modal { transform: translateY(0) scale(1); }
.modal__head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
}
.modal__title { font-size: 16px; font-weight: 640; letter-spacing: -0.02em; }
.modal__sub { color: var(--text-2); font-size: 11.5px; line-height: 1.55; margin-top: 4px; max-width: 560px; }
.modal__close {
  width: 29px; height: 29px;
  display: grid; place-items: center;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text-3);
  flex: none;
}
.modal__close:hover { color: var(--text); border-color: var(--line-strong); }
.modal__body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px; }
.modal__foot { flex: none; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--bg-1); }
.modal__actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.modal__copy { color: var(--text-2); font-size: 13px; line-height: 1.6; }
.modal--export { max-width: 720px; }
.modal--filter { max-width: 520px; }
.modal--templates { max-width: 980px; }
.modal--shortcuts { max-width: 880px; }

.export-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; }
.export-preview {
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--checker);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 240px;
}
.export-preview__image { width: 100%; flex: 1; object-fit: contain; display: block; min-height: 0; background: var(--checker); }
.export-preview__foot { padding: 8px 10px; border-top: 1px solid var(--line); background: var(--bg-1); }
.export-preview__meta { font-family: var(--mono); font-size: 9.5px; color: var(--text-3); }
.export-controls { display: flex; flex-direction: column; gap: 13px; }
.export-note { font-size: 10px; color: var(--text-3); }

.filter-dialog { display: flex; flex-direction: column; gap: 12px; }
.filter-dialog__head { display: flex; align-items: center; gap: 8px; }
.filter-dialog__icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: #b9b0ff;
}
.preview-status {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  border-radius: 99px;
  background: rgba(55, 211, 155, 0.1);
  border: 1px solid rgba(55, 211, 155, 0.3);
  color: #6fe8bd;
  font-size: 10px;
  font-weight: 560;
}
.preview-status::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--success);
  animation: pulse 1.8s infinite;
}
.filter-fields { display: flex; flex-direction: column; gap: 6px; }
.filter-control {
  display: grid;
  grid-template-columns: 118px 1fr 58px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.filter-control:last-child { border-bottom: none; }
.filter-control__label { font-size: 11.5px; color: var(--text-2); }
.filter-control__value { font-family: var(--mono); font-size: 10.5px; color: var(--text-2); text-align: right; }
.filter-control .color-input { width: 100%; height: 30px; }

.resize-dialog { display: flex; flex-direction: column; gap: 12px; }

.templates { display: flex; flex-direction: column; gap: 14px; }
.template-tabs { position: sticky; top: 0; z-index: 2; padding-bottom: 4px; }
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.template-card {
  display: flex; flex-direction: column;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  overflow: hidden;
  text-align: left;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s var(--ease), box-shadow 0.15s;
  padding: 0;
}
.template-card:hover { border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.template-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  display: grid; place-items: center;
  overflow: hidden;
}
.template-card__preview { width: 100%; height: 100%; object-fit: contain; display: block; }
.template-card__media .badge { position: absolute; top: 7px; left: 7px; }
.template-card__body { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.template-card__body strong { font-size: 12px; font-weight: 580; }
.template-card__body span { font-family: var(--mono); font-size: 9px; color: var(--text-3); }
.template-card__body small { font-size: 10px; color: var(--text-3); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.shortcuts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.shortcuts__group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.shortcuts__title { font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-3); }
.shortcuts__rows { display: flex; flex-direction: column; }
.shortcut {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.shortcut:last-child { border-bottom: none; }
.shortcut__label { font-size: 11.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 820px) {
  .export-grid { grid-template-columns: 1fr; }
  .export-preview { min-height: 180px; }
  .shortcuts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .modal-backdrop { padding: 12px; }
  .modal__head, .modal__body, .modal__foot { padding-left: 15px; padding-right: 15px; }
  .shortcuts { grid-template-columns: 1fr; }
  .filter-control { grid-template-columns: 90px 1fr 48px; }
}

/* ==========================================================================
   Context menu / toast / color picker
   ========================================================================== */

.context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 200px;
  padding: 5px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  animation: menuin 0.12s var(--ease);
}
@keyframes menuin { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.context-menu__item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  text-align: left;
}
.context-menu__item:hover { background: var(--bg-3); color: var(--text); }
.context-menu__item.is-danger { color: #ff8b9b; }
.context-menu__item.is-danger:hover { background: rgba(255, 92, 114, 0.1); }
.context-menu__item:disabled { opacity: 0.38; pointer-events: none; }
.context-menu__icon { width: 16px; display: inline-flex; justify-content: center; flex: none; color: var(--text-3); }
.context-menu__label { flex: 1; }
.context-menu__sep { height: 1px; background: var(--line); margin: 4px 6px; }

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastin 0.22s var(--ease);
}
@keyframes toastin { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.toast.is-leaving { opacity: 0; transform: translateY(4px); transition: all 0.2s var(--ease); }
.toast__dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--accent-2); box-shadow: 0 0 0 4px rgba(69, 214, 255, 0.1); }
.toast--success .toast__dot { background: var(--success); box-shadow: 0 0 0 4px rgba(55, 211, 155, 0.1); }
.toast--warn .toast__dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(255, 200, 87, 0.1); }
.toast--error .toast__dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 92, 114, 0.1); }
.toast__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.toast__text strong { font-size: 11.5px; font-weight: 580; color: var(--text); }
.toast__text span { font-size: 10.5px; color: var(--text-3); line-height: 1.45; }
.toast__close {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border: none; border-radius: 5px;
  background: transparent;
  color: var(--text-3);
  flex: none;
}
.toast__close:hover { background: var(--bg-3); color: var(--text); }

.colorpick { display: flex; flex-direction: column; gap: 8px; }
.colorpick__sv {
  position: relative;
  height: 130px;
  border-radius: 9px;
  border: 1px solid var(--line);
  cursor: crosshair;
  touch-action: none;
}
.colorpick__dot {
  position: absolute;
  width: 13px; height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.colorpick__hue { -webkit-appearance: none; appearance: none; width: 100%; height: 10px; border-radius: 99px; }
.colorpick__hue::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0, 0, 0, 0.5); box-shadow: var(--shadow-sm);
}
.colorpick__row { display: flex; align-items: center; gap: 8px; }
.colorpick__preview { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-strong); flex: none; }
.input--hex { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; }
.colorpick__swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.swatch { aspect-ratio: 1; border-radius: 5px; border: 1px solid var(--line); background: var(--swatch); padding: 0; }
.swatch:hover { transform: scale(1.08); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
