/* ==========================================================================
   Corunit Tickets — design system (see DESIGN.md)
   Family: playful × cinematic. One Corunit orange. Gold = reward. Hairline depth.
   ========================================================================== */

:root {
  --bg: #0B0E0C;
  --panel: #121613;
  --panel2: #191F1A;
  --line: #232B24;
  --line-strong: #313B32;
  --text: #EDF3EC;
  --dim: #98A79B;
  --faint: #5C685E;
  --accent: #FF7A2F;
  --accent-press: #F26B22;
  --accent-ink: #1E0C00;
  --gold: #F5C84C;
  --p-low: #7D8DF5;
  --p-med: #4FC97E;
  --p-high: #EDBE3D;
  --p-urgent: #F55C4F;
  --s-doing: #6FA8F5;
  --r-panel: 14px;
  --r-ctl: 10px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Instrument Sans", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --shadow-modal: 0 24px 80px rgba(0, 0, 0, .55);
  --glow: 0 0 26px rgba(255, 122, 47, .22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img, svg { display: block; }
.mono { font-family: var(--font-mono); }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.gold { color: var(--gold); }
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.lg { width: 22px; height: 22px; }
.icon.sm { width: 15px; height: 15px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line);
  padding: 18px 14px 14px;
  display: flex; flex-direction: column; gap: 5px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; /* short screens: everything stays reachable */
  scrollbar-width: thin;
}
.sidebar .spacer { flex: 1; min-height: 10px; }
.wordmark {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  letter-spacing: .01em; padding: 6px 10px 18px; display: flex; align-items: center; gap: 9px;
}
.wordmark .dot { width: 10px; height: 10px; background: var(--accent); border-radius: 3px; transform: rotate(45deg); }
.wordmark small { display: block; font-family: var(--font-mono); font-size: 10px; font-weight: 400; color: var(--faint); letter-spacing: .14em; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--r-ctl);
  color: var(--dim); font-weight: 500; position: relative;
  transition: color .15s, background .15s;
}
.nav-item:hover { color: var(--text); background: var(--panel); }
.nav-item.active { color: var(--text); background: var(--panel2); }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px; background: var(--accent);
}
.sidebar .spacer { flex: 1; }

