:root {
  --bg: #fbf9f4;
  --bg-glow-1: rgba(227, 181, 75, .18);
  --bg-glow-2: rgba(61, 90, 200, .12);
  --card: #ffffff;
  --card-2: #f6f3ec;
  --ink: #1a1f36;
  --ink-2: #4a5170;
  --ink-3: #8a90a8;
  --line: #e9e4d8;
  --navy: #1d2752;
  --navy-2: #2e3c7a;
  --gold: #c99a2e;
  --gold-2: #e3b54b;
  --gold-soft: #fbf1d9;
  --good: #2f8f6b;
  --good-soft: #e3f4ec;
  --warn: #b5603a;
  --warn-soft: #fbeae2;
  --ice: #4b8cc9;
  --ice-soft: #e4f0fb;
  --shadow: 0 1px 2px rgba(26, 31, 54, .05), 0 8px 28px rgba(26, 31, 54, .07);
  --radius: 18px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1326; --bg-glow-1: rgba(227, 181, 75, .10); --bg-glow-2: rgba(91, 120, 240, .14);
    --card: #171c35; --card-2: #1e2443; --ink: #eef0f8; --ink-2: #b6bbd3; --ink-3: #7c83a3; --line: #2a3156;
    --navy: #8fa2ff; --navy-2: #b3c0ff; --gold: #e3b54b; --gold-2: #f0c96a; --gold-soft: #2c2715;
    --good: #5cc79c; --good-soft: #15302a; --warn: #ec9a74; --warn-soft: #36211a; --ice: #7db6ec; --ice-soft: #172a40;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(900px 500px at 85% -10%, var(--bg-glow-1), transparent 60%),
                    radial-gradient(800px 500px at -10% 10%, var(--bg-glow-2), transparent 60%);
  background-attachment: fixed; min-height: 100vh; -webkit-font-smoothing: antialiased; line-height: 1.5;
}
a { color: var(--navy-2); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); line-height: 1.15; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: .86rem; }
.small { font-size: .88rem; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px 110px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.brand svg { flex: none; }
.topbar .spacer { flex: 1; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--card-2); display: grid; place-items: center; font-weight: 600; font-size: .85rem; }

