/* Bunny Studio – designsystem */

:root {
  color-scheme: light;
  --bg: #f4f2f7;
  --surface: #ffffff;
  --surface-2: #faf9fc;
  --sunken: #efecf3;
  --ink: #17141c;
  --ink-2: #48424f;
  --muted: #857d8f;
  --line: #e7e2ed;
  --line-2: #d9d2e1;
  --brand: #f0388f;
  --brand-2: #9b5cf6;
  --brand-soft: color-mix(in srgb, var(--brand) 12%, #fff);
  --brand-ink: color-mix(in srgb, var(--brand) 72%, #000);
  --grad: linear-gradient(135deg, color-mix(in srgb, var(--brand) 92%, #fff) 0%, color-mix(in srgb, var(--brand-2) 92%, #fff) 100%);
  --grad-soft: linear-gradient(135deg, color-mix(in srgb, var(--brand) 8%, #fff) 0%, color-mix(in srgb, var(--brand-2) 8%, #fff) 100%);
  --ok: #138a3d;
  --ok-soft: #e3f6ea;
  --warn: #b45309;
  --warn-soft: #fdf1df;
  --err: #c8282d;
  --err-soft: #fde8e8;
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
  --shadow-sm: 0 1px 2px rgba(23, 20, 28, 0.05);
  --shadow: 0 1px 2px rgba(23, 20, 28, 0.04), 0 8px 24px -12px rgba(23, 20, 28, 0.14);
  --shadow-lg: 0 30px 80px -24px rgba(23, 20, 28, 0.35), 0 2px 8px rgba(23, 20, 28, 0.06);
  --r: 16px;
  --r-sm: 11px;
  --r-xs: 8px;
  --sidebar: 244px;
  --chat: 400px;
  /* kostnadstyper (validerad kategoripalett, fast ordning) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --chart-surface: #ffffff;
  --grid: #ece8f0;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111014;
    --surface: #1a181f;
    --surface-2: #1f1d25;
    --sunken: #15131a;
    --ink: #f3f0f7;
    --ink-2: #c9c3d2;
    --muted: #8f879a;
    --line: #2b2833;
    --line-2: #3a3644;
    --brand-soft: color-mix(in srgb, var(--brand) 22%, #1a181f);
    --brand-ink: color-mix(in srgb, var(--brand) 55%, #fff);
    --grad-soft: linear-gradient(135deg, color-mix(in srgb, var(--brand) 16%, #1a181f) 0%, color-mix(in srgb, var(--brand-2) 16%, #1a181f) 100%);
    --ok: #4ade80; --ok-soft: #12291b;
    --warn: #fbbf24; --warn-soft: #2d2410;
    --err: #f87171; --err-soft: #321617;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.8);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
    --chart-surface: #1a181f;
    --grid: #2b2833;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111014;
  --surface: #1a181f;
  --surface-2: #1f1d25;
  --sunken: #15131a;
  --ink: #f3f0f7;
  --ink-2: #c9c3d2;
  --muted: #8f879a;
  --line: #2b2833;
  --line-2: #3a3644;
  --brand-soft: color-mix(in srgb, var(--brand) 22%, #1a181f);
  --brand-ink: color-mix(in srgb, var(--brand) 55%, #fff);
  --grad-soft: linear-gradient(135deg, color-mix(in srgb, var(--brand) 16%, #1a181f) 0%, color-mix(in srgb, var(--brand-2) 16%, #1a181f) 100%);
  --ok: #4ade80; --ok-soft: #12291b;
  --warn: #fbbf24; --warn-soft: #2d2410;
  --err: #f87171; --err-soft: #321617;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.8);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181;
  --chart-surface: #1a181f;
  --grid: #2b2833;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
img, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden, [hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }

/* ---------- Ramverk ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--chat);
  height: 100vh;
  height: 100dvh;
}
.app.chat-closed { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.app.chat-closed .chat { display: none; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; background: var(--grad); display: grid; place-items: center;
  color: #fff; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand) 60%, transparent);
}
.brand-mark svg { width: 22px; height: 22px; stroke: #fff; }
.brand b { display: block; font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.brand span { display: block; font-size: 12px; color: var(--muted); margin-top: -2px; }

.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 600; font-size: 14.5px; text-decoration: none; transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.sidebar .spacer { flex: 1; }
.side-card {
  border: 1px solid var(--line); border-radius: var(--r); padding: 14px; background: var(--surface-2);
}
.side-card .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.side-card .value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.jobs { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.job { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; font-size: 12.5px; }
.job .dot { grid-row: span 2; }
.job b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job span { color: var(--muted); }
.side-foot { display: flex; gap: 6px; margin-top: 10px; }

.main { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 18px 32px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
}
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.view { padding: 6px 32px 48px; container-type: inline-size; container-name: view; }

/* Karaktärsväxlare */
.switch-wrap { position: relative; margin-bottom: 14px; }
.switcher {
  all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; border-radius: 14px;
  cursor: pointer; border: 1px solid var(--line); background: var(--surface-2); transition: border-color 0.15s, background 0.15s;
}
.switcher:hover { border-color: var(--line-2); background: var(--sunken); }
.switcher .avatar.sm, .switch-menu .avatar.sm { width: 36px; height: 36px; border-radius: 11px; }
.switcher .sw-text { flex: 1; min-width: 0; }
.switcher .sw-text b { display: block; font-size: 15px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switcher .sw-text span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark.sm { width: 36px; height: 36px; border-radius: 11px; }
.brand-mark.sm svg { width: 18px; height: 18px; }
.switch-menu {
  position: absolute; z-index: 35; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop 0.14s;
}
.switch-menu a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; color: var(--ink); font-weight: 650; font-size: 14px; text-decoration: none; }
.switch-menu a:hover { background: var(--sunken); }
.switch-menu a.on { background: var(--brand-soft); }
.switch-menu .sw-dot { width: 10px; height: 10px; border-radius: 50%; margin-left: auto; }
.switch-menu .avatar.sm { width: 28px; height: 28px; border-radius: 9px; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 6px; }
.nav-avatar { width: 20px; height: 20px; border-radius: 6px; overflow: hidden; flex: none; background: var(--sunken); }
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center 15%; }

.drop {
  display: flex; align-items: center; justify-content: center; min-height: 110px; padding: 12px; gap: 8px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-2); border-radius: 14px; color: var(--muted); font-weight: 600; font-size: 13.5px; transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.drop > span { display: inline-flex; align-items: center; gap: 8px; }

/* Studiokort på översikten */
.studio-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.studio-card {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-sm); transition: transform 0.15s, box-shadow 0.15s;
}
.studio-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.studio-card .cover { position: relative; height: 170px; overflow: hidden; }
.studio-card .cover img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; }
.studio-card .cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 55%, rgba(0, 0, 0, 0.35)); }
.studio-card .band { height: 5px; }
.studio-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.studio-card .body h3 { font-size: 18px; }
.studio-card .body p { margin: 0; color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.studio-card .stats-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.studio-card.new { align-items: center; justify-content: center; min-height: 300px; border: 2px dashed var(--line-2); background: transparent; box-shadow: none; color: var(--muted); gap: 10px; font-weight: 700; }
.studio-card.new:hover { color: var(--brand-ink); border-color: var(--brand); }
.studio-card.new .big { width: 56px; height: 56px; border-radius: 18px; background: var(--grad-soft); display: grid; place-items: center; color: var(--brand-ink); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 11px; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; }
.swatches button.on { box-shadow: 0 0 0 2px var(--ink); }
.new-looks { flex-direction: column; gap: 10px; min-height: 110px; }
.new-looks input[type=file] { display: none; }
.new-thumbs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.new-thumbs img { width: 56px; height: 72px; object-fit: cover; border-radius: 8px; }

/* Looks i karaktärsvyn */
.looks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.look-card { position: relative; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.look-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; display: block; }
.look-card .look-bar { display: flex; gap: 4px; padding: 6px; background: var(--surface); border-top: 1px solid var(--line); }
.look-card .look-bar .btn { flex: 1; padding: 0 6px; font-size: 12px; height: 28px; }
.look-card .look-bar .btn.on { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.look-card .zoom { top: 6px; left: 6px; }
.look-card:hover .zoom { opacity: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field + .field { margin-top: 0; }
.toggle-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); cursor: pointer; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--brand); margin-top: 2px; flex: none; }
.toggle-row b { font-size: 14px; }
.toggle-row .hint { margin-top: 2px; }
.chip.locked { background: var(--ok-soft); color: var(--ok); }

/* ---------- Byggstenar ---------- */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 16px 20px 20px; }
.card-foot {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line);
  background: var(--surface-2); border-radius: 0 0 var(--r) var(--r);
}
.card-foot .grow { flex: 1; }
.step-num {
  width: 26px; height: 26px; border-radius: 9px; background: var(--grad); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 13px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-weight: 650; font-size: 14px; cursor: pointer; white-space: nowrap; transition: transform 0.06s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus, .textarea:focus, .select:focus { outline: none; box-shadow: var(--focus); border-color: var(--brand); }
.btn.primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--brand) 90%, transparent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--sunken); color: var(--ink); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); background: var(--err-soft); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.icon { width: 38px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; }
.btn .cost { font-weight: 600; opacity: 0.85; font-size: 12.5px; padding-left: 8px; border-left: 1px solid rgba(255, 255, 255, 0.35); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field + .field { margin-top: 18px; }
.field > label, .label-row { font-size: 13px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.label-row .aside { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 12.5px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-sm);
  padding: 10px 12px; transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { resize: vertical; min-height: 92px; line-height: 1.55; }
.textarea.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; line-height: 1.6; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23857d8f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.hint { font-size: 12.5px; color: var(--muted); }
.hint.warn { color: var(--warn); }
.hint.err { color: var(--err); }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border-radius: 12px; border: 1px solid var(--line);
}
.seg button {
  display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; padding: 7px 13px; border-radius: 9px;
  font-weight: 650; font-size: 13.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.seg.block { display: flex; }
.seg.block button { flex: 1; justify-content: center; }
.aspect-glyph { border: 1.8px solid currentColor; border-radius: 3px; display: inline-block; }
.aspect-glyph.p { width: 10px; height: 16px; }
.aspect-glyph.l { width: 17px; height: 10px; }
.aspect-glyph.s { width: 13px; height: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 650; background: var(--sunken); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap;
}
.chip.brand { background: var(--brand-soft); color: var(--brand-ink); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.err { background: var(--err-soft); color: var(--err); }
.chip.outline { background: transparent; border-color: var(--line-2); }
button.chip { cursor: pointer; }
button.chip.toggle:not(.on) { background: transparent; border-color: var(--line-2); color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; }
.dot.pulse { animation: pulse 1.1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: 0.25; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Väljare med miniatyrer */
.picker { display: grid; grid-auto-flow: column; grid-auto-columns: 84px; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x proximity; }
.picker.wide { grid-auto-columns: 132px; }
.pick {
  position: relative; border: 0; padding: 0; background: var(--sunken); border-radius: 12px; overflow: hidden; cursor: pointer;
  aspect-ratio: 3 / 4; scroll-snap-align: start; outline: 2px solid transparent; outline-offset: 2px; transition: outline-color 0.15s, transform 0.15s;
}
.picker.wide .pick { aspect-ratio: 4 / 3; }
.pick img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.pick:hover { transform: translateY(-2px); }
.pick.on { outline-color: var(--brand); }
.pick.on::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--brand)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 12px no-repeat;
  box-shadow: 0 0 0 2px var(--surface);
}
.pick .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 11.5px; font-weight: 650; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pick.add, .pick.none { display: grid; place-items: center; color: var(--muted); border: 1.5px dashed var(--line-2); background: transparent; font-size: 12px; font-weight: 650; }
.pick.add:hover, .pick.none:hover { color: var(--brand-ink); border-color: var(--brand); }
.pick.add div, .pick.none div { display: flex; flex-direction: column; align-items: center; gap: 6px; }

.checker { background-color: #fff; background-image: conic-gradient(#eee 25%, #fff 0 50%, #eee 0 75%, #fff 0); background-size: 14px 14px; }
.pick.logo { aspect-ratio: 1; }
.pick.logo img, .tile .media.logo img { object-fit: contain; padding: 10px; background-color: #fff; background-image: conic-gradient(#eee 25%, #fff 0 50%, #eee 0 75%, #fff 0); background-size: 14px 14px; }

/* Förstoringsknapp och ljuslåda */
.zoom {
  position: absolute; z-index: 2; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; cursor: zoom-in;
  background: rgba(15, 12, 20, 0.62); color: #fff; backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.15s, transform 0.15s;
}
.zoom:hover { transform: scale(1.08); background: rgba(15, 12, 20, 0.8); }
.pick .zoom { top: 6px; left: 6px; width: 26px; height: 26px; }
.tile .media .zoom { bottom: 8px; right: 8px; }
.drawer-media { position: relative; }
.drawer-media .zoom { top: 10px; right: 10px; opacity: 1; }
.pick:hover .zoom, .tile:hover .zoom, .zoom:focus-visible { opacity: 1; }
@media (hover: none) { .zoom { opacity: 1; } }
.drawer-media img[data-preview], .action-card img[data-preview] { cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(8, 6, 12, 0.94); display: flex; flex-direction: column; animation: fade 0.15s; }
.lb-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 24px 72px 8px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: calc(100vh - 110px); border-radius: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); background: #000; }
.lb-bar { display: flex; align-items: center; gap: 10px; padding: 12px 20px 18px; color: #fff; }
.lb-cap { flex: 1; font-size: 14px; color: rgba(255, 255, 255, 0.85); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { font-size: 13px; color: rgba(255, 255, 255, 0.6); font-variant-numeric: tabular-nums; }
.lb-bar .btn { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.18); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.1); color: #fff; display: grid; place-items: center; }
.lb-nav:hover { background: rgba(255, 255, 255, 0.2); }
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }
@media (max-width: 820px) { .lb-stage { padding: 12px 8px 4px; } .lb-nav { top: auto; bottom: 70px; transform: none; } }

/* ---------- Studio ---------- */

.studio-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.studio-grid > .card { display: flex; flex-direction: column; }
.prompt-box summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px; }
.prompt-box summary::-webkit-details-marker { display: none; }
.prompt-box summary svg { transition: transform 0.15s; }
.prompt-box[open] summary svg { transform: rotate(90deg); }
.prompt-box .textarea { margin-top: 10px; min-height: 180px; }
.selected-scene { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.selected-scene .thumb { width: 92px; height: 116px; border-radius: 9px; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.tag-row .chip { height: 24px; font-size: 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 500; cursor: pointer; }
.tag-row .chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.plan-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-height: 26px; }
.range { width: 100%; accent-color: var(--brand); }

.result { display: grid; grid-template-columns: 1fr; gap: 12px; }
.progress-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-sm); background: var(--grad-soft); border: 1px solid var(--line); }
.progress-card b { display: block; font-size: 14px; }
.progress-card span { font-size: 12.5px; color: var(--muted); }
.progress-card .spinner { color: var(--brand); }

/* ---------- Kort i rutnät ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar .grow { flex: 1; }
.search { position: relative; min-width: 220px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 36px; height: 38px; }
.input.date { width: 158px; height: 38px; padding: 6px 10px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 14px; font-weight: 650; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--brand); }
.tabs .count { font-size: 12px; background: var(--sunken); padding: 1px 8px; border-radius: 99px; color: var(--muted); }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 18px; }
.tile {
  position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; cursor: pointer; box-shadow: var(--shadow-sm); transition: transform 0.15s, box-shadow 0.15s; text-align: left; padding: 0;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tile .media { position: relative; aspect-ratio: 4 / 5; background: var(--sunken); overflow: hidden; }
.tile .media img { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; }
.tile .badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.tile .badges .right { margin-left: auto; }
.tile .badges .chip { height: 22px; font-size: 11.5px; padding: 0 8px; background: rgba(15, 12, 20, 0.6); color: #fff; backdrop-filter: blur(6px); }
.tile .badges .chip.brand { background: var(--brand); }
.tile .badges .chip.err { background: var(--err); color: #fff; }
.tile .play { position: absolute; inset: 0; display: grid; place-items: center; }
.tile .play span { width: 44px; height: 44px; border-radius: 50%; background: rgba(15, 12, 20, 0.5); display: grid; place-items: center; color: #fff; backdrop-filter: blur(6px); }
.tile .play svg { fill: #fff; stroke: none; margin-left: 2px; }
.tile .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.tile .desc { font-size: 13.5px; line-height: 1.45; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile .desc.empty { color: var(--muted); font-style: italic; }
.tile .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-top: auto; }
.tile .meta .grow { flex: 1; }
.tile .busy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; font-size: 13px; font-weight: 650; background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 85%, transparent), color-mix(in srgb, var(--brand-2) 85%, transparent)); text-align: center; padding: 12px; }
.tile .busy .spinner { width: 22px; height: 22px; }
.shimmer { background: linear-gradient(100deg, var(--sunken) 30%, var(--surface-2) 50%, var(--sunken) 70%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px;
  padding: 48px 20px; border: 1.5px dashed var(--line-2); border-radius: var(--r); color: var(--muted);
}
.empty .big { width: 52px; height: 52px; border-radius: 16px; background: var(--grad-soft); display: grid; place-items: center; color: var(--brand-ink); }
.empty h3 { color: var(--ink); }

.section-head { display: flex; align-items: center; gap: 10px; margin: 30px 0 14px; }
.section-head .actions { margin-left: auto; }

/* ---------- Detaljpanel, modal, toast ---------- */

.scrim { position: fixed; inset: 0; background: rgba(12, 10, 16, 0.45); backdrop-filter: blur(3px); z-index: 40; animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); z-index: 41; background: var(--surface);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head .actions { margin-left: auto; display: flex; gap: 6px; }
.drawer-body { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.drawer-body > * { flex-shrink: 0; }
.drawer-media { border-radius: var(--r-sm); overflow: hidden; background: #000; display: grid; place-items: center; max-height: 58vh; }
.drawer-media img, .drawer-media video { max-height: 58vh; width: auto; max-width: 100%; }
.drawer-media.square img, .drawer-media.square video { aspect-ratio: 1; object-fit: cover; }
.meta-list { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 13.5px; margin: 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; overflow-wrap: anywhere; }
.save-state { font-size: 12px; color: var(--muted); transition: opacity 0.3s; }

.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
/* Högre än fönstret: rubrik och knappar står kvar, innehållet rullar. */
.modal { width: min(460px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); animation: pop 0.18s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
.modal-head { padding: 20px 22px 4px; }
.modal-body { padding: 14px 22px 4px; overflow-y: auto; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 14px 11px 12px; border-radius: 14px;
  background: #1c1922; color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600; animation: pop 0.2s;
}
.toast .ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.12); }
.toast.ok .ic { background: #138a3d; }
.toast.err .ic { background: #c8282d; }
.toast a { color: #ff9fcf; font-weight: 700; }

/* ---------- Kalender ---------- */

.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-head div { padding: 10px 12px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-day {
  min-height: 128px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 5px;
  cursor: pointer; transition: background 0.12s; min-width: 0;
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { background: var(--sunken); }
.cal-day.out .n { color: var(--muted); opacity: 0.6; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-day .n { font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; }
.cal-day.today .n span { background: var(--grad); color: #fff; border-radius: 8px; padding: 1px 7px; }
.cal-item {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px 3px 3px; border-radius: 7px; font-size: 12px; font-weight: 600; min-width: 0;
  background: var(--sunken); color: var(--ink-2); border: 1px solid transparent;
}
.cal-item img { width: 20px; height: 20px; border-radius: 5px; object-fit: cover; flex: none; }
.cal-item .ph { width: 20px; height: 20px; border-radius: 5px; flex: none; display: grid; place-items: center; background: var(--surface); color: var(--muted); }
.cal-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-item.film { background: color-mix(in srgb, var(--series-1) 12%, var(--surface)); }
.cal-item.scen { background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.cal-item.plan { background: transparent; border: 1.5px dashed var(--line-2); }
.cal-more { font-size: 11.5px; color: var(--muted); font-weight: 650; padding-left: 4px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.day-panel { margin-top: 22px; }

/* ---------- Kostnader ---------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { padding: 16px 18px; }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; margin-top: 2px; }
.stat .sub { font-size: 12.5px; color: var(--muted); }
.charts { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 20px; }
.chart-card { padding: 18px 20px; }
.chart-card h3 { margin-bottom: 4px; }
.chart { position: relative; margin-top: 14px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.tip {
  position: absolute; pointer-events: none; z-index: 3; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 10px 12px; font-size: 12.5px; min-width: 170px;
}
.tip b { display: block; margin-bottom: 6px; }
.tip .row { display: flex; align-items: center; gap: 8px; }
.tip .row .v { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 650; }
.hbar { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; font-size: 13px; margin-top: 12px; }
.hbar .track { height: 14px; background: transparent; position: relative; }
.hbar .fill { height: 14px; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .v { font-variant-numeric: tabular-nums; font-weight: 650; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 800; background: var(--surface-2); border-top: 1px solid var(--line); }
.table .ref { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; color: var(--ink); }
.table td.model { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.nw { white-space: nowrap; }

/* ---------- Bunny (persona, prompter, minnen) ---------- */

.bunny-head { display: flex; gap: 18px; align-items: center; padding: 20px; margin-bottom: 20px; background: var(--grad-soft); }
.avatar { width: 64px; height: 64px; border-radius: 20px; overflow: hidden; flex: none; background: var(--sunken); box-shadow: 0 0 0 3px var(--surface); }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; transform: scale(2.6); transform-origin: 47% 21%; background: #fff; }
.avatar.sm { width: 30px; height: 30px; border-radius: 10px; box-shadow: none; }
.bunny-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; }
.side-nav button { all: unset; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 650; font-size: 14px; color: var(--ink-2); }
.side-nav button:hover { background: var(--sunken); }
.side-nav button.on { background: var(--brand-soft); color: var(--brand-ink); }
.editor .textarea { min-height: 52vh; }
.placeholders { display: flex; flex-wrap: wrap; gap: 6px; }
.placeholders code { font-size: 12px; background: var(--sunken); border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

/* ---------- Chatt ---------- */

.chat {
  display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-left: 1px solid var(--line);
  position: relative;
}
.chat-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px; }
.chat-head .title { flex: 1; min-width: 0; font-weight: 750; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-mode { padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
.chat-list { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 100%; }
.msg .av { width: 30px; height: 30px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--grad); color: #fff; overflow: hidden; }
.msg .av svg { width: 16px; height: 16px; }
.msg .bubble { font-size: 14px; line-height: 1.55; min-width: 0; overflow-wrap: anywhere; }
.msg .bubble p { margin: 0 0 8px; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .bubble ul { margin: 4px 0 8px; padding-left: 20px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--brand-soft); color: var(--ink); padding: 9px 13px; border-radius: 16px 16px 4px 16px; max-width: 85%; }
.msg.bot .bubble { padding-top: 4px; flex: 1; }
.action-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.action-card .top { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.action-card .top img { width: 44px; height: 54px; border-radius: 8px; object-fit: cover; flex: none; }
.action-card .top b { display: block; font-size: 13px; }
.action-card .top span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.action-card .btns { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.chat-empty { margin: auto 0; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.chat-empty h3 { font-size: 17px; }
.chat-empty .av { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--grad); color: #fff; overflow: hidden; }
.chat-empty .av svg { width: 20px; height: 20px; }
.suggestion { all: unset; cursor: pointer; font-size: 13.5px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); width: 100%; box-sizing: border-box; }
.suggestion:hover { border-color: var(--brand); color: var(--brand-ink); }
.composer { padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.composer-box { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--line-2); border-radius: 16px; padding: 6px 6px 6px 12px; background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; }
.composer-box:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.composer textarea { flex: 1; border: 0; resize: none; background: transparent; outline: none; max-height: 180px; min-height: 24px; padding: 7px 0; line-height: 1.45; }
.history {
  position: absolute; inset: 0; z-index: 4; background: var(--surface); display: flex; flex-direction: column; animation: fade 0.12s;
}
.history-list { overflow-y: auto; padding: 8px; }
.history-item { all: unset; box-sizing: border-box; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; cursor: pointer; width: 100%; }
.history-item:hover { background: var(--sunken); }
.history-item.on { background: var(--brand-soft); }
.history-item b { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item span { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.chat-fab { display: none; }
@media (max-width: 820px) {
  .chat-fab {
    display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 31;
    width: 52px; height: 52px; border-radius: 18px; border: 0; background: var(--grad); color: #fff; box-shadow: 0 12px 28px -10px color-mix(in srgb, var(--brand) 80%, transparent); cursor: pointer;
  }
  .chat-fab svg { width: 22px; height: 22px; }
  .app:not(.chat-closed) ~ .chat-fab { display: none; }
}

/* ---------- Inloggning, konto och användare ---------- */

body.signed-out .app, body.signed-out .chat-fab { display: none; }
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 60%), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--brand-2) 14%, transparent), transparent 60%), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 28px 28px 24px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-weight: 800; letter-spacing: -0.02em; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card form { margin-top: 18px; }
.auth-card .field + .field { margin-top: 12px; }
.auth-err { margin-top: 12px; padding: 10px 12px; border-radius: var(--r-xs); background: var(--err-soft); color: var(--err); font-size: 13.5px; font-weight: 600; }
.auth-btn { width: 100%; justify-content: center; margin-top: 18px; height: 44px; }
.auth-foot { margin: 16px 0 0; text-align: center; }

.me {
  flex: none; margin-left: auto; width: 36px; height: 36px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 3px var(--surface), 0 4px 12px -6px color-mix(in srgb, var(--brand) 80%, transparent);
}
.topbar .actions:not(:empty) + .me { margin-left: 4px; }
.me:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--surface), var(--focus); }
.me-initials { font-size: 13px; font-weight: 800; letter-spacing: 0.02em; }
.me.big { width: 46px; height: 46px; margin-left: 0; cursor: default; box-shadow: none; }
.me.big .me-initials { font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.account-head { display: flex; gap: 14px; align-items: flex-start; }

.user-list { display: grid; gap: 12px; }
.user-row { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; }
.user-row.off { opacity: 0.6; }
.user-main { flex: 1; min-width: 0; }
.user-name { display: flex; gap: 8px; align-items: baseline; }
.user-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pw-box { font-size: 22px; letter-spacing: 0.06em; text-align: center; padding: 16px; border-radius: var(--r-sm); background: var(--sunken); border: 1px dashed var(--line-2); user-select: all; margin-bottom: 10px; }

@container view (max-width: 700px) {
  .user-row { flex-wrap: wrap; }
  .user-side { width: 100%; align-items: flex-start; }
  .user-actions { justify-content: flex-start; }
}

/* ---------- Mindre skärmar ---------- */

/* Layouten följer innehållsytan (som krymper när chatten är dockad), inte fönstret. */
@container view (max-width: 980px) {
  .studio-grid { grid-template-columns: minmax(0, 1fr); }
  .charts { grid-template-columns: minmax(0, 1fr); }
}
@container view (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .bunny-layout, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .side-nav { flex-direction: row; overflow-x: auto; }
}
@container view (max-width: 480px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1180px) {
  .app, .app.chat-closed { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .chat { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 45; box-shadow: var(--shadow-lg); }
  .app.chat-closed .chat { display: none; }
}
@media (max-width: 820px) {
  :root { --sidebar: 0px; }
  .app, .app.chat-closed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); overflow: visible;
  }
  .sidebar .brand, .sidebar .spacer, .sidebar .side-card, .sidebar .side-foot, .sidebar .switch-wrap, .nav-sep { display: none; }
  .nav { display: flex; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11px; }
  .nav a .count { display: none; }
  .nav a[data-wide] { display: none; }
  .topbar { padding: 14px 16px 10px; }
  .view { padding: 4px 16px 96px; }
  h1 { font-size: 22px; }
  .cal-day { min-height: 74px; padding: 5px; }
  .cal-item span { display: none; }
  .cal-item { padding: 2px; }
  .cal-head div { padding: 8px 4px; text-align: center; }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .chat { width: 100vw; }
}

@media print {
  .sidebar, .chat, .topbar .actions, .toolbar, .charts, .no-print { display: none !important; }
  .app { display: block; height: auto; }
  .main { overflow: visible; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* ---------- Projekt ---------- */

.switch-menu .menu-head { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 8px 8px 4px; }
.switch-menu .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.no-costs .side-card .label, body.no-costs .side-card .value { display: none; }
body.no-costs .side-card:has(.jobs:empty) { display: none; }
body.no-costs .side-card .jobs { margin-top: 0; }
.auth-seg { margin-top: 18px; }
.project-pick { display: grid; gap: 6px; }
.project-pick button {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); cursor: pointer; font-weight: 650; font-size: 14px;
}
.project-pick button:hover { background: var(--sunken); }
.project-pick button.on { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.project-pick button span { flex: 1; min-width: 0; }
.project-pick button:focus-visible { box-shadow: var(--focus); }
.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.project-card { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color 0.15s, transform 0.15s; }
.project-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.project-card:focus-visible { box-shadow: var(--focus); }
.project-card h3 { display: flex; gap: 10px; align-items: center; }
.project-card.new { align-items: center; justify-content: center; color: var(--muted); border-style: dashed; box-shadow: none; min-height: 132px; font-weight: 650; }
.project-sections { display: grid; gap: 18px; }
.project-sections .card { padding: 18px 20px; }
.project-sections .card h3 { margin-bottom: 4px; }
.member-row, .invite-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.member-row:first-of-type, .invite-row:first-of-type { border-top: 0; }
.member-row .me.big { width: 36px; height: 36px; }
.member-row .me.big .me-initials { font-size: 12.5px; }
.member-row .grow, .invite-row .grow { flex: 1; min-width: 0; }
.link-box { font-size: 13px; word-break: break-all; padding: 12px 14px; border-radius: var(--r-sm); background: var(--sunken); border: 1px dashed var(--line-2); user-select: all; margin-bottom: 10px; }
@container view (max-width: 600px) {
  .member-row, .invite-row { flex-wrap: wrap; }
}
.key-list { margin-top: 6px; }
.key-row { padding: 14px 0; border-top: 1px solid var(--line); }
.key-row:first-child { border-top: 0; }
.member-roles { display: grid; gap: 8px; }
.member-role { display: flex; align-items: center; gap: 12px; font-weight: 650; }
.member-role span { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.member-role .select { width: auto; min-width: 170px; }
.member-block { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.limit-row { display: grid; gap: 8px; margin-top: 10px; }
.limit-row label { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 500; }
.limit-row .input { width: 76px; }
.limit-row [name=max_clips] { width: 124px; }
.proj-lines { display: grid; gap: 6px; margin-top: 8px; }
.proj-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.proj-line .proj-name { display: inline-flex; gap: 6px; align-items: center; font-weight: 650; font-size: 13.5px; margin-right: 4px; }

/* Sidomenyns delar: projektet överst, studion, det som hör till projektet och admin. */
.switcher .sw-text .sw-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 16px 12px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-label.admin { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.project-nav { margin: -4px 0 6px; }
.studio-wrap { margin-bottom: 2px; border-top: 1px solid var(--line); }
.studio-wrap .nav-label { padding-top: 14px; }
.studio-switcher {
  all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 8px;
  border-radius: 12px; cursor: pointer; font-size: 15px; letter-spacing: -0.01em;
}
.studio-switcher:hover { background: var(--sunken); }
.studio-switcher:focus-visible { box-shadow: var(--focus); }
.studio-switcher b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio-switcher .avatar.sm { width: 28px; height: 28px; border-radius: 9px; }
.switch-menu .menu-empty { padding: 8px; font-size: 13px; color: var(--muted); }
@media (max-width: 820px) {
  .nav-label { display: none; }
  /* I mobilens nederkant: studions flikar först, sedan projektets. */
  .sidebar .project-nav { order: 2; flex: 0 0 auto; margin: 0; }
  .sidebar #nav { order: 1; }
}

/* Chatten: assistenten och projektets karaktärer. */
.chat-who { display: flex; flex-wrap: wrap; }
.chat-who button { flex: 1 1 auto; justify-content: center; min-width: 0; }
.who-av { width: 18px; height: 18px; border-radius: 6px; overflow: hidden; flex: none; background: var(--sunken); }
.who-av img { width: 100%; height: 100%; object-fit: cover; object-position: center 15%; }
.chat.no-studio .chat-mode, .chat.no-studio .composer, .chat.no-studio #histBtn, .chat.no-studio #newBtn { display: none; }

/* Dokumentationen (admin): innehållsförteckning till vänster, ett kort per kapitel. */
.doc-toc { position: sticky; top: 76px; }
.doc { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.doc-chapter { min-width: 0; padding: 20px 24px 22px; scroll-margin-top: 80px; }
.doc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.doc-head h2 { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.doc-head h2 svg { color: var(--brand-ink); }
.doc-chapter h3 { margin: 22px 0 8px; }
.doc-chapter p { margin: 0 0 10px; line-height: 1.55; color: var(--ink-2); }
.doc-chapter p.hint { font-size: 12.5px; color: var(--muted); }
.doc-chapter ul { margin: 0 0 10px; padding-left: 20px; line-height: 1.55; }
.doc-chapter code { font-size: 12px; background: var(--sunken); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.doc-dl { display: grid; grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); gap: 0; margin: 0 0 10px; font-size: 14px; }
.doc-dl dt, .doc-dl dd { padding: 9px 0; border-top: 1px solid var(--line); line-height: 1.5; }
.doc-dl dt { font-weight: 700; padding-right: 16px; }
.doc-dl dd { margin: 0; color: var(--ink-2); }
.doc-dl dt:first-of-type, .doc-dl dt:first-of-type + dd { border-top: 0; }
.doc-table { margin-bottom: 6px; font-size: 13.5px; }
.doc-table td:not(:first-child), .doc-table th:not(:first-child) { text-align: center; white-space: nowrap; }
.doc-yes { color: var(--ok); font-weight: 800; }
@container view (max-width: 760px) {
  .doc-toc { top: 70px; z-index: 4; }
  .doc-toc button { white-space: nowrap; flex: none; }
  .doc-dl { grid-template-columns: minmax(0, 1fr); }
  .doc-dl dt { padding-bottom: 0; }
  .doc-dl dd { border-top: 0; padding-top: 2px; }
  .doc-table td:not(:first-child), .doc-table th:not(:first-child) { white-space: normal; }
}
@media (max-width: 820px) { .doc-toc { position: static; } }
@media print {
  .doc-toc { display: none; }
  .doc-layout { display: block; }
  .doc-chapter { break-inside: avoid-page; }
}
