@font-face { font-family: "Unbounded"; src: url("fonts/unbounded.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Inter"; src: url("fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #f2f2ec; --ink: #111111; --mute: #55554f; --line: #d9d9d1; --card: #ffffff;
  --inv: #111111; --inv-ink: #f2f2ec; --inv-mute: #b9b9b0;
  --accent: #d4ff3a; --on-accent: #111111; --danger: #b3261e;
  --display: "Unbounded", system-ui, sans-serif;
  --text: "Inter", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e0e0c; --ink: #f2f2ec; --mute: #a3a39a; --line: #2e2e2a; --card: #1b1b18;
  --inv: #f2f2ec; --inv-ink: #111111; --inv-mute: #55554f; --danger: #ff8a7a;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 400 15px/1.4 var(--text); -webkit-font-smoothing: antialiased; }
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
p, h1, h2 { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }

.screen { flex: 1; display: flex; flex-direction: column; padding: 16px 20px calc(24px + env(safe-area-inset-bottom)); }
.top { display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
.logo { font: 900 18px var(--display); letter-spacing: .02em; }
.kicker { font: 700 13px var(--display); letter-spacing: .04em; text-transform: uppercase; }
.label { font: 700 11px var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.mute { color: var(--mute); }
.small { font-size: 13px; }
.spacer { flex: 1; min-height: 16px; }

.counter { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.counter .big { font: 900 92px/.9 var(--display); letter-spacing: -.05em; }
.counter .of { font: 500 26px var(--display); color: var(--mute); }
.counter .side { margin-left: auto; text-align: right; font-size: 13px; color: var(--mute); }
.cells { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin-top: 12px; }
.cell { height: 10px; border-radius: 3px; background: var(--line); }
.cell.done { background: var(--ink); }
.cell.current { background: var(--accent); }

.now { margin-top: 20px; background: var(--inv); color: var(--inv-ink); border-radius: 22px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.now .tag { display: flex; align-items: center; gap: 8px; font: 700 11px var(--display); letter-spacing: .08em; color: var(--inv-mute); }
.now .tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.now h1 { font: 700 20px/1.3 var(--display); }
.now .meta { font-size: 14px; color: var(--inv-mute); }

.row { display: flex; gap: 10px; margin-top: 10px; }
.btn { height: 56px; border-radius: 18px; border: 0; display: flex; align-items: center; justify-content: center; padding: 0 16px;
  font: 700 15px var(--display); text-decoration: none; transition: transform .08s ease; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--accent); color: var(--on-accent); flex: 2; }
.btn.outline { background: transparent; border: 2px solid var(--ink); color: var(--ink); flex: 1; font-size: 13px; }
.btn.dark { background: var(--inv); color: var(--inv-ink); }
.btn.block { width: 100%; flex: none; }

.others { margin-top: 24px; display: flex; flex-direction: column; gap: 8px; }
.other { background: var(--card); border-radius: 16px; padding: 12px 16px; min-height: 60px; display: flex; align-items: center; gap: 12px; }
.other .t { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.other .t b { font-weight: 600; font-size: 15px; }

.card { background: var(--card); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.card h2 { font: 700 18px/1.3 var(--display); }

/* Done screen */
.done-top { background: var(--accent); color: #111111; padding: 16px 20px 28px; display: flex; flex-direction: column; }
.done-top .counter .of, .done-top .counter .side { color: #111111; opacity: .75; }
.done-top .counter .big { font-size: 112px; }
.done-top .cell { background: rgba(17,17,17,.18); }
.done-top .cell.done, .done-top .cell.current { background: #111111; }
.done-top.full { flex: 1; padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.done-top h1 { font: 900 32px/1.1 var(--display); letter-spacing: -.02em; margin-top: 10px; }

/* Stuck screen */
textarea { width: 100%; min-height: 120px; resize: vertical; border: 2px solid var(--ink); border-radius: 16px; padding: 12px 14px;
  background: var(--card); color: var(--ink); font: 400 15px/1.45 var(--text); }
textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }

/* Empty */
.hero { width: 100%; height: 300px; object-fit: cover; object-position: 0% 100%; display: block; }
:root[data-theme="dark"] .hero { width: auto; margin: 0 20px; border-radius: 22px; height: 280px; }
.empty h1 { font: 900 32px/1.1 var(--display); letter-spacing: -.03em; }

.center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.skeleton { opacity: .4; }
.sr { position: absolute; left: -9999px; }

/* ---------- v4b: tabs, sections, forms ---------- */
body.has-tabs .screen { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--bg); border-top: 1px solid var(--line);
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
.tabbar nav { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tab { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 52px;
  font: 600 11px var(--text); color: var(--mute); }
.tab .pill { width: 56px; height: 30px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.tab.on { color: var(--ink); }
.tab.on .pill { background: var(--accent); color: var(--on-accent); }
.icon { width: 20px; height: 20px; }
.iconbtn { width: 44px; height: 44px; border: 0; background: none; display: flex; align-items: center; justify-content: center; color: var(--ink); margin-right: -12px; }
.iconbtn:disabled { color: var(--mute); opacity: .5; }
.backlink { background: none; border: 0; padding: 10px 12px 10px 0; color: var(--mute); font: 600 14px var(--text); align-self: flex-start; }

.chips { display: flex; gap: 6px; overflow-x: auto; margin-top: 14px; scrollbar-width: none; }
.chip { flex-shrink: 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--card); color: var(--ink); font: 600 13px var(--text); }
.chip.on { background: var(--inv); color: var(--inv-ink); }

.ms { border-radius: 16px; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.ms.done { background: var(--card); }
.ms.planned { border: 2px dashed var(--line); }
.ms.active { background: var(--inv); color: var(--inv-ink); border-radius: 18px; padding: 14px 16px 8px; }
.ms .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font: 700 13px var(--display); }
.ms .head .n { font: 500 12px var(--text); opacity: .8; }
.ms.planned .head { color: var(--mute); }
.srow { display: flex; align-items: center; gap: 10px; min-height: 36px; border-top: 1px solid var(--inv-mute); font-size: 14px; }
.ms.active .srow { border-top-color: rgba(127,127,120,.35); }
.ms.planned .srow, .ms.done .srow { border-top-color: var(--line); }
.dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; border: 2px solid currentColor; opacity: .6; }
.srow.done .dot { background: currentColor; border: 0; opacity: .5; }
.srow.done .tt { text-decoration: line-through; opacity: .6; }
.srow.current .dot { background: var(--accent); border: 0; opacity: 1; }
.srow .tt { flex: 1; }
.srow .m { font-size: 12px; opacity: .7; }

.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; height: 110px; margin-top: 20px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 6px; justify-content: flex-end; height: 100%; }
.bar i { display: block; width: 100%; border-radius: 6px; background: var(--ink); min-height: 6px; }
.bar i.zero { background: var(--line); }
.bar i.today { background: var(--accent); }
.bar span { font-size: 12px; color: var(--mute); }
.list { background: var(--card); border-radius: 18px; padding: 4px 16px; }
.list .li { display: flex; justify-content: space-between; align-items: center; min-height: 48px; border-top: 1px solid var(--line); gap: 12px; }
.list .li:first-child { border-top: 0; }
.list .li b { font: 700 14px var(--display); }
.weeknav { display: flex; align-items: center; gap: 4px; }
.weeknav button { width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--card); color: var(--ink); }
.weeknav button:disabled { opacity: .35; }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.field label { font-weight: 600; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--mute); }
input[type=text], input[type=date], input[type=time] { height: 50px; border: 2px solid var(--ink); border-radius: 14px; padding: 0 14px;
  background: var(--card); color: var(--ink); font: 400 16px var(--text); width: 100%; }
input:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
textarea { font-size: 16px; }
.setrow { display: flex; align-items: center; justify-content: space-between; min-height: 56px; border-top: 1px solid var(--line); gap: 12px; }
.setrow:first-child { border-top: 0; }
.setrow input[type=time] { width: 120px; height: 40px; border-width: 0; background: var(--bg); text-align: center; font: 700 15px var(--display); }
.switch { width: 52px; height: 32px; border-radius: 999px; border: 0; background: var(--line); padding: 3px; display: flex; flex-shrink: 0; }
.switch span { width: 26px; height: 26px; border-radius: 999px; background: var(--card); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] span { transform: translateX(20px); background: #111; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; background: var(--card); border-radius: 16px; padding: 4px; }
.seg button { height: 44px; border: 0; border-radius: 12px; background: transparent; font: 700 13px var(--display); color: var(--ink); }
.seg button.on { background: var(--inv); color: var(--inv-ink); }
.toast { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); background: var(--inv); color: var(--inv-ink);
  padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 20; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
.other { width: 100%; border: 0; text-align: left; color: var(--ink); }

/* ---------- v4c: actions on goals ---------- */
button.srow { width: 100%; background: none; border: 0; border-top: 1px solid rgba(127,127,120,.35); color: inherit; text-align: left; padding: 0; font: inherit; font-size: 14px; }
.ms.planned button.srow { border-top-color: var(--line); }
button.head { width: 100%; background: none; border: 0; padding: 0; color: inherit; text-align: left; min-height: 32px; }
.ms.planned button.head { color: var(--mute); }
.addline { margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px;
  border: 2px dashed var(--line); border-radius: 16px; background: none; color: var(--mute); font: 600 14px var(--text); }
.acts { background: var(--card); border-radius: 18px; padding: 0 16px; }
.act { width: 100%; min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0;
  background: none; border: 0; border-top: 1px solid var(--line); text-align: left; color: var(--ink); }
.act:first-child { border-top: 0; }
.act > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.act b { font-weight: 600; font-size: 15px; }
.act.danger b { color: var(--danger); }
.mini { height: 36px; padding: 0 12px; border-radius: 10px; border: 2px solid var(--ink); background: transparent; color: var(--ink); font: 600 13px var(--text); }
.mini.danger { border-color: var(--danger); color: var(--danger); }
.mini:disabled { opacity: .4; }
input[type=number] { height: 50px; border: 2px solid var(--ink); border-radius: 14px; padding: 0 14px; background: var(--card); color: var(--ink); font: 400 16px var(--text); width: 140px; }
