:root {
  --bg: #161A33;
  --surface: #1F2445;
  --surface-2: #2A3060;
  --line: #343B70;
  --text: #ECEEF8;
  --muted: #9AA0C8;
  --flax: #E0B65A;
  --flax-ink: #2B2109;
  --danger: #EF8A6B;

  --t-idea: #E0B65A;
  --t-task: #4FB8A3;
  --t-decision: #A68BF0;
  --t-question: #EF8A6B;
  --t-reminder: #6AA6F0;
  --t-note: #9AA0C8;

  --r: 10px;
  --side: 232px;
  --font: "IBM Plex Sans Arabic", system-ui, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--flax); outline-offset: 2px; }
h1, h2, h3 { font-weight: 600; line-height: 1.3; margin: 0; }
h2 { font-size: 22px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- controls */
.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 10px 18px;
  font-weight: 500;
}
.btn.primary { background: var(--flax); border-color: var(--flax); color: var(--flax-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--muted); padding: 0; text-decoration: underline; }
input[type=password], input[type=search], textarea, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 14px;
}
textarea { resize: vertical; }
select { width: auto; }
.err { color: var(--danger); min-height: 1.4em; margin: 6px 0; font-size: 14px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 14px;
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .sw { width: 8px; height: 8px; border-radius: 50%; }
.chip[aria-pressed=true] { color: var(--text); border-color: var(--muted); background: var(--surface); }

/* ---------- login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); display: grid; gap: 8px; text-align: center; }
.login-card img { margin: 0 auto 8px; border-radius: 16px; }
.login-card h1 { font-size: 26px; margin-bottom: 16px; }
.login-card label { text-align: start; font-size: 14px; color: var(--muted); }

/* ---------- layout */
.app { display: grid; grid-template-columns: var(--side) 1fr; height: 100%; }
.side {
  border-inline-end: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; padding: 4px 10px 22px; }
.brand img { border-radius: 9px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: none; border: 0; border-radius: var(--r);
  padding: 9px 12px; text-align: start; color: var(--muted);
}
.nav-item .ico { width: 20px; text-align: center; font-size: 17px; }
.nav-item:hover { color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); }
.count { margin-inline-start: auto; font-style: normal; font-size: 13px; color: var(--flax); }
.count:empty { display: none; }

/* record: the one loud element */
.rec-slot { order: -1; margin-bottom: 18px; background: var(--flax); color: var(--flax-ink); font-weight: 600; padding: 12px; }
.rec-slot:hover { color: var(--flax-ink); filter: brightness(1.05); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--flax-ink); margin-inline: 4px; }
.brand { order: -2; }
.side-foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 10px 12px 0; }
.side-foot p { margin: 0 0 6px; }

.main { overflow: auto; position: relative; }
.view { padding: 28px 32px 120px; max-width: 980px; }
#view-map { max-width: none; height: 100%; display: flex; flex-direction: column; padding-bottom: 0; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.graph { flex: 1; min-height: 420px; margin: 0 -32px; border-top: 1px solid var(--line); }
.empty { position: absolute; inset: 40% 0 auto; text-align: center; padding: 0 24px; pointer-events: none; }
.empty p { margin: 4px 0; }

