:root {
  --bg: #0B0D10;
  --surface: #15181D;
  --surface-2: #232830;
  --line: #232830;
  --text: #F2F4F7;
  --muted: #9AA3AE;
  --soft: #C9CFD6;
  --accent: #C6F432;
  --accent-ink: #0B0D10;
  --accent-bg: #1F2A10;
  --accent-line: #2A3A10;
  --blue: #5AA9FF;
  --blue-bg: #13263D;
  --blue-text: #8EC5FF;
  --orange: #FF9F5A;
  --orange-bg: #3A2410;
  --yellow: #FFD84D;
  --yellow-bg: #3A3410;
  --purple: #B9A6FF;
  --radius: 20px;
  --tabbar: calc(64px + env(safe-area-inset-bottom));
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'SF Pro Text', Inter, 'Segoe UI', Roboto, sans-serif; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
p, h1, h2, h3 { margin: 0; }
a { color: var(--accent); }

#app { min-height: 100%; }
.screen { padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--tabbar) + 24px); display: flex; flex-direction: column; gap: 12px; max-width: 560px; margin: 0 auto; }
.screen.full { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }

h1 { font-size: 28px; font-weight: 700; line-height: 1.2; }
h2 { font-size: 21px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
.lbl { font-size: 12px; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; }
.muted { color: var(--muted); font-size: 13px; }
.soft { color: var(--soft); }
.num { font-family: ui-rounded, 'SF Pro Rounded', -apple-system, sans-serif; font-weight: 700; font-variant-numeric: tabular-nums; }
.big { font-size: 24px; }
.good { color: var(--accent); }
.warn { color: var(--orange); }
.info { color: var(--blue-text); }

.row { display: flex; gap: 10px; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.hi { border: 1px solid var(--accent-line); }
.card.blue { background: var(--blue-bg); }
.card.tight { gap: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 16px; border-radius: 14px; border: 0; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border: 1px solid #3A4250; color: var(--accent); }
.btn.small { min-height: 38px; font-size: 13px; padding: 0 12px; border-radius: 12px; }
.btn.danger { color: var(--orange); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--soft); }
.chip.on, .chip.good { background: var(--accent-bg); color: var(--accent); }
.chip.warn { background: var(--orange-bg); color: var(--orange); }
.chip.info { background: var(--blue-bg); color: var(--blue-text); }
.chip.yellow { background: var(--yellow-bg); color: var(--yellow); }

.pick { min-height: 44px; padding: 8px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--soft); font-weight: 600; cursor: pointer; text-align: left; }
.pick.on { background: var(--accent-bg); color: var(--accent); border-color: #4A6A12; }
.pick small { display: block; font-weight: 400; font-size: 12px; opacity: .8; }

.bar { height: 8px; border-radius: 4px; background: #262B33; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar.blue > i { background: var(--blue); }
.bar.orange > i { background: var(--orange); }
.bar.purple > i { background: var(--purple); }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
input, select, textarea { background: var(--surface); border: 1px solid #2A3038; border-radius: 12px; padding: 12px; width: 100%; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg { display: flex; gap: 4px; background: #0F1215; border-radius: 12px; padding: 3px; }
.seg button { flex: 1; min-height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; }

/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar); padding-bottom: env(safe-area-inset-bottom); background: rgba(17, 20, 24, .96); backdrop-filter: blur(16px); border-top: 1px solid #1E2228; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); z-index: 20; }
.tabbar button { border: 0; background: none; color: #8A929C; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; font-weight: 600; cursor: pointer; }
.tabbar button.on { color: var(--accent); }

/* overlays */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 40; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet { background: var(--surface); border-radius: 24px 24px 0 0; padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px); display: flex; flex-direction: column; gap: 10px; max-height: 88vh; overflow-y: auto; max-width: 560px; width: 100%; margin: 0 auto; }
.page { position: fixed; inset: 0; background: var(--bg); z-index: 30; overflow-y: auto; }
.toast { position: fixed; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 12px); z-index: 60; background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line); border-radius: 16px; padding: 12px 16px; font-weight: 600; max-width: 528px; margin: 0 auto; animation: drop .25s ease-out; }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } }

