/* Orvia — mobile-first life workspace.
   Layout: one column on phones with a 5-slot bottom bar (Quick Add raised in the middle);
   on wide screens the same five destinations move to a left rail. */
:root {
  --paper: #f3f4f9;        /* app ground, cool blue-grey */
  --surface: #ffffff;      /* grouped lists, sheets */
  --ink: #1a1d3a;          /* deep indigo text */
  --muted: #676c8c;
  --line: #e3e5ef;
  --soft: #eceef7;         /* chips, pressed states */
  --primary: #3a3fb4;      /* selection, links */
  --primary-soft: #e6e7fb;
  --marigold: #f0a202;     /* the one bold accent: Quick Add + today ring */
  --marigold-ink: #3a2600;
  --income: #12805a;
  --expense: #c63a58;
  --warn: #b86e00;
  --shadow: 0 10px 30px rgba(26, 29, 58, 0.14);

  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Hind", "Noto Sans", system-ui, -apple-system, sans-serif;

  --r-sheet: 26px;
  --r-group: 18px;
  --r-pill: 999px;
  --nav-h: 66px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1126; --surface: #191c37; --ink: #eceef9; --muted: #9da1c2;
    --line: #2a2e52; --soft: #23264a; --primary: #9296ff; --primary-soft: #262a5c;
    --marigold: #f5b12b; --marigold-ink: #2b1c00; --income: #3fc28f; --expense: #f06f8b;
    --warn: #f0a94a; --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1126; --surface: #191c37; --ink: #eceef9; --muted: #9da1c2;
  --line: #2a2e52; --soft: #23264a; --primary: #9296ff; --primary-soft: #262a5c;
  --marigold: #f5b12b; --marigold-ink: #2b1c00; --income: #3fc28f; --expense: #f06f8b;
  --warn: #f0a94a; --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
svg.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.app { min-height: 100%; }
.main { max-width: 600px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + 40px + env(safe-area-inset-bottom, 0px)); }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 8px; padding: 12px 0 10px;
  background: var(--paper);
}
.topbar h1 { font-size: 24px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); }
.iconbtn:active { background: var(--soft); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 0 8px env(safe-area-inset-bottom, 0px);
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
}
.nav button {
  height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; color: var(--muted); font-weight: 500;
}
.nav button[aria-current="page"] { color: var(--primary); }
.nav button[aria-current="page"] svg { stroke-width: 2.2; }
.nav .add { position: relative; }
.nav .add span.fab {
  width: 58px; height: 58px; border-radius: 20px; margin-top: -26px;
  background: var(--marigold); color: var(--marigold-ink);
  display: grid; place-items: center; box-shadow: 0 8px 20px rgba(240, 162, 2, 0.38);
  transition: transform .15s ease;
}
.nav .add span.fab svg { width: 28px; height: 28px; stroke-width: 2.4; }
.nav .add:active span.fab { transform: scale(.94); }
.nav .add .lbl { color: var(--ink); }

@media (min-width: 900px) {
  .nav {
    top: 0; right: auto; width: 96px; border-top: 0; border-right: 1px solid var(--line);
    grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: start; padding: 24px 8px;
    gap: 6px;
  }
  .nav .add { order: -1; margin-bottom: 18px; }
  .nav .add span.fab { margin-top: 0; }
  .main { margin-left: 96px; max-width: none; padding: 0 40px 60px; }
  .main > .wrap { max-width: 760px; margin: 0 auto; }
  .split { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; }
}

/* ---------- groups & rows ---------- */
.section { margin-top: 22px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 8px; }
.sec-h h2 { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.sec-h .link { color: var(--primary); font-size: 14px; font-weight: 500; }
.sec-h.alert h2 { color: var(--expense); }
.group { background: var(--surface); border-radius: var(--r-group); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; width: 100%; text-align: left;
  border-top: 1px solid var(--line);
}
.group > .row:first-child, .group > :first-child .row { border-top: 0; }
.row .body { flex: 1; min-width: 0; }
.row .t { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--muted); margin-top: 1px; }
.row .s .late { color: var(--expense); font-weight: 500; }
.row .end { text-align: right; flex: none; }
button.row:active, .tap:active { background: var(--soft); }
.row.done .t { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

.check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); flex: none;
  display: grid; place-items: center; color: transparent; transition: background .15s, border-color .15s;
}
.check.hi { border-color: var(--expense); }
.check.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.check svg { width: 15px; height: 15px; stroke-width: 3; }
.pri { color: var(--expense); font-weight: 600; }
.tag { color: var(--primary); }
.badge { font-size: 12px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--soft); color: var(--muted); }

