/* Polymathus design system. Warm cream pages, big soft white cards, black pill controls,
   lime + deep green for progress, orange flourishes. Phone = app, tablet = side pill, desktop = web app. */
:root {
  --bg: #F3EEE6; --side: #EDE6DA; --card: #FFFFFF; --soft: #F7F3EC;
  --text: #141A17; --muted: #6A6F68; --faint: #9DA098;
  --line: rgba(20,26,23,.08); --hover: rgba(20,26,23,.06);
  --ink: #141A17; --ink-text: #FFFFFF;
  --lime: #D7F25C; --green: #0F5C45; --orange: #FF6B2C; --accent: #0F5C45; --danger: #D9503F;
  --hero: #141A17; --hero-text: #FFFFFF;
  --t-idea: #FFE9A8; --t-learning: #D5E6EE; --t-journal: #D9EEDB; --t-project: #E5DAF2; --t-hot: #FAD9C1; --t-gray: rgba(20,26,23,.07);
  --nav-bg: #141A17; --nav-ic: rgba(255,255,255,.62); --nav-act-bg: #FFFFFF; --nav-act-ic: #141A17;
  --shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 12px 32px rgba(70,50,20,.07);
  --pop: 0 14px 34px rgba(20,26,23,.28);
  --display: "Bricolage Grotesque", "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --font: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --script: Caveat, "Segoe Script", cursive;
  --nav-h: 64px; --canvas: var(--bg); --nav-w: 0px; --content-w: 760px;
}
:root[data-theme="dark"] {
  --bg: #101613; --side: #0B100D; --card: #1A2320; --soft: #151D1A;
  --text: #F1EEE6; --muted: #9AA39B; --faint: #66706A;
  --line: rgba(255,255,255,.08); --hover: rgba(255,255,255,.07);
  --ink: #D7F25C; --ink-text: #141A17; --accent: #D7F25C;
  --hero: #0F5C45; --hero-text: #FFFFFF;
  --t-idea: #5A4A1D; --t-learning: #213B4A; --t-journal: #1F4A38; --t-project: #3D3158; --t-hot: #5C3A22; --t-gray: rgba(255,255,255,.09);
  --nav-bg: #212C27; --nav-ic: rgba(255,255,255,.55); --nav-act-bg: #D7F25C; --nav-act-ic: #141A17;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 30px rgba(0,0,0,.35);
  --pop: 0 14px 34px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #101613; --side: #0B100D; --card: #1A2320; --soft: #151D1A;
    --text: #F1EEE6; --muted: #9AA39B; --faint: #66706A;
    --line: rgba(255,255,255,.08); --hover: rgba(255,255,255,.07);
    --ink: #D7F25C; --ink-text: #141A17; --accent: #D7F25C;
    --hero: #0F5C45; --hero-text: #FFFFFF;
    --t-idea: #5A4A1D; --t-learning: #213B4A; --t-journal: #1F4A38; --t-project: #3D3158; --t-hot: #5C3A22; --t-gray: rgba(255,255,255,.09);
    --nav-bg: #212C27; --nav-ic: rgba(255,255,255,.55); --nav-act-bg: #D7F25C; --nav-act-ic: #141A17;
    --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 30px rgba(0,0,0,.35);
    --pop: 0 14px 34px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 500 15.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.ic { width: 22px; height: 22px; flex: none; }

/* shell */
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; background: var(--canvas); position: relative; }
@media (min-width: 520px) and (max-width: 599px) { .app { border-inline: 1px solid var(--line); } }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(16px + env(safe-area-inset-top)) 20px 8px; background: color-mix(in srgb, var(--canvas) 90%, transparent); backdrop-filter: blur(14px); min-height: 68px; }
.top h1 { margin: 0; font: 700 34px/1.05 var(--display); letter-spacing: -.035em; }
.top .date { font-size: 13px; color: var(--muted); font-weight: 600; }
.top .mid { flex: 1; min-width: 0; text-align: center; font: 700 18px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .l { flex: 1; min-width: 0; }
main { padding: 6px 16px 140px; }
.has-composer main { padding-bottom: 214px; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--text); flex: none; }
.iconbtn:active { transform: scale(.94); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--lime); color: #141A17; display: grid; place-items: center; font: 800 17px var(--display); overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* floating nav pill (phone) */
.tabbar { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); width: min(340px, calc(100% - 32px)); height: var(--nav-h); border-radius: 999px; background: var(--nav-bg); box-shadow: var(--pop); padding: 8px; }
.tabbar .nav-in { display: flex; width: 100%; height: 100%; align-items: center; justify-content: space-between; }
.tabbar .brand, .tabbar .nav-gap, .tabbar .nav-settings, .tabbar span { display: none; }
.tabbar button { width: 48px; height: 48px; border-radius: 50%; border: 0; background: none; display: grid; place-items: center; color: var(--nav-ic); transition: background .2s, color .2s; }
.tabbar button.on { background: var(--nav-act-bg); color: var(--nav-act-ic); }
.tabbar .ic { width: 22px; height: 22px; }

