/* 25MINUTE — Quiet Productivity
   Design tokens ---------------------------------------------------------- */

:root {
  --bg: #f6f5f2;
  --bg-elev: #fffefb;
  --text: #1b1b1d;
  --text-soft: #4a4a4e;
  --muted: #8a8a8e;
  --hairline: rgba(0, 0, 0, 0.09);
  --hairline-strong: rgba(0, 0, 0, 0.18);
  --accent: #c2803d;         /* focus: muted amber */
  --accent-soft: rgba(194, 128, 61, 0.14);
  --btn-bg: #1b1b1d;
  --btn-fg: #f6f5f2;
  --shadow: 0 18px 60px rgba(20, 20, 20, 0.14);

  --font-ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Segoe UI", Roboto, "Noto Sans JP", system-ui, sans-serif;
  --font-num: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI Variable Display", "Segoe UI", Roboto, system-ui, sans-serif;

  --ring: clamp(272px, 58vmin, 420px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

/* Break: a touch cooler, a touch calmer */
:root[data-mode="short"],
:root[data-mode="long"] {
  --bg: #f1f4f3;
  --bg-elev: #fbfdfc;
  --accent: #5e9b8c;
  --accent-soft: rgba(94, 155, 140, 0.16);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131314;
    --bg-elev: #1c1c1e;
    --text: #ececea;
    --text-soft: #b9b9b6;
    --muted: #7f7f84;
    --hairline: rgba(255, 255, 255, 0.11);
    --hairline-strong: rgba(255, 255, 255, 0.22);
    --accent: #d69a58;
    --accent-soft: rgba(214, 154, 88, 0.16);
    --btn-bg: #ececea;
    --btn-fg: #131314;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
  :root:not([data-theme="light"])[data-mode="short"],
  :root:not([data-theme="light"])[data-mode="long"] {
    --bg: #111517;
    --bg-elev: #191e20;
    --accent: #71b1a1;
    --accent-soft: rgba(113, 177, 161, 0.16);
  }
}

:root[data-theme="dark"] {
  --bg: #131314;
  --bg-elev: #1c1c1e;
  --text: #ececea;
  --text-soft: #b9b9b6;
  --muted: #7f7f84;
  --hairline: rgba(255, 255, 255, 0.11);
  --hairline-strong: rgba(255, 255, 255, 0.22);
  --accent: #d69a58;
  --accent-soft: rgba(214, 154, 88, 0.16);
  --btn-bg: #ececea;
  --btn-fg: #131314;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
:root[data-theme="dark"][data-mode="short"],
:root[data-theme="dark"][data-mode="long"] {
  --bg: #111517;
  --bg-elev: #191e20;
  --accent: #71b1a1;
  --accent-soft: rgba(113, 177, 161, 0.16);
}

/* Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.8s var(--ease), color 0.4s;
}

body.is-running { overflow: hidden; }

a { color: inherit; text-decoration-color: var(--hairline-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.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;
}

[hidden] { display: none !important; }

/* Header ---------------------------------------------------------------- */

.site-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 22px 0;
  pointer-events: none;
}
.site-header > * { pointer-events: auto; }

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}
.parent-link {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s, opacity 0.5s var(--ease);
}
.parent-link:hover { color: var(--text); text-decoration: underline; }

.brand {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  transition: opacity 0.5s var(--ease);
}
.brand-sub {
  font-weight: 400;
  letter-spacing: 0.02em;
  font-size: 12px;
  color: var(--muted);
  transition: opacity 0.4s var(--ease);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  transition: color 0.2s, background-color 0.2s, opacity 0.5s var(--ease), transform 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--hairline); }
.icon-btn:active { transform: scale(0.94); }

/* Timer stage ----------------------------------------------------------- */

main { display: block; }

.timer-stage {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 20px 40px;
  gap: 0;
}

/* Mobile notice（狭い画面幅でのみ、一度だけ表示） */
.notice {
  display: none;
  width: min(100%, 420px);
  margin: 0 0 20px;
  padding: 9px 6px 9px 14px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--hairline);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.6;
}
.notice p { margin: 0; flex: 1; }
.notice-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  transition: color 0.2s, background-color 0.2s;
}
.notice-close:hover { color: var(--text); background: var(--hairline-strong); }
@media (max-width: 640px) {
  .notice { display: flex; }
}
.is-running .notice,
.is-complete .notice { display: none; }