.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); padding: 4px; border-radius: 999px; box-shadow: var(--shadow); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 999px; cursor: pointer; color: var(--ink-2); font-weight: 500; white-space: nowrap; font-size: .93rem; }
.tab.on { background: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { .tab.on { color: #0f1326; } }
@media (max-width: 720px) {
  .tabs.main { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20; justify-content: space-between; }
  .tab { padding: 9px 10px; font-size: .86rem; }
}

.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr); margin-top: 16px; }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c7 { grid-column: span 7; } .c6 { grid-column: span 6; } .c5 { grid-column: span 5; } .c4 { grid-column: span 4; }
@media (max-width: 860px) { .c8, .c7, .c6, .c5, .c4 { grid-column: span 12; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card > h2, .card > h3 { margin-bottom: 10px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }

.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: 26px 24px; color: #fff; margin-top: 8px;
  background: radial-gradient(600px 300px at 90% 0%, rgba(227, 181, 75, .55), transparent 60%),
              radial-gradient(500px 300px at 0% 100%, rgba(120, 150, 255, .35), transparent 60%),
              linear-gradient(135deg, #1d2752, #2a3a85);
  box-shadow: 0 18px 40px rgba(29, 39, 82, .28);
}
.hero h1 { color: #fff; }
.hero .sub { color: rgba(255, 255, 255, .82); margin-top: 6px; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, .14); backdrop-filter: blur(6px); font-size: .9rem; font-weight: 500; border: 1px solid rgba(255,255,255,.18); }
.pill b { font-weight: 700; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--card-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.planned { background: var(--card-2); }
.chip.confirmed { background: var(--ice-soft); color: var(--ice); border-color: transparent; }
.chip.done, .chip.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.chip.gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card); padding: 10px 16px; border-radius: 12px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); transition: transform .08s ease, box-shadow .15s ease; }
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--navy); color: #fff; border-color: transparent; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f1326; } }
.btn.gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #241a02; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: .86rem; border-radius: 10px; }
.btn.big { padding: 14px 22px; font-size: 1.05rem; border-radius: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

label.f { display: block; font-size: .86rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
textarea { resize: vertical; min-height: 64px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.bar { height: 10px; border-radius: 999px; background: var(--card-2); overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .4s ease; }
.bar.navy > i { background: linear-gradient(90deg, var(--navy-2), var(--navy)); }
.bar.good > i { background: linear-gradient(90deg, #58c49b, var(--good)); }
.meter { margin-top: 12px; }
.meter .row { margin-bottom: 6px; font-size: .9rem; }
.meter b { font-weight: 700; }

.tasks { list-style: none; padding: 0; margin: 0; }
.tasks li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.tasks li:last-child { border-bottom: 0; }
.check { appearance: none; width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--ink-3); flex: none; cursor: pointer; display: grid; place-items: center; margin-top: 1px; background: var(--card); }
.check:checked { background: var(--good); border-color: var(--good); }
.check:checked::after { content: ''; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.tasks li.done span { color: var(--ink-3); text-decoration: line-through; }

.challenge { margin-top: 14px; border-radius: 14px; padding: 14px; background: linear-gradient(135deg, var(--gold-soft), transparent); border: 1px solid var(--line); }
.challenge .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); font-weight: 700; }

.seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.seg button { border: 1px solid var(--line); background: var(--card-2); padding: 7px 12px; border-radius: 999px; cursor: pointer; font-size: .88rem; font-weight: 500; color: var(--ink-2); }
.seg button.on { background: var(--navy); color: #fff; border-color: transparent; }
@media (prefers-color-scheme: dark) { .seg button.on { color: #0f1326; } }

.timer { text-align: center; padding: 6px 0; }
.timer .clock { font-family: var(--serif); font-size: clamp(2.6rem, 9vw, 3.6rem); font-weight: 600; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.timer .live { display: inline-flex; align-items: center; gap: 6px; color: var(--good); font-weight: 600; font-size: .9rem; }
.timer .live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--card-2) 0); flex: none; }
.ring > div { width: 94px; height: 94px; border-radius: 50%; background: var(--card); display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring b { font-family: var(--serif); font-size: 1.5rem; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dh { font-size: .72rem; color: var(--ink-3); text-align: center; font-weight: 600; }
.cal .d { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; font-size: .78rem; font-weight: 600; background: var(--card-2); color: var(--ink-3); border: 1px solid transparent; position: relative; cursor: default; }
.cal .d.complete { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a1e03; }
.cal .d.rescue, .cal .d.today-rescue { background: var(--gold-soft); color: var(--gold); border-color: var(--gold); }
.cal .d.rest { background: transparent; border: 1px dashed var(--line); }
.cal .d.missed { background: var(--warn-soft); color: var(--warn); }
.cal .d.frozen { background: var(--ice-soft); color: var(--ice); }
.cal .d.future { background: transparent; border: 1px solid var(--line); color: var(--ink-3); }
.cal .d.before { visibility: hidden; }
.cal .d.today { outline: 2px solid var(--navy); outline-offset: 1px; }
.cal .d.exam::after { content: '★'; position: absolute; top: 1px; right: 4px; font-size: .62rem; color: var(--navy-2); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: .78rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week .wd { text-align: center; padding: 8px 2px; border-radius: 12px; background: var(--card-2); font-size: .78rem; }
.week .wd b { display: block; font-size: 1rem; margin-top: 2px; }
.week .wd.complete { background: var(--good-soft); color: var(--good); }
.week .wd.rescue, .week .wd.today-rescue { background: var(--gold-soft); color: var(--gold); }
.week .wd.missed { background: var(--warn-soft); color: var(--warn); }
.week .wd.frozen { background: var(--ice-soft); color: var(--ice); }

.status-big { display: flex; align-items: center; gap: 16px; }
.status-big .icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 2rem; flex: none; }
.status-big .icon.good { background: var(--good-soft); }
.status-big .icon.wait { background: var(--card-2); }
.status-big .icon.gold { background: var(--gold-soft); }

.wish { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }
.wish + .wish { margin-top: 8px; }
.wish .num { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; background: var(--card-2); flex: none; }
.wish.earned { border-color: var(--gold); background: linear-gradient(135deg, var(--gold-soft), var(--card) 70%); }
.wish.earned .num { background: var(--gold); color: #241a02; }
.wish.granted { opacity: .85; }
.wish.granted .num { background: var(--good); color: #fff; }
.wish .body { flex: 1; min-width: 0; }
.wish .t { font-weight: 600; overflow-wrap: anywhere; }
.wish input[type=text] { padding: 7px 10px; }

.exam { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.exam:last-child { border-bottom: 0; }
.exam .date { width: 56px; text-align: center; flex: none; border-radius: 12px; background: var(--card-2); padding: 6px 0; line-height: 1.1; }
.exam .date b { display: block; font-family: var(--serif); font-size: 1.3rem; }
.exam .date small { font-size: .7rem; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.exam .body { flex: 1; min-width: 0; }

.feed > div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed > div:last-child { border-bottom: 0; }

.note-banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--gold); box-shadow: var(--shadow); margin-top: 16px; }
.contract-banner { padding: 14px 16px; border-radius: 16px; background: var(--ice-soft); color: var(--ink); margin-top: 16px; border: 1px solid transparent; }

.landing { max-width: 1080px; margin: 0 auto; padding: 0 16px 60px; }
.landing .hero { padding: 48px 28px; }
.landing .hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); max-width: 14ch; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-top: 20px; }
.features .card h3 { margin: 8px 0 4px; }
.emoji { font-size: 1.6rem; }
.gbtn { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.gbtn svg { width: 18px; height: 18px; }

.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.choice .card { cursor: pointer; transition: transform .1s ease, border-color .15s; }
.choice .card:hover { transform: translateY(-2px); border-color: var(--gold); }

.code { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; font-weight: 700; background: var(--card-2); padding: 3px 8px; border-radius: 8px; }
.copyline { display: flex; gap: 8px; align-items: center; }
.copyline input { font-size: .85rem; }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 500; transition: all .25s ease; pointer-events: none; z-index: 50; box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }
@media (prefers-color-scheme: dark) { #toast { color: #0f1326; } }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.celebrate { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(15, 19, 38, .55); z-index: 60; padding: 16px; }
.celebrate .card { max-width: 420px; text-align: center; padding: 30px 24px; }
.celebrate .big { font-size: 3rem; }

.demo-bar { background: var(--gold-soft); color: var(--ink); text-align: center; font-size: .85rem; padding: 6px 12px; }
.demo-bar a { font-weight: 600; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.kpi { background: var(--card-2); border-radius: 14px; padding: 12px; }
.kpi b { display: block; font-family: var(--serif); font-size: 1.5rem; }
.kpi span { font-size: .8rem; color: var(--ink-2); }
.cmp b.up { color: var(--good); } .cmp b.down { color: var(--warn); }
details summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
