/* nidhi — layout and components, on top of web-kit's design tokens.
 * PolyForm Noncommercial 1.0.0. (c) 2026 Dr Sohil Momin. */

body { background: var(--bg0); }

/* an id rule like #list{display:grid} beats the UA's [hidden]{display:none},
   so hidden panels stayed on screen until this line existed */
[hidden] { display: none !important; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }

header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px 16px; margin: 0 -16px 14px;
  background: color-mix(in srgb, var(--bg0) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
a.brand { text-decoration: none; color: var(--accent); }
.brand { font-weight: 700; letter-spacing: .14em; font-size: var(--step-1); color: var(--accent); }
.brand small { display: block; letter-spacing: .02em; font-weight: 400; color: var(--faint); font-size: .7rem; }
.spacer { flex: 1 1 auto; }

input[type="search"], input[type="text"], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; color: var(--ink); width: 100%;
}
input[type="search"] { flex: 1 1 220px; width: auto; min-width: 140px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  flex: 0 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 13px; color: var(--ink);
}
button:hover { border-color: var(--accent-soft); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-soft); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }

nav#folders { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 16px; }
.chip {
  font-size: .82rem; padding: 6px 11px; border-radius: 999px;
  background: var(--bg1); border: 1px solid var(--line); color: var(--ink-soft);
}
.chip b { color: var(--faint); font-weight: 600; margin-left: 4px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on b { color: color-mix(in srgb, #fff 70%, transparent); }

#list { display: grid; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer;
}
.card:hover, .card:focus-visible { border-color: var(--accent-soft); }
.card h3 { font-size: var(--step-1); margin: 0 0 4px; }
.card p { color: var(--ink-soft); font-size: .9rem; margin: 0 0 9px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag {
  font-size: .72rem; padding: 2px 8px; border-radius: 999px;
  background: var(--bg1); border: 1px solid var(--line); color: var(--ink-soft);
}
.tag.seal { background: color-mix(in srgb, var(--gold) 18%, var(--bg1)); border-color: var(--gold); color: var(--ink); }
.tag.dead { border-style: dashed; color: var(--bad); }
.when { margin-left: auto; font-size: .75rem; color: var(--faint); }

.empty { text-align: center; padding: 56px 20px; color: var(--ink-soft); }
.empty h2 { font-size: var(--step-2); margin-bottom: 8px; color: var(--ink); }

#editor { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
#editor .row { display: grid; gap: 10px; margin-bottom: 10px; }
#editor .row.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { #editor .row.two { grid-template-columns: 1fr; } }
#e-body { min-height: 320px; resize: vertical; font-family: var(--mono); font-size: .9rem; line-height: 1.6; }
#e-links { font-size: .82rem; color: var(--ink-soft); margin: 4px 0 12px; min-height: 1.4em; }
#e-links b { color: var(--ink); font-weight: 600; margin-right: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

footer.foot {
  margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between;
  font-size: .78rem; color: var(--faint);
}
.stamp { font-family: var(--mono); }

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px);
  max-width: min(560px, 92vw); padding: 11px 15px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--bg0); font-size: .85rem;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: var(--ok); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }

.fatal {
  margin: 16px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bad) 14%, var(--surface)); border: 1px solid var(--bad);
}
.mut { color: var(--faint); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* phones: keep the header to three rows rather than four */
@media (max-width: 560px) {
  header.top { gap: 7px; padding: 10px 12px; }
  header.top button, header.top select { padding: 7px 9px; font-size: .8rem; }
  .brand { font-size: .95rem; }
  #q { flex-basis: 100%; }
}

/* filing suggestions */
#e-suggest { margin: 0 0 12px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--bg1); font-size: .82rem; }
#e-suggest .line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
#e-suggest .lead { color: var(--ink-soft); }
button.sugg { font-size: .78rem; padding: 3px 9px; border-radius: 999px; background: var(--surface); }
button.sugg:hover { border-color: var(--accent); color: var(--accent); }
#e-suggest .why { color: var(--faint); }

/* conflict review */
#review { border: 1px solid var(--gold); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; background: color-mix(in srgb, var(--gold) 8%, var(--surface)); }
#review h2 { font-size: var(--step-1); margin: 0 0 4px; }
#review-note { font-size: .82rem; margin: 0 0 10px; }
.conflict { border-top: 1px solid var(--line); padding: 10px 0; }
.conflict:first-child { border-top: 0; }
.conflict h3 { font-size: .95rem; margin: 0 0 3px; }
.conflict .fields { font-size: .78rem; color: var(--ink-soft); margin-bottom: 7px; }
.conflict .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.conflict button { font-size: .78rem; padding: 5px 10px; }

/* view switcher */
nav#views { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
nav#views button {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none;
  padding: 8px 12px; color: var(--ink-soft); font-size: .88rem;
}
nav#views button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.pill { display: inline-block; min-width: 1.4em; padding: 0 5px; border-radius: 999px; background: var(--bg1); color: var(--faint); font-size: .72rem; }
nav#views button.on .pill { background: color-mix(in srgb, var(--accent) 16%, var(--bg1)); color: var(--accent); }