/* sidebar player card */
.player {
  border: 1px solid var(--line); border-radius: var(--r-panel);
  padding: 12px; display: grid; grid-template-columns: 44px 1fr; gap: 10px 12px; align-items: center;
  background: var(--panel);
}
.player .who { min-width: 0; }
.player .who b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .who span { font-size: 12px; color: var(--gold); font-weight: 600; }
.player .meters { grid-column: 1 / -1; }
.xpbar { height: 6px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.xpbar span { display: block; height: 100%; background: var(--gold); border-radius: 4px; transition: width .8s cubic-bezier(.2, .9, .2, 1); }
.player .sub { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 5px; font-family: var(--font-mono); }
.streak { display: inline-flex; align-items: center; gap: 4px; color: var(--p-high); font-weight: 600; }

.avatar {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; letter-spacing: .02em; flex: none;
  width: 32px; height: 32px;
  background: hsl(var(--h) 30% 22%); color: hsl(var(--h) 80% 78%);
  border: 1px solid hsl(var(--h) 30% 30%);
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.xl { width: 72px; height: 72px; font-size: 24px; }
.avatar.sq { border-radius: 9px; }

/* ---------- main column ---------- */
.main { min-width: 0; padding: 26px 30px 90px; max-width: 1240px; margin-inline: auto; width: 100%; }

/* thin, quiet scrollbars everywhere (Chrome/Edge) */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.topbar h1 { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.topbar .sub { width: 100%; color: var(--dim); margin-top: -6px; font-size: 13.5px; }
.topbar .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: var(--r-ctl);
  transition: transform .06s, box-shadow .2s, background .15s;
}
.btn:hover { box-shadow: var(--glow); background: var(--accent-press); }
.btn:active { transform: translateY(1px); }
.btn .icon { stroke-width: 2; }
.btn-line {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); color: var(--text);
  font-weight: 500; font-size: 14px; padding: 8px 15px; border-radius: var(--r-ctl);
  transition: border-color .15s, background .15s, transform .06s;
}
.btn-line:hover { border-color: var(--faint); background: var(--panel); }
.btn-line:active { transform: translateY(1px); }
.btn-ghost { color: var(--dim); font-weight: 500; font-size: 14px; padding: 8px 10px; border-radius: var(--r-ctl); display: inline-flex; gap: 7px; align-items: center; }
.btn-ghost:hover { color: var(--text); background: var(--panel); }
.btn-danger { border-color: rgba(245, 92, 79, .4); color: var(--p-urgent); }
.btn-danger:hover { border-color: var(--p-urgent); background: rgba(245, 92, 79, .08); }
.btn.sm, .btn-line.sm { padding: 6px 11px; font-size: 13px; }
.btn[disabled], .btn-line[disabled] { opacity: .55; pointer-events: none; }
.btn .spin { display: none; }
.btn.loading .spin { display: block; animation: rot 0.9s linear infinite; }
.btn.loading .notspin { display: none; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- panels, stats ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 18px; }
.panel h2 { font-family: var(--font-display); font-size: 15px; font-weight: 500; letter-spacing: .01em; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.panel h2 .count { color: var(--faint); font-family: var(--font-mono); font-size: 12px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, 1fr); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 16px 18px; }
.stat .num {
  font-family: var(--font-display); font-size: 40px; font-weight: 700;
  letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums;
}
.stat .lbl { color: var(--dim); font-size: 13px; margin-top: 2px; }
.stat.hot .num { color: var(--accent); }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.chip.mono { font-family: var(--font-mono); font-weight: 400; }
.pr-low    { color: var(--p-low);    background: rgba(125, 141, 245, .13); }
.pr-med    { color: var(--p-med);    background: rgba(79, 201, 126, .12); }
.pr-high   { color: var(--p-high);   background: rgba(237, 190, 61, .13); }
.pr-urgent { color: var(--p-urgent); background: rgba(245, 92, 79, .14); }
.st-open     { color: var(--dim);     background: var(--panel2); }
.st-doing    { color: var(--s-doing); background: rgba(111, 168, 245, .13); }
.st-resolved { color: var(--p-med);   background: rgba(79, 201, 126, .12); }
.st-done     { color: var(--accent);  background: rgba(255, 122, 47, .12); }
.chip.overdue { color: var(--p-urgent); background: rgba(245, 92, 79, .14); }
.tag { font-size: 11px; color: var(--faint); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }

/* ---------- forms ---------- */
label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--dim); margin: 14px 0 6px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--panel2); border: 1px solid var(--line);
  border-radius: var(--r-ctl); padding: 9px 12px; color: var(--text);
  font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 122, 47, .15); }
.input::placeholder { color: var(--faint); }
textarea.input { resize: vertical; min-height: 92px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.checkrow { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--dim); margin-top: 12px; }
.checkrow input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table tr.me td { background: rgba(255, 122, 47, .04); }

/* ---------- kanban ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filters .input { width: auto; }
.filters .search { min-width: 220px; }
.kb { display: grid; grid-template-columns: repeat(4, minmax(280px, 1fr)); gap: 14px; align-items: start; }
.kb-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); display: flex; flex-direction: column; min-height: 200px; }
.kb-head { display: flex; align-items: center; gap: 8px; padding: 13px 14px 10px; font-family: var(--font-display); font-weight: 500; font-size: 14px; }
.kb-head .n { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--faint); }
.kb-head .swatch { width: 8px; height: 8px; border-radius: 2px; }
.kb-body { padding: 6px 10px 12px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: calc(100vh - 250px); min-height: 60px; }
.kb-card {
  background: var(--panel2); border: 1px solid var(--line);
  border-left: 3px solid var(--faint); border-radius: 10px;
  padding: 11px 12px; cursor: grab; position: relative;
  transition: border-color .15s, transform .12s;
}
.kb-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.kb-card.pr-low { border-left-color: var(--p-low); background: var(--panel2); color: var(--text); }
.kb-card.pr-med { border-left-color: var(--p-med); background: var(--panel2); color: var(--text); }
.kb-card.pr-high { border-left-color: var(--p-high); background: var(--panel2); color: var(--text); }
.kb-card.pr-urgent { border-left-color: var(--p-urgent); background: var(--panel2); color: var(--text); }
.kb-card .t { font-weight: 600; font-size: 13.5px; line-height: 1.35; margin: 5px 0 8px; }
.kb-card .meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--faint); }
.kb-card .code { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.kb-card .meta .avatar { width: 20px; height: 20px; font-size: 9px; margin-left: auto; }
.kb-card .bar { margin-top: 9px; }
.sortable-ghost { opacity: .35; border-style: dashed; }
.sortable-drag { box-shadow: 0 14px 40px rgba(0, 0, 0, .5); cursor: grabbing; }
.kb-body.drag-over { outline: 1px dashed var(--faint); outline-offset: -6px; border-radius: 10px; }

/* progress */
.bar { height: 5px; background: rgba(255, 255, 255, .06); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s cubic-bezier(.2, .9, .2, 1); }
.bar.gold span { background: var(--gold); }
.ring { transform: rotate(-90deg); }
.ring .bgc { stroke: rgba(255, 255, 255, .08); }
.ring .fgc { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .9s cubic-bezier(.2, .9, .2, 1); }
.ringwrap { position: relative; width: 64px; height: 64px; flex: none; }
.ringwrap .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 13px; font-weight: 600; }