/* Task */
.task {
  width: min(100%, 420px);
  margin: 0 0 22px;
  text-align: center;
  min-height: 36px;
}
.task-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 15px;
  text-align: center;
  padding: 6px 8px;
  border-radius: 0;
  transition: border-color 0.2s, color 0.2s;
}
.task-input::placeholder { color: var(--muted); opacity: 0.8; }
.task-input:hover { border-bottom-color: var(--hairline); }
.task-input:focus { outline: none; border-bottom-color: var(--hairline-strong); color: var(--text); }
.task-display {
  display: none;
  margin: 0;
  padding: 6px 8px;
  font-size: 15px;
  color: var(--text-soft);
  overflow-wrap: anywhere;
}
.is-running .task-input { display: none; }
.is-running .task-display { display: block; }
.is-running .task-display:empty { display: none; }

/* Clock */
.clock {
  position: relative;
  width: var(--ring);
  height: var(--ring);
  display: grid;
  place-items: center;
}
.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}
.ring circle {
  fill: none;
  stroke-width: 1.1;
  stroke-linecap: round;
}
.ring-track { stroke: var(--hairline); }
.ring-progress {
  stroke: var(--accent);
  stroke-dasharray: 304.73;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.8s, opacity 0.6s;
}
.is-idle .ring-progress { opacity: 0.55; }
.is-complete .ring-progress {
  stroke-dashoffset: 0 !important;
  transition: stroke-dashoffset 0.9s var(--ease), stroke 0.4s;
  animation: ring-glow 1.6s var(--ease) 1;
}
@keyframes ring-glow {
  0%   { filter: drop-shadow(0 0 0 transparent); stroke-width: 1.1; }
  35%  { filter: drop-shadow(0 0 6px var(--accent)); stroke-width: 1.8; }
  100% { filter: drop-shadow(0 0 0 transparent); stroke-width: 1.1; }
}

.clock-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 84%;
}

.mode-label {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  color: var(--muted);
  text-transform: uppercase;
  transition: color 0.4s;
}
.is-complete .mode-label { color: var(--accent); }

.time {
  margin: 0;
  font-family: var(--font-num);
  font-size: calc(var(--ring) * 0.28);
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  color: var(--text);
  white-space: nowrap;
  transition: color 0.4s, opacity 0.4s;
}
.time .colon {
  position: relative;
  top: -0.07em;
  opacity: 0.45;
  margin: 0 0.01em;
  font-weight: 200;
}
.is-paused .time { opacity: 0.55; }

.status-line {
  margin: 10px 0 0;
  min-height: 1.4em;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color 0.4s;
}
.is-complete .status-line { color: var(--accent); }

/* Controls */
.controls {
  margin-top: 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.btn-primary {
  min-width: 212px;
  padding: 15px 44px;
  border: 1px solid var(--btn-bg);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  transition: transform 0.16s var(--ease), background-color 0.25s, color 0.25s, border-color 0.25s, opacity 0.25s, box-shadow 0.25s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.965); }

/* While running, the primary action is PAUSE and it should step back */
.is-running .btn-primary {
  background: transparent;
  color: var(--muted);
  border-color: var(--hairline-strong);
}
.is-running .btn-primary:hover { color: var(--text); border-color: var(--text); opacity: 1; }

.controls { transition: opacity 0.4s var(--ease); }
.is-complete .controls { opacity: 0; pointer-events: none; }

.controls-sub {
  display: flex;
  gap: 26px;
  min-height: 20px;
}
.btn-text {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s, transform 0.15s;
}
.btn-text:hover { color: var(--text); }
.btn-text:active { transform: scale(0.95); }

/* Progress dots + today */
.progress {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: opacity 0.5s var(--ease), visibility 0.5s;
}
.dots { display: flex; gap: 11px; }
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  transition: background-color 0.5s var(--ease), border-color 0.5s, transform 0.5s var(--ease);
}
.dot.is-filled { background: var(--text); border-color: var(--text); }
.dot.is-new { animation: dot-pop 0.7s var(--ease) 1; }
@keyframes dot-pop {
  0%   { transform: scale(0.6); }
  50%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}
