/* ==========================================================================
   QIG Social Platform — Design System
   Light (warm editorial, default) + dark editorial themes via
   html[data-theme="light|dark"]. Space Grotesk (display) + Inter (body).
   Brand accents used semantically: QGN gradient, Aeria yellow, QDK orange —
   identical in both themes.
   ========================================================================== */

:root {
  /* ------------------------------------------------------------------
     THEME-INVARIANT TOKENS (brand, type, metrics)
     ------------------------------------------------------------------ */

  /* --- Brand: QGN --- */
  --qgn-grad:      linear-gradient(100deg,#F4D548 0%,#A7CB3F 24%,#4FB477 44%,#1AC0A6 66%,#2BB0E6 100%);
  --qgn-grad-text: linear-gradient(95deg,#9C6E0A 0%,#3E8C28 26%,#0C7E76 58%,#1A7EC0 100%);
  --qgn:           #4FB477;
  --qgn-soft:      rgba(79,180,119,0.14);
  --qgn-line:      rgba(79,180,119,0.42);

  /* --- Brand: Aeria --- */
  --aeria:      #FDD756;
  --aeria-dark: #232827;
  --aeria-soft: rgba(253,215,86,0.13);
  --aeria-line: rgba(253,215,86,0.42);

  /* --- Brand: QDK --- */
  --qdk:      #FE5000;
  --qdk-soft: rgba(254,80,0,0.13);
  --qdk-line: rgba(254,80,0,0.42);

  /* --- Type --- */
  --font-display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* --- Metrics --- */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --header-h: 62px;
  --maxw: 1220px;
  --tab-num: "tnum" 1, "lnum" 1;

  /* ------------------------------------------------------------------
     LIGHT THEME (default) — warm editorial linen, QIG master brand
     ------------------------------------------------------------------ */
  color-scheme: light;

  /* --- Surfaces (linen / warm white) --- */
  --bg:        #F4F2EF;
  --bg-2:      #EDEAE4;
  --surface:   #FFFFFF;
  --surface-2: #F7F5F1;
  --surface-3: #EDE9E3;
  --elevated:  #FFFFFF;
  --line:      #E8E4DF;
  --line-2:    #D8D2CA;
  --overlay:   rgba(40, 34, 28, 0.40);
  --appbar-bg: rgba(247, 245, 241, 0.85);

  /* --- Ink (near-black with warm dim/faint steps) --- */
  --ink:       #1A1A1A;
  --ink-2:     #403C37;
  --ink-3:     #5D5850;
  --ink-4:     #6F6A62;
  --ink-faint: #B9B2A8;
  --ink-contrast: #FFFFFF;  /* text sitting on a var(--ink) surface */
  --ink-strong:   #000000;  /* hover state of the primary (ink) button */

  /* --- Functional (darkened for AA contrast on light surfaces) --- */
  --good:     #1E7A47;
  --warn:     #946A00;
  --bad:      #C62F35;
  --info:     #0B6E99;
  --building: #6B3FBF;

  /* --- Brand chip / pill ink (readable brand-tinted text) --- */
  --qgn-ink:   #2E7D4F;
  --aeria-ink: #8A6400;
  --qdk-ink:   #BA3B00;

  /* --- Shadows (lighter, subtler in light mode) --- */
  --shadow:    0 1px 2px rgba(60,50,40,0.04), 0 10px 28px -18px rgba(60,50,40,0.14);
  --shadow-lg: 0 24px 60px -24px rgba(60,50,40,0.30);
}

/* ------------------------------------------------------------------
   DARK THEME — near-black editorial (the original palette)
   ------------------------------------------------------------------ */
html[data-theme="dark"] {
  color-scheme: dark;

  --bg:        #0e0f12;
  --bg-2:      #131519;
  --surface:   #16181d;
  --surface-2: #1b1e24;
  --surface-3: #22262e;
  --elevated:  #1e2229;
  --line:      #262b33;
  --line-2:    #313742;
  --overlay:   rgba(8, 9, 11, 0.72);
  --appbar-bg: rgba(14, 15, 18, 0.82);

  --ink:       #f4f5f7;
  --ink-2:     #c4c9d2;
  --ink-3:     #8a919e;
  --ink-4:     #5e6572;
  --ink-faint: #3c414b;
  --ink-contrast: #0d0e11;
  --ink-strong:   #ffffff;

  --good:     #4FB477;
  --warn:     #FDD756;
  --bad:      #FF5B60;
  --info:     #2BB0E6;
  --building: #c9a3ff;

  --qgn-ink:   #bfe6cd;
  --aeria-ink: #f6e6a8;
  --qdk-ink:   #ffb492;

  --shadow:    0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px -12px rgba(0,0,0,0.55);
  --shadow-lg: 0 24px 60px -20px rgba(0,0,0,0.7);
}

/* ==========================================================================
   Reset / base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; margin: 0; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(43,176,230,0.32); }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: var(--tab-num); }

/* Scrollbar */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 20px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ==========================================================================
   Login
   ========================================================================== */
#login {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 620px at 78% -8%, rgba(43,176,230,0.10), transparent 60%),
    radial-gradient(900px 560px at 12% 108%, rgba(79,180,119,0.10), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 40px 36px 34px;
  box-shadow: var(--shadow-lg);
}
.login-mark {
  display: flex; align-items: center; gap: 11px; margin-bottom: 26px;
}
.login-mark .dotset { display: flex; gap: 5px; }
.login-mark .dotset i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.login-title { font-size: 20px; letter-spacing: -0.02em; }
.login-title b { font-weight: 600; }
.login-title .thin { color: var(--ink-3); font-weight: 400; }
.login-card h2 { font-size: 26px; margin-bottom: 6px; }
.login-card .sub { color: var(--ink-3); font-size: 13.5px; margin-bottom: 26px; }
.login-card label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin-bottom: 8px; }
.login-card .field { margin-bottom: 18px; }
.login-err {
  color: var(--bad); font-size: 13px; margin-bottom: 16px; min-height: 18px;
  display: flex; align-items: center; gap: 7px;
}
.login-err:empty { display: none; }

/* ==========================================================================
   App shell
   ========================================================================== */
#app { display: none; min-height: 100vh; flex-direction: column; }
#app.ready { display: flex; }

.appbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 24px;
  background: var(--appbar-bg);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brandmark { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brandmark .grad-bar { width: 4px; height: 26px; border-radius: 3px; background: var(--qgn-grad); }
.brandmark .wm { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.brandmark .wm span { color: var(--ink-3); font-weight: 400; }

.nav { display: flex; gap: 2px; margin-left: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 13px; border-radius: 9px; font-size: 13.5px; font-weight: 500;
  color: var(--ink-3); white-space: nowrap; position: relative; transition: color .15s, background .15s;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.active { color: var(--ink); background: var(--surface-3); }

.appbar-right { display: flex; align-items: center; gap: 14px; margin-left: auto; flex-shrink: 0; }
.legend { display: flex; align-items: center; gap: 9px; padding-right: 4px; }
.legend .ld { display: flex; align-items: center; gap: 5px; }
.legend .ld i { width: 9px; height: 9px; border-radius: 50%; }
.legend .ld span { font-size: 11px; color: var(--ink-3); letter-spacing: 0.02em; }
.legend .ld i.b-qgn { background: var(--qgn-grad); }
.legend .ld i.b-aeria { background: var(--aeria); }
.legend .ld i.b-qdk { background: var(--qdk); }

.bell { position: relative; }
.bell button, .theme-toggle button {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center;
  transition: background .15s, color .15s, border-color .15s;
}
.bell button:hover, .theme-toggle button:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line-2); }

/* Theme toggle: moon shown in light (switch to dark), sun shown in dark */
.theme-toggle .ic-sun { display: none; }
html[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
html[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
.bell .badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg); font-variant-numeric: tabular-nums;
}
.bell .badge.hide { display: none; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2);
  background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 700;
  display: grid; place-items: center; cursor: pointer; letter-spacing: 0.02em;
}
.avatar:hover { color: var(--ink); }

/* Notifications popover */
.notif-pop {
  position: absolute; top: calc(100% + 12px); right: 0; width: 360px; max-width: calc(100vw - 32px);
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); z-index: 80; overflow: hidden;
  animation: pop .14s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.notif-pop .np-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notif-pop .np-head b { font-family: var(--font-display); font-size: 14px; }
.notif-pop .np-body { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: 11px; padding: 13px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.notif-item:last-child { border-bottom: none; }
.notif-item .ni-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.notif-item .ni-txt { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.notif-item .ni-txt time { display: block; color: var(--ink-4); font-size: 11.5px; margin-top: 3px; }
.notif-empty { padding: 30px 16px; text-align: center; color: var(--ink-4); font-size: 13px; }

/* ==========================================================================
   Layout
   ========================================================================== */
.main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 30px 24px 80px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head .ph-l { min-width: 0; }
.page-head .eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-4); margin-bottom: 9px; font-weight: 600; }
.page-head h1 { font-size: 30px; letter-spacing: -0.025em; }
.page-head .lede { color: var(--ink-3); font-size: 14px; margin-top: 8px; max-width: 60ch; }
.page-head .ph-r { display: flex; gap: 10px; flex-wrap: wrap; }

/* Toolbar (filters) */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; color: var(--ink-3); padding: 6px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 500; transition: color .12s, background .12s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface-3); color: var(--ink); }
.seg button.on .bd { box-shadow: 0 0 0 3px var(--surface-3); }
.seg .bd { width: 8px; height: 8px; border-radius: 50%; }