/* ---------- ticket rows / lists ---------- */
.trow {
  display: flex; align-items: center; gap: 6px 12px; padding: 11px 12px;
  flex-wrap: wrap; /* chips wrap below the title instead of clipping */
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel2);
  transition: border-color .15s, transform .1s;
  min-width: 0; overflow: hidden;
}
.trow .t { flex: 1 1 140px; }
.trow:hover { border-color: var(--line-strong); transform: translateX(2px); }
.trow .t { font-weight: 600; font-size: 13.5px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .code { font-family: var(--font-mono); font-size: 11px; color: var(--faint); flex: none; }
.trow .right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.vlist { display: flex; flex-direction: column; gap: 8px; }

/* ---------- ticket detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.tickhead h1 { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin: 6px 0 10px; }
.tickhead .chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.desc { color: var(--dim); font-size: 14.5px; white-space: pre-wrap; }
.side .panel { margin-bottom: 14px; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--faint); }
.actionrow { display: flex; gap: 9px; flex-wrap: wrap; }

/* AI brief */
.brief { border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.brief-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  background: linear-gradient(180deg, rgba(255, 122, 47, .07), transparent);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display); font-weight: 500;
}
.brief-head .cost { margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); }
.brief-body { padding: 16px; display: grid; gap: 16px; }
.brief-sec h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); margin-bottom: 8px; }
.brief-sec ul, .brief-sec ol { padding-left: 20px; display: grid; gap: 5px; font-size: 14px; }
.brief-sec ol li::marker { color: var(--accent); font-family: var(--font-mono); font-size: 12px; }
.brief-sec ul li::marker { color: var(--accent); }
.brief-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.brief-foot .ok { color: var(--p-med); font-size: 13px; display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.brief-empty { text-align: center; padding: 34px 20px; }
.brief-empty p { color: var(--dim); font-size: 13.5px; max-width: 380px; margin: 8px auto 16px; }

/* checklist */
.check-item { display: flex; align-items: center; gap: 11px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: 0; }
.checkbox {
  width: 20px; height: 20px; border: 1.5px solid var(--line-strong); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; flex: none;
  transition: background .15s, border-color .15s; cursor: pointer;
}
.checkbox svg { width: 12px; height: 12px; stroke: var(--accent-ink); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 16; stroke-dashoffset: 16; transition: stroke-dashoffset .25s ease .05s; }
.check-item.done .checkbox { background: var(--accent); border-color: var(--accent); }
.check-item.done .checkbox svg { stroke-dashoffset: 0; }
.check-item .txt { flex: 1; font-size: 14px; transition: color .2s; position: relative; }
.check-item .txt::after { content: ""; position: absolute; left: 0; top: 55%; height: 1.5px; width: 0; background: var(--faint); transition: width .25s ease; }
.check-item.done .txt { color: var(--faint); }
.check-item.done .txt::after { width: 100%; }
.check-item .ai-mark { font-size: 10px; font-family: var(--font-mono); color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.check-item .del { opacity: 0; color: var(--faint); transition: opacity .15s; }
.check-item:hover .del { opacity: 1; }
.check-item .del:hover { color: var(--p-urgent); }
.addcheck { display: flex; gap: 8px; margin-top: 10px; }

/* comments */
.comment { display: grid; grid-template-columns: 32px 1fr; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment .head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.comment .head b { font-size: 13.5px; }
.comment .head time { color: var(--faint); font-size: 11.5px; }
.comment .body { font-size: 14px; color: var(--dim); white-space: pre-wrap; margin-top: 2px; }
.comment .internal-mark { font-size: 10px; color: var(--p-high); border: 1px solid rgba(237, 190, 61, .35); padding: 1px 6px; border-radius: 4px; }

/* activity feed */
.feed-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: 13px; color: var(--dim); }
.feed-item .avatar { width: 24px; height: 24px; font-size: 9px; margin-top: 1px; }
.feed-item b { color: var(--text); font-weight: 600; }
.feed-item .xp { font-family: var(--font-mono); font-size: 11px; color: var(--gold); margin-left: auto; white-space: nowrap; }
.feed-item time { font-size: 11px; color: var(--faint); }

/* ---------- leaderboard ---------- */
.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; align-items: end; margin-bottom: 18px; }
.pod { text-align: center; padding: 20px 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); position: relative; }
.pod .avatar { margin: 0 auto 10px; }
.pod .medal { position: absolute; top: 10px; left: 12px; font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--faint); }
.pod.first { padding-top: 34px; border-color: rgba(245, 200, 76, .45); }
.pod.first .medal { color: var(--gold); font-size: 18px; }
.pod .xp { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.pod .lvl { color: var(--gold); font-size: 12px; font-weight: 600; }
.pod b { display: block; margin-top: 2px; }
.lb-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.lb-tab { padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--dim); border: 1px solid var(--line); }
.lb-tab.active { background: var(--panel2); color: var(--text); border-color: var(--line-strong); }
.badge-shelf { display: flex; gap: 5px; flex-wrap: wrap; }
.badge-shelf .b { font-size: 15px; }

