:root {
    --bg: #2b1612; --bg2: #160b09; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #fff3ef; --muted: #f0c9bf; --accent: #ff7b5c; --accent-ink: #2a0904; --field: rgba(255,255,255,.08);
    --soft: rgba(255,123,92,.16); --good: #8ce99a; --warn: #ffd43b; --warn-bg: rgba(255,212,59,.13); --bad: #ffa8a8;
    --focus: #ff7b5c; --short: #69db7c; --long: #74c0fc; --mode-ink: #1d0905;
    color-scheme: dark;
}
@media (prefers-color-scheme: light) {
    :root { --bg: #fff6f2; --bg2: #ffe6dd; --card: #fff; --line: #f3c6b8; --ink: #2b0f08; --muted: #714034;
            --accent: #d9381e; --accent-ink: #fff; --field: #fffaf8; --soft: #ffebe4; --good: #2b8a3e; --warn: #a15c00; --warn-bg: #fff4d6; --bad: #c92a2a;
            --focus: #d9381e; --short: #2b8a3e; --long: #1864ab; --mode-ink: #fff; color-scheme: light; }
}
:root[data-theme="light"] { --bg: #fff6f2; --bg2: #ffe6dd; --card: #fff; --line: #f3c6b8; --ink: #2b0f08; --muted: #714034;
            --accent: #d9381e; --accent-ink: #fff; --field: #fffaf8; --soft: #ffebe4; --good: #2b8a3e; --warn: #a15c00; --warn-bg: #fff4d6; --bad: #c92a2a;
            --focus: #d9381e; --short: #2b8a3e; --long: #1864ab; --mode-ink: #fff; color-scheme: light; }
:root[data-theme="dark"] {
    --bg: #2b1612; --bg2: #160b09; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #fff3ef; --muted: #f0c9bf; --accent: #ff7b5c; --accent-ink: #2a0904; --field: rgba(255,255,255,.08);
    --soft: rgba(255,123,92,.16); --good: #8ce99a; --warn: #ffd43b; --warn-bg: rgba(255,212,59,.13); --bad: #ffa8a8;
    --focus: #ff7b5c; --short: #69db7c; --long: #74c0fc; --mode-ink: #1d0905;
    color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding: clamp(1rem,4vw,2.5rem) 1rem 4rem; display: flex; justify-content: center;
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
       background: var(--bg2) linear-gradient(180deg, var(--bg), var(--bg2) 900px) no-repeat; touch-action: manipulation; }
.app { width: min(560px, 100%); min-width: 0; display: flex; flex-direction: column; }
.col-main, .col-side { display: contents; }
.app > .topbar, .app > .back { order: 0; }
.app > header, .warn-box { order: 1; }
.timer { order: 2; }
.tasks { order: 3; }
.day { order: 4; }
.week { order: 5; }
.settings { order: 6; }
.app > .faq { order: 7; }
.app > footer { order: 8; }
header { text-align: center; margin-bottom: 1.1rem; }
h1 { margin: 0; font-size: 1.7rem; line-height: 1.2; letter-spacing: -.02em; }
.sub { margin: .4rem 0 0; color: var(--muted); font-size: 1rem; }
h2 { margin: 0 0 .7rem; font-size: 1.15rem; overflow-wrap: anywhere; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; margin-bottom: .9rem; min-width: 0; }
label, .label-like { display: block; margin: .9rem 0 .35rem; font-size: .9rem; font-weight: 600; color: var(--muted); padding: 0; }
input[type=text], input[type=date], input[type=time], select { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink);
       background: var(--field); border: 1px solid var(--line); border-radius: 12px; -webkit-appearance: none; appearance: none; }
select, input[type=date], input[type=time] { -webkit-appearance: auto; appearance: auto; }
input[aria-invalid="true"] { border-color: var(--bad); }
select option { color: #111; background: #fff; }
input:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: .75; }
.hint { margin: .5rem 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
.warn-box { margin: 0 0 .9rem; padding: .7rem .9rem; border-radius: 12px; background: var(--warn-bg); border-left: 5px solid var(--warn); font-weight: 600; }
.err { margin: .4rem 0 0; color: var(--bad); font-weight: 600; font-size: .92rem; }
.err:empty { display: none; }
.msg { margin-top: .6rem; font-size: .95rem; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; }
.msg:empty { display: none; }

/* buttons */
.primary, .secondary, .danger { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: .5rem .8rem; border-radius: 12px;
       font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; line-height: 1.2; overflow-wrap: anywhere; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); margin-top: .8rem; }
.secondary { border: 1px solid var(--line); background: var(--field); color: var(--ink); font-weight: 600; }
.secondary.small { width: auto; min-height: 44px; padding: 0 .85rem; font-size: .92rem; margin: 0; }
.secondary.off { opacity: .45; cursor: default; }
.danger { border: 1px solid var(--bad); background: transparent; color: var(--bad); font-weight: 600; margin-top: .9rem; }
button:disabled { opacity: .45; cursor: default; }
.link { display: inline-flex; align-items: center; min-height: 44px; padding: 0; margin-top: .3rem; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.row-btns { display: grid; gap: .6rem; margin-top: .8rem; }
.row-btns .primary { margin-top: 0; }
.row-btns.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.inline { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; min-width: 0; }
.inline input { width: 6rem; flex: 0 0 6rem; }
.unit { color: var(--muted); font-size: .9rem; min-width: 0; overflow-wrap: anywhere; }
.check { display: flex; align-items: center; gap: .6rem; margin: .5rem 0; min-height: 44px; color: var(--ink); font-weight: 500; font-size: 1rem; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: 0 0 22px; margin: 0; accent-color: var(--accent); }

/* timer */
.timer { --m: var(--focus); text-align: center; border-color: color-mix(in srgb, var(--m) 55%, var(--line)); background: color-mix(in srgb, var(--m) 10%, var(--card)); }
.timer[data-mode="short"] { --m: var(--short); }
.timer[data-mode="long"] { --m: var(--long); }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; padding: .3rem; border-radius: 14px; background: var(--field); border: 1px solid var(--line); }
.mode { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; padding: .3rem .4rem; line-height: 1.15; }
.mode[aria-pressed="true"] { background: var(--m); color: var(--mode-ink); }
.phase { margin: 1rem 0 0; color: var(--muted); font-weight: 600; font-size: .95rem; }
.time { font-size: clamp(4.2rem, 21vw, 6.6rem); font-weight: 800; line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: .2rem 0 0; color: var(--ink); }
.ends { margin: .1rem 0 0; color: var(--muted); font-size: .95rem; }
.working { margin: .8rem auto 0; padding: .55rem .8rem; border-radius: 12px; background: var(--field); border: 1px solid var(--line); max-width: 100%; overflow-wrap: anywhere; font-size: .98rem; }
.working .k { color: var(--muted); }
.ctrl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin-top: 1rem; }
.ctrl .big { grid-column: 1 / -1; margin: 0; min-height: 60px; font-size: 1.25rem; background: var(--m); color: var(--mode-ink); border-radius: 14px; }
.ask { margin-top: 1rem; padding: .9rem; border-radius: 12px; border: 1px solid var(--m); background: var(--field); text-align: left; }
.ask p { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.timer .msg { justify-content: center; }

/* tasks */
.box-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .7rem; }
.task { border: 1px solid var(--line); border-radius: 14px; padding: .8rem .9rem; background: var(--field); min-width: 0; }
.task.current { border: 2px solid var(--accent); background: var(--soft); }
.task.done .task-name { text-decoration: line-through; color: var(--muted); }
.task-top { display: flex; gap: .6rem; align-items: baseline; }
.task-name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; min-width: 0; }
.task-meta { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.task-btns { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.pick { min-height: 44px; padding: 0 .9rem; border-radius: 999px; border: 1px solid var(--accent); background: transparent; color: var(--accent); font: inherit; font-weight: 700; font-size: .92rem; cursor: pointer; }
.pick[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.task-btns .grp { display: flex; gap: .5rem; margin-left: auto; }
.inline-check { margin: 0; min-height: 44px; font-size: .92rem; }
.task-edit label:first-child, .rec-edit label:first-child { margin-top: 0; }
.bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: .5rem; }
.bar.small { height: 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; }

/* day */
.head-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.head-row h2 { margin: 0; }
.total { margin: .5rem 0 0; font-size: 1.25rem; font-weight: 800; overflow-wrap: anywhere; }
.goal .hint { margin-top: .35rem; }
.split { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .35rem; }
.split li { display: flex; justify-content: space-between; gap: .8rem; padding: .45rem .7rem; border-radius: 10px; background: var(--soft); }
.split .nm { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.split .v { color: var(--muted); white-space: nowrap; font-size: .92rem; }
.log { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.rec { border: 1px solid var(--line); border-radius: 12px; padding: .55rem .7rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; background: var(--field); }
.rec.part { border-style: dashed; }
.rec-txt { display: flex; flex-wrap: wrap; gap: .1rem .7rem; min-width: 0; flex: 1 1 12rem; }
.rec-txt .when { font-variant-numeric: tabular-nums; font-weight: 700; }
.rec-txt .nm { overflow-wrap: anywhere; min-width: 0; }
.rec-txt .v { color: var(--muted); }
.rec-btns { display: flex; gap: .4rem; }
.rec-edit, .task-edit { width: 100%; }
.sub-form { margin-top: .6rem; padding: .9rem; border: 1px solid var(--line); border-radius: 12px; }
.sub-form .label-like { margin-top: 0; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }

/* week */
.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .35rem; margin-top: .9rem; }
.day-bar { display: flex; flex-direction: column; align-items: center; gap: .25rem; min-height: 44px; padding: .3rem .1rem; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; cursor: pointer; min-width: 0; }
.day-bar.sel { border-color: var(--accent); background: var(--soft); }
.day-bar .col { position: relative; display: block; width: 100%; max-width: 34px; height: 110px; border-radius: 8px; background: var(--field); overflow: hidden; }
.day-bar .col i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); border-radius: 8px 8px 0 0; }
.day-bar .val { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.day-bar .lbl { font-size: .82rem; font-weight: 600; }
.day-bar.today .lbl { color: var(--accent); }

/* settings */
.preset-grid { display: grid; gap: .6rem; }
.preset { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; min-height: 56px; padding: .6rem .9rem; border-radius: 12px; border: 1px solid var(--line); background: var(--field); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.preset b { font-size: 1.05rem; }
.preset span { color: var(--muted); font-size: .88rem; }
.preset[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--soft); }
.set-grid { display: grid; gap: 0 1rem; }
.with-btn { display: flex; gap: .6rem; align-items: center; }
.with-btn select { flex: 1 1 auto; }
.with-btn .small { min-height: 48px; flex: 0 0 auto; white-space: nowrap; }
.checks { margin-top: .6rem; }
.tool-grid { display: grid; gap: .6rem; margin-top: 1rem; }

.faq { margin-top: 1rem; }
.faq details { border-bottom: 1px solid var(--line); padding: .7rem 0; }
.faq summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.faq p { color: var(--muted); margin: .5rem 0 0; }
footer { text-align: center; margin-top: 1.4rem; font-size: .9rem; }
footer a { color: var(--muted); }

.back { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; margin: 0 0 .5rem; padding: 0 1rem 0 .8rem; border: 1px solid var(--line, rgba(127,127,127,.4)); border-radius: 999px; color: var(--muted, var(--mut, inherit)); font-size: .92rem; font-weight: 600; text-decoration: none; background: transparent; }
.back:hover { color: var(--ink, inherit); border-color: currentColor; }
.back:focus-visible { outline: 3px solid var(--accent, var(--acc, #fff)); outline-offset: 2px; }
@media print { .back { display: none; } }

@media (max-width: 380px) {
    .card { padding: .95rem .85rem; }
    .row-btns.two, .pair { grid-template-columns: 1fr; }
    .mode { font-size: .86rem; }
    .ctrl { grid-template-columns: 1fr; }
    .inline { flex-wrap: wrap; }
}
@media (min-width: 600px) {
    .preset-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .set-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
    .app { width: min(1140px, 100%); display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); column-gap: 1.5rem; align-items: start; }
    .app > * { grid-column: 1 / -1; }
    .col-main, .col-side { display: block; min-width: 0; }
    .app > .topbar { grid-row: 1; }
    .app > header { grid-row: 2; }
    .app > .warn-box { grid-row: 3; }
    .app > .col-main { grid-column: 1; grid-row: 4; }
    .app > .col-side { grid-column: 2; grid-row: 4; }
    .app > .settings { grid-row: 5; margin-top: .6rem; }
    .app > .faq { grid-row: 6; width: min(760px, 100%); justify-self: center; }
    .app > footer { grid-row: 7; width: min(760px, 100%); justify-self: center; }
    header h1 { font-size: 2.3rem; }
    .timer { padding: 1.4rem 1.6rem; }
    .time { font-size: 7.4rem; }
    .settings .set-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .settings .checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
}
#clear-done { margin-top: .7rem; }
