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

[hidden] {
  display: none !important;
}

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;
  scroll-padding-top: 96px;
  scrollbar-color: var(--line-strong) transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--signal-soft);
  color: var(--ink);
}

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

a:hover {
  color: var(--signal-dark);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

input[type="number"] {
  caret-color: var(--signal);
}

.shell {
  width: min(calc(100% - var(--gut) * 2), var(--shell));
  margin-inline: auto;
}

.reading-shell {
  width: min(calc(100% - var(--gut) * 2), 780px);
}

.skip {
  position: absolute;
  top: -80px;
  left: 16px;
  z-index: 30;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

.skip:focus {
  top: 12px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  height: 72px;
  background: var(--paper);
  border-bottom: 1px solid var(--line-strong);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  color: var(--signal);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.site-header nav a:hover {
  color: var(--ink);
}

.site-header nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--signal);
}

main {
  flex: 1 0 auto;
  padding-top: 72px;
}

/* Hero and the live instrument */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  align-items: start;
  gap: clamp(32px, 5vw, 72px);
  min-height: min(calc(100svh - 72px), 760px);
  padding: clamp(72px, 13vh, 128px) 0 clamp(48px, 8vh, 96px);
}

.hero-copy {
  max-width: 36rem;
}

.hero-copy h1 {
  max-width: 9ch;
  margin: 0;
  font-size: clamp(3.25rem, 5.2vw, 4.6rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 0.96;
  text-wrap: balance;
}

.lede {
  max-width: 31ch;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1.65;
}

.hero-fact {
  max-width: 31ch;
  margin: 40px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.9375rem;
}

[data-enter] {
  animation: enter 700ms var(--ease) both;
}

.timer-panel[data-enter] {
  animation-delay: 80ms;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.timer-panel {
  width: 100%;
  padding: clamp(18px, 2.2vw, 30px);
  border: 1px solid var(--night-line);
  border-radius: var(--radius-lg);
  background: var(--night);
  color: var(--night-ink);
  color-scheme: dark;
  align-self: center;
}

.timer-panel :focus-visible {
  outline-color: var(--night-signal);
}

.panel-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  min-height: 26px;
}

.status-label,
.status-detail {
  margin: 0;
  font-size: 0.875rem;
}

.status-label {
  color: var(--night-ink);
  font-weight: 600;
}

.status-label::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  background: var(--night-signal);
  vertical-align: 0.1em;
}

.status-detail {
  color: var(--night-muted);
  text-align: right;
}

.clock-wrap {
  padding: clamp(16px, 2.5vw, 26px) 0 14px;
  text-align: center;
}

.clock {
  margin: 0;
  color: var(--night-ink);
  font-family: var(--clock);
  font-size: clamp(4rem, 8.8vw, 7.6rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
  line-height: 0.94;
  white-space: nowrap;
}

.progress {
  height: 2px;
  margin-top: 22px;
  background: var(--night-line);
  overflow: hidden;
}

.progress > span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--night-signal);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 160ms linear;
}

.presets-label {
  margin: 22px 0 0;
  color: var(--night-muted);
  font-size: 0.75rem;
}

.panel-hint {
  margin: 14px 0 0;
  color: var(--night-muted);
  font-size: 0.75rem;
  text-align: center;
}

.presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 22px;
}

.presets button,
.phase-tabs button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--night-line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--night-ink);
  font-size: 0.9375rem;
  transition: background 160ms var(--ease), transform 160ms var(--ease), border-color 160ms var(--ease);
}

.presets button:hover:not(:disabled),
.phase-tabs button:hover:not(:disabled) {
  background: var(--night-2);
  border-color: var(--night-muted);
  transform: translateY(-2px);
}

.presets button:active:not(:disabled),
.phase-tabs button:active:not(:disabled) {
  transform: translateY(1px);
}

.presets button[aria-pressed="true"],
.phase-tabs button[aria-pressed="true"] {
  background: var(--night-ink);
  border-color: var(--night-ink);
  color: var(--night);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

.actions button,
.settings button,
.record button,
.manual-actions button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--night-line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--night-ink);
  transition: background 160ms var(--ease), transform 160ms var(--ease), border-color 160ms var(--ease);
}

.actions button:hover:not(:disabled),
.settings button:hover:not(:disabled),
.record button:hover:not(:disabled),
.manual-actions button:hover:not(:disabled) {
  background: var(--night-2);
  border-color: var(--night-muted);
}

.actions button:active:not(:disabled),
.settings button:active:not(:disabled),
.record button:active:not(:disabled),
.manual-actions button:active:not(:disabled) {
  transform: translateY(1px);
}

button.primary,
.button-link.primary {
  min-height: 52px;
  min-width: 190px;
  padding: 0 22px;
  border: 1px solid var(--night-ink);
  background: var(--night-ink);
  color: var(--night);
  font-weight: 650;
}

button.primary:hover:not(:disabled),
.button-link.primary:hover {
  background: #fff;
  border-color: #fff;
  color: var(--night);
}

button.primary:active:not(:disabled) {
  transform: translateY(1px);
}