/* profile badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge-card { border: 1px solid var(--line); border-radius: 12px; padding: 13px; text-align: center; background: var(--panel2); }
.badge-card .e { font-size: 26px; line-height: 1; margin-bottom: 8px; filter: none; }
.badge-card b { font-size: 13px; display: block; }
.badge-card span { font-size: 11.5px; color: var(--faint); }
.badge-card.locked { opacity: .38; filter: saturate(.2); }

/* ---------- modals ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(5, 7, 5, .72);
  backdrop-filter: blur(3px); z-index: 60;
  display: none; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 16px; overflow-y: auto;
}
.scrim.open { display: flex; animation: fadein .18s ease; }
.modal {
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-modal); animation: pop .22s cubic-bezier(.2, 1.2, .3, 1);
}
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); font-family: var(--font-display); font-weight: 500; font-size: 16px; }
.modal-head .x { margin-left: auto; color: var(--faint); padding: 4px; border-radius: 6px; }
.modal-head .x:hover { color: var(--text); background: var(--panel2); }
.modal-body { padding: 4px 20px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } }
@keyframes fadein { from { opacity: 0; } }

/* import wizard */
.imp-drop {
  border: 1.5px dashed var(--line-strong); border-radius: 12px;
  padding: 10px; margin-top: 14px; text-align: center; color: var(--faint); font-size: 12.5px;
  transition: border-color .15s, background .15s;
}
.imp-drop.over { border-color: var(--accent); background: rgba(255, 122, 47, .05); }
.imp-rows { max-height: 300px; overflow-y: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; }
.imp-row { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.imp-row:last-child { border-bottom: 0; }
.imp-row .st { font-family: var(--font-mono); font-size: 11px; flex: none; width: 26px; color: var(--p-med); }
.imp-row.bad .st { color: var(--p-urgent); }
.imp-row .err { margin-left: auto; color: var(--p-urgent); font-size: 12px; }
.imp-summary { display: flex; gap: 14px; margin-top: 12px; font-size: 13px; color: var(--dim); }
.imp-summary b { color: var(--text); }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 9px; z-index: 90; max-width: 340px; }
.toast {
  background: var(--panel2); border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 11px 14px; font-size: 13.5px; display: flex; gap: 10px; align-items: center;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .4);
  animation: toastin .3s cubic-bezier(.2, 1.1, .3, 1);
}
.toast.out { animation: toastout .25s ease forwards; }
.toast.err { border-color: rgba(245, 92, 79, .5); }
.toast.xp { border-color: rgba(245, 200, 76, .5); }
.toast.xp .amt { font-family: var(--font-display); font-weight: 700; color: var(--gold); font-size: 16px; white-space: nowrap; }
.toast.badge-toast { border-color: rgba(245, 200, 76, .5); }
.toast.badge-toast .e { font-size: 22px; }
.toast.badge-toast b { display: block; color: var(--gold); font-size: 13px; }
.toast.badge-toast span { font-size: 12px; color: var(--dim); }
@keyframes toastin { from { transform: translateX(30px); opacity: 0; } }
@keyframes toastout { to { transform: translateX(30px); opacity: 0; } }

