@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/inter-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/inter-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --accent: #0f6b6e;
  --accent-hover: #0b5457;
  --ink: #1d2b36;
  --muted: #5d6b75;
  --inset: #f3f6f7;
  --line: #d7e0e4;
  --card: #ffffff;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --btn-radius: 12px;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: Inter, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: linear-gradient(#4d4e4e 0%, #716861 30%, #8a7968 55%, #a6865a 85%, #ac854e 100%);
  background-attachment: fixed;
}

@media (max-width: 800px), (hover: none) {
  body { background-attachment: scroll; }
}

button,
input,
select { font: inherit; color: inherit; }

button,
a,
input,
select,
summary { touch-action: manipulation; }

img, svg { display: block; }

p, ul, ol { margin: 0 0 16px; }
p:last-child, ul:last-child, ol:last-child { margin-bottom: 0; }

h1, h2, h3 {
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: break-word;
}

h1 { font-size: 2.2rem; margin: 0 0 12px; letter-spacing: -0.02em; }
h2 { font-size: 1.75rem; margin: 0 0 12px; }
h3 { font-size: 1.25rem; margin: 0 0 8px; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }

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

.skip {
  position: absolute;
  left: 16px;
  top: -48px;
  background: var(--card);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: var(--btn-radius);
  z-index: 2;
}
.skip:focus { top: 8px; }

.wrap {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

@media (min-width: 1280px) {
  .wrap { width: min(1180px, calc(100% - 100px)); }
}

.site-header {
  background: var(--card);
  color: var(--ink);
}

.header-bar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  min-height: 44px;
}
.logo:hover { color: var(--ink); }
.logo svg { width: 24px; height: 24px; color: var(--accent); }

.menu-btn {
  display: none;
  min-height: 48px;
  min-width: 48px;
  padding: 0 16px;
  border-radius: var(--btn-radius);
  border: 1px solid var(--line);
  background: var(--card);
  font-weight: 700;
  cursor: pointer;
}

#site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

#site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  color: var(--ink);
  text-decoration: none;
}

#site-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 6px;
}

@media (max-width: 1080px) {
  .header-bar { flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; }
  #site-nav { display: none; flex-basis: 100%; padding-bottom: 8px; }
  #site-nav.is-open { display: block; }
  #site-nav ul { flex-direction: column; gap: 0; }
  #site-nav a { width: 100%; }
}

main { flex: 1; padding: 16px 0 56px; }

.tool-layout { display: grid; gap: 24px; }
.main-col { display: grid; gap: 24px; align-content: start; }

@media (min-width: 1200px) {
  .tool-layout.has-side { grid-template-columns: 760px minmax(0, 1fr); align-items: start; }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

@media (max-width: 700px) {
  .card { padding: 20px; }
}

.tool-stack { display: grid; gap: 8px; }
.tool-stack > * { margin-block: 0; }
.lede { color: var(--muted); max-width: 68ch; }
.hint { color: var(--muted); margin: 0; max-width: 68ch; }
.bpm-block .hint { text-align: center; max-width: none; }
.meter-tag, .unit-tag { text-align: center; font-weight: 700; margin: 0; }
.unit-tag { color: var(--ink); }
.meter-tag { color: var(--muted); font-weight: 400; }

.status {
  min-height: 28px;
  margin: 0;
  font-weight: 700;
}

.flash,
.notice {
  margin: 0;
  padding: 12px;
  background: var(--inset);
  border-radius: var(--btn-radius);
  border: 1px solid var(--line);
}

.bpm-block { display: grid; gap: 8px; }
.bpm-block label, .field label, .checkline { font-weight: 700; }

.bpm-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: 12px;
  align-items: center;
}

.bpm-input {
  width: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  padding: 0;
  min-height: 64px;
}

.icon-btn {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.field { display: grid; gap: 8px; }
fieldset.field { border: 0; margin: 0; padding: 0; min-inline-size: 0; }
legend { font-weight: 700; padding: 0; }

.slider-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: -4px;
}

