:root {
  --bg: #f5f3ed; --surface: #fffef9; --ink: #303c33; --muted: #6f766a; --faint: #a3a998; --line: #e2e4d9;
  --accent: #526b45; --accent-soft: #e8eddf; --ring: #82976b;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
body[data-mode="short"] { --ring: #6f9a8a; }
body[data-mode="long"] { --ring: #7489a6; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: light; }
body { margin: 0; min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Header */
.top { width: 100%; max-width: 1040px; margin: 0 auto; padding: 20px 24px; display: flex; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; font: 600 24px/1 var(--serif); letter-spacing: -.04em; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; padding-bottom: 4px; border-radius: 50% 50% 50% 8px;
  background: var(--accent); color: #faf8ed; font: italic 24px/1 var(--serif); }
.top nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.top nav a:not(.icon-btn) { margin-right: 10px; color: var(--muted); text-decoration: none; font-size: 14px; }

/* Buttons */
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--muted); transition: background .2s, color .2s; }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.play { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 156px; padding: 14px 26px; border: 0; border-radius: 999px;
  background: var(--accent); color: #fffef6; font-size: 15px; font-weight: 500; box-shadow: 0 4px 12px -4px rgb(82 107 69 / .45); transition: background .2s; }
.play svg { width: 18px; height: 18px; }
.play .i-pause, .play[data-state="running"] .i-play { display: none; }
.play[data-state="running"] .i-pause { display: block; }
.btn { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 9px 18px; font-size: 15px; }
.btn-solid { border-color: var(--accent); background: var(--accent); color: #fff; }
.text-btn { border: 0; background: none; padding: 0; color: var(--muted); font-size: 14px; white-space: nowrap; }
@media (hover: hover) {
  .icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
  .play:hover { background: #435a38; }
  .text-btn:hover, .top nav a:not(.icon-btn):hover { color: var(--ink); }
  .btn:hover { border-color: var(--faint); }
  .btn-solid:hover { background: #435a38; }
}

/* Card: timer + tasks */
.workspace { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 8px 24px 0; }
.card { display: grid; grid-template-columns: 1.25fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 10px 32px -22px rgb(52 73 39 / .3); overflow: hidden; }
.timer { display: flex; flex-direction: column; align-items: center; padding: 32px 24px 28px; min-width: 0; }
.modes { display: flex; gap: 2px; padding: 4px; border-radius: 999px; background: #f0f1e9; }
.modes button { border: 0; border-radius: 999px; background: transparent; padding: 8px 16px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.modes button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgb(41 59 37 / .1); }

.dial { position: relative; width: min(72vw, 280px); aspect-ratio: 1; margin: 28px 0 26px; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.track { fill: none; stroke: #e8ecdf; stroke-width: 1.5; }
.ring { fill: none; stroke: var(--ring); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .4s; }
.readout { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 14%; text-align: center; }
.time { font: 300 clamp(60px, 19vw, 76px)/1 var(--sans); letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.label { max-width: 100%; margin-top: 12px; color: var(--muted); font: italic 16px/1.4 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls { display: flex; align-items: center; gap: 20px; }
.round { display: flex; align-items: center; gap: 10px; margin: 24px 0 0; color: var(--muted); font-size: 13px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: #e1e5d6; transition: background .3s; }
.dots i.on { background: var(--accent); }

.side { padding: 32px 28px; border-left: 1px solid var(--line); background: #fdfdf8; }
.side h2 { margin: 0 0 12px; font: 400 19px/1.3 var(--serif); }
.side h2 + * { margin-top: 0; }
.side .task-list + h2 { margin-top: 32px; }
.task-entry { display: flex; gap: 8px; padding: 6px 6px 6px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.task-entry:focus-within { border-color: var(--ring); }
.task-entry input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; }
.task-entry input::placeholder { color: var(--muted); }
.task-entry button { border: 0; border-radius: 8px; background: var(--accent-soft); padding: 7px 12px; font-size: 14px; color: var(--accent); white-space: nowrap; }
.task-list { list-style: none; margin: 8px 0 0; padding: 0; }
.task-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.task-check { flex: none; width: 22px; height: 22px; padding: 0; border: 1.5px solid #bcc6ad; border-radius: 50%; background: transparent; color: var(--accent); font-size: 12px; line-height: 1; }
.task-name { flex: 1; min-width: 0; padding: 6px 0; border: 0; background: none; text-align: left; font-size: 15px; overflow-wrap: anywhere; }
.task-delete { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 20px; line-height: 1; }
.task-list li.active .task-name { color: var(--accent); font-weight: 500; }
.task-list li.active .task-check { border-color: var(--accent); }
.task-list li.completed .task-check { background: var(--accent-soft); border-color: var(--accent-soft); }
.task-list li.completed .task-name { color: var(--muted); text-decoration: line-through; cursor: default; }
@media (hover: hover) { .task-delete { opacity: 0; } .task-list li:hover .task-delete, .task-delete:focus-visible { opacity: 1; } .task-delete:hover { color: var(--ink); } }
.today { display: flex; gap: 24px; margin: 0; color: var(--muted); font-size: 14px; }
.today strong { margin-right: 6px; color: var(--ink); font: 400 28px/1 var(--serif); }

/* Ads: reserved space, below the card, never next to the controls */
.ad { position: relative; display: flex; align-items: center; justify-content: center; }
.ad-wide { width: 100%; max-width: 728px; min-height: 90px; margin: 56px auto 0; }
.ad-tag { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ad-preview { border: 1px dashed #d6dacb; border-radius: 10px; }
.ad-empty { display: none !important; }

footer { padding: 28px 24px 24px; text-align: center; color: var(--muted); font-size: 13px; }
footer p { margin: 4px 0; }
footer a { text-decoration: none; }
@media (hover: hover) { footer a:hover { color: var(--ink); } }

@media (max-width: 760px) {
  .top { padding: 14px 16px; }

  .workspace { padding: 4px 12px 0; }
  .card { grid-template-columns: 1fr; border-radius: 20px; }
  .timer { padding: 22px 16px 26px; }
  .modes { width: 100%; max-width: 340px; }
  .modes button { flex: 1; padding: 9px 8px; }
  .side { padding: 24px 20px 26px; border-left: 0; border-top: 1px solid var(--line); }
  .ad-wide { max-width: 336px; min-height: 280px; margin-top: 40px; }
}

/* Short desktop/laptop windows: fit the whole card without scrolling */
@media (min-width: 761px) and (max-height: 800px) {
  .top { padding-top: 12px; padding-bottom: 12px; }
  .timer, .side { padding-top: 22px; padding-bottom: 20px; }
  /* Dial follows window height: ~350px of the page is everything else. */
  .dial { width: clamp(170px, calc(100svh - 350px), 250px); margin: 16px 0; }
  .time { font-size: clamp(46px, calc((100svh - 350px) * .26), 64px); }
  .round { margin-top: 16px; }
  footer { padding: 16px 24px; }
}


/* Settings */
dialog { width: min(92vw, 440px); padding: 26px 26px 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / .25); }
dialog::backdrop { background: rgb(245 243 237 / .7); backdrop-filter: blur(4px); }
dialog h2 { margin: 0 0 20px; font: 400 24px/1.2 var(--serif); }
dialog h2:focus { outline: none; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-bottom: 18px; }
.grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.unit { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.unit input { width: 64px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); text-align: center; font-size: 16px;
  -moz-appearance: textfield; appearance: textfield; }
.unit input::-webkit-inner-spin-button, .unit input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.unit input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 15px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 38px; height: 22px; margin: 0; border-radius: 11px; background: var(--line); cursor: pointer; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.row { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.spacer { flex: 1; }

/* Content pages */
.page { flex: 1; width: 100%; max-width: 640px; margin: 24px auto 0; padding: 0 24px; font-size: 17px; }
.page h1 { margin: 0 0 .8em; font: 400 34px/1.2 var(--serif); }
.page h2 { margin: 2em 0 .5em; font: 400 22px/1.3 var(--serif); }
.page p, .page li { color: #4d5449; }
.cta { display: inline-block; margin-top: 18px; padding: 12px 24px; border-radius: 999px; background: var(--accent); color: #fff; text-decoration: none; font-size: 16px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
.page .fine { font-size: 14px; color: var(--muted); }
.share { padding: 12px 0 2px; border-top: 1px solid var(--line); }
.share label { font-size: 15px; }
.share-row { display: flex; gap: 8px; margin-top: 8px; }
.share-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--muted); font-size: 14px; }
.share p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.text-btn.danger { color: #b0493b; }
@media (hover: hover) { .text-btn.danger:hover { color: #8e3328; } }
@media (max-height: 720px) {
  dialog { padding: 18px 22px 16px; }
  dialog h2 { margin-bottom: 12px; }
  .grid { gap: 10px 16px; margin-bottom: 10px; }
  .switch { padding: 7px 0; }
  .share { padding-top: 8px; }
  .row { margin-top: 12px; }
}
@media (max-height: 620px) and (min-width: 600px) {
  .grid { grid-template-columns: repeat(4, 1fr); align-items: end; }
  .unit input { width: 54px; }
}
@media (max-height: 560px) {
  dialog { padding: 14px 20px 12px; }
  dialog h2 { font-size: 20px; margin-bottom: 8px; }
  .switch { padding: 5px 0; }
}
