:root {
  --bg: #12100c;
  --bg-2: #1b1813;
  --panel: #221e18;
  --line: #3c3428;
  --text: #f6efe2;
  --muted: #b4a790;
  --gold: #e2b45c;
  --gold-2: #8c6a2e;
  --feat: #7dcea0;
  --bug: #e08b78;
  --imp: #8ebcda;
  --hand: #cbb892;
  --chore: #8d867b;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
  font-family: Vazirmatn, Tahoma, sans-serif;
  color: var(--text);
  background: var(--bg);
}

@font-face {
  font-family: Vazirmatn;
  src: url("https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { max-width: 100%; overflow-x: clip; }
body { margin: 0; min-height: 100vh; }
body:has(#login:not([hidden])) { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
a { color: var(--gold); }

.login {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: auto;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(226, 180, 92, .16), transparent 28%),
    linear-gradient(160deg, #1a160f, #0e0c09 60%);
}
.login-card {
  width: min(460px, 100%);
  background: rgba(28, 24, 18, .92);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.eyebrow { color: var(--gold); letter-spacing: .04em; font-size: 13px; }
.lede, .muted { color: var(--muted); line-height: 1.8; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
label.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
}
label.remember input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--gold);
}
input, select {
  background: #12100c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
}
button {
  background: var(--gold);
  color: #1a140a;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
}
button.ghost, button.tiny {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
button.tiny { padding: 6px 10px; border-radius: 999px; font-weight: 500; }
button.active, .nav button.active { background: #3a2e18; color: var(--gold); border-color: var(--gold-2); }
.form-error { color: var(--bug); }
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 12px;
  padding: 14px 22px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 16, 12, .94);
  backdrop-filter: blur(12px);
}
.top-row, .top-actions, .row, .chips, .pager, .task-actions, .badges {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.top-row { justify-content: space-between; }
.brand { display: grid; gap: 2px; }
.brand strong { font-size: 18px; }
.sync-note { color: var(--muted); font-size: 13px; }
#app, .shell, #view, .grid { min-width: 0; max-width: 100%; }
.shell { width: min(1180px, 100%); margin: 0 auto; padding: 18px 22px 48px; display: grid; gap: 16px; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav button {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  white-space: nowrap;
}
.filters {
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}
.filters-primary {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.filters-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.filters-row:has(.check) {
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(160px, 0.9fr);
}
.filters-row:has(#status) {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.filter-item,
.search-field {
  display: grid;
  grid-template-rows: 20px auto;
  gap: 6px;
  min-width: 0;
  align-content: start;
}
.filter-label {
  display: block;
  height: 20px;
  line-height: 20px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.filters label { min-width: 0; color: inherit; }
.filters input,
.filters select {
  width: 100%;
  height: 44px;
  min-height: 44px;
  margin: 0;
}
.date-field { position: relative; display: block; height: 44px; }
.date-field strong {
  display: flex;
  align-items: center;
  height: 44px;
  min-height: 44px;
  background: #12100c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--text);
  font-weight: 500;
}
.date-field input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  height: 100%;
}
.filters .check {
  display: grid;
  grid-template-rows: 20px 44px;
  gap: 6px;
}
.filters .check .check-box {
  display: flex;
  align-items: center;
  height: 44px;
  min-height: 44px;
  padding: 0 12px;
  background: #12100c;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.filters .check input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--gold);
}
.search-field input {
  height: 48px;
  min-height: 48px;
  font-size: 15px;
  padding: 0 14px;
}
.search-field input.is-searching { border-color: var(--gold-2); box-shadow: 0 0 0 1px rgba(226, 180, 92, .25); }
.search-hint {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  min-height: 18px;
}
.lanes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.results-bar strong { font-size: 15px; }
.grid { display: grid; gap: 12px; min-width: 0; }
.stats { display: flex; gap: 12px; }
.cards-2 { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: stretch; }
.cards-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card, .list-card, .prompt-card, .detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  min-width: 0;
}
.stat {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 92px;
}
.stat strong { font-size: 30px; line-height: 1; }
.stat span, .card h2, .card h3 { color: var(--muted); font-size: 14px; font-weight: 500; }
.narrative { line-height: 1.9; font-size: 15px; overflow-wrap: anywhere; }
.chart { display: flex; align-items: end; gap: 3px; height: 200px; width: 100%; min-width: 0; padding-top: 8px; }
.bar { flex: 1 1 0; min-width: 0; width: auto; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 6px; }
.stack { width: 100%; flex: 1; display: flex; flex-direction: column-reverse; justify-content: start; background: #15130f; border-radius: 6px; overflow: hidden; }
.stack i { display: block; width: 100%; }
.feat { background: var(--feat); }
.bug { background: var(--bug); }
.imp { background: var(--imp); }
.hand { background: var(--hand); }
.rel { background: var(--gold); }
.chore { background: var(--chore); }
.bar span { font-size: 10px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 99px; margin-left: 4px; }
.hours { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 8px; min-width: 0; }
.hour { min-width: 0; background: #15130f; border-radius: 10px; padding: 8px 10px; }
.hour span, .hour small { display: block; }
.hour b { display: block; height: 6px; max-width: 100%; background: var(--gold); border-radius: 99px; margin-top: 6px; }
.card:not(:has(table)) { overflow: hidden; }
.card:has(table) { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
.commit, .task, .pulse-row {
  display: grid;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.task-main { display: grid; gap: 6px; min-width: 0; }
.kind, .area {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  font-size: 12px;
}
.kind.feature { color: var(--feat); }
.kind.bugfix { color: var(--bug); }
.kind.improvement { color: var(--imp); }
.kind.handoff, .kind.release { color: var(--hand); }
.subject {
  margin: 0;
  font-weight: 700;
  line-height: 1.55;
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  overflow-wrap: anywhere;
}
button.tiny { white-space: nowrap; }
button.tiny.done { background: #1c3326; color: var(--feat); border-color: #2f6a45; }
button.tiny.copy {
  background: rgba(226, 180, 92, .12);
  color: var(--gold);
  border-color: var(--gold-2);
}
button:disabled {
  opacity: .38;
  cursor: not-allowed;
}
.work.final { border-color: #2f6a45; box-shadow: inset 0 0 0 1px rgba(125, 206, 160, .18); }
.meta { color: var(--muted); font-size: 13px; line-height: 1.7; }
.search-insight {
  display: grid;
  gap: 8px;
  border-color: var(--gold-2);
  background: #1c1812;
}
.search-insight p { margin: 0; line-height: 1.85; }
.insight-line { color: var(--gold); }
.note {
  background: #18150f;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.stack-cards { display: grid; gap: 16px; min-width: 0; }
.work {
  display: grid;
  gap: 14px;
  padding: 18px;
}
.work-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.work-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}
.work-meta code, .noise-item code {
  direction: ltr;
  unicode-bidi: isolate;
  background: #15130f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
}
.warn-chip { color: var(--bug); border-color: rgba(224, 139, 120, .35); }
.fa-title { margin: 0; font-size: 18px; line-height: 1.75; font-weight: 700; color: var(--text); }
.report { color: var(--muted); line-height: 1.85; }
.cue {
  line-height: 1.75;
  font-size: 13px;
  color: var(--muted);
  background: rgba(226, 180, 92, .06);
  border-radius: 10px;
  padding: 8px 10px;
}
.origin {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  background: #18150f;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.origin .subject { font-weight: 500; font-size: 13px; color: var(--muted); }
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}
.prompt-block {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 8px;
  min-width: 0;
  background: #18150f;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.prompt-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.prompt-head h3 { color: var(--gold); font-size: 14px; font-weight: 700; }
.prompt {
  margin: 0;
  white-space: pre-wrap;
  background: #12100c;
  border: 1px solid #2a241c;
  border-radius: 12px;
  padding: 12px;
  line-height: 1.7;
  max-height: 280px;
  overflow: auto;
  font-family: Vazirmatn, Tahoma, sans-serif;
  font-size: 13px;
  unicode-bidi: plaintext;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-2) #15130f;
}
.prompt::-webkit-scrollbar { width: 8px; height: 8px; }
.prompt::-webkit-scrollbar-track { background: #15130f; border-radius: 99px; }
.prompt::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #a8843d, #6f5424);
  border-radius: 99px;
}
.work-foot {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
  border-top: 1px solid var(--line);
}
.work-foot a { font-size: 13px; font-weight: 500; }
.noise-list { display: grid; gap: 0; padding: 4px 16px; }
.noise-item {
  display: grid;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.noise-item:last-child { border-bottom: 0; }
.detail {
  margin-top: 12px;
}
.files { max-height: 180px; overflow: auto; color: var(--muted); font-size: 13px; line-height: 1.7; }
.toast {
  position: fixed;
  bottom: 18px;
  left: 18px;
  background: var(--gold);
  color: #1a140a;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
}
summary { cursor: pointer; font-weight: 700; }
details.card { display: block; }
.pager {
  display: grid;
  gap: 12px;
  justify-content: stretch;
  align-items: center;
  margin-top: 4px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.pager-summary {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.pager-summary b { color: var(--text); font-weight: 700; }
.pager-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.pager-pages {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.pager-num {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 12px;
  background: #15130f;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}
.pager-num.active {
  background: #3a2e18;
  color: var(--gold);
  border-color: var(--gold-2);
}
.pager-gap {
  color: var(--muted);
  padding: 0 4px;
  font-size: 14px;
}
.warn { color: var(--bug); }
.agent-pick {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--gold-2);
  border-radius: 14px;
  background: rgba(226, 180, 92, .06);
}
.agent-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #3a2e18;
  color: var(--gold);
  border: 1px solid var(--gold-2);
  font-size: 13px;
  font-weight: 700;
}
.studio-hero h2 { color: var(--text); font-size: 22px; }
.studio-form { display: grid; gap: 14px; }
.studio-targets { grid-template-columns: minmax(160px, 220px) minmax(0, 1fr); }
.studio-guide { display: grid; gap: 6px; }
.studio-guide textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  background: #12100c;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  line-height: 1.8;
  color: var(--text);
}
.upload-box {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  background: #12100c;
  border: 1px dashed var(--gold-2);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
}
.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.studio-preview {
  display: grid;
  gap: 10px;
  justify-items: start;
}
.studio-preview img {
  max-width: min(420px, 100%);
  border-radius: 14px;
  border: 1px solid var(--line);
}
.studio-out {
  max-height: 420px;
  margin-top: 4px;
}
.studio-bucket { display: grid; gap: 12px; margin-top: 18px; }
.studio-bucket h3 { color: var(--gold); font-size: 16px; }
.depth-chip.short { color: var(--feat); }
.depth-chip.medium { color: var(--imp); }
.depth-chip.deep { color: var(--bug); }
.studio-item.depth-deep { border-color: rgba(224, 139, 120, .35); }
.studio-item.depth-medium { border-color: rgba(142, 188, 218, .3); }
@media (max-width: 980px) {
  .filters-row,
  .filters-row:has(.check),
  .filters-row:has(#status) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .studio-targets { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .cards-2 { grid-template-columns: 1fr; }
  .stats { flex-wrap: wrap; }
  .stat { flex: 1 1 calc(33.33% - 12px); }
  .top-row { align-items: flex-start; }
  .shell, .top { padding-inline: 12px; }
  .prompt-grid { grid-template-columns: 1fr; }
  .results-bar { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
  .stat { flex: 1 1 calc(50% - 12px); }
  .pager-controls { gap: 6px; }
  .pager-num { min-width: 34px; height: 34px; }
  .filters-row,
  .filters-row:has(.check),
  .filters-row:has(#status) {
    grid-template-columns: 1fr;
  }
}