.search { flex: 1; max-width: 460px; }
.filters { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.row:hover .row-title { color: var(--flax); }
.row .bar { border-radius: 2px; }
.row-title { font-weight: 500; }
.row-sub { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-meta { color: var(--muted); font-size: 13px; white-space: nowrap; text-align: end; }
.row-meta > span { display: block; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.tag { font-size: 13px; color: var(--muted); }
.tag::before { content: "#"; opacity: .6; }

.task { grid-template-columns: 28px 1fr auto; align-items: start; }
.check {
  width: 22px; height: 22px; margin-top: 3px; border-radius: 6px;
  border: 1.5px solid var(--t-task); background: none; padding: 0;
  display: grid; place-items: center; font-size: 13px; color: var(--bg);
}
.task.done .check { background: var(--t-task); }
.task.done .row-title { text-decoration: line-through; color: var(--muted); }
.due.late { color: var(--danger); }
.done-block { margin-top: 28px; }
.done-block summary { cursor: pointer; color: var(--muted); }

.status { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); }
.status.error { color: var(--danger); border-color: var(--danger); }
.status.pending, .status.processing { color: var(--flax); border-color: var(--flax); }

/* ---------- ask */
.ask { display: grid; gap: 10px; grid-template-columns: 1fr auto; align-items: end; }
.answer { margin-top: 24px; padding: 20px 22px; background: var(--surface); border-radius: var(--r); white-space: pre-wrap; max-width: 72ch; }
.answer .src { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; white-space: normal; }

/* ---------- panel */
.panel {
  position: fixed; inset-block: 0; inset-inline-end: 0;
  width: min(460px, 100%);
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  padding: 26px 26px 60px;
  overflow: auto; z-index: 20;
}
.panel-close { position: absolute; inset-inline-end: 14px; top: 14px; background: none; border: 0; color: var(--muted); font-size: 18px; width: 36px; height: 36px; }
.p-type { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.p-type .sw { width: 10px; height: 10px; border-radius: 50%; }
.panel h3 { font-size: 21px; margin: 10px 0 14px; padding-inline-end: 30px; }
.p-content { white-space: pre-wrap; max-width: 62ch; }
.p-sec { margin-top: 26px; }
.p-sec h4 { margin: 0 0 8px; font-size: 14px; font-weight: 500; color: var(--muted); }
.p-link { display: block; width: 100%; text-align: start; background: var(--bg); border: 0; border-radius: var(--r); padding: 10px 12px; margin-bottom: 6px; }
.p-link small { display: block; color: var(--muted); }
.p-link .rel { color: var(--flax); font-size: 13px; }
.p-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 26px; }
.p-actions .btn { padding: 6px 12px; font-size: 14px; }
.transcript { font-size: 14px; color: var(--muted); white-space: pre-wrap; background: var(--bg); padding: 12px 14px; border-radius: var(--r); }
.mind { height: 340px; background: var(--bg); border-radius: var(--r); margin-top: 8px; }
.edit-title { margin: 10px 0; }

/* ---------- capture sheet */
.sheet-wrap { position: fixed; inset: 0; background: rgba(10, 12, 28, .7); display: grid; place-items: center; z-index: 30; padding: 16px; }
.sheet { position: relative; width: min(440px, 100%); background: var(--surface); border-radius: 18px; padding: 30px 26px 26px; text-align: center; }
.sheet h3 { font-size: 20px; }
.big-rec { position: relative; width: 132px; height: 132px; margin: 26px auto 8px; display: block; background: none; border: 0; padding: 0; }
.big-rec .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--flax); opacity: .5; }
.big-rec .core { position: absolute; inset: 22px; border-radius: 50%; background: var(--flax); transition: inset .2s, border-radius .2s; }
.big-rec.on .core { inset: 42px; border-radius: 12px; background: var(--danger); }
.big-rec.on .ring { border-color: var(--danger); }
@media (prefers-reduced-motion: no-preference) {
  .big-rec.on .ring { animation: breathe 1.4s ease-in-out infinite; }
  @keyframes breathe { 50% { transform: scale(1.08); opacity: .9; } }
}
.rec-time { color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.7em; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; margin: 20px 0 14px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#textForm { display: grid; gap: 10px; }

.toast {
  position: fixed; bottom: 26px; inset-inline-start: 50%; transform: translateX(50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: var(--r);
  z-index: 40; font-weight: 500; max-width: calc(100% - 32px);
}

/* ---------- mobile */
.desk-only { }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side {
    order: 2; flex-direction: row; justify-content: space-around; align-items: center;
    border: 0; border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--bg); gap: 0;
  }
  .brand, .desk-only { display: none !important; }
  .nav-item { flex-direction: column; gap: 0; font-size: 12px; padding: 6px 8px; }
  .nav-item .ico { font-size: 19px; }
  .count { position: absolute; margin: 0; transform: translate(-14px, -4px); }
  .nav-item { position: relative; }
  .rec-slot { order: 0; margin: -26px 0 0; width: 62px; height: 62px; border-radius: 50%; padding: 0; justify-content: center; border: 4px solid var(--bg); }
  .rec-slot .rec-label { display: none; }
  .rec-slot .rec-dot { width: 18px; height: 18px; margin: 0; }
  .view { padding: calc(18px + env(safe-area-inset-top)) 18px 40px; }
  .graph { margin: 0 -18px; }
  .row { grid-template-columns: 4px 1fr; }
  .row .row-meta { grid-column: 2; text-align: start; display: flex; gap: 12px; flex-wrap: wrap; }
  .row-meta > span { display: inline; }
  .mind { height: 420px; }
  .task { grid-template-columns: 28px 1fr; }
  .task .row-meta { grid-column: 2; }
  .ask { grid-template-columns: 1fr; }
  .panel { padding-top: calc(26px + env(safe-area-inset-top)); }
  .sheet-wrap { place-items: end center; padding: 0; }
  .sheet { border-radius: 18px 18px 0 0; padding-bottom: calc(26px + env(safe-area-inset-bottom)); }
}