/* ==========================================================================
   Form controls
   ========================================================================== */
.inp, .sel, .ta {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; color: var(--ink); font-size: 14px;
  transition: border-color .15s, background .15s; -webkit-appearance: none; appearance: none;
}
.inp::placeholder, .ta::placeholder { color: var(--ink-4); }
.inp:focus, .sel:focus, .ta:focus { outline: none; border-color: var(--line-2); background: var(--surface-2); }
.ta { resize: vertical; min-height: 96px; line-height: 1.5; }
.sel {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236f6a62' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
html[data-theme="dark"] .sel {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a919e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
.search { position: relative; }
.search .inp { padding-left: 38px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-4); pointer-events: none; }
.fld { margin-bottom: 16px; }
.fld > label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); margin-bottom: 8px; }
.fld .hint { color: var(--ink-4); font-size: 12px; margin-top: 6px; }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-size: 13.5px; font-weight: 500;
  transition: background .14s, border-color .14s, transform .05s, opacity .14s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { flex-shrink: 0; }
.btn.sm { padding: 7px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { padding: 13px 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--ink-contrast); border-color: var(--ink); font-weight: 600; }
.btn.primary:hover { background: var(--ink-strong); border-color: var(--ink-strong); }
.btn.danger { color: var(--bad); border-color: transparent; background: transparent; }
.btn.danger:hover { background: rgba(255,91,96,0.1); border-color: rgba(255,91,96,0.28); }
.btn.icon { padding: 9px; width: 38px; height: 38px; }

