/* Focus Timer — public static build for doohickeytools.com/focus-timer/ */
/* Hidden elements must stay hidden: .dialog-backdrop sets display:flex,
   which otherwise overrides the browser's built-in [hidden] rule and
   leaves dialogs visible (and unclosable) on load. */
[hidden] { display: none !important; }
:root {
  --bg: #faf5ec;
  --card: #ffffff;
  --ink: #26221c;
  --muted: #6f6a5e;
  --line: #e8dfcf;
  --red: #e14d2a;
  --red-dark: #c93f20;
  --red-soft: #fdeee8;
  --dark: #22252b;
  --amber: #f0a832;
  --amber-dark: #d18d1d;
  --green: #2f9e44;
  --radius: 16px;
  --font: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

.page { max-width: 1080px; margin: 0 auto; padding: 20px 20px 48px; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

h2 { font-size: 1.25rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 0 0 12px; }

/* ---------- Header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.brand-emoji { font-size: 1.7rem; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill {
  background: #eef3e6; color: #4c7a34; border: 1px solid #cfdfc0;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
  padding: 4px 10px; border-radius: 999px;
}
.pill.guest { background: #fdf3e3; color: #9a6a12; border-color: #f0d9a8; }
.pill.premium { background: #22252b; color: #ffd97a; border-color: #22252b; }
.guest-note {
  background: #fdf3e3; border: 1px solid #f0d9a8; color: #7a5410;
  border-radius: 10px; padding: 10px 14px; margin: 8px 0 0; font-size: 0.92rem;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-size: 0.95rem; font-weight: 600;
  border: 1px solid transparent; border-radius: 999px;
  padding: 9px 18px; cursor: pointer; background: #fff; color: var(--ink);
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-amber { background: var(--amber); color: #231a05; }
.btn-amber:hover { background: var(--amber-dark); color: #fff; }
.btn-light { background: #fff; color: var(--ink); }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }
.btn-round {
  width: 52px; height: 52px; padding: 0; border-radius: 50%;
  background: #fff; border: 1px solid var(--line);
  font-size: 1.3rem; line-height: 1; color: var(--ink);
}
.btn-start {
  background: var(--red); color: #fff; font-size: 1.15rem;
  padding: 14px 44px; min-width: 170px;
}
.btn-start:hover { background: var(--red-dark); }
.btn-start.running { background: var(--dark); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; margin-top: 20px; align-items: start; }
.col-left, .col-right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .brand { font-size: 1.35rem; }
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  box-shadow: 0 1px 3px rgba(38, 34, 28, 0.05);
}

/* ---------- Timer ---------- */
.timer-card { text-align: center; }
.tabs {
  display: inline-flex; background: #f3ede1; border-radius: 999px; padding: 4px; gap: 2px;
}
.tab {
  font-family: inherit; font-size: 0.92rem; font-weight: 600;
  border: 0; border-radius: 999px; padding: 8px 16px; cursor: pointer;
  background: transparent; color: var(--muted);
}
.tab.active { background: var(--red); color: #fff; }
.timer-sub { color: var(--muted); margin: 16px 0 4px; min-height: 1.4em; }
.timer-sub strong { color: var(--ink); }

.ring-wrap { position: relative; width: 260px; height: 260px; margin: 6px auto 4px; }
.ring { width: 260px; height: 260px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: #f0e8d8; stroke-width: 12; }
.ring-progress {
  fill: none; stroke: var(--red); stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 691.15; stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s linear;
}
.ring-progress.break { stroke: var(--green); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
}
.time { font-size: 3.4rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-status { color: var(--red); font-weight: 600; font-size: 0.95rem; margin-top: 6px; }
.ring-status.break { color: var(--green); }

.cycle-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 6px 0 18px; }
.dots { display: inline-flex; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #e6ddcb; display: inline-block; }
.dot.filled { background: var(--red); }
.cycle-text { color: var(--muted); font-size: 0.92rem; }

.controls { display: flex; align-items: center; justify-content: center; gap: 16px; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 16px 0 0; }

/* ---------- Ad slot (exactly one) ---------- */
.ad-slot {
  border: 2px dashed #cfc4ae; border-radius: var(--radius);
  padding: 18px 20px; text-align: center; background: #fffdf8;
}
.ad-label { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em; color: #a39a86; }
.ad-copy { margin: 10px 0 4px; font-weight: 600; }
.ad-sub { margin: 0 0 10px; color: var(--muted); font-size: 0.9rem; }
.ad-link {
  font-family: inherit; font-size: 0.92rem; font-weight: 700; color: var(--red);
  background: none; border: 0; cursor: pointer; padding: 0; text-decoration: none;
}
.ad-link:hover { text-decoration: underline; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 10px; text-align: center;
}
.stat-value { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.week-block { margin-top: 20px; }
.week-head { display: flex; align-items: baseline; justify-content: space-between; }
.week-sub { color: var(--muted); font-size: 0.88rem; }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 120px; margin-top: 14px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bar-val { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { width: 100%; max-width: 44px; min-height: 4px; background: var(--red); border-radius: 6px 6px 0 0; }
.bar.today { background: var(--dark); }
.bar-day { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
#historyToggle { margin-top: 14px; }

.history { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.history-list { list-style: none; margin: 0 0 10px; padding: 0; max-height: 260px; overflow-y: auto; }
.history-list li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid #f1ebdd; font-size: 0.92rem;
}
.history-list li:last-child { border-bottom: 0; }
.history-when { color: var(--muted); white-space: nowrap; }
.history-skipped { color: var(--muted); font-style: italic; }

/* ---------- Tasks ---------- */
.tasks-head { display: flex; align-items: baseline; justify-content: space-between; }
.tasks-count { color: var(--muted); font-size: 0.92rem; font-weight: 600; }
.tasks-copy { color: var(--muted); margin: 8px 0 16px; }
.add-task { display: flex; gap: 8px; align-items: center; }
.add-task input[type="text"] {
  flex: 1; min-width: 0; font-family: inherit; font-size: 0.95rem;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
}
.add-task input[type="number"] {
  width: 56px; font-family: inherit; font-size: 0.95rem; text-align: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; background: #fff;
}
.estimate-wrap { font-size: 1.15rem; }
.task-list { list-style: none; margin: 16px 0 0; padding: 0; }
.task-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid #f1ebdd;
}
.task-row:last-child { border-bottom: 0; }
.task-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--red); flex: none; cursor: pointer; }
.task-title {
  font-family: inherit; font-size: 0.98rem; text-align: left; flex: 1; min-width: 0;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink);
  overflow-wrap: anywhere;
}
.task-title:hover { text-decoration: underline; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-row.active .task-title { font-weight: 700; }
.focusing-badge {
  flex: none; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em;
  background: var(--red-soft); color: var(--red); border-radius: 999px; padding: 3px 8px;
}
.task-poms { flex: none; font-size: 0.95rem; letter-spacing: 1px; white-space: nowrap; }
.task-poms .pom-done { color: var(--red); }
.task-poms .pom-todo { color: #d8cfba; }
.task-icon-btn {
  flex: none; font-family: inherit; font-size: 0.95rem; background: none; border: 0;
  cursor: pointer; color: var(--muted); padding: 4px; line-height: 1;
}
.task-icon-btn:hover { color: var(--ink); }
.task-edit-input {
  flex: 1; min-width: 0; font-family: inherit; font-size: 0.98rem;
  border: 1px solid var(--red); border-radius: 8px; padding: 6px 8px;
}
.empty-state { color: var(--muted); margin: 16px 0 0; }
#clearDoneBtn { margin-top: 14px; }

/* ---------- How it works ---------- */
.how-card { background: var(--dark); color: #f4f1ea; border-color: var(--dark); }
.how-card h3 { color: #fff; }
.steps { margin: 0 0 18px; padding-left: 22px; }
.steps li { margin-bottom: 8px; }
.steps li::marker { color: var(--amber); font-weight: 700; }
.how-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Dialogs ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; background: rgba(30, 25, 18, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.dialog {
  background: #fff; border-radius: 18px; padding: 26px; width: 100%; max-width: 440px;
  max-height: calc(100vh - 48px); overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}
.dialog-wide { max-width: 720px; }
.dialog h2 { font-size: 1.4rem; margin-bottom: 6px; }
.dialog-sub { color: var(--muted); margin: 0 0 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; }
.field input {
  width: 100%; font-family: inherit; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; margin: 10px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--red); cursor: pointer; }
.dialog-note { color: var(--muted); font-size: 0.9rem; margin: 16px 0 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .plans { grid-template-columns: 1fr; } }
.plan {
  border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.plan-highlight { border: 2px solid var(--red); background: #fff8f5; }
.plan h3 { margin: 0; }
.plan-price { font-size: 1.5rem; font-weight: 800; }
.plan-price span { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.plan ul { margin: 0; padding-left: 18px; font-size: 0.92rem; }
.plan ul li { margin-bottom: 5px; }
.plan-cta { margin-top: auto; width: 100%; }
.preview-check { margin-top: 14px; font-weight: 600; }

/* ---------- Site footer ---------- */
.site-footer { text-align: center; margin-top: 28px; font-size: 0.85rem; }
.site-footer a { color: var(--muted); }