.text-button {
  border-color: transparent !important;
  color: var(--night-muted) !important;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-button:hover:not(:disabled) {
  background: transparent !important;
  color: var(--night-ink) !important;
}

.error {
  margin: 16px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--night-signal);
  background: #2a1510;
  color: #ffc2b2;
  font-size: 0.875rem;
}

.live {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--night-muted);
  font-size: 0.8125rem;
  text-align: center;
}

/* Panel details */
.settings {
  margin-top: 18px;
  border-top: 1px solid var(--night-line);
}

.settings summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 4px 0;
  color: var(--night-muted);
  font-size: 0.875rem;
  cursor: pointer;
  list-style: none;
}

.settings summary::-webkit-details-marker {
  display: none;
}

.settings summary::after {
  content: "＋";
  margin-left: auto;
  color: var(--night-muted);
  font-family: var(--mono);
  font-size: 0.875rem;
}

.settings[open] summary::after {
  content: "－";
}

.settings summary:hover {
  color: var(--night-ink);
}

.settings-body {
  padding: 6px 0 4px;
}

.time-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}

.time-fields legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.time-fields label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--night-muted);
  font-size: 0.875rem;
}

input[type="number"] {
  width: 74px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--night-line);
  border-radius: var(--radius);
  background: var(--night-2);
  color: var(--night-ink);
  font-family: var(--mono);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

input[type="number"]:focus-visible {
  border-color: var(--night-signal);
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--night-muted);
  font-size: 0.875rem;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--night-ink);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  margin-bottom: 12px;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--night-muted);
  font-size: 0.8125rem;
}

.settings-grid input {
  width: 100%;
}

.small {
  color: var(--night-muted);
  font-size: 0.8125rem;
  line-height: 1.55;
}

/* Completion and record */
.done-card {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--night-signal);
  border-radius: var(--radius);
  background: #251711;
}

.done-kicker {
  margin: 0 0 4px;
  color: var(--night-signal);
  font-size: 0.8125rem;
  font-weight: 650;
}

.done-text {
  margin: 0;
  color: var(--night-ink);
  font-size: 1.0625rem;
}

.done-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.done-actions .primary {
  min-height: 44px;
  min-width: 0;
}

.phase-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.phase-tabs button {
  flex: 1 1 0;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.phase-tabs span {
  margin-left: 4px;
  opacity: 0.65;
  font-family: var(--mono);
}

.cycle-dots {
  display: flex;
  gap: 7px;
  justify-content: center;
  margin-top: 14px;
}

.cycle-dots span {
  width: 8px;
  height: 8px;
  border: 1px solid var(--night-line);
  background: transparent;
}

.cycle-dots span.is-filled {
  background: var(--night-signal);
  border-color: var(--night-signal);
}

.record {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--night-line);
}

.record h2 {
  margin: 0 0 2px;
  color: var(--night-ink);
  font-size: 0.875rem;
}

.record p {
  margin: 0;
  color: var(--night-muted);
  font-size: 0.875rem;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.manual-copy {
  margin-top: 14px;
}

.manual-copy label {
  display: block;
  margin-bottom: 6px;
  color: var(--night-muted);
  font-size: 0.8125rem;
}

.manual-copy textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--night-line);
  border-radius: var(--radius);
  background: var(--night-2);
  color: var(--night-ink);
  font-size: 0.875rem;
  line-height: 1.6;
}

.manual-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Content sections */
.section {
  padding: clamp(64px, 9vh, 96px) 0;
  border-top: 1px solid var(--line);
}

.section h2 {
  margin: 0 0 32px;
  font-size: clamp(2rem, 3.2vw, 3rem);
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1.02;
  text-wrap: balance;
}

.how {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}

.how h2 {
  margin: 0;
}

.how .note {
  grid-column: 2;
  margin-top: 0;
}

.steps {
  max-width: 62ch;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 0 0 24px 48px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  counter-increment: step;
}