.today {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.today span { color: var(--text-soft); }

/* Stats */
.stats {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: opacity 0.5s var(--ease), visibility 0.5s;
}
.stats p { margin: 0; }
.stat-streak:empty, .stat-focus:empty { display: none; }
.week {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 26px;
  margin-top: 6px;
}
.week-bar {
  width: 10px;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.week-bar i {
  display: block;
  width: 100%;
  min-height: 2px;
  border-radius: 2px;
  background: var(--hairline-strong);
  transition: height 0.6s var(--ease), background-color 0.4s;
}
.week-bar.has-focus i { background: var(--accent); }
.week-bar.is-today i { box-shadow: 0 0 0 1px var(--hairline); }
.privacy-note {
  margin-top: 16px !important;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  opacity: 0.75;
}

/* FOCUS VIEW ------------------------------------------------------------ */

.is-running .brand { opacity: 0.35; }
.is-running .brand-sub { opacity: 0; }
.is-running .parent-link { opacity: 0; pointer-events: none; }
.is-running .icon-btn#settingsBtn { opacity: 0.35; }
.is-running .icon-btn#settingsBtn:hover { opacity: 1; }
.is-running .progress,
.is-running .stats,
.is-running .content,
.is-running .site-footer {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.content, .site-footer { transition: opacity 0.5s var(--ease), visibility 0.5s; }

/* SEO content ----------------------------------------------------------- */

.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 64px 24px 48px;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.95;
  border-top: 1px solid var(--hairline);
}
.content h2 {
  margin: 56px 0 14px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.5;
  color: var(--text);
}
.content h2:first-child { margin-top: 0; }
.content p { margin: 0 0 16px; }
.content ol, .content ul { margin: 0 0 16px; padding-left: 1.4em; }
.content li { margin-bottom: 6px; }
.content strong { color: var(--text); font-weight: 600; }

.site-footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 24px 48px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.site-footer p { margin: 0; }

/* Settings dialog ------------------------------------------------------- */

.settings {
  width: min(440px, calc(100vw - 28px));
  max-height: min(88vh, 760px);
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 22px;
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
}
.settings::backdrop {
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.settings[open] { animation: dialog-in 0.28s var(--ease); }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.settings-form { margin: 0; padding: 22px 26px 24px; }
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.settings-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.settings-group {
  border: 0;
  margin: 0;
  padding: 16px 0 6px;
}
.settings-group + .settings-group { border-top: 1px solid var(--hairline); }
.settings-group legend {
  padding: 0;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
}
.field-row label { font-size: 14px; color: var(--text); }
.field-label { display: flex; flex-direction: column; gap: 1px; }
.field-hint {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.field-limit {
  display: none;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.field-limit.is-visible { display: block; animation: limit-in 0.2s var(--ease); }
@keyframes limit-in { from { opacity: 0; } to { opacity: 1; } }
.field-note {
  margin: 2px 0 8px;
  font-size: 12px;
  color: var(--muted);
}
.field-row.is-disabled { opacity: 0.4; }
.field-row.is-disabled input,
.field-row.is-disabled button { cursor: not-allowed; }

/* 「？」チップと、その場に開く説明 */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--hairline-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  vertical-align: 1px;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.help-btn:hover { color: var(--text); border-color: var(--text); }
.help-btn[aria-expanded="true"] { background: var(--text); border-color: var(--text); color: var(--bg-elev); }
.field-help {
  margin: -2px 0 10px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--hairline);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-soft);
}

input[type="number"] {
  width: 76px;
  padding: 7px 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"]:focus { outline: none; border-color: var(--text); }

.segmented {
  display: flex;
  margin: 6px 0 8px;
  padding: 3px;
  border: 1px solid var(--hairline);
  border-radius: 11px;
  background: var(--hairline);
}
.segmented label {
  flex: 1;
  position: relative;
  text-align: center;
}
.segmented input {
  position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer;
}
.segmented span {
  display: block;
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
}
.segmented input:checked + span {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.volume-row { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  width: 130px;
  accent-color: var(--text);
  margin: 0;
}
.btn-small {
  padding: 6px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 12px;
  color: var(--text-soft);
  transition: border-color 0.2s, color 0.2s, transform 0.15s;
}
.btn-small:hover { color: var(--text); border-color: var(--text); }
.btn-small:active { transform: scale(0.95); }

/* Switch */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 42px; height: 24px;
  margin: 0;
  border-radius: 999px;
  background: var(--hairline-strong);
  cursor: pointer;
  transition: background-color 0.25s;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg-elev);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s var(--ease);
}
.switch:checked { background: var(--text); }
.switch:checked::after { transform: translateX(18px); }

.settings-foot {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* Mobile ---------------------------------------------------------------- */

@media (max-width: 480px) {
  .site-header { padding-left: 16px; padding-right: 10px; }
  .brand-sub { display: none; }
  .header-left { gap: 10px; }
  .parent-link { font-size: 10.5px; }
  .timer-stage { padding: 64px 16px 32px; }
  .btn-primary { min-width: 190px; padding: 14px 36px; }
  .content { padding: 48px 20px 40px; font-size: 14.5px; }
  .content h2 { font-size: 17px; margin-top: 44px; }
  input[type="range"] { width: 110px; }
}

@media (max-height: 640px) {
  :root { --ring: clamp(220px, 50vmin, 420px); }
  .controls { margin-top: 22px; }
  .progress { margin-top: 22px; }
  .stats { margin-top: 18px; }
}

/* Reduced motion -------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  .ring-progress { transition: none !important; }
  html { scroll-behavior: auto; }
}