input[type="range"] {
  width: 100%;
  height: 48px;
  margin: 0;
  accent-color: var(--accent);
  background: transparent;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

select {
  min-height: 48px;
  width: 100%;
  border-radius: var(--btn-radius);
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0 12px;
}

.btn,
.btn-primary,
.btn-tap,
.example,
.beat-edit {
  border-radius: var(--btn-radius);
  min-height: 48px;
  cursor: pointer;
}

.btn,
.btn-tap,
.example,
.beat-edit {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-tap, .btn-primary { width: 100%; }

.btn {
  padding: 0 16px;
  font-weight: 700;
  background: var(--inset);
}

.btn:hover, .btn-tap:hover, .example:hover, .beat-edit:hover, .icon-btn:hover {
  background: var(--inset);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--accent);
  font-weight: 700;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-primary:disabled,
.btn:disabled,
.beat-edit:disabled {
  background: var(--inset);
  color: var(--ink);
  border: 1px solid var(--line);
  cursor: not-allowed;
  opacity: 1;
}

.btn-tap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 1.05rem;
  background: var(--inset);
}

body[data-page="tap"] .btn-tap { min-height: 88px; font-size: 1.35rem; }
body[data-page="tap"] .tool-card { max-width: 760px; margin-inline: auto; }

.beats { display: flex; flex-wrap: wrap; gap: 8px; }
.beat {
  flex: 1 1 72px;
  min-width: 44px;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: var(--btn-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--card);
}
.beat svg { width: 20px; height: 20px; }
.beat.is-current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.subs { display: flex; gap: 6px; min-height: 12px; }
.pip {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: var(--line);
}
.pip.is-current { background: var(--accent); }
.position {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.position strong { color: var(--ink); font-size: 1.25rem; }
.is-off { display: none; }

.field-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}
.field-error svg { color: var(--accent); flex: none; }

.choice-grid, .example-grid, .presets, .split, .beat-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { grid-template-columns: 1fr 1fr; }
.beat-edit-grid { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }

.choice { display: block; position: relative; height: 100%; cursor: pointer; }
.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.choice-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 48px;
  height: 100%;
  padding: 12px 40px 12px 12px;
  border: 2px solid var(--line);
  border-radius: var(--btn-radius);
  background: var(--card);
  position: relative;
}
.choice-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.choice-title { font-weight: 700; }
.choice-detail { color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.choice .check {
  visibility: hidden;
  color: var(--accent);
  position: absolute;
  top: 10px;
  right: 8px;
}
.choice .check svg { width: 24px; height: 24px; }
.choice:has(input:checked) .choice-body { border-color: var(--accent); background: var(--inset); }
.choice:has(input:checked) .check { visibility: visible; }
.choice:has(input:focus-visible) .choice-body {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.choice:has(input:disabled) { cursor: not-allowed; }
.choice:has(input:disabled) .choice-body { background: var(--inset); }

.sketch { display: inline-flex; align-items: flex-end; gap: 3px; height: 28px; }
.sketch i {
  display: block;
  width: 4px;
  height: 14px;
  background: var(--ink);
  border-radius: 2px;
}
.sketch i.tall { height: 28px; }

.example {
  text-align: left;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
}
.example-title { font-weight: 700; }
.example-detail { color: var(--muted); }
.example.is-selected { border: 2px solid var(--accent); background: var(--inset); }

.beat-edit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 8px 12px;
  text-align: left;
  background: var(--card);
}
.beat-edit[data-state="accent"] { border: 2px solid var(--accent); }
.beat-edit[data-state="silent"] { border-style: dashed; }
.beat-num { font-variant-numeric: tabular-nums; font-weight: 700; }
.beat-name { font-weight: 700; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.actions .btn, .actions .btn-primary { width: auto; }

details.advanced, .faq { border-top: 1px solid var(--line); }
details.advanced { margin-top: 8px; }
details.advanced summary, .faq summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
details.advanced summary::-webkit-details-marker,
.faq summary::-webkit-details-marker { display: none; }
details.advanced summary::after,
.faq summary::after {
  content: "";
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  flex: none;
  margin-bottom: 4px;
}
details[open] summary::after { transform: rotate(225deg); margin-bottom: -4px; }
.advanced-body, .faq p, .faq + .faq p { padding-bottom: 8px; }
.advanced-body { display: grid; gap: 16px; padding-top: 8px; }

.support { margin-top: 56px; display: grid; gap: 24px; }
.page-start { display: grid; gap: 24px; }
.prose p, .prose li { max-width: 68ch; }
.prose ol, .prose ul { padding-left: 1.25rem; }
.prose li + li { margin-top: 8px; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: break-word;
}
th { font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.form-grid { display: grid; gap: 16px; }
@media (min-width: 800px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .wide { grid-column: 1 / -1; }
}

.number-input, .text-input {
  min-height: 48px;
  width: 100%;
  border-radius: var(--btn-radius);
  border: 1px solid var(--line);
  padding: 0 12px;
  font-variant-numeric: tabular-nums;
  background: var(--card);
}

.now-line { display: flex; align-items: baseline; gap: 12px; margin: 0; flex-wrap: wrap; }
.now-bpm {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.plan { margin: 0; padding-left: 1.25rem; }
.plan li.is-current { font-weight: 700; }

.estimate-label { margin: 0; font-weight: 700; text-align: center; }
.estimate {
  margin: 0;
  min-height: 4.4rem;
  text-align: center;
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.site-footer {
  background: var(--card);
  color: var(--ink);
  padding: 32px 0;
}
.footer-grid { display: grid; gap: 12px; }
.tagline { font-weight: 700; margin: 0; }
.footer-nav { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-nav a { font-weight: 700; }
.related { color: var(--muted); margin: 0; max-width: 68ch; }

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 28px;
  width: min(440px, calc(100% - 32px));
  box-shadow: var(--shadow);
  color: var(--ink);
}
dialog::backdrop { background: rgba(29, 43, 54, 0.45); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.dialog-actions .btn, .dialog-actions .btn-primary { flex: 1; width: auto; }

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

@media (max-width: 420px) {
  .presets { grid-template-columns: 1fr 1fr; }
}

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

@media (forced-colors: active) {
  .btn-primary { border: 2px solid ButtonText; }
  .beat.is-current { border: 2px solid Highlight; }
}
