:root {
  --bg: #111418; --card: #1a1f26; --card2: #222832; --text: #e8eaed; --muted: #9aa3ad;
  --accent: #f59e0b; --accent-ink: #111418; --ok: #22c55e; --bad: #ef4444; --line: #2c333d;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f5f7; --card: #ffffff; --card2: #eef0f3; --text: #15181c; --muted: #5b6470; --line: #dde1e6; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; }
#weekbadge { font-size: 13px; color: var(--muted); text-align: right; }
main { max-width: 720px; margin: 0 auto; padding: 16px 16px 110px; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 0; font-size: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
nav button span { font-size: 11px; }
nav button.active { color: var(--accent); }
.hidden { display: none !important; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
h2 { margin: 4px 0 12px; font-size: 20px; }
button, .btn { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 15px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.danger { color: var(--bad); }
button.ghost { background: none; border: 0; padding: 4px 8px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
input, select, textarea { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; font-size: 16px; width: 100%; font-family: inherit; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.setrow { display: grid; grid-template-columns: 1.2fr 1fr 0.9fr auto; gap: 6px; margin-top: 10px; }
.setrow input, .setrow select { padding: 10px 6px; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 14px; }
.chip button { all: unset; margin-left: 6px; color: var(--muted); cursor: pointer; }
.sugg { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--card2); border-radius: 6px; font-size: 14px; }
.sugg b { color: var(--accent); }
.tpl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.tpl button { padding: 16px 0; font-size: 18px; font-weight: 700; }
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { background: var(--accent); color: var(--accent-ink); align-self: flex-end; max-width: 85%; }
.msg.assistant { background: var(--card); border: 1px solid var(--line); }
#timer { position: fixed; top: 62px; right: 12px; white-space: nowrap; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 6px 12px; border-radius: 999px; z-index: 6; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.3); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.login { max-width: 360px; margin: 15vh auto 0; }
.ok { color: var(--ok); } .bad { color: var(--bad); }
canvas { max-width: 100%; }

.bar { height: 10px; background: var(--card2); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.bar.big { height: 14px; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), #fbbf24); border-radius: 999px; transition: width .4s; }
.xp { cursor: pointer; }
.coins { font-weight: 700; color: var(--accent); }
.tasks { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.task { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer; transition: transform .1s; }
.task:active { transform: scale(.98); }
.task .tick { flex: 0 0 34px; height: 34px; border-radius: 10px; border: 2px solid var(--muted); display: grid; place-items: center; font-weight: 900; font-size: 20px; }
.task.done { opacity: .6; }
.task.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.task.done .ttl { text-decoration: line-through; }
.task.next { border: 2px solid var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.task .ttl { font-weight: 600; }
.task .pts { font-weight: 700; color: var(--accent); font-size: 14px; }
.nowtag { background: var(--accent); color: var(--accent-ink); padding: 0 6px; border-radius: 6px; font-size: 11px; }
button.small { padding: 6px 10px; font-size: 13px; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; z-index: 20; }
.floatxp { position: fixed; z-index: 20; font-weight: 900; color: var(--accent); font-size: 22px; animation: up 1.1s ease-out forwards; pointer-events: none; }
.spark { position: fixed; z-index: 20; font-size: 20px; animation: burst 1s ease-out forwards; pointer-events: none; }
@keyframes up { to { transform: translateY(-60px); opacity: 0; } }
@keyframes burst { to { transform: translate(var(--dx), -90px) rotate(200deg); opacity: 0; } }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 30; display: grid; place-items: center; overflow: hidden; }
.modal-in { background: var(--card); border: 2px solid var(--accent); border-radius: 18px; padding: 24px; text-align: center; max-width: 320px; animation: pop .35s ease-out; }
.modal .big { font-size: 28px; font-weight: 900; margin-bottom: 6px; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.spark.rain { top: -30px; animation: fall 2s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.hc { aspect-ratio: 1; background: var(--accent); border-radius: 6px; display: grid; place-items: center; font-size: 12px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.badge { background: var(--card2); border-radius: 12px; padding: 10px; text-align: center; font-size: 14px; }
.badge .bi { font-size: 30px; }
.badge.locked { opacity: .35; filter: grayscale(1); }
@media (prefers-reduced-motion: reduce) { .floatxp, .spark, .modal-in { animation: none; } .spark { display: none; } }