.statline { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--ink-soft); margin: 0 0 14px; }
.statline b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* review */
#review-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 20px; min-height: 220px; }
#review-card .front { font-size: var(--step-2); font-weight: 600; margin-bottom: 8px; }
#review-card .back { font-family: var(--mono); font-size: .9rem; white-space: pre-wrap; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
#review-card .actions { margin-top: 18px; }
#review-card .done { text-align: center; color: var(--ink-soft); padding: 40px 10px; }
.grade-again { color: var(--bad); }
.grade-good { color: var(--accent); }
.grade-easy { color: var(--ok); }

/* health */
/* the severity chart replaced the bar strip: it needs its own height, not 54px */
#health-spark { display: block; height: auto; margin: 0 0 18px; }
#health-spark svg { max-height: 200px; }
.tl { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; }
.tl .ev { position: relative; padding: 0 0 16px; }
.tl .ev::before { content: ""; position: absolute; left: -21px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-soft); }
.tl .when { font-size: .74rem; color: var(--faint); font-family: var(--mono); }
.tl .what { font-size: .9rem; }
.sev { font-size: .7rem; color: var(--bad); margin-left: 6px; }

/* money */
#tx-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 16px; }
#tx-form .row { display: grid; gap: 10px; margin-bottom: 10px; }
#tx-form .row.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { #tx-form .row.two { grid-template-columns: 1fr; } }
#money-body table { width: 100%; border-collapse: collapse; font-size: .84rem; }
#money-body th, #money-body td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
#money-body th { color: var(--faint); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
#money-body td.num { text-align: right; font-variant-numeric: tabular-nums; }
#money-body h3 { font-size: var(--step-1); margin: 18px 0 8px; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }

/* sync */
.note { font-size: .84rem; color: var(--ink-soft); background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; margin: 0 0 14px; }
.note b { color: var(--ink); }
.note.warn { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--surface)); }
#sync-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 16px; }
#sync-form .row { display: grid; gap: 10px; margin-bottom: 10px; }
#sync-form .row.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { #sync-form .row.two { grid-template-columns: 1fr; } }
#sync-status.on { color: var(--ok); }
#sync-status.bad { color: var(--bad); }
#sync-log { font-size: .84rem; }
#sync-log .entry { padding: 8px 0; border-bottom: 1px solid var(--line); }
#sync-log .entry .when { font-family: var(--mono); font-size: .74rem; color: var(--faint); }

/* recently deleted */
.chip.gone { border-style: dashed; }
.card.tomb { cursor: default; opacity: .82; }
.card.tomb .actions { display: flex; gap: 8px; margin-top: 10px; }
.card.tomb button { font-size: .78rem; padding: 5px 11px; }

/* draft banner */
.draft {
  border: 1px solid var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--surface));
  border-radius: var(--radius-sm); padding: 9px 12px; margin-bottom: 12px; font-size: .84rem;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.draft b { color: var(--ink); }

/* tag filter row */
nav#tags { display: flex; flex-wrap: wrap; gap: 6px; margin: -8px 0 16px; align-items: center; }
nav#tags:empty { display: none; }
.tagchip {
  font-size: .76rem; padding: 4px 10px; border-radius: 999px; background: transparent;
  border: 1px solid var(--line); color: var(--ink-soft);
}
.tagchip b { color: var(--faint); font-weight: 600; margin-left: 4px; }
.tagchip.on { background: var(--ink); border-color: var(--ink); color: var(--bg0); }
.tagchip.on b { color: color-mix(in srgb, var(--bg0) 70%, transparent); }
.tagchip .x { margin-left: 6px; opacity: .7; }

/* selection */
.card.picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card .pick { float: right; margin: 0 0 8px 12px; width: 18px; height: 18px; accent-color: var(--accent); }
#bulkbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 11px 14px; margin: 0 0 14px; border-radius: var(--radius);
  border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  font-size: .84rem;
}
#bulkbar #bulk-count { font-weight: 600; }
#bulkbar select, #bulkbar input { width: auto; padding: 6px 9px; font-size: .82rem; }
#bulkbar input { max-width: 140px; }
#bulkbar button { font-size: .8rem; padding: 6px 11px; }
#bulkbar .danger { margin-left: auto; }

/* undo in the toast */
/* the toast itself must not swallow clicks, but its button must be clickable —
   an Undo nobody can press is worse than no Undo */
.toast #toast-undo { pointer-events: auto; }
.toast #toast-undo {
  margin-left: 12px; padding: 3px 10px; font-size: .78rem; border-radius: 4px;
  background: transparent; border: 1px solid color-mix(in srgb, var(--bg0) 55%, transparent);
  color: inherit; font-weight: 600;
}
.toast #toast-undo:hover { background: color-mix(in srgb, var(--bg0) 18%, transparent); }