/* level-up banner */
.levelup {
  position: fixed; top: 26px; left: 50%; transform: translateX(-50%);
  z-index: 95; background: var(--panel); border: 1px solid rgba(245, 200, 76, .6);
  border-radius: 16px; padding: 18px 30px; text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5), 0 0 40px rgba(245, 200, 76, .15);
  animation: lvlin .5s cubic-bezier(.2, 1.3, .3, 1);
}
.levelup .t { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .28em; color: var(--gold); }
.levelup .n { font-family: var(--font-display); font-size: 27px; font-weight: 700; letter-spacing: -.01em; margin-top: 3px; }
.levelup.out { animation: lvlout .4s ease forwards; }
@keyframes lvlin { from { transform: translate(-50%, -70px); opacity: 0; } }
@keyframes lvlout { to { transform: translate(-50%, -70px); opacity: 0; } }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 30px 16px; color: var(--faint); }
.empty svg { margin: 0 auto 10px; opacity: .8; }
.empty p { font-size: 13.5px; }
.empty b { color: var(--dim); display: block; font-size: 14px; margin-bottom: 2px; }

/* ---------- login ---------- */
.login { display: grid; grid-template-columns: 1.15fr 1fr; min-height: 100vh; }
.login-art {
  position: relative; overflow: hidden; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between; padding: 40px 46px;
  background: radial-gradient(1200px 700px at 20% 110%, rgba(255, 122, 47, .07), transparent 60%), var(--bg);
}
.login-art .wordmark { padding: 0; }
.login-hero h1 {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -.03em;
  font-size: clamp(40px, 5.4vw, 66px); line-height: 1.02;
}
.login-hero h1 .hot { color: var(--accent); }
.login-hero p { color: var(--dim); font-size: 15.5px; margin-top: 14px; max-width: 400px; }
.login-svg { position: absolute; right: -60px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.float { animation: floaty 7s ease-in-out infinite; }
.float.d1 { animation-delay: -2.2s; }
.float.d2 { animation-delay: -4.4s; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-13px); } }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h2 { font-family: var(--font-display); font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
.login-card .sub { color: var(--dim); font-size: 14px; margin-top: 4px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 20px; padding: 12px; font-size: 15px; }
.login-err { margin-top: 14px; border: 1px solid rgba(245, 92, 79, .4); background: rgba(245, 92, 79, .07); color: var(--p-urgent); border-radius: 10px; padding: 10px 13px; font-size: 13.5px; }
.demo-creds { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 16px; font-size: 12.5px; color: var(--faint); }
.demo-creds code { font-family: var(--font-mono); color: var(--dim); background: var(--panel2); padding: 1px 6px; border-radius: 5px; font-size: 11.5px; }
.demo-creds li { list-style: none; margin-top: 6px; }

/* ---------- portal ---------- */
.portal-shell { max-width: 900px; margin: 0 auto; padding: 0 20px 80px; }
.portal-top { display: flex; align-items: center; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.portal-top .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.timeline { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 18px 0 6px; }
.tl-step { text-align: center; position: relative; padding-top: 22px; font-size: 12px; color: var(--faint); }
.tl-step::before {
  content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 12px; border-radius: 50%; background: var(--panel2); border: 2px solid var(--line-strong);
}
.tl-step::after { content: ""; position: absolute; top: 11px; left: calc(-50% + 8px); width: calc(100% - 16px); height: 2px; background: var(--line); }
.tl-step:first-child::after { display: none; }
.tl-step.hit { color: var(--text); font-weight: 600; }
.tl-step.hit::before { background: var(--accent); border-color: var(--accent); }
.tl-step.hit::after { background: var(--accent); }

/* ---------- stagger entrance ---------- */
[data-stagger] > * { opacity: 0; transform: translateY(10px); }
[data-stagger].in > * { opacity: 1; transform: none; transition: opacity .4s ease, transform .45s cubic-bezier(.2, .9, .25, 1); }
[data-stagger].in > *:nth-child(1) { transition-delay: 0ms; } [data-stagger].in > *:nth-child(2) { transition-delay: 40ms; }
[data-stagger].in > *:nth-child(3) { transition-delay: 80ms; } [data-stagger].in > *:nth-child(4) { transition-delay: 120ms; }
[data-stagger].in > *:nth-child(5) { transition-delay: 160ms; } [data-stagger].in > *:nth-child(6) { transition-delay: 200ms; }
[data-stagger].in > *:nth-child(7) { transition-delay: 240ms; } [data-stagger].in > *:nth-child(8) { transition-delay: 280ms; }
[data-stagger].in > *:nth-child(n+9) { transition-delay: 320ms; }

/* two-column page splits */
.split { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; }
.split.narrowside { grid-template-columns: 340px minmax(0, 1fr); }
.split > * { min-width: 0; }
.split .panel { min-width: 0; overflow: hidden; }
.feed-item > div { min-width: 0; overflow-wrap: anywhere; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .split, .split.narrowside { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto;
    flex-direction: row; align-items: center; gap: 2px;
    border-right: 0; border-top: 1px solid var(--line);
    background: rgba(11, 14, 12, .92); backdrop-filter: blur(12px);
    padding: 8px 10px; z-index: 50; overflow-x: auto;
  }
  .wordmark, .player, .sidebar .spacer, .nav-item span.lbl { display: none; }
  .nav-item { flex-direction: column; gap: 3px; font-size: 10px; padding: 7px 12px; }
  .nav-item.active::before { left: 10px; right: 10px; top: auto; bottom: -8px; width: auto; height: 3px; }
  .main { padding: 18px 16px 110px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .kb { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
  .kb-col { min-width: 290px; scroll-snap-align: start; }
  .detail { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 34vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .login-svg { display: none; }
  .podium { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .modal { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  [data-stagger] > * { opacity: 1; transform: none; }
}

/* ==========================================================================
   LIGHT THEME — same bones, paper canvas
   ========================================================================== */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F2EB;
  --panel: #FDFCF8;
  --panel2: #EDEAE0;
  --line: #E0DCCF;
  --line-strong: #C7C3B2;
  --text: #1A1D1A;
  --dim: #57625A;
  --faint: #8D968E;
  --accent: #F06A1E;
  --accent-press: #DE5D14;
  --accent-ink: #FFF8F1;
  --gold: #AD7F12;
  --p-low: #5563D6;
  --p-med: #1E9A55;
  --p-high: #A87F10;
  --p-urgent: #D8402F;
  --s-doing: #2E6FD0;
  --shadow-modal: 0 24px 70px rgba(70, 60, 35, .28);
  --glow: 0 0 22px rgba(240, 106, 30, .25);
}
:root[data-theme="light"] .bar { background: rgba(0, 0, 0, .08); }
:root[data-theme="light"] .ring .bgc { stroke: rgba(0, 0, 0, .10); }
:root[data-theme="light"] .scrim { background: rgba(45, 42, 32, .45); }
:root[data-theme="light"] .avatar {
  background: hsl(var(--h) 52% 88%); color: hsl(var(--h) 48% 30%);
  border-color: hsl(var(--h) 38% 74%);
}
:root[data-theme="light"] .login-art { background: radial-gradient(1200px 700px at 20% 110%, rgba(240, 106, 30, .08), transparent 60%), var(--bg); }
:root[data-theme="light"] .btn { font-weight: 700; }
.theme-btn .only-dark { display: flex; }
.theme-btn .only-light { display: none; }
:root[data-theme="light"] .theme-btn .only-dark { display: none; }
:root[data-theme="light"] .theme-btn .only-light { display: flex; }

/* floating theme toggle (login page) */
.theme-fab {
  position: fixed; top: 16px; right: 16px; z-index: 40;
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--panel);
  display: flex; align-items: center; justify-content: center; color: var(--dim);
  transition: color .15s, border-color .15s, transform .06s;
}
.theme-fab:hover { color: var(--text); border-color: var(--faint); }
.theme-fab:active { transform: translateY(1px); }

/* ---------- sidebar global search ---------- */
.search-nav { display: none; }
@media (max-width: 960px) { .search-nav { display: flex; } }
.side-search { position: relative; margin: 0 0 12px; }
.side-search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 15px; height: 15px; }
.side-search input { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 30px 8px 32px; color: var(--text); font: inherit; font-size: 13px; }
.side-search input:focus { outline: 0; border-color: var(--accent); }
.side-search input::placeholder { color: var(--faint); }
.side-search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-family: var(--font-mono); font-size: 10px; color: var(--faint); border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 5px; }

/* ---------- view switcher tabs ---------- */
.vtabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; }
.vtab { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--dim); }
.vtab:hover { color: var(--text); }
.vtab.active { background: var(--panel2); color: var(--text); border: 1px solid var(--line-strong); margin: -1px; }

/* ---------- avatar stack (crew) ---------- */
.astack { display: inline-flex; padding-left: 7px; align-items: center; }
.astack .avatar { margin-left: -7px; box-shadow: 0 0 0 2px var(--panel); }
.astack.sm .avatar { width: 22px; height: 22px; font-size: 9px; }
.astack .more { margin-left: 3px; font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }

/* ---------- list view ---------- */
.lv tr { cursor: pointer; }
.lv td .t { font-weight: 600; }
.lv th a { color: var(--faint); display: inline-flex; gap: 4px; align-items: center; }
.lv th a:hover, .lv th a.on { color: var(--text); }

/* ---------- calendar view ---------- */
.cal-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-title { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: -.01em; min-width: 170px; }
.cal-scroll { overflow-x: auto; }
.cal { min-width: 760px; border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; background: var(--panel); }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow { padding: 9px 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 600; border-bottom: 1px solid var(--line); }
.cal-day { min-height: 106px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 7px; display: flex; flex-direction: column; gap: 4px; }
.cal-row .cal-day:nth-child(7n) { border-right: 0; }
.cal-row:last-child .cal-day { border-bottom: 0; }
.cal-day.out { background: var(--bg); }
.cal-day.out > * { opacity: .45; }
.cal-day .dn { font-family: var(--font-mono); font-size: 11px; color: var(--faint); width: 21px; height: 21px; display: flex; align-items: center; justify-content: center; }
.cal-day.today .dn { background: var(--accent); color: var(--accent-ink); border-radius: 7px; font-weight: 600; }
.cal-t { display: block; font-size: 11px; line-height: 1.35; padding: 3px 7px; border-radius: 6px; background: var(--panel2); border-left: 2px solid var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: transform .1s; }
.cal-t:hover { transform: translateX(2px); }
.cal-t.done { opacity: .5; text-decoration: line-through; }
.cal-t .cd { font-family: var(--font-mono); font-size: 9.5px; color: var(--faint); margin-right: 4px; }

/* ---------- recurring templates ---------- */
.rec-card .top { display: flex; align-items: flex-start; gap: 10px; }
.rec-card h3 { font-family: var(--font-display); font-size: 15.5px; font-weight: 700; line-height: 1.3; }
.rec-card .meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 12px; align-items: center; }
.rec-card .next { font-family: var(--font-mono); font-size: 11.5px; color: var(--dim); }
.rec-card.paused { opacity: .55; }
.rec-card .foot { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); padding-top: 12px; }
.chip.auto { color: var(--accent); background: rgba(255, 122, 47, .12); }
.chip.interval { color: var(--dim); background: var(--panel2); }