.ico {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--soft); color: var(--ink); font-size: 18px;
}
.ico svg { width: 20px; height: 20px; }

.empty {
  background: var(--surface); border-radius: var(--r-group); padding: 22px 18px; color: var(--muted);
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
}
.empty b { color: var(--ink); font-family: var(--font-display); font-weight: 600; }

/* ---------- home ---------- */
.hello { display: flex; align-items: center; gap: 18px; margin-top: 6px; }
.hello .greet { flex: 1; min-width: 0; }
.hello .greet p { margin: 0; color: var(--muted); }
.hello .greet h2 { font-size: 26px; line-height: 1.15; margin-top: 2px; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 104px; height: 104px; transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring .prog { stroke: var(--marigold); stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring .dot { fill: var(--primary); }
.ring .c { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.05; }
.ring .c b { font-family: var(--font-display); font-size: 24px; display: block; }
.ring .c small { font-size: 12px; color: var(--muted); }

.strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.stat { background: var(--surface); border-radius: 16px; padding: 10px 12px; text-align: left; }
.stat small { color: var(--muted); font-size: 12.5px; display: block; }
.stat b { font-family: var(--font-display); font-size: 18px; font-variant-numeric: tabular-nums; display: block; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.bad b { color: var(--expense); }

/* ---------- segmented / chips ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(max-content, 1fr); overflow-x: auto; scrollbar-width: none; background: var(--soft); padding: 4px; border-radius: 14px; gap: 4px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { padding: 8px 9px; border-radius: 10px; font-weight: 500; color: var(--muted); font-size: 14px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(26,29,58,.1); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 14px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line);
  font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip .n { color: inherit; opacity: .6; margin-left: 4px; }

/* ---------- calendar ---------- */
.week { display: flex; align-items: center; gap: 4px; margin-top: 14px; }
.week .days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 8px; border-radius: 14px; }
.day small { font-size: 12px; color: var(--muted); }
.day b { font-family: var(--font-display); font-size: 17px; font-weight: 600; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; }
.day.today b { color: var(--primary); }
.day[aria-pressed="true"] b { background: var(--primary); color: #fff; }
.day i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.day i.has { background: var(--marigold); }
.month-h { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.month-h h2 { font-size: 19px; }
.time { font-family: var(--font-display); font-size: 13px; font-weight: 600; width: 50px; flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.evbar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--primary); flex: none; }

/* ---------- money ---------- */
.money-sum { background: var(--surface); border-radius: var(--r-group); padding: 16px; margin-top: 14px; }
.money-sum .net { font-family: var(--font-display); font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; }
.money-sum .lbl { color: var(--muted); font-size: 14px; }
.money-sum .io { display: flex; gap: 22px; margin-top: 10px; flex-wrap: wrap; }
.money-sum .io b { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.inc { color: var(--income); } .exp { color: var(--expense); }
.amt { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.datehead { font-size: 13px; color: var(--muted); padding: 14px 6px 6px; font-weight: 500; }
.bar { display: block; height: 8px; border-radius: 8px; background: var(--soft); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 8px; }
.bar.over > span { background: var(--expense); }
.bar.near > span { background: var(--warn); }
.monthnav { display: flex; align-items: center; justify-content: space-between; }
.monthnav b { font-family: var(--font-display); }

/* ---------- library ---------- */
.searchbox {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 0 14px; height: 46px;
  border: 1px solid var(--line);
}
.searchbox input { flex: 1; border: 0; background: none; outline: none; min-width: 0; height: 100%; font-size: 16px; }
.searchbox svg { color: var(--muted); }
.notecard .t { white-space: normal; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.preview { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }

/* ---------- project ---------- */
.proj-hero { background: var(--surface); border-radius: var(--r-group); padding: 18px; margin-top: 6px; }
.proj-hero h2 { font-size: 24px; }
.proj-hero p { color: var(--muted); margin: 6px 0 0; }
.proj-hero .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15, 17, 38, .45); z-index: 50; opacity: 0; transition: opacity .2s; }
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; max-height: 92%; overflow-y: auto;
  background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow);
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  max-width: 600px; margin: 0 auto;
}
.sheet.show { transform: none; }
@media (min-width: 900px) {
  .sheet { bottom: auto; top: 50%; border-radius: var(--r-sheet); transform: translateY(-40%) scale(.98); opacity: 0; max-width: 520px; transition: transform .2s, opacity .2s; }
  .sheet.show { transform: translateY(-50%); opacity: 1; }
}
.grab { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 4px auto 12px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sheet-h h2 { font-size: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .lab { font-size: 14px; color: var(--muted); font-weight: 500; }
.in {
  width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 11px 13px; font-size: 16px; outline: none;
}
.in:focus { border-color: var(--primary); background: var(--surface); }
textarea.in { min-height: 110px; resize: vertical; }
.in.big { font-size: 20px; font-family: var(--font-display); font-weight: 500; padding: 12px 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > .field { min-width: 0; }
.opts { display: flex; gap: 8px; flex-wrap: wrap; }
.opt { padding: 7px 14px; border-radius: var(--r-pill); border: 1px solid var(--line); font-size: 14px; font-weight: 500; }
.opt[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.amount-in { display: flex; align-items: center; gap: 6px; border-bottom: 2px solid var(--line); padding: 4px 2px; margin-bottom: 16px; }
.amount-in:focus-within { border-color: var(--primary); }
.amount-in span { font-family: var(--font-display); font-size: 32px; color: var(--muted); }
.amount-in input { border: 0; outline: none; background: none; font-family: var(--font-display); font-size: 36px; font-weight: 600; width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }
details.more { margin: 4px 0 14px; }
details.more summary { color: var(--primary); font-weight: 500; cursor: pointer; padding: 6px 0; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { margin-bottom: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 20px;
  border-radius: 14px; font-weight: 600; font-size: 16px; background: var(--primary); color: #fff; width: 100%;
}
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { background: transparent; color: var(--expense); }
.btn.sm { height: 38px; width: auto; font-size: 14px; padding: 0 14px; border-radius: 12px; }
.btnrow { display: flex; gap: 10px; margin-top: 6px; }
.btnrow > * { flex: 1; }

/* quick add */
.qa-input { display: flex; align-items: center; gap: 10px; border: 2px solid var(--marigold); border-radius: 16px; padding: 4px 6px 4px 14px; background: var(--paper); }
.qa-input input { flex: 1; border: 0; background: none; outline: none; font-size: 18px; min-width: 0; height: 48px; }
.qa-go { width: 44px; height: 44px; border-radius: 12px; background: var(--marigold); color: var(--marigold-ink); display: grid; place-items: center; flex: none; }
.qa-go:disabled { opacity: .35; }
.qa-prev { min-height: 28px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 2px 4px; font-size: 14px; }
.qa-prev .pill { background: var(--soft); border-radius: var(--r-pill); padding: 2px 10px; }
.qa-prev .kind { background: var(--ink); color: var(--paper); font-weight: 600; }
.qa-hint { color: var(--muted); font-size: 13.5px; margin: 4px 2px 16px; }
.qa-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.qa-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 16px; background: var(--paper); font-size: 13.5px; font-weight: 500; }
.qa-grid button:active { background: var(--soft); }
.qa-grid .ico { background: var(--surface); }

/* search overlay */
.search-ov { position: fixed; inset: 0; z-index: 70; background: var(--paper); overflow-y: auto; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 40px; }
.search-ov .inner { max-width: 600px; margin: 0 auto; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom, 0px)); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 10px 10px 16px; border-radius: 14px;
  display: flex; align-items: center; gap: 14px; font-size: 15px; width: max-content; max-width: calc(100% - 32px); transition: all .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: var(--marigold); font-weight: 600; padding: 4px 8px; }
.toast:empty { display: none; }

.banner { background: var(--primary-soft); color: var(--ink); border-radius: 14px; padding: 10px 14px; font-size: 14px; margin-top: 10px; }
.fileline { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; background: var(--paper); }
.muted { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