/* skip link — visible only when it has focus */
.skip {
  position: absolute; left: 8px; top: -48px; z-index: 60;
  background: var(--accent); color: #fff; padding: 9px 14px; border-radius: 0 0 6px 6px;
  text-decoration: none; font-size: .86rem; transition: top .15s ease;
}
.skip:focus { top: 0; }

/* the help sheet */
.sheet {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in srgb, var(--ink) 45%, transparent); padding: 20px;
}
.sheet-in {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; max-width: 520px; width: 100%; max-height: 86vh; overflow: auto;
  box-shadow: 0 30px 60px -30px rgba(36,28,20,.6);
}
.sheet-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { font-size: var(--step-2); margin: 0; flex: 1; }
.sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 0 0 14px; font-size: .88rem; }
.sheet dt { text-align: right; }
.sheet dd { margin: 0; color: var(--ink-soft); }
.sheet kbd {
  font-family: var(--mono); font-size: .76rem; padding: 2px 7px; border-radius: 4px;
  border: 1px solid var(--line); border-bottom-width: 2px; background: var(--bg1); color: var(--ink);
}
.sheet #help-note { font-size: .78rem; margin: 0; }

/* first run */
.welcome {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: clamp(22px,3.4vw,36px);
  background: var(--surface); text-align: left;
}
.welcome h2 { font-size: var(--step-2); margin: 0 0 10px; }
.welcome p { color: var(--ink-soft); font-size: .94rem; max-width: 62ch; margin: 0 0 18px; }
.welcome .actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* markdown preview */
#e-preview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; min-height: 320px; font-size: .94rem; line-height: 1.65; }
#e-preview h1, #e-preview h2, #e-preview h3, #e-preview h4 { margin: 14px 0 6px; line-height: 1.25; }
#e-preview h1 { font-size: 1.4rem; } #e-preview h2 { font-size: 1.2rem; } #e-preview h3 { font-size: 1.05rem; }
#e-preview p { margin: 0 0 10px; }
#e-preview ul, #e-preview ol { margin: 0 0 10px; padding-left: 22px; }
#e-preview li { margin-bottom: 3px; }
#e-preview blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink-soft); }
#e-preview pre { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; overflow: auto; margin: 0 0 10px; }
#e-preview code { font-family: var(--mono); font-size: .86em; }
#e-preview hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
#e-preview .md-link { color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }

/* editor state line */
.edstats { display: flex; gap: 14px; font-size: .76rem; color: var(--faint); margin: 6px 0 12px; font-family: var(--mono); }
.edstats #e-dirty.dirty { color: var(--gold); }
.edstats #e-dirty.clean { color: var(--ok); }

/* search result count and highlights */
.resultcount { font-size: .78rem; color: var(--faint); margin: 0 0 10px; font-family: var(--mono); }
mark { background: color-mix(in srgb, var(--gold) 40%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.tagchip .pencil { margin-left: 6px; opacity: .65; }

/* the rest of a long list */
.more { text-align: center; padding: 8px 0 4px; }
.more button { font-size: .84rem; }

/* the transaction list */
.txacts { text-align: right; }
button.linkish { background: none; border: 0; padding: 2px 4px; font-size: .78rem; color: var(--accent); text-decoration: underline; }
.txform { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.txform input, .txform select { width: auto; padding: 5px 8px; font-size: .82rem; }
.txform input#txe-amount { max-width: 110px; }
.txform button { font-size: .78rem; padding: 5px 10px; }

/* attachments */
#e-files { margin: 4px 0 10px; }
.filelist { display: flex; flex-wrap: wrap; gap: 8px; }
.fileitem {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  font-size: .8rem; max-width: 100%;
}
.fileitem img { width: 34px; height: 34px; object-fit: cover; border-radius: 4px; display: block; }
.fileitem .fname { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fileitem .fsize { color: var(--faint); font-family: var(--mono); font-size: .72rem; }
.fileitem button { padding: 2px 7px; font-size: .72rem; }
.fileitem .x { color: var(--accent); }

/* budgets */
.budgets { display: grid; gap: 10px; margin: 8px 0 14px; }
.budget, .rule { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; background: var(--surface); }
.budget .bhead, .rule .bhead { display: flex; align-items: baseline; gap: 10px; font-size: .84rem; }
.budget .btag, .rule .btag { font-family: var(--mono); color: var(--accent); }
.budget .bnum, .rule .bnum { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.budget .bbar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 7px 0 4px; }
.budget .bbar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.budget.over .bbar i { background: var(--danger); }
.budget .bfoot, .rule .bfoot { font-size: .74rem; }

/* the severity chart */
svg.chart { display: block; width: 100%; height: auto; max-height: 190px; overflow: visible; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .tick { fill: var(--faint); font-size: 9px; font-family: var(--mono); text-anchor: end; }
svg.chart .tick.x { text-anchor: start; }
svg.chart .tick.x.end { text-anchor: end; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
svg.chart circle.pt { fill: var(--accent); }
svg.chart circle.pt:hover { r: 5; }
