:root {
  --bg: #FAEEDA;
  --card: #ffffff;
  --card-2: #FDF6EA;
  --line: #F3DDB5;
  --text: #412402;
  --text-2: #854F0B;
  --text-3: #B98A4A;
  --accent: #D85A30;
  --accent-soft: #FAECE7;
  --accent-text: #712B13;
  --on-accent: #ffffff;
  --teal: #0F6E56;
  --teal-soft: #E1F5EE;
  --teal-text: #085041;
  --purple: #534AB7;
  --purple-soft: #EEEDFE;
  --purple-text: #3C3489;
  --amber: #EF9F27;
  --amber-soft: #FAC775;
  --red: #A32D2D;
  --red-soft: #FCEBEB;
  --radius: 16px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1d1306;
  --card: #2b1d0c;
  --card-2: #342410;
  --line: #4a3418;
  --text: #FAEEDA;
  --text-2: #FAC775;
  --text-3: #BA8F55;
  --accent: #E8693D;
  --accent-soft: #4A1B0C;
  --accent-text: #F5C4B3;
  --teal: #5DCAA5;
  --teal-soft: #04342C;
  --teal-text: #9FE1CB;
  --purple: #AFA9EC;
  --purple-soft: #26215C;
  --purple-text: #CECBF6;
  --amber-soft: #633806;
  --red: #F09595;
  --red-soft: #501313;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.ti-i { width: 22px; height: 22px; display: block; }

#app { padding: 14px 14px calc(var(--tab-h) + var(--safe-b) + 24px); max-width: 560px; margin: 0 auto; }
.screen { display: flex; flex-direction: column; gap: 12px; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1 { font-size: 22px; font-weight: 700; margin: 2px 0 0; letter-spacing: -.2px; }
h2 { font-size: 17px; font-weight: 700; margin: 8px 2px 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; }
.card.soft { background: var(--card-2); }
.card.accent { background: var(--accent); color: var(--on-accent); }
.card.teal { background: var(--teal-soft); color: var(--teal-text); }
.card.purple { background: var(--purple-soft); color: var(--purple-text); }
.card .label { font-size: 12px; opacity: .85; margin-bottom: 2px; }
.card.teal .label { color: var(--teal); opacity: 1; }
.card.purple .label { color: var(--purple); opacity: 1; }
.big { font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.tap { transition: transform .08s; }
.tap:active { transform: scale(.98); }

.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s; }
.bar.teal > i { background: var(--teal); }
.bar.purple > i { background: var(--purple); }
.bar.danger > i { background: var(--red); }

.ring { --p: 0; --size: 64px; width: var(--size); height: var(--size); border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--amber-soft) 0);
  display: grid; place-items: center; }
.ring > span { width: calc(var(--size) - 14px); height: calc(var(--size) - 14px); border-radius: 50%;
  background: var(--card); display: grid; place-items: center; font-weight: 700; font-size: 14px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  background: var(--card-2); color: var(--text-2); font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--on-accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.badge.teal { background: var(--teal-soft); color: var(--teal-text); }
.badge.purple { background: var(--purple-soft); color: var(--purple-text); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 16px;
  border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--card-2); color: var(--text); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--card-2); }

.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.check { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--amber); flex: none;
  display: grid; place-items: center; color: transparent; }
.check.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.done-text { text-decoration: line-through; color: var(--text-3); }
.time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); min-width: 44px; font-size: 14px; }

.seg { display: flex; background: var(--card); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; height: 34px; border-radius: 9px; font-size: 14px; color: var(--text-2); font-weight: 600; }
.seg button.on { background: var(--accent); color: var(--on-accent); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); display: flex; }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px;
  color: var(--text-3); font-weight: 600; padding: 4px 0; }
.tabbar button.on { color: var(--accent); }

.fab { position: fixed; right: 18px; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); z-index: 11; width: 56px; height: 56px;
  border-radius: 18px; background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(216, 90, 48, .35); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; border-radius: 12px;
  background: var(--card); }
.day .wd { font-size: 11px; color: var(--text-3); font-weight: 600; }
.day .dn { font-size: 17px; font-weight: 700; }
.day .dots { display: flex; gap: 3px; height: 6px; }
.day .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.day .dots i.t { background: var(--teal); }
.day .dots i.p { background: var(--purple); }
.day.today .dn { color: var(--accent); }
.day.sel { background: var(--accent); }
.day.sel .wd, .day.sel .dn { color: #fff; }
.day.sel .dots i { background: #fff; }

.bars { display: flex; align-items: flex-end; gap: 2px; height: 110px; padding-top: 6px; }
.bars > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; height: 100%; }
.bars .e { background: var(--accent); border-radius: 3px 3px 0 0; min-height: 0; }
.bars .i { background: var(--teal); border-radius: 3px 3px 0 0; }
.bars-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 4px; }