.steps li:last-child {
  margin-bottom: 0;
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  color: var(--signal);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.steps strong {
  display: block;
  margin-bottom: 2px;
  font-weight: 650;
}

.note {
  max-width: 62ch;
  margin: 32px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.prose,
.faq {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}

.prose h2,
.faq h2 {
  margin: 0;
}

.section-body {
  min-width: 0;
}

.prose p {
  max-width: 64ch;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 1.0625rem;
  line-height: 1.8;
}

.definitions {
  margin: 0;
}

.definitions > div {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.definitions > div:last-child {
  border-bottom: 1px solid var(--line);
}

.definitions dt {
  font-weight: 650;
}

.definitions dd {
  margin: 0;
  color: var(--muted);
}

.faq details {
  border-top: 1px solid var(--line);
}

.faq details:last-child {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  min-height: 56px;
  padding: 14px 0;
  font-size: 1.0625rem;
  font-weight: 600;
  cursor: pointer;
}

.faq details p {
  max-width: 64ch;
  margin: 0 0 18px;
  color: var(--muted);
}

/* Ads */
.ad-wrap {
  width: min(calc(100% - var(--gut) * 2), var(--shell));
  margin: 0 auto;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.ad-wrap:has([data-tool-ad-slot][hidden]) {
  display: none;
}

[data-tool-ad-slot] {
  color: var(--muted);
  font-size: 0.875rem;
}

[data-tool-ad-slot] small {
  display: block;
  margin-bottom: 4px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

[data-tool-ad-slot] strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

[data-tool-ad-slot] p {
  margin: 0;
}

[data-tool-ad-slot] a {
  color: var(--ink);
}

/* Closing */
.closing {
  margin-top: 0;
  border-top: 1px solid var(--night-line);
  background: var(--night);
  color: var(--night-ink);
}

.footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 32px;
  min-height: 260px;
  padding: 64px 0;
}

.footer-inner p {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
}

.footer-inner .small {
  display: inline-block;
  margin-top: 12px;
  color: var(--night-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.footer-inner nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
}

.footer-inner a {
  color: var(--night-muted);
  font-size: 0.9375rem;
  text-decoration: none;
}

.footer-inner a:hover {
  color: var(--night-ink);
}

/* 404 */
.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}

.button-link:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.button-link.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.button-link.primary:hover {
  background: #000;
  color: var(--paper);
}

/* Fullscreen */
.timer-panel:fullscreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 6vh 6vw;
  border: 0;
  border-radius: 0;
  background: var(--night);
}

.timer-panel:fullscreen .clock {
  font-size: clamp(5rem, 20vw, 15rem);
}

.timer-panel:fullscreen .presets,
.timer-panel:fullscreen .settings,
.timer-panel:fullscreen .record,
.timer-panel:fullscreen .manual-copy {
  display: none;
}

.timer-panel:fullscreen .actions {
  margin-top: 32px;
}

.timer-panel:fullscreen .actions button {
  border-color: var(--night-muted);
}

/* Reading and 404 pages */
.intro {
  max-width: 46rem;
  padding: clamp(48px, 9vh, 96px) 0 32px;
}

.intro h1 {
  margin: 0;
  font-size: clamp(2.6rem, 4.2vw, 4rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 0.98;
  text-wrap: balance;
}

.intro .lede {
  max-width: 42rem;
  margin-top: 20px;
}

.article {
  padding-bottom: 48px;
}

.article h2 {
  margin: 40px 0 12px;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.article p,
.article li {
  max-width: 68ch;
  color: var(--muted);
}

.article ul {
  padding-left: 1.25em;
}

.article code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.875em;
}

/* Responsive */
@media (max-width: 1100px) {
  .hero {
    grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
    gap: 40px;
  }

  .hero-copy h1 {
    font-size: clamp(2.9rem, 5vw, 3.8rem);
  }
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 32px;
    padding: 40px 0 56px;
  }

  .hero-copy {
    max-width: 40rem;
  }

  .hero-copy h1 {
    max-width: none;
    font-size: clamp(2.8rem, 8vw, 3.8rem);
  }

  .lede,
  .hero-fact {
    max-width: 42rem;
  }

  .hero-fact {
    margin-top: 24px;
  }

  .timer-panel {
    max-width: 44rem;
  }

  .how {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .how h2 {
    margin-bottom: 8px;
  }

  .how .note {
    grid-column: auto;
    margin-top: 0;
  }
}

@media (max-width: 700px) {
  .site-header,
  .header-inner {
    height: 60px;
  }

  main {
    padding-top: 60px;
  }

  .site-header nav {
    gap: 14px;
  }

  .site-header nav a {
    font-size: 0.875rem;
  }

  .hero {
    padding: 28px 0 48px;
  }

  .hero-copy h1 {
    font-size: 2.6rem;
  }

  .lede {
    margin-top: 18px;
    font-size: 1rem;
  }

  .hero-fact {
    margin-top: 20px;
    padding-top: 12px;
    font-size: 0.875rem;
  }

  .timer-panel {
    padding: 18px 16px 16px;
  }

  .clock {
    font-size: clamp(3.2rem, 17vw, 5rem);
  }

  .presets button {
    padding: 0 6px;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions .primary {
    grid-column: 1 / -1;
    width: 100%;
  }

  .actions button {
    width: 100%;
  }

  .actions:has(#add-minute) #fullscreen {
    grid-column: 1 / -1;
  }

  .phase-tabs button {
    padding: 0 6px;
    font-size: 0.8125rem;
    white-space: nowrap;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .record {
    align-items: flex-start;
  }

  .record-actions {
    width: 100%;
  }

  .section {
    padding: 64px 0;
  }

  .section h2 {
    margin-bottom: 24px;
    font-size: 1.9rem;
  }

  .prose,
  .faq {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .prose h2,
  .faq h2 {
    margin-bottom: 8px;
  }

  .steps li {
    padding-left: 36px;
  }

  .definitions > div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    align-items: start;
    min-height: 0;
    padding: 48px 0;
    gap: 28px;
  }
}

@media (max-width: 360px) {
  .brand span {
    display: none;
  }

  .site-header nav {
    gap: 10px;
  }

  .clock {
    font-size: 3.05rem;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
