/* Theme tokens: the defaults below are the classic wood design; themes.css overrides them via [data-theme] */
:root, [data-theme="holz"] {
  --font: "Segoe UI", system-ui, sans-serif;
  --r-board: 36px; --r-paper: 10px; --r-ctl: 9px; --r-sm: 6px;

  --page: #efece6;
  --board:
    radial-gradient(120% 60% at 20% 10%, rgba(255,235,200,.15), transparent 40%),
    radial-gradient(90% 40% at 80% 90%, rgba(60,30,5,.18), transparent 50%),
    repeating-linear-gradient(92deg, rgba(0,0,0,.06) 0 1px, transparent 1px 7px),
    linear-gradient(135deg, #c89b66, #b98a52 40%, #a97a45 75%, #96683a);
  --board-shadow: 0 20px 28px rgba(0,0,0,.22), inset 0 2px 3px rgba(255,255,255,.35), inset 0 -3px 6px rgba(0,0,0,.30), inset 0 0 0 1px rgba(70,40,10,.35);
  --paper: linear-gradient(178deg, #f7f5f0, #f2efe8 60%, #ece8de);
  --paper-shadow: 0 1px 2px rgba(0,0,0,.25), inset 0 0 40px rgba(190,175,150,.25);

  --ink: #33302b; --ink-strong: #2d2a26; --ink-soft: #777163;
  --sub: #8b857a; --faint: #a39b8b; --placeholder: #b3aa96;
  --rule: #d6cfbf; --rule-soft: #e0dacb;
  --field-border: #d8d0be; --field-bg: #fdfcfa; --field-dash: rgba(255,255,255,.45); --dash: #b9b09c;
  --box-border: #b3aa96; --ring-track: #e3ded2; --scroll: #cfc6b4;
  --wash: rgba(0,0,0,.06); --wash-2: rgba(0,0,0,.1); --wash-3: rgba(0,0,0,.03);
  --btn-ink: #4a463f; --acct: #6f6857; --close-ink: #6b5a3e; --close-bg: rgba(0,0,0,.10);
  --prio-ring: #7d7462; --prio-gap: #fbfaf7; --upd-bg: rgba(255,255,255,.55);

  --accent: #4a9d6b; --accent-dark: #3c7d55; --accent-glow: rgba(74,157,107,.4); --on-accent: #fff;
  --toast-bg: rgba(45,42,38,.94); --toast-ink: #f5f2ea; --toast-accent: #a8e6bd;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--page);
  display: grid;
  place-items: center;
  overflow: hidden;
}
body.desktop { background: transparent; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

svg.i { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- board ---------- */
.clipboard {
  position: relative;
  width: 420px; height: 580px;
  border-radius: var(--r-board);
  background: var(--board);
  box-shadow: var(--board-shadow);
}

.paper {
  position: absolute;
  inset: 58px 24px 16px;
  padding: 58px 26px 52px;
  display: flex; flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-paper);
  background: var(--paper);
  box-shadow: var(--paper-shadow);
}

/* ---------- clip (drag handle in desktop mode) ---------- */
.clip { position: absolute; top: -26px; left: 50%; width: 190px; height: 96px; margin-left: -95px; z-index: 5; }
.clip-body {
  position: absolute; bottom: 0; left: 0;
  width: 190px; height: 62px;
  background: linear-gradient(180deg, #f4f4f2, #cfcfcb 30%, #9fa09c 70%, #7e7f7b);
  border-radius: 10px 10px 14px 14px;
  box-shadow: 0 6px 6px rgba(0,0,0,.30), inset 0 2px 2px rgba(255,255,255,.9), inset 0 -3px 4px rgba(0,0,0,.35);
}
.clip-tail {
  position: absolute; bottom: 34px; left: 36px;
  width: 118px; height: 54px;
  background: linear-gradient(180deg, #ececea, #c4c5c1 55%, #8f908c);
  border-radius: 8px 8px 4px 4px;
}
.clip-hole {
  position: absolute; top: 2px; left: 82px;
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6a6b67, #3c3d3a 70%);
  box-shadow: inset 0 2px 3px rgba(0,0,0,.7), 0 1px 1px rgba(255,255,255,.6);
}
.clip-hole::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #2b2c2a, #131312); }
.rivet {
  position: absolute; bottom: 18px; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fdfdfd, #a8a8a4 60%, #6f6f6b);
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.rivet.l { left: 26px; } .rivet.r { right: 26px; }
.clip-mouth { position: absolute; bottom: 6px; left: 14px; right: 14px; height: 5px; border-radius: 3px; background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.12)); }

.desktop .clip, .desktop .header { -webkit-app-region: drag; cursor: move; }

.close-btn {
  display: none; position: absolute; top: 7px; right: 7px; z-index: 20;
  width: 26px; height: 26px; border: 0; border-radius: 8px;
  place-items: center; cursor: pointer;
  background: var(--close-bg); color: var(--close-ink); opacity: .55;
  transition: opacity .15s, background .15s, color .15s;
  -webkit-app-region: no-drag;
}
.close-btn svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.desktop .close-btn { display: grid; }
.min-btn, .max-btn { display: none; }
.min-btn svg, .max-btn svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1; }
.close-btn:hover { opacity: 1; background: rgba(192,57,43,.14); color: #c0392b; }

/* ---------- phones: board fills the screen ---------- */
@media (max-width: 500px) {
  body { place-items: start center; }
  .clipboard { width: 100vw; height: calc(100dvh - 30px); margin-top: 30px; border-radius: 0; }
  .paper { inset: 58px 10px max(10px, env(safe-area-inset-bottom)); padding-left: 18px; padding-right: 18px; }
  .footer { left: 18px; right: 18px; }
  .undo-toast { left: 18px; right: 18px; }
  .compose-row input, .due-input, .auth input, .edit { font-size: 16px; }
}

/* ---------- header ---------- */
.header {
  flex: none; display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 12px; margin-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
.title { font-size: 21px; font-weight: 700; letter-spacing: .3px; color: var(--ink-strong); }
.subtitle { font-size: 11px; font-weight: 500; color: var(--sub); margin-top: 2px; }
.ring { width: 40px; height: 40px; flex: none; transform: rotate(-90deg); -webkit-app-region: no-drag; }
.ring circle { fill: none; stroke-width: 4; }
.ring-bg { stroke: var(--ring-track); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 106.8; stroke-dashoffset: 106.8; transition: stroke-dashoffset .4s ease; }
.ring text { transform: rotate(90deg); transform-origin: 20px 20px; fill: var(--accent); font-size: 10px; font-weight: 700; text-anchor: middle; stroke: none; }

/* ---------- tasks ---------- */
.task-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }

.task {
  position: relative; display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 10px; margin-bottom: 4px; border-radius: var(--r-ctl);
  content-visibility: auto; contain-intrinsic-size: auto 58px;
  transition: opacity .25s, transform .22s;
}
.task.new { animation: task-in .25s ease; }
.task.done { opacity: .62; }
.task.removing { opacity: 0; transform: translateX(14px); }
@keyframes task-in { from { opacity: 0; transform: translateY(-6px); } }

.priority { flex: none; width: 5px; align-self: stretch; margin: 2px 0; border-radius: 3px; }
.red .priority, .priority.red { background: linear-gradient(180deg, #e05545, #c0392b); }
.yellow .priority, .priority.yellow { background: linear-gradient(180deg, #f0b429, #d99a17); }
.green .priority, .priority.green { background: linear-gradient(180deg, #58b07a, #4a9d6b); }

.checkbox {
  flex: none; width: 20px; height: 20px; margin-top: 1px;
  display: grid; place-items: center; cursor: pointer;
  border-radius: var(--r-sm); border: 2px solid var(--box-border); background: var(--field-bg); color: var(--on-accent);
  transition: background .2s, border-color .2s, transform .1s;
}
.checkbox:active { transform: scale(.88); }
.checkbox svg { stroke-width: 3; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .25s ease .05s; }
.done .checkbox { background: var(--accent); border-color: var(--accent); }
.done .checkbox svg { stroke-dashoffset: 0; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14.5px; font-weight: 600; line-height: 1.3; color: var(--ink); word-break: break-word; }
.strike {
  background: linear-gradient(currentColor, currentColor) 0 55% / 0% 1.5px no-repeat;
  transition: background-size .3s ease, color .3s ease;
}
.done .strike { background-size: 100% 1.5px; color: var(--ink-soft); }
.edit { width: 100%; padding: 1px 4px; margin: -2px -5px; border: 1.5px solid var(--accent); border-radius: 5px; background: var(--field-bg); font-weight: 600; outline: 0; }

.task-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.task-meta:empty { display: none; }
.due { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600; color: var(--sub); }
.due.soon { color: #c98a1b; }
.due.urgent { color: #c0392b; }
.due.overdue { color: #b3261e; font-weight: 700; }
.tag { padding: 2px 7px; border-radius: 20px; font-size: 9px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; }
.tag.red { background: rgba(224,85,69,.14); color: #c0392b; }
.tag.yellow { background: rgba(240,180,41,.18); color: #a5700e; }

.del-btn {
  position: absolute; top: 9px; right: 4px; width: 24px; height: 24px;
  display: none; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--sub); cursor: pointer;
}
.done .del-btn { display: grid; opacity: 0; transition: opacity .15s, background .15s, color .15s; }
.done:hover .del-btn, .del-btn:focus-visible { opacity: 1; }
.del-btn:hover { background: rgba(192,57,43,.1); color: #c0392b; }

.done-row {
  display: flex; align-items: center; gap: 7px; margin: 2px 10px 4px; padding: 9px 10px;
  border-radius: var(--r-ctl); font-size: 12px; font-weight: 600; color: var(--sub); cursor: pointer; user-select: none;
}
.done-row:hover { background: var(--wash-3); }
.chev { font-size: 10px; transition: transform .2s; }
.done-row.open .chev { transform: rotate(90deg); }
.clear-all { margin-left: auto; padding: 4px 9px; border: 0; border-radius: var(--r-sm); background: transparent; color: #c0392b; font-size: 11px; font-weight: 700; cursor: pointer; }
.clear-all:hover { background: rgba(192,57,43,.1); }

.empty { padding: 28px 0 14px; text-align: center; font-size: 12.5px; font-weight: 500; color: var(--faint); }

/* ---------- composer ---------- */
.composer { flex: none; margin: 10px 0 0 10px; width: calc(100% - 20px); }
.compose-row { display: flex; gap: 6px; }
.compose-row input {
  flex: 1; min-width: 0; padding: 10px 12px; font-size: 13px;
  border: 1.5px dashed var(--dash); border-radius: var(--r-ctl); background: var(--field-dash); outline: 0;
  transition: border-color .15s, background .15s;
}
.compose-row input:focus { border: 1.5px solid var(--accent); background: var(--field-bg); }
.compose-row input::placeholder, .due-input::placeholder { color: var(--placeholder); }
.confirm {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: var(--r-ctl);
  background: var(--accent); color: var(--on-accent); font-size: 18px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 3px var(--accent-glow); transition: background .15s, transform .1s;
}
.confirm:hover { background: var(--accent-dark); }
.confirm:active { transform: scale(.94); }

.compose-opts { display: none; align-items: center; gap: 10px; margin-top: 8px; }
.composer:focus-within .compose-opts { display: flex; }
.prio-pick { display: flex; gap: 6px; }
.prio-dot {
  appearance: none; width: 18px; height: 18px; margin: 0; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; opacity: .45; transition: transform .1s, opacity .15s;
}
.prio-dot:hover { transform: scale(1.15); opacity: .8; }
.prio-dot:checked { opacity: 1; border-color: var(--prio-ring); box-shadow: 0 0 0 2px var(--prio-gap), 0 1px 4px rgba(0,0,0,.25); }
.prio-dot.red { background: #e05545; }
.prio-dot.yellow { background: #f0b429; }
.prio-dot.green { background: #58b07a; }
.due-input { flex: 1; min-width: 0; padding: 7px 10px; font-size: 12px; border: 1.5px solid var(--field-border); border-radius: 8px; background: var(--field-bg); outline: 0; }
.due-input:focus { border-color: var(--accent); }

/* ---------- toast + footer ---------- */
.undo-toast {
  position: absolute; left: 26px; right: 26px; bottom: 40px; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 13px; border-radius: 10px;
  background: var(--toast-bg); color: var(--toast-ink); font-size: 12px; font-weight: 600;
  box-shadow: 0 6px 16px rgba(0,0,0,.28);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.undo-toast.show { opacity: 1; transform: none; pointer-events: auto; }
#undo-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#undo-btn { flex: none; padding: 5px 11px; border: 0; border-radius: 7px; background: rgba(255,255,255,.14); color: var(--toast-accent); font-size: 11.5px; font-weight: 700; cursor: pointer; }
#undo-btn:hover { background: rgba(255,255,255,.24); }

.footer {
  position: absolute; left: 26px; right: 26px; bottom: 14px; padding-top: 8px;
  display: flex; align-items: center; gap: 10px;
  border-top: 1px solid var(--rule-soft); font-size: 10px; font-weight: 600; color: var(--faint);
}
#footer { margin-right: auto; }
.sync-state:empty { display: none; }
.sync-state::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--accent); }
.sync-state.syncing::before { background: #f0b429; }
.sync-state.offline::before { background: #c0392b; }
.account-btn { padding: 2px 6px; border: 0; border-radius: 5px; background: transparent; color: var(--acct); font-size: 10px; font-weight: 700; cursor: pointer; }
.account-btn:hover { background: var(--wash); }

/* ---------- sign-in overlay + settings ---------- */
.auth, .settings {
  position: absolute; inset: 0; z-index: 30; padding: 70px 30px 30px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--paper);
}
.settings { padding: 38px 24px 16px; gap: 7px; overflow-y: auto; }
.settings button { padding: 9px; }
.auth h2, .settings h2 { font-size: 19px; color: var(--ink-strong); }
.auth p, .settings p { font-size: 12px; line-height: 1.45; color: var(--sub); margin-bottom: 4px; }
.auth input { padding: 11px 12px; font-size: 13px; border: 1.5px solid var(--field-border); border-radius: var(--r-ctl); background: var(--field-bg); outline: 0; }
.auth input:focus { border-color: var(--accent); }
.auth-code { padding: 12px; text-align: center; font: 700 26px/1 ui-monospace, Consolas, monospace; letter-spacing: 4px; color: var(--ink-strong); background: var(--field-bg); border: 1.5px dashed var(--dash); border-radius: var(--r-ctl); user-select: all; }
.settings { text-align: center; }
.settings .logo { width: 52px; height: 52px; align-self: center; flex: none; border-radius: 13px; box-shadow: 0 8px 18px rgba(0,0,0,.22); }
.settings .upd { margin: 4px 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; border-radius: 12px; background: var(--upd-bg); box-shadow: inset 0 0 0 1px var(--rule-soft); }
.settings .design { margin: 4px 0 0; padding: 10px; display: flex; flex-direction: column; gap: 8px; border-radius: 12px; background: var(--upd-bg); box-shadow: inset 0 0 1px 1px var(--rule-soft); }
.settings .design b { font-size: 13px; color: var(--ink-strong); }
.theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-opt { padding: 6px 6px 7px !important; display: flex; flex-direction: column; align-items: center; gap: 6px; border: 2px solid transparent !important; border-radius: 10px !important; background: var(--wash) !important; color: var(--ink) !important; font-size: 11.5px !important; font-weight: 600 !important; font-family: var(--font); }
.theme-opt[aria-pressed="true"] { border-color: var(--accent) !important; }
.theme-sw { position: relative; width: 100%; height: 46px; border-radius: 7px; background: var(--board); box-shadow: var(--board-shadow); }
.theme-sw::before { content: ""; position: absolute; inset: 7px 9px 0; border-radius: 3px 3px 0 0; background: var(--paper); }
.theme-sw::after { content: ""; position: absolute; right: 14px; bottom: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.settings .upd b { font-size: 13px; color: var(--ink-strong); }
.settings .upd p { min-height: 18px; margin: 0; font-weight: 600; }
.account-btn.has-update::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 4px; vertical-align: middle; border-radius: 50%; background: var(--accent); }
.auth-error { min-height: 16px; font-size: 11.5px; font-weight: 600; color: #b3261e; }
.auth button, .settings button { padding: 11px; border: 0; border-radius: var(--r-ctl); font-size: 13px; font-weight: 700; cursor: pointer; }
.auth-main { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 3px var(--accent-glow); }
.auth-main:hover { background: var(--accent-dark); }
.auth-alt { background: var(--wash); color: var(--btn-ink); }
.auth-alt:hover { background: var(--wash-2); }
.auth-skip { background: transparent; color: var(--sub); font-weight: 600 !important; }
.auth button:disabled, .settings button:disabled { opacity: .6; cursor: default; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.compose-row input:focus-visible, .due-input:focus-visible, .edit:focus-visible { outline: 0; }