/* Brand-tinted action buttons */
.btn.brand[data-b="qgn"] { background: var(--qgn-grad); color: #0c1410; border-color: transparent; font-weight: 600; }
.btn.brand[data-b="qgn"]:hover { filter: brightness(1.06); }
.btn.brand[data-b="aeria"] { background: var(--aeria); color: #1c1c1c; border-color: transparent; font-weight: 600; }
.btn.brand[data-b="aeria"]:hover { filter: brightness(1.04); }
.btn.brand[data-b="qdk"] { background: var(--qdk); color: #fff; border-color: transparent; font-weight: 600; }
.btn.brand[data-b="qdk"]:hover { background: #ff6a26; }

/* ==========================================================================
   Chips / badges
   ========================================================================== */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 100px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; border: 1px solid var(--line-2);
  color: var(--ink-2); background: var(--surface-2); white-space: nowrap;
}
.chip.sm { padding: 3px 8px; font-size: 11px; }
.chip i.dot { width: 7px; height: 7px; border-radius: 50%; }

/* Brand chips */
.chip.brand[data-b="qgn"] { border-color: var(--qgn-line); color: var(--qgn-ink); background: var(--qgn-soft); }
.chip.brand[data-b="qgn"] i.dot { background: var(--qgn-grad); }
.chip.brand[data-b="aeria"] { border-color: var(--aeria-line); color: var(--aeria-ink); background: var(--aeria-soft); }
.chip.brand[data-b="aeria"] i.dot { background: var(--aeria); }
.chip.brand[data-b="qdk"] { border-color: var(--qdk-line); color: var(--qdk-ink); background: var(--qdk-soft); }
.chip.brand[data-b="qdk"] i.dot { background: var(--qdk); }

/* Status chips */
.chip.st { text-transform: capitalize; }
.chip.st[data-s="new"]         { color: var(--info);  border-color: rgba(43,176,230,0.4);  background: rgba(43,176,230,0.1); }
.chip.st[data-s="shortlisted"] { color: var(--warn);  border-color: rgba(253,215,86,0.4);  background: rgba(253,215,86,0.1); }
.chip.st[data-s="building"]    { color: var(--building); border-color: rgba(170,120,255,0.4); background: rgba(170,120,255,0.12); }
.chip.st[data-s="built"]       { color: var(--good);  border-color: rgba(79,180,119,0.4);  background: rgba(79,180,119,0.1); }
.chip.st[data-s="rejected"],
.chip.st[data-s="expired"],
.chip.st[data-s="cancelled"]   { color: var(--ink-4); border-color: var(--line-2); background: var(--surface-2); }
.chip.st[data-s="scheduled"]   { color: var(--info);  border-color: rgba(43,176,230,0.4);  background: rgba(43,176,230,0.1); }
.chip.st[data-s="notified"]    { color: var(--warn);  border-color: rgba(253,215,86,0.4);  background: rgba(253,215,86,0.1); }
.chip.st[data-s="done"],
.chip.st[data-s="posted"]      { color: var(--good);  border-color: rgba(79,180,119,0.4);  background: rgba(79,180,119,0.1); }
.chip.st[data-s="received"]    { color: var(--ink-2); }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card.pad { padding: 20px; }

/* Brand left-accent card */
.acard { position: relative; overflow: hidden; }
.acard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.acard[data-b="qgn"]::before   { background: var(--qgn-grad); }
.acard[data-b="aeria"]::before { background: var(--aeria); }
.acard[data-b="qdk"]::before   { background: var(--qdk); }

/* Grids */
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: 1.6fr 1fr; align-items: start; }
.grid.imgs { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

/* ==========================================================================
   Idea cards
   ========================================================================== */
.idea { padding: 20px 22px 18px 26px; display: flex; flex-direction: column; gap: 13px; transition: border-color .15s; }
.idea:hover { border-color: var(--line-2); }
.idea .i-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.idea .i-top .spacer { flex: 1; }
.idea .i-date { font-size: 12px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.idea h3 { font-size: 18px; line-height: 1.25; letter-spacing: -0.02em; }
.idea .hook { color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.idea .meta { display: flex; flex-direction: column; gap: 9px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.idea .meta .row { display: flex; gap: 9px; font-size: 13px; align-items: baseline; }
.idea .meta .row .k { color: var(--ink-4); flex-shrink: 0; width: 74px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; padding-top: 1px; }
.idea .meta .row .v { color: var(--ink-2); line-height: 1.45; }
.idea .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.idea .i-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.idea .i-foot .spacer { flex: 1; }
.idea .src { font-size: 12.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.idea .src:hover { color: var(--info); }
.idea.is-building { opacity: 0.92; }
.building-strip {
  display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--building);
  background: rgba(170,120,255,0.08); border: 1px solid rgba(170,120,255,0.24);
  padding: 9px 12px; border-radius: 9px;
}
.spin { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ==========================================================================
   Stat tiles (dashboard)
   ========================================================================== */
.stat { padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.stat .st-k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); display: flex; align-items: center; gap: 8px; font-weight: 600; }
.stat .st-k i.dot { width: 9px; height: 9px; border-radius: 50%; }
.stat .st-v { font-family: var(--font-display); font-size: 40px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; margin-top: 6px; }
.stat .st-sub { font-size: 12.5px; color: var(--ink-4); }
.stat.link { transition: border-color .15s, transform .1s; }
.stat.link:hover { border-color: var(--line-2); }

/* Section header */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 34px 0 16px; }
.sec-head h2 { font-size: 18px; letter-spacing: -0.02em; }
.sec-head a { font-size: 13px; color: var(--ink-3); }
.sec-head a:hover { color: var(--ink); }

/* Rows list (dashboard latest packs / activity) */
.rowlist { display: flex; flex-direction: column; }
.rrow { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--line); }
.rrow:last-child { border-bottom: none; }
.rrow .rr-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.rrow .rr-main { flex: 1; min-width: 0; }
.rrow .rr-title { font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rrow .rr-sub { font-size: 12px; color: var(--ink-4); margin-top: 2px; }
.rrow .rr-time { font-size: 12px; color: var(--ink-4); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* Due-soon rail */
.due-item { display: flex; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--line); align-items: center; }
.due-item:last-child { border-bottom: none; }
.due-item .di-when { width: 62px; flex-shrink: 0; text-align: center; }
.due-item .di-when .d { font-family: var(--font-display); font-size: 21px; font-weight: 600; line-height: 1; }
.due-item .di-when .m { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-4); margin-top: 3px; }
.due-item .di-body { flex: 1; min-width: 0; }
.due-item .di-title { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-item .di-sub { font-size: 12px; color: var(--ink-4); margin-top: 3px; display: flex; align-items: center; gap: 7px; }
.due-item.overdue .di-when .d { color: var(--bad); }

/* ==========================================================================
   Packs
   ========================================================================== */
.pack { display: flex; flex-direction: column; }
.pack .pk-head { padding: 20px 22px 16px 26px; }
.pack .pk-head .pk-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.pack .pk-head h3 { font-size: 19px; letter-spacing: -0.02em; line-height: 1.25; }
.pack .pk-head .pk-date { font-size: 12px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 2px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: none; background: none; color: var(--ink-3); padding: 11px 14px; font-size: 13px; font-weight: 500;
  position: relative; transition: color .14s;
}
.tabs button:hover { color: var(--ink-2); }
.tabs button.on { color: var(--ink); }
.tabs button.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.tab-body { padding: 20px 22px 22px 26px; }
.copyblock { position: relative; }
.copyblock .cb-txt {
  white-space: pre-wrap; font-size: 13.5px; line-height: 1.62; color: var(--ink-2);
  max-height: 320px; overflow-y: auto; padding: 15px 16px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 11px;
}
.copyblock .cb-txt.blog { font-size: 14px; }
.copyblock .cb-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.copyblock .cb-bar .cb-meta { font-size: 12px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.seo-box { margin-top: 14px; padding: 14px 16px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; }
.seo-box .seo-k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-4); margin-bottom: 8px; font-weight: 600; }
.seo-box .kw { display: flex; gap: 6px; flex-wrap: wrap; }
.seo-box p { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.seo-box + .seo-box { margin-top: 10px; }

.pack-img { position: relative; border-radius: 11px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 1; background: var(--bg-2); }
.pack-img img { width: 100%; height: 100%; object-fit: cover; }
.pack-img .pi-ov { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0,0,0,0.6), transparent 45%); opacity: 0; transition: opacity .16s; display: flex; align-items: flex-end; justify-content: flex-end; padding: 10px; gap: 6px; }
.pack-img:hover .pi-ov { opacity: 1; }
.pack-img .pi-btn { width: 32px; height: 32px; border-radius: 8px; background: rgba(20,22,26,0.9); border: 1px solid rgba(255,255,255,0.16); color: #fff; display: grid; place-items: center; }
.pack-img .pi-btn:hover { background: rgba(30,34,40,0.95); }

.noimg {
  padding: 26px; text-align: center; border: 1px dashed var(--line-2); border-radius: 12px; background: var(--bg-2);
}
.noimg p { color: var(--ink-3); font-size: 13.5px; margin-bottom: 15px; max-width: 42ch; margin-left: auto; margin-right: auto; }

/* ==========================================================================
   Create (image studio)
   ========================================================================== */
.studio { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 940px) { .studio { grid-template-columns: 380px 1fr; align-items: start; } }
.studio-panel { position: sticky; top: calc(var(--header-h) + 22px); }
.brandpick { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 20px; }
.brandpick button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 13px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 7px; transition: border-color .14s, background .14s;
}
.brandpick button i.dot { width: 15px; height: 15px; border-radius: 50%; }
.brandpick button i.dot.b-qgn { background: var(--qgn-grad); }
.brandpick button i.dot.b-aeria { background: var(--aeria); }
.brandpick button i.dot.b-qdk { background: var(--qdk); }
.brandpick button span { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.brandpick button:hover { border-color: var(--line-2); }
.brandpick button.on { background: var(--surface-3); }
.brandpick button.on span { color: var(--ink); }
.brandpick button.on[data-b="qgn"] { border-color: var(--qgn-line); }
.brandpick button.on[data-b="aeria"] { border-color: var(--aeria-line); }
.brandpick button.on[data-b="qdk"] { border-color: var(--qdk-line); }

.opt-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.opt-grid.two { grid-template-columns: repeat(3,1fr); }
.opt {
  border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 10px 6px;
  text-align: center; transition: border-color .12s, background .12s;
}
.opt .oi { display: grid; place-items: center; height: 30px; color: var(--ink-3); }
.opt .ol { font-size: 11.5px; color: var(--ink-3); font-weight: 500; margin-top: 2px; }
.opt:hover { border-color: var(--line-2); }
.opt.on { background: var(--surface-3); border-color: var(--line-2); }
.opt.on .ol, .opt.on .oi { color: var(--ink); }
.ratio-box { border: 1.5px solid currentColor; border-radius: 3px; }

.result-stage {
  min-height: 300px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-2);
  display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden;
}
.result-stage .placeholder { text-align: center; color: var(--ink-4); }
.result-stage .placeholder svg { margin: 0 auto 14px; opacity: 0.5; }
.gen-progress { text-align: center; }
.gen-progress .big-spin { width: 40px; height: 40px; border: 3px solid var(--line-2); border-top-color: var(--ink-2); border-radius: 50%; animation: sp 0.9s linear infinite; margin: 0 auto 18px; }
.gen-progress .gp-t { font-family: var(--font-display); font-size: 15px; color: var(--ink-2); }
.gen-progress .gp-s { font-size: 12.5px; color: var(--ink-4); margin-top: 6px; }
.result-img { width: 100%; }
.result-img img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.saved-note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--good); margin-top: 14px; }

.history-rail { margin-top: 26px; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px,1fr)); gap: 9px; }
.hist-item { position: relative; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 1; background: var(--bg-2); cursor: pointer; }
.hist-item img { width: 100%; height: 100%; object-fit: cover; }
.hist-item .hi-ov { position: absolute; inset: 0; background: rgba(10,11,13,0.55); opacity: 0; display: grid; place-items: center; transition: opacity .14s; color: #fff; }
.hist-item:hover .hi-ov { opacity: 1; }

/* Studio brand theming (accent variable swap) */
.studio[data-b="qgn"]   { --accent: var(--qgn); --accent-line: var(--qgn-line); }
.studio[data-b="aeria"] { --accent: var(--aeria); --accent-line: var(--aeria-line); }
.studio[data-b="qdk"]   { --accent: var(--qdk); --accent-line: var(--qdk-line); }

/* ==========================================================================
   Calendar
   ========================================================================== */
.cal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.cal-head h2 { font-size: 22px; letter-spacing: -0.02em; min-width: 220px; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; }
.cal-nav button:hover { background: var(--surface-3); color: var(--ink); }

.cal-layout { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 1000px) { .cal-layout { grid-template-columns: 1fr 320px; align-items: start; } }

.cal-grid { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.cal-dow { display: grid; grid-template-columns: repeat(7,1fr); background: var(--bg-2); border-bottom: 1px solid var(--line); }
.cal-dow div { padding: 10px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-4); text-align: center; font-weight: 600; }
.cal-body { display: grid; grid-template-columns: repeat(7,1fr); }
.cal-cell { min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 7px 8px; position: relative; cursor: pointer; transition: background .12s; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.other { background: var(--bg); opacity: 0.5; }
.cal-cell.today .cc-n { background: var(--ink); color: var(--ink-contrast); }
.cal-cell .cc-n { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-3); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; font-weight: 500; }
.cal-cell .cc-add { position: absolute; top: 7px; right: 7px; opacity: 0; color: var(--ink-4); transition: opacity .12s; }
.cal-cell:hover .cc-add { opacity: 1; }
.cal-events { margin-top: 5px; display: flex; flex-direction: column; gap: 3px; }
.cal-pill {
  font-size: 11px; padding: 3px 7px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-weight: 500; border-left: 3px solid; background: var(--surface-2); color: var(--ink-2);
  display: flex; align-items: center; gap: 5px;
}
.cal-pill[data-b="qgn"]   { border-color: var(--qgn); background: var(--qgn-soft); color: var(--qgn-ink); }
.cal-pill[data-b="aeria"] { border-color: var(--aeria); background: var(--aeria-soft); color: var(--aeria-ink); }
.cal-pill[data-b="qdk"]   { border-color: var(--qdk); background: var(--qdk-soft); color: var(--qdk-ink); }
.cal-pill.done { opacity: 0.5; text-decoration: line-through; }
.cal-pill.overdue { box-shadow: inset 0 0 0 1px rgba(255,91,96,0.4); }

.agenda { display: flex; flex-direction: column; }
.agenda h3 { font-size: 15px; margin-bottom: 14px; }
.agenda-day { margin-bottom: 18px; }
.agenda-day .ad-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-4); margin-bottom: 9px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.agenda-item { display: flex; gap: 11px; padding: 11px; border-radius: 11px; border: 1px solid var(--line); margin-bottom: 8px; background: var(--surface); cursor: pointer; transition: border-color .12s; position: relative; overflow: hidden; }
.agenda-item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.agenda-item[data-b="qgn"]::before { background: var(--qgn-grad); }
.agenda-item[data-b="aeria"]::before { background: var(--aeria); }
.agenda-item[data-b="qdk"]::before { background: var(--qdk); }
.agenda-item:hover { border-color: var(--line-2); }
.agenda-item.done { opacity: 0.55; }
.agenda-item .ai-time { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; width: 52px; flex-shrink: 0; padding-left: 6px; }
.agenda-item .ai-body { flex: 1; min-width: 0; }
.agenda-item .ai-title { font-size: 13.5px; line-height: 1.35; }
.agenda-item .ai-sub { font-size: 11.5px; color: var(--ink-4); margin-top: 4px; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.agenda-item.overdue .ai-time { color: var(--bad); }

/* ==========================================================================
   Activity table
   ========================================================================== */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.act-scroll { overflow-x: auto; }
table.act { width: 100%; border-collapse: collapse; min-width: 620px; }
table.act th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-4); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); font-weight: 600; white-space: nowrap; }
table.act td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
table.act tr:last-child td { border-bottom: none; }
table.act tr:hover td { background: var(--surface-2); }
table.act .t-when { color: var(--ink-4); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12.5px; }
table.act .t-what { color: var(--ink-2); }
table.act .t-kind { color: var(--ink); font-weight: 500; }
.kind-ico { display: inline-flex; width: 26px; height: 26px; border-radius: 7px; align-items: center; justify-content: center; background: var(--surface-3); color: var(--ink-3); margin-right: 4px; vertical-align: middle; }