/* ---------- search page ---------- */
.gsearch { display: flex; gap: 10px; margin-bottom: 22px; max-width: 560px; }
.gsearch .input { font-size: 16px; padding: 12px 16px; }
.g-section h2 { font-family: var(--font-display); font-size: 13px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; margin: 20px 0 10px; }

@media (max-width: 960px) {
  .side-search, .theme-btn span.lbl { display: none; }
  .vtabs { width: 100%; }
  .vtab { flex: 1; justify-content: center; }
}

/* ==========================================================================
   Cora — floating assistant (drag to move, corner-drag to resize)
   ========================================================================== */
.cora-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 70;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  transition: transform .12s, box-shadow .2s;
}
.cora-fab:hover { transform: translateY(-2px); box-shadow: var(--glow), 0 10px 30px rgba(0, 0, 0, .35); }
.cora-fab .icon { width: 24px; height: 24px; stroke-width: 1.8; }
.cora-fab.hide { display: none; }

.cora {
  position: fixed; right: 18px; bottom: 82px; z-index: 80;
  width: 390px; height: 540px;
  min-width: 300px; min-height: 380px; max-width: 94vw; max-height: 88vh;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 16px; box-shadow: var(--shadow-modal);
  display: none; flex-direction: column; overflow: hidden; resize: both;
}
.cora.open { display: flex; animation: pop .2s cubic-bezier(.2, 1.2, .3, 1); }
.cora.max { width: 580px; height: 700px; }
.cora-head {
  display: flex; align-items: center; gap: 9px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); cursor: grab; user-select: none;
  font-family: var(--font-display); font-weight: 500; font-size: 14px; flex: none;
}
.cora-head:active { cursor: grabbing; }
.cora-head > .icon { color: var(--accent); }
.cora-head .hint { font-size: 10px; color: var(--faint); font-family: var(--font-mono); font-weight: 400; }
.cora-head .btns { margin-left: auto; display: flex; gap: 2px; }
.cora-head .btns button { color: var(--faint); padding: 5px; border-radius: 7px; display: flex; }
.cora-head .btns button:hover { color: var(--text); background: var(--panel2); }
.cora-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cora-m { max-width: 86%; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.cora-m.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 13px 13px 4px 13px; font-weight: 500; }
.cora-m.bot { align-self: flex-start; background: var(--panel2); padding: 9px 12px; border-radius: 13px 13px 13px 4px; }
.cora-m.thinking span { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); margin-right: 3px; animation: cthink 1s ease-in-out infinite; }
.cora-m.thinking span:nth-child(2) { animation-delay: .15s; }
.cora-m.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes cthink { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.cora-hello { font-size: 12.5px; color: var(--faint); text-align: center; padding: 6px 10px; }
.cora-input { display: flex; gap: 8px; padding: 11px; border-top: 1px solid var(--line); flex: none; align-items: flex-end; }
.cora-input textarea {
  flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 11px; color: var(--text); font: inherit; font-size: 13.5px;
  resize: none; height: 38px; max-height: 92px;
}
.cora-input textarea:focus { outline: 0; border-color: var(--accent); }
.cora-input button { flex: none; width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; }
.cora-input button:active { transform: translateY(1px); }
@media (max-width: 960px) {
  .cora { left: 3vw !important; right: auto; top: auto !important; bottom: 76px !important; width: 94vw !important; height: 62vh !important; }
  .cora-fab { bottom: 78px; }
}

/* ---------- files ---------- */
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.file-row:last-child { border-bottom: 0; }
.file-ico {
  width: 34px; height: 34px; border-radius: 8px; background: var(--panel2);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600; color: var(--dim);
  text-transform: uppercase; flex: none;
}
.file-row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-row .fmeta { color: var(--faint); font-size: 11.5px; font-family: var(--font-mono); flex: none; }
.file-row .del2 { margin-left: auto; }
.upl input[type=file] { display: none; }

/* ---------- compliance panel ---------- */
.comp { border: 1px solid rgba(237, 190, 61, .38); border-radius: var(--r-panel); background: var(--panel); margin-bottom: 14px; overflow: hidden; }
.comp-head { display: flex; gap: 9px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-family: var(--font-display); font-weight: 500; color: var(--p-high); }
.comp ul { padding: 12px 16px 12px 34px; display: grid; gap: 6px; font-size: 13.5px; color: var(--dim); }
.comp ul li::marker { color: var(--p-high); }
.comp-foot { padding: 0 16px 14px; display: flex; align-items: center; gap: 10px; }

/* skill chips */
.chip.skill { color: var(--s-doing); background: rgba(111, 168, 245, .12); }

/* pagination + kanban overflow link */
.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 16px; }
.pager .dim { margin-right: auto; font-size: 12.5px; }
.kb-more {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; font-size: 12px; color: var(--dim);
  border: 1px dashed var(--line-strong); border-radius: 8px;
}
.kb-more:hover { color: var(--text); border-color: var(--faint); }

/* mini-RAG memory rows */
.mem-row { padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--dim); line-height: 1.55; }
.mem-row:last-child { border-bottom: 0; }
