/* Halo — "Golden Hour": warm editorial luxury + dopamine. White / black / gold. */
:root {
  --bg: #f6efe1;              /* warm paper */
  --bg-2: #efe6d3;
  --surface: #fffdf8;
  --surface-2: #f3ebda;
  --ink: #1b1710;            /* near-black */
  --ink-2: #514a3a;
  --ink-dim: #948b74;
  --gold: #c69a2e;
  --gold-2: #edcf7a;         /* light gold */
  --gold-deep: #97701f;
  --line: #e7dcc4;
  --urgent: #cf4b56;
  --good: #4f9a63;
  --radius: 20px;
  --tap: 54px;
  --shadow: 0 4px 18px rgba(60, 44, 12, .07);
  --shadow-lg: 0 18px 48px rgba(60, 44, 12, .18);
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(120% 60% at 80% -10%, rgba(237,207,122,.35), transparent 60%),
    radial-gradient(90% 50% at -10% 0%, rgba(198,154,46,.12), transparent 55%),
    var(--bg);
  color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  display: flex; flex-direction: column; min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  overscroll-behavior: none;
}
/* faint grain */
body::before { content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.hidden { display: none !important; }
main, .topbar, .nav { position: relative; z-index: 1; }

/* Brand */
.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px 4px; flex-wrap: wrap; }
.brand-mark { flex: 0 0 auto; }
.brand { font-family: var(--font-display); font-weight: 900; letter-spacing: .2px; font-size: 21px; margin-right: auto; }
.ctx-filter { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.ctx-btn { border: none; background: transparent; color: var(--ink-dim); font-family: var(--font-body); font-weight: 700; font-size: 12.5px; padding: 7px 13px; border-radius: 999px; cursor: pointer; }
.ctx-btn.active { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a2205; box-shadow: var(--shadow); }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view { flex: 1; padding: 6px 18px 130px; }
.stagger > * { animation: rise .5s cubic-bezier(.2,.7,.2,1) both; }
.stagger > *:nth-child(1){animation-delay:.02s}.stagger > *:nth-child(2){animation-delay:.07s}
.stagger > *:nth-child(3){animation-delay:.12s}.stagger > *:nth-child(4){animation-delay:.17s}
.stagger > *:nth-child(5){animation-delay:.22s}.stagger > *:nth-child(6){animation-delay:.27s}
.stagger > *:nth-child(n+7){animation-delay:.3s}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* HOME — coach hero */
.coach { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 26px;
  background: linear-gradient(135deg, #fffdf8, #f4ead4); box-shadow: var(--shadow); padding: 20px; margin-bottom: 14px; }
.coach::after { content: ''; position: absolute; right: -40px; top: -50px; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(237,207,122,.6), transparent 70%); pointer-events: none; }
.coach-top { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.coach .hi { font-family: var(--font-display); font-weight: 900; font-size: 27px; line-height: 1.05; margin: 0 0 6px; }
.coach .hi .sun { color: var(--gold); }
.coach .sub { margin: 0; color: var(--ink-2); font-size: 15px; max-width: 22ch; }
/* progress ring */
.ring { position: relative; width: 78px; height: 78px; flex: 0 0 78px; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: url(#goldgrad); stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.ring .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; color: var(--gold-deep); }
.momentum { display: flex; gap: 8px; margin-top: 16px; }
.chip-stat { display: flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chip-stat b { color: var(--gold-deep); font-size: 15px; }

/* Category identity scroller */
.cat-scroll { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; margin: 4px -4px 6px; -webkit-overflow-scrolling: touch; }
.cat-scroll::-webkit-scrollbar { display: none; }
.cat-pill { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px 8px 10px; cursor: pointer; box-shadow: var(--shadow); transition: transform .1s; }
.cat-pill:active { transform: scale(.96); }
.cat-pill .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; }
.cat-pill .cn { font-weight: 600; font-size: 14px; }
.cat-pill .cc { color: var(--ink-dim); font-weight: 700; font-size: 13px; }

/* Focus card */
.focus { position: relative; border-radius: 22px; padding: 18px 18px 16px; margin: 8px 0 6px; color: #2a2205; overflow: hidden;
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); box-shadow: 0 12px 30px rgba(198,154,46,.35); }
.focus .kicker { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; font-weight: 800; opacity: .7; }
.focus .ft { font-family: var(--font-display); font-weight: 700; font-size: 21px; line-height: 1.15; margin: 6px 0 12px; }
.focus .fbtn { background: rgba(27,23,16,.9); color: var(--gold-2); border: none; border-radius: 12px; padding: 10px 16px; font-weight: 700; font-family: var(--font-body); cursor: pointer; }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 4px 10px; }
.section-title h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin: 0; }
.vision-intro { color: var(--ink-2); margin: 2px 4px 14px; }

/* Items */
.card-list { display: flex; flex-direction: column; gap: 9px; }
.item { position: relative; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 15px; padding: 13px 12px; box-shadow: var(--shadow); overflow: hidden; touch-action: pan-y; }
.item .cat-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 15px; flex: 0 0 30px; }
.item.done .item-title { color: var(--ink-dim); text-decoration: line-through; }
.item-title { flex: 1; font-size: 15.5px; }
.check { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; border: 2px solid var(--gold); background: transparent; color: #fff; font-size: 16px; cursor: pointer; transition: transform .15s, background .15s; }
.check:active { transform: scale(.85); }
.item.done .check { background: var(--good); border-color: var(--good); animation: pop .35s; }
@keyframes pop { 0%{transform:scale(.6)} 60%{transform:scale(1.2)} 100%{transform:scale(1)} }
.badge { font-size: 10.5px; color: var(--urgent); border: 1px solid var(--urgent); border-radius: 8px; padding: 2px 6px; font-weight: 700; }
.del { width: 30px; height: 30px; border: none; background: transparent; color: var(--ink-dim); font-size: 19px; cursor: pointer; }
.item .swipe-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; pointer-events: none; opacity: 0; font-weight: 800; font-size: 13px; }
.empty { text-align: center; color: var(--ink-dim); margin-top: 14vh; padding: 0 30px; font-family: var(--font-display); font-size: 18px; }
.done-wrap summary { color: var(--ink-dim); font-size: 14px; padding: 6px 4px; cursor: pointer; }
.section { font-family: var(--font-display); font-size: 17px; color: var(--gold-deep); font-weight: 700; margin: 20px 4px 8px; }

/* Boards */
.boards { display: flex; gap: 14px; overflow-x: auto; padding: 6px 2px 20px; -webkit-overflow-scrolling: touch; }
.board-col { flex: 0 0 80%; max-width: 320px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 12px; min-height: 180px; transition: background .15s, box-shadow .15s; }
.board-col.drop { background: #fff5da; box-shadow: inset 0 0 0 2px var(--gold); }
.board-col h3 { font-family: var(--font-display); margin: 4px 6px 12px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.board-col h3 .count { margin-left: auto; color: var(--ink-dim); font-family: var(--font-body); font-weight: 700; font-size: 13px; }
.board-card { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 12px; margin-bottom: 9px; box-shadow: var(--shadow); cursor: grab; touch-action: none; }
.board-card.dragging { opacity: .5; transform: scale(1.03); }
.board-card.urgent { border-left: 3px solid var(--urgent); }
.board-card .bt { font-size: 14.5px; }
.board-card .tag { display: inline-block; font-size: 10.5px; color: var(--gold-deep); background: rgba(198,154,46,.14); border-radius: 6px; padding: 2px 7px; margin-top: 9px; font-weight: 700; }

/* Vision */
.vision-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 6px 0 20px; }
.vision-tile { position: relative; border-radius: 20px; padding: 18px; min-height: 128px; color: #2a2205; overflow: hidden;
  background: linear-gradient(150deg, var(--gold-2), var(--gold)); box-shadow: var(--shadow); display: flex; align-items: flex-end; transition: transform .12s; }
.vision-tile:active { transform: scale(.97); }
.vision-tile:nth-child(3n) { background: linear-gradient(150deg, #fff3d1, #ecd28a); }
.vision-tile:nth-child(4n) { background: linear-gradient(150deg, #221d13, #3f3722); color: var(--gold-2); }
.vision-tile .star { position: absolute; top: 12px; right: 14px; opacity: .5; font-size: 18px; }
.vision-tile .t { font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 1.2; }

/* Buttons + capture */
.btn { min-height: var(--tap); padding: 0 20px; border-radius: 14px; border: none; font-size: 16px; font-weight: 700; font-family: var(--font-body); cursor: pointer; background: var(--surface-2); color: var(--ink); }
.btn.primary { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a2205; flex: 1; box-shadow: var(--shadow); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.export-row { display: flex; gap: 10px; margin-top: 18px; }
.text-fallback { max-width: 460px; margin: 8px auto 0; }
.fallback-msg { color: var(--ink-dim); text-align: center; margin: 0 0 10px; }
#text-form { display: flex; gap: 10px; }
#text-input { flex: 1; min-height: var(--tap); padding: 0 16px; font-size: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-family: var(--font-body); }

/* Capture hero mic */
.capture-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 8px 0; }
.mic { width: 96px; height: 96px; border-radius: 50%; border: none; color: #2a2205; position: relative;
  background: radial-gradient(circle at 32% 28%, var(--gold-2), var(--gold));
  box-shadow: 0 10px 30px rgba(198,154,46,.5), inset 0 -3px 10px rgba(120,90,10,.25);
  display: grid; place-items: center; cursor: pointer; transition: transform .12s, background .2s; touch-action: none; user-select: none; -webkit-user-select: none; }
.mic:active { transform: scale(.95); }
.mic.listening::before, .mic.listening::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--gold); animation: sonar 1.6s ease-out infinite; }
.mic.listening::after { animation-delay: .8s; }
.mic.armed { background: radial-gradient(circle at 32% 28%, #7fd39e, var(--good)); color: #06231a; box-shadow: 0 10px 30px rgba(79,154,99,.5); }
.mic.armed::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--good); animation: sonar 1.6s ease-out infinite; }
@keyframes sonar { 0%{transform:scale(1);opacity:.6} 100%{transform:scale(1.8);opacity:0} }
.mic-icon { display: grid; place-items: center; }
.mic-label { color: var(--ink-dim); margin: 0; font-size: 13.5px; text-align: center; max-width: 30ch; }
.transcript { min-height: 24px; text-align: center; font-size: 18px; font-family: var(--font-display); }

/* Capture FAB */
.fab { position: fixed; right: 18px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 45; width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer; color: #2a2205;
  background: radial-gradient(circle at 32% 28%, var(--gold-2), var(--gold)); box-shadow: var(--shadow-lg); display: grid; place-items: center; }
.fab:active { transform: scale(.94); }

/* Instant card */
.card-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(30,22,8,.44); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .18s; }
@keyframes fade { from { opacity: 0; } }
.card { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.card.show { animation: sheet .22s cubic-bezier(.2,.8,.2,1); }
@keyframes sheet { from { transform: translateY(60px); opacity: 0; } }
.card-inner { background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 18px 18px 12px; box-shadow: var(--shadow-lg); }
.card-title { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin: 2px 0 14px; }
.card-row { display: flex; align-items: flex-start; gap: 10px; }
.chips { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 13px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-size: 14px; font-family: var(--font-body); cursor: pointer; }
.chip.selected { background: linear-gradient(135deg, var(--gold-2), var(--gold)); border-color: var(--gold); color: #2a2205; font-weight: 700; }
.urgent-toggle { min-height: 40px; padding: 0 12px; border-radius: 20px; white-space: nowrap; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-dim); font-size: 13px; font-family: var(--font-body); cursor: pointer; }
.urgent-toggle.on { background: rgba(207,75,86,.12); border-color: var(--urgent); color: var(--urgent); }
.card-actions { display: flex; gap: 10px; margin-top: 16px; }
.card-hint { text-align: center; color: var(--ink-dim); font-size: 12px; margin: 8px 0 2px; }

/* Undo + flash + sparkle */
.undo-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 70; background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 12px 10px 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-lg); max-width: 92vw; animation: sheet .2s; }
.undo-btn { background: transparent; border: none; color: var(--gold-2); font-weight: 800; font-size: 16px; cursor: pointer; padding: 6px 8px; }
.flash { position: fixed; left: 50%; transform: translateX(-50%); top: calc(16px + env(safe-area-inset-top)); z-index: 80; background: #fff; color: var(--urgent); border: 1px solid var(--urgent); border-radius: 12px; padding: 10px 16px; max-width: 92vw; text-align: center; box-shadow: var(--shadow); transition: opacity .3s; }
.flash.hide { opacity: 0; }
#sparkle-layer { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.spark { position: absolute; font-size: 16px; will-change: transform, opacity; animation: spark .8s ease-out forwards; }
@keyframes spark { 0%{transform:translate(0,0) scale(.4);opacity:1} 100%{transform:translate(var(--dx),var(--dy)) scale(1.1);opacity:0} }

/* Create tab: generator cards */
.gen-row { display: flex; gap: 10px; margin: 4px 0 6px; }
.gen-card { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  font-family: var(--font-body); font-weight: 700; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.gen-card:active { transform: scale(.97); }
.gen-card .gen-ico { font-size: 24px; color: var(--gold-deep); }

/* Create reveal panel */
.create-reveal { border: 1px solid var(--line); border-radius: 20px; background: var(--surface-2); padding: 14px; margin: 8px 0 22px; box-shadow: var(--shadow); }
.create-reveal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.create-reveal-head h3 { font-family: var(--font-display); font-size: 18px; margin: 0; }
.gen-panel .boards { padding-left: 0; padding-right: 0; }
.gen-panel .vision-grid { padding-top: 0; }

/* Category manager */
.cat-manager { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.cat-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); }
.cat-row-name { flex: 1; font-weight: 600; font-size: 14.5px; display: flex; flex-direction: column; }
.cat-row-count { font-weight: 500; font-size: 11.5px; color: var(--ink-dim); }
.ctx-pill { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font-size: 11.5px; font-weight: 700; padding: 5px 10px; border-radius: 999px; cursor: pointer; }
.ctx-pill.ctx-work { background: rgba(198,154,46,.14); border-color: var(--gold); color: var(--gold-deep); }
.ctx-pill.ctx-personal { background: rgba(207,75,86,.1); border-color: var(--urgent); color: var(--urgent); }
.ctx-pill.ctx-both { background: var(--surface-2); }

.add-cat-form { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 24px; }
.add-cat-form input[type=text] { min-height: var(--tap); padding: 0 16px; font-size: 15px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-family: var(--font-body); }
.add-cat-row { display: flex; gap: 8px; }
.add-cat-row select { flex: 1; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-family: var(--font-body); font-size: 13.5px; padding: 0 8px; }

/* Nav */
.nav { display: flex; border-top: 1px solid var(--line); background: rgba(255,253,248,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding-bottom: env(safe-area-inset-bottom); }
.nav-btn { flex: 1; min-height: var(--tap); background: transparent; border: none; color: var(--ink-dim); font-size: 11px; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; text-transform: uppercase; letter-spacing: .5px; transition: color .12s; }
.nav-btn .ico { font-size: 18px; }
.nav-btn.active { color: var(--gold-deep); }
.nav-btn.active .ico { transform: translateY(-1px); }