/* ==========================================================================
   Settings
   ========================================================================== */
.settings-grid { display: flex; flex-direction: column; gap: 20px; max-width: 760px; }
.set-card { padding: 22px 24px; }
.set-card h3 { font-size: 16px; margin-bottom: 4px; }
.set-card .sc-desc { font-size: 13px; color: var(--ink-3); margin-bottom: 18px; }
.kv { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kv:last-of-type { border-bottom: none; }
.kv .kv-k { font-size: 12.5px; color: var(--ink-3); width: 140px; flex-shrink: 0; }
.kv .kv-v { flex: 1; min-width: 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; }
.kv .kv-v.mask { letter-spacing: 0.1em; }
.copybtn-inline { flex-shrink: 0; }
.bot-run { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.bot-run:last-child { border-bottom: none; }
.bot-run .br-l { display: flex; align-items: center; gap: 11px; }
.bot-run .br-l i.dot { width: 11px; height: 11px; border-radius: 50%; }
.bot-run .br-name { font-size: 14px; font-weight: 500; }
.bot-run .br-sched { font-size: 12px; color: var(--ink-4); margin-top: 2px; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; }
.status-dot i { width: 8px; height: 8px; border-radius: 50%; }
.status-dot i.ok { background: var(--good); box-shadow: 0 0 0 3px rgba(79,180,119,0.16); }
.status-dot i.off { background: var(--ink-4); }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 120; background: var(--overlay); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px; animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 500px; background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); max-height: calc(100vh - 48px); overflow-y: auto;
  animation: pop .16s ease;
}
.modal.wide { max-width: 620px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.modal-head h3 { font-size: 18px; }
.modal-head .mh-close { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink-3); display: grid; place-items: center; }
.modal-head .mh-close:hover { background: var(--surface-3); color: var(--ink); }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 16px 24px 22px; }
.modal-foot .spacer { flex: 1; }