.amount-in { color: var(--teal); font-weight: 700; white-space: nowrap; }
.amount-out { color: var(--text); font-weight: 700; white-space: nowrap; }

.sheet-bg { position: fixed; inset: 0; background: rgba(40, 20, 0, .45); z-index: 50; display: flex; align-items: flex-end;
  animation: fadebg .15s; }
@keyframes fadebg { from { opacity: 0; } }
.sheet { background: var(--bg); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(18px + var(--safe-b)); max-height: 88vh; overflow-y: auto; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--text-2); font-weight: 600; }
.input { width: 100%; height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card);
  padding: 0 12px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { height: 96px; padding: 10px 12px; resize: none; }
.input.amount { font-size: 28px; font-weight: 700; height: 60px; }
.err { color: var(--red); font-size: 13px; min-height: 0; }

.q-card { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.q-text { font-size: 17px; font-weight: 600; line-height: 1.45; }
.opt { text-align: left; padding: 13px 14px; border-radius: 12px; background: var(--card-2); border: 2px solid transparent;
  font-size: 15px; line-height: 1.35; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.opt.right { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-text); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.passage { background: var(--card-2); border-radius: 12px; padding: 12px; font-size: 14.5px; line-height: 1.55; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; }
.timer.over { color: var(--red); }
.qdots { display: flex; gap: 4px; flex-wrap: wrap; }
.qdots i { width: 10px; height: 10px; border-radius: 3px; background: var(--line); }
.qdots i.a { background: var(--amber); }
.qdots i.c { background: var(--accent); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px;
  text-align: left; min-height: 92px; }
.tile .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.tile:nth-child(3n+2) .ic { background: var(--teal-soft); color: var(--teal); }
.tile:nth-child(3n) .ic { background: var(--purple-soft); color: var(--purple); }
.tile b { font-size: 15px; }

.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 99; background: var(--text);
  color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; animation: fade .2s; }
.empty { text-align: center; color: var(--text-3); padding: 18px 8px; font-size: 14px; }
.loader { display: grid; place-items: center; padding: 60px 0; color: var(--text-3); }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.guide h3 { margin: 6px 0 4px; font-size: 16px; }
.guide p, .guide li { font-size: 14.5px; line-height: 1.55; margin: 4px 0; }
.guide ul { padding-left: 18px; margin: 4px 0; }
.ach { display: flex; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.ach .e { font-size: 26px; width: 34px; text-align: center; }
.ach.locked { opacity: .45; filter: grayscale(1); }

.lessons-row { display: flex; gap: 8px; overflow-x: auto; margin: 6px -14px 4px; padding: 0 14px 4px; scrollbar-width: none; }
.lessons-row::-webkit-scrollbar { display: none; }
.lesson { flex: none; display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 12px; background: var(--teal-soft); color: var(--teal-text); font-size: 14px; white-space: nowrap; }
.lesson .n { width: 20px; height: 20px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.lesson .t { font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }

.wx-mini { display: flex; align-items: center; gap: 12px; width: 100%; }
.wx-ic { font-size: 34px; line-height: 1; }
.wx-hero { display: flex; flex-direction: column; gap: 4px; }
.wx-temp { font-size: 56px; font-weight: 800; letter-spacing: -2px; line-height: 1.05; }
.wx-big { font-size: 64px; line-height: 1; }
.wx-adv { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.wx-adv:last-child { border-bottom: 0; }
.wx-hours { display: flex; gap: 6px; overflow-x: auto; margin: 10px -14px 0; padding: 0 14px 4px; scrollbar-width: none; }
.wx-hours::-webkit-scrollbar { display: none; }
.wx-hour { flex: none; width: 58px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0;
  border-radius: 14px; background: var(--card-2); font-size: 14px; }
.wx-hour.now { background: var(--accent-soft); color: var(--accent-text); }
.wx-rain { font-size: 11px; color: var(--text-3); min-height: 14px; }
.wx-rain.hi { color: var(--accent); font-weight: 700; }
.wx-day { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.wx-day:last-child { border-bottom: 0; }
.wx-wd { width: 72px; font-weight: 600; }
.wx-p { width: 46px; font-size: 12px; color: var(--accent); }
.wx-lo { width: 36px; text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }
.wx-hi { width: 36px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wx-range { flex: 1; height: 6px; border-radius: 3px; background: var(--line); position: relative; }
.wx-range i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, #5DCAA5, #EF9F27, #D85A30); }
.wx-cell { display: flex; flex-direction: column; gap: 4px; }