/* composer */
.bars { position: fixed; z-index: 20; left: 0; right: 0; bottom: calc(14px + var(--nav-h) + 12px + env(safe-area-inset-bottom)); display: flex; justify-content: center; padding: 0 16px; pointer-events: none; }
.bars > * { pointer-events: auto; }
.composer { width: min(480px, 100%); display: flex; align-items: flex-end; gap: 8px; padding: 7px; background: var(--card); border: 1px solid var(--line); border-radius: 32px; box-shadow: var(--pop); }
.composer[hidden] { display: none; }
.composer textarea { scrollbar-width: none; flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; resize: none; padding: 11px 4px; max-height: 120px; line-height: 1.4; }
.composer textarea::placeholder { color: var(--faint); }
.round { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none; }
.round.soft { background: var(--hover); color: var(--text); }
.round.ink { background: var(--ink); color: var(--ink-text); }
.round[hidden] { display: none; }

/* type */
h2 { margin: 30px 4px 12px; font: 700 21px/1.2 var(--display); letter-spacing: -.025em; color: var(--text); }
h3 { margin: 0; font: 700 17px/1.25 var(--display); letter-spacing: -.02em; }
p { margin: 4px 0; }
.sub { color: var(--muted); } .small { font-size: 13.5px; } .faint { color: var(--faint); font-size: 12.5px; font-weight: 600; }
.script { font: 600 22px var(--script); color: var(--orange); letter-spacing: .2px; }
.big { font: 700 40px/1 var(--display); letter-spacing: -.04em; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; line-height: 1.55; padding: 1px 10px; border-radius: 999px; background: var(--t-gray); color: var(--text); white-space: nowrap; }
.tag.idea { background: var(--t-idea); } .tag.learning { background: var(--t-learning); } .tag.journal { background: var(--t-journal); }
.tag.project { background: var(--t-project); } .tag.hot { background: var(--t-hot); }
.tag.click { cursor: pointer; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; flex-wrap: nowrap; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 28px; padding: 18px 20px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.click { cursor: pointer; transition: transform .15s; } .card.click:active { transform: scale(.99); }
.card p { color: var(--muted); font-size: 14.5px; white-space: pre-wrap; }
.empty { color: var(--muted); text-align: center; padding: 30px 16px; border: 1.5px dashed var(--line); border-radius: 28px; }
.hello { padding: 4px 4px 14px; } .hello .sub { margin-top: 2px; }
.card.sel { border-color: var(--ink); box-shadow: 0 0 0 1.5px var(--ink); }

/* buttons + fields */
.btn { white-space: nowrap; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 9px 18px; font-weight: 700; font-size: 14.5px; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--ink); color: var(--ink-text); border-color: transparent; }
.btn.accent { background: var(--lime); color: #141A17; border-color: transparent; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); padding: 7px 10px; }
.btn.good { color: var(--green); } .btn.bad { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.cta { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 17px 22px; border: 0; border-radius: 999px; background: var(--ink); color: var(--ink-text); font: 700 16.5px var(--display); letter-spacing: -.01em; box-shadow: var(--pop); }
.link { color: var(--text); font-weight: 700; background: none; border: 0; padding: 0; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
input, select, textarea.field { width: 100%; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 13px 16px; font: inherit; outline: none; }
input:focus, select:focus, textarea.field:focus { border-color: var(--ink); }
textarea.field { min-height: 120px; resize: vertical; line-height: 1.55; }
label { display: block; font-size: 13.5px; font-weight: 700; color: var(--muted); margin: 18px 4px 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 700; color: var(--muted); }
.pill.on { background: var(--ink); color: var(--ink-text); border-color: transparent; }
.search { position: relative; margin: 6px 0 12px; }
.search .ic { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); }
.search input { padding-left: 46px; border-radius: 999px; box-shadow: var(--shadow); }

/* editorial home */
.datechip { display: inline-block; background: var(--ink); color: var(--ink-text); border-radius: 999px; padding: 4px 14px; font-size: 13px; font-weight: 700; }
.headline { font: 600 40px/1.04 var(--display); letter-spacing: -.04em; margin: 12px 0 6px; } .headline b { font-weight: 800; }

/* review card */
.flash { text-align: center; padding: 28px 22px 22px; }
.flash .q { font: 700 24px/1.2 var(--display); letter-spacing: -.03em; margin: 14px 0 20px; }
.flash .a { text-align: left; background: var(--soft); border-radius: 20px; padding: 14px 16px; margin-bottom: 16px; color: var(--muted); white-space: pre-wrap; }

/* stream timeline */
.tl { position: relative; padding-left: 42px; }
.tl::before { content: ""; position: absolute; left: 14px; top: 6px; bottom: 6px; width: 1.5px; background: var(--line); }
.daypill { display: table; margin: 18px auto 12px; background: var(--hover); color: var(--muted); border-radius: 999px; padding: 3px 14px; font-size: 12.5px; font-weight: 700; position: relative; left: -21px; }
.entry { position: relative; margin-bottom: 12px; }
.rail { position: absolute; left: -42px; top: 10px; width: 30px; height: 30px; border-radius: 50%; background: var(--canvas); display: grid; place-items: center; color: var(--muted); }
.rail .ic { width: 17px; height: 17px; }
.ecard { background: var(--card); border-radius: 24px; padding: 15px 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.ecard h3 { font-size: 16px; margin-bottom: 4px; }
.ecard .body { color: var(--text); font-size: 15.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ecard .body.clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.ecard .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; color: var(--faint); font-size: 12.5px; font-weight: 600; }
.thought { border-left: 3px solid var(--orange); padding: 2px 0 2px 12px; margin: 10px 0; font-size: 14.5px; }
.q-list { margin: 10px 0 0; padding-left: 20px; } .q-list li { margin: 6px 0; }

/* journal widgets */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font: 800 28px/1.1 var(--display); letter-spacing: -.04em; } .stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.cal { display: grid; grid-template-columns: repeat(14, 1fr); gap: 5px; }
.cal i { aspect-ratio: 1; border-radius: 6px; background: var(--hover); } .cal i.on { background: var(--green); } .cal i.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.moods { display: flex; align-items: flex-end; gap: 5px; height: 56px; } .moods i { flex: 1; background: var(--hover); border-radius: 5px; min-height: 5px; } .moods i.on { background: var(--orange); }

/* recording */
.rec { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: flex; justify-content: center; }
.rec[hidden], .sheet[hidden], .lock[hidden], .auth[hidden] { display: none; }
.rec .inner { width: min(480px, 100%); display: flex; flex-direction: column; padding: calc(16px + env(safe-area-inset-top)) 24px calc(26px + env(safe-area-inset-bottom)); }
.rec .head { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; font: 700 18px var(--display); text-align: center; }
.rec .stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; min-height: 0; }
.wave { display: flex; align-items: center; gap: 12px; height: 150px; }
.wave i { width: 36px; border-radius: 18px; background: var(--hover); height: 44px; transition: height .3s; border: 1px solid var(--line); }
.wave.live i { background: var(--green); border-color: transparent; animation: bob 1.1s ease-in-out infinite; }
:root[data-theme="dark"] .wave.live i { background: var(--lime); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .wave.live i { background: var(--lime); } }
.wave i:nth-child(1) { --h: 76px; } .wave i:nth-child(2) { --h: 140px; animation-delay: .15s !important; } .wave i:nth-child(3) { --h: 104px; animation-delay: .3s !important; } .wave i:nth-child(4) { --h: 60px; animation-delay: .45s !important; }
@keyframes bob { 0%, 100% { height: 40px; } 50% { height: var(--h); } }
.timer { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer .ic { width: 14px; height: 14px; }
.live-text { max-height: 22vh; overflow: auto; width: 100%; text-align: center; color: var(--muted); font-size: 16px; padding: 0 4px; }
.rec .ctrl { display: flex; align-items: center; justify-content: space-between; }
.rec .ctrl .round { width: 58px; height: 58px; }
.rec .ctrl .pause { width: 100px; height: 58px; border-radius: 29px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; }

/* sheets, lock, sign-in */
.sheet, .lock { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(15,20,17,.5); }
.panel { width: min(480px, 100%); max-height: 92dvh; overflow: auto; background: var(--bg); border-radius: 32px 32px 0 0; padding: 22px 22px calc(24px + env(safe-area-inset-bottom)); }
.lock { align-items: center; background: var(--bg); }
.lock .panel { background: none; text-align: center; max-width: 320px; }
.lock input { text-align: center; font-size: 24px; letter-spacing: .4em; margin: 18px 0; }
.toast { position: fixed; z-index: 90; left: 50%; bottom: calc(var(--nav-h) + 104px); transform: translateX(-50%); background: var(--ink); color: var(--ink-text); padding: 11px 20px; border-radius: 999px; font-size: 14px; font-weight: 700; max-width: 88vw; box-shadow: var(--pop); }
.ai-off { background: var(--t-idea); border-radius: 22px; padding: 13px 16px; margin: 0 0 12px; font-size: 14px; }
code { background: var(--hover); border-radius: 6px; padding: 1px 6px; font-size: 13px; }
.auth { position: fixed; inset: 0; z-index: 55; display: flex; flex-direction: column; background: var(--bg); padding: calc(24px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom)); overflow: auto; }
.authbox { width: min(420px, 100%); margin: auto; display: flex; flex-direction: column; min-height: min(100%, 720px); }
.authart { flex: 1; display: grid; place-items: center; position: relative; min-height: 280px; }
.brandmark { width: 92px; height: 92px; border-radius: 26px; box-shadow: var(--pop); position: relative; z-index: 2; }
.orb { position: absolute; border-radius: 50%; }
.orb.a { width: 120px; height: 120px; background: var(--lime); left: 12%; top: 14%; } .orb.b { width: 78px; height: 78px; background: var(--orange); right: 14%; top: 8%; }
.orb.c { width: 150px; height: 150px; background: var(--green); right: 6%; bottom: 8%; } .orb.d { width: 64px; height: 64px; background: var(--t-learning); left: 10%; bottom: 14%; }
.authbox h1 { margin: 6px 0 4px; font: 700 42px/1.02 var(--display); letter-spacing: -.045em; }
.authbox .script { display: block; margin: 0 0 10px; font-size: 28px; }
.gbtn { margin: 22px 0 8px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px 20px; border: 0; border-radius: 999px; background: var(--ink); color: var(--ink-text); font: 700 16.5px var(--display); box-shadow: var(--pop); }
.gbtn .g { width: 30px; height: 30px; border-radius: 50%; background: #fff; display: grid; place-items: center; } .gbtn:disabled { opacity: .6; }

/* ---------- tablet: floating pill rail on the left ---------- */
@media (min-width: 600px) {
  :root { --nav-w: 104px; }
  .app { max-width: none; margin: 0; padding-left: var(--nav-w); }
  .top { padding-inline: max(28px, calc((100% - var(--content-w)) / 2 + 28px)); }
  main { max-width: var(--content-w); margin: 0 auto; padding: 6px 28px 160px; }
  .has-composer main { padding-bottom: 190px; }
  .tabbar { left: 18px; top: 50%; bottom: auto; transform: translateY(-50%); width: 68px; height: auto; padding: 10px 0; }
  .tabbar .nav-in { flex-direction: column; gap: 10px; justify-content: center; }
  .tabbar .nav-settings { display: grid; }
  .bars { left: var(--nav-w); bottom: 24px; padding: 0 24px; }
  .composer { width: min(var(--content-w), 100%); }
  .top [data-tab="settings"] { display: none; }
  .sheet { align-items: center; }
  .panel { width: min(540px, 92vw); border-radius: 32px; }
  .toast { bottom: 110px; }
  .lock .panel { width: 320px; }
  .headline { font-size: 52px; }
}

/* ---------- desktop: web-app sidebar ---------- */
@media (min-width: 1024px) {
  :root { --nav-w: 252px; --content-w: 860px; }
  .app.wide-split { --content-w: 1240px; }
  .top h1 { font-size: 38px; } .top { min-height: 88px; padding-top: 26px; }
  .tabbar { left: 0; top: 0; bottom: 0; transform: none; width: var(--nav-w); height: auto; border-radius: 0; background: var(--side); box-shadow: none; border-right: 1px solid var(--line); padding: 22px 14px 20px; }
  .tabbar .nav-in { gap: 4px; justify-content: flex-start; align-items: stretch; }
  .tabbar .brand { display: flex; align-items: center; gap: 12px; font: 800 20px var(--display); letter-spacing: -.03em; padding: 4px 12px 22px; color: var(--text); }
  .tabbar .brand img { width: 34px; height: 34px; border-radius: 10px; }
  .tabbar .nav-gap { display: block; flex: 1; }
  .tabbar span { display: inline; }
  .tabbar button { width: auto; height: 46px; border-radius: 16px; display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 0 14px; font-weight: 700; font-size: 15px; color: var(--muted); }
  .tabbar button:hover { background: var(--hover); }
  .tabbar button.on { background: var(--ink); color: var(--ink-text); }
  .tabbar .nav-settings { display: flex; }
  .headline { font-size: 60px; }
  .homegrid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: start; }
  .homegrid .full { grid-column: 1 / -1; }
  .split { display: grid; grid-template-columns: 350px 1fr; gap: 36px; align-items: start; }
  .split .list { position: sticky; top: 96px; max-height: calc(100dvh - 120px); overflow: auto; padding: 0 6px 0 0; }
  .split .list h2:first-of-type { margin-top: 22px; }
  .split .detail .dhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 4px; min-height: 48px; }
  .split .detail .dhead h2 { font-size: 30px; margin: 0; line-height: 1.2; }
  .tl { padding-left: 46px; } .rail { left: -46px; } .daypill { left: -23px; }
}
@media (hover: hover) { .card.click:hover { border-color: var(--faint); } .pill:hover { background: var(--soft); } .btn.primary:hover { filter: brightness(1.15); } }
.dmeta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin: 2px 4px 8px; }
.dmeta select { width: auto; min-width: 150px; padding: 8px 14px; font-size: 13.5px; font-weight: 700; border-radius: 999px; }
@media (min-width: 1024px) { .split .list .search { margin-top: 0; } .split .detail .dhead { min-height: 52px; } }