/* ==========================================================================
   Empty states / toasts / misc
   ========================================================================== */
.empty { text-align: center; padding: 64px 24px; }
.empty .em-ico { width: 64px; height: 64px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto 20px; color: var(--ink-4); }
.empty h3 { font-size: 18px; margin-bottom: 8px; }
.empty p { color: var(--ink-3); font-size: 14px; max-width: 42ch; margin: 0 auto 20px; line-height: 1.55; }

.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-3) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r); }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-card { height: 200px; }

.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 11px; padding: 12px 17px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg);
  font-size: 13.5px; color: var(--ink); pointer-events: auto; animation: toastin .22s ease; max-width: 90vw;
}
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast.out { animation: toastout .22s ease forwards; }
@keyframes toastout { to { opacity: 0; transform: translateY(10px); } }
.toast .t-ic { flex-shrink: 0; display: grid; place-items: center; }
.toast.ok .t-ic { color: var(--good); }
.toast.err .t-ic { color: var(--bad); }
.toast.info .t-ic { color: var(--info); }

.copied-flash { color: var(--good) !important; }

.muted { color: var(--ink-4); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--line); margin: 20px 0; border: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .grid.two { grid-template-columns: 1fr; }
  .legend { display: none; }
  .page-head h1 { font-size: 25px; }
}
@media (max-width: 620px) {
  .main { padding: 22px 16px 70px; }
  .appbar { padding: 0 14px; gap: 10px; }
  .brandmark .wm { font-size: 15px; }
  .nav a { padding: 7px 10px; font-size: 13px; }
  .grid.cards { grid-template-columns: 1fr; }
  .fld-row { grid-template-columns: 1fr; }
  .cal-cell { min-height: 70px; padding: 5px; }
  .cal-cell .cc-n { font-size: 11px; width: 20px; height: 20px; }
  .cal-pill { font-size: 9.5px; padding: 2px 4px; }
  .cal-pill .cp-txt { display: none; }
  .page-head { margin-bottom: 20px; }
  .page-head .ph-r { width: 100%; }
  .stat .st-v { font-size: 34px; }
  .brandpick { grid-template-columns: 1fr; }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
}