/* camera */
.cam { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.cam video { flex: 1; width: 100%; object-fit: cover; min-height: 0; }
.cam .top { position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: center; }
.cam .bottom { padding: 16px 16px calc(env(safe-area-inset-bottom) + 20px); display: flex; flex-direction: column; align-items: center; gap: 12px; background: #000; }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: var(--accent); cursor: pointer; }
.shutter[disabled] { opacity: .4; }

.ring-wrap { position: relative; width: 76px; height: 76px; flex-shrink: 0; }
.ring-wrap .num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; }

.setrow { display: grid; grid-template-columns: 34px 1fr 1fr 64px 46px; gap: 6px; align-items: center; padding: 6px 4px; border-radius: 10px; }
.setrow.done { background: var(--accent-bg); }
.setrow input { padding: 8px; text-align: center; min-height: 40px; }
.check { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--surface-2); color: #6B7380; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.check.on { background: var(--accent); color: var(--accent-ink); }

.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 12px 14px; border-radius: 16px; line-height: 1.5; white-space: pre-wrap; max-width: 92%; }
.msg.me { align-self: flex-end; background: var(--accent-bg); color: var(--text); }
.msg.ai { align-self: flex-start; background: var(--surface); }

.empty { text-align: center; padding: 24px 12px; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --soft: #222; }
  body { background: #fff; color: #000; }
  .tabbar, .no-print, .toast { display: none !important; }
  .page { position: static; }
  #app > main { display: none; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* comfort.js: text size, high contrast, low data */

html.fs-large body{font-size:17px}
html.fs-large h3{font-size:18px}
html.fs-large .muted,html.fs-large .btn.small,html.fs-large .seg button,html.fs-large [style*="font-size:13px"],html.fs-large [style*="font-size:14px"]{font-size:15px!important}
html.fs-large .lbl,html.fs-large .chip,html.fs-large .pick small,html.fs-large label.field,html.fs-large [style*="font-size:12px"]{font-size:14px!important}
html.fs-large .tabbar button{font-size:12px}

html.fs-xl body{font-size:19px}
html.fs-xl h3{font-size:20px}
html.fs-xl .muted,html.fs-xl .btn.small,html.fs-xl .seg button,html.fs-xl [style*="font-size:13px"],html.fs-xl [style*="font-size:14px"]{font-size:17px!important}
html.fs-xl .lbl,html.fs-xl .chip,html.fs-xl .pick small,html.fs-xl label.field,html.fs-xl [style*="font-size:12px"]{font-size:16px!important}
html.fs-xl .tabbar button{font-size:14px}
html.hc{--muted:#C4CBD4;--soft:#E6EAEF}
html.hc .card{border:1px solid #4A5361}
html.hc .pick,html.hc .seg{border:1px solid #5A6472}
html.hc .tabbar button{color:#D0D6DD}
html.hc a{text-decoration:underline}
html.hc .btn.ghost{border-color:var(--accent)}
html.lowdata img[data-lowdata]{display:none!important}
.cf-q{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;margin:-12px -10px -12px -6px;padding:0;border:0;background:transparent;cursor:pointer;vertical-align:middle}
.cf-q span{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--surface-2);color:var(--soft);font-size:12px;font-weight:700}
.cf-ill{display:flex;flex-direction:column;gap:6px;padding:14px;border-radius:16px;background:#0F1215;min-height:120px}
.cf-ill i{display:block;border-radius:6px;background:var(--surface-2)}

/* Today card: 3 ticks, first-week mission, unlock text, week ring, evening wrap */
.ticks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tick { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 88px; padding: 10px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--soft); cursor: pointer; text-align: center; }
.tick.on { background: var(--accent-bg); border-color: #4A6A12; color: var(--accent); }
.tick-dot { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid currentColor; font-weight: 700; }
.tick.on .tick-dot { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tick-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tick-txt small { font-size: 11px; color: var(--muted); line-height: 1.25; }
.mission { font-size: 14px; color: var(--yellow); background: var(--yellow-bg); border-radius: 12px; padding: 8px 12px; }
.unlock { font-size: 13px; color: var(--muted); line-height: 1.3; min-height: 34px; }
.week-ring { position: relative; display: inline-flex; width: 56px; height: 56px; align-items: center; justify-content: center; flex: none; }
.week-ring svg { position: absolute; inset: 0; }
.week-ring .num { font-size: 13px; }
.card.evening { border: 1px solid #3A3A6A; background: #16182A; }