:root {
  color-scheme: light;
  --paper: #f4eee5;
  --paper-strong: #fffaf3;
  --ink: #281d16;
  --muted: #75665c;
  --line: rgba(76, 49, 31, 0.15);
  --wood: #442817;
  --wood-deep: #23150e;
  --wood-soft: #6c4227;
  --gold: #e3b45d;
  --gold-bright: #f5d38b;
  --sage: #55715c;
  --sage-soft: #e0eadf;
  --danger: #a1483f;
  --shadow: 0 24px 70px rgba(61, 38, 23, 0.13);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 15px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171310;
  --paper-strong: #211b17;
  --ink: #f6ecdf;
  --muted: #b6a79d;
  --line: rgba(245, 211, 139, 0.15);
  --sage-soft: #26362c;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 9% 0%, rgba(227, 180, 93, 0.18), transparent 28rem),
    radial-gradient(circle at 100% 18%, rgba(85, 113, 92, 0.13), transparent 31rem),
    var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  position: relative;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--wood-soft), var(--wood-deep));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.11), 0 7px 20px rgba(51, 30, 17, 0.22);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: var(--gold);
  left: 20px;
  transform-origin: bottom center;
}

.brand-mark::before {
  width: 2px;
  height: 24px;
  bottom: 8px;
  transform: rotate(18deg);
}

.brand-mark::after {
  width: 9px;
  height: 7px;
  bottom: 22px;
  margin-left: -3px;
  border-radius: 50%;
  transform: rotate(18deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions a {
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
}

.top-actions a:hover {
  color: var(--ink);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-strong);
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 18px auto 48px;
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 26px;
  align-items: start;
}

.metronome-card,
.practice-column {
  min-width: 0;
}

.section-kicker,
.eyebrow {
  color: var(--sage);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.metronome-card > h1,
.practice-heading h2 {
  margin: 7px 0 20px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-weight: 600;
  line-height: 1.12;
}

.metronome-card > h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.metronome-case {
  position: sticky;
  top: 18px;
  overflow: hidden;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 38%),
    repeating-linear-gradient(95deg, rgba(255, 255, 255, 0.012) 0 2px, rgba(0, 0, 0, 0.018) 2px 6px),
    linear-gradient(160deg, var(--wood-soft), var(--wood) 47%, var(--wood-deep));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.11);
  color: #fff8ee;
  transition: box-shadow 100ms ease;
}

.metronome-case.flash {
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(245, 211, 139, 0.38), inset 0 0 45px rgba(245, 211, 139, 0.15);
}

.tempo-stepper {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 14px;
}

.tempo-stepper > button,
.mini-stepper button,
.segmented button {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.075);
  color: #fff8ee;
  cursor: pointer;
}

.tempo-stepper > button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.55rem;
}

.tempo-stepper > button:hover,
.mini-stepper button:hover,
.segmented button:hover {
  background: rgba(255, 255, 255, 0.13);
}

.tempo-display {
  text-align: center;
}

.tempo-display strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4.2rem, 11vw, 6.3rem);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.07em;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}

.tempo-display span {
  display: block;
  margin-top: 10px;
  color: var(--gold-bright);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.tempo-term {
  margin: 10px 0 5px;
  color: rgba(255, 248, 238, 0.65);
  text-align: center;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: 0.92rem;
}

.pendulum {
  position: relative;
  height: 112px;
  margin: 2px auto 0;
}

.pendulum-rod {
  position: absolute;
  z-index: 1;
  top: 15px;
  left: 50%;
  width: 3px;
  height: 86px;
  border-radius: 999px;
  background: linear-gradient(90deg, #a8752f, var(--gold-bright), #966323);
  box-shadow: 0 4px 9px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%) rotate(0deg);
  transform-origin: 50% 9px;
}

.pendulum-rod span {
  position: absolute;
  left: 50%;
  top: 49px;
  width: 30px;
  height: 21px;
  border-radius: 48%;
  background: linear-gradient(145deg, var(--gold-bright), #b67a29);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.48);
  transform: translateX(-50%);
}

.pendulum-pivot {
  position: absolute;
  z-index: 2;
  top: 17px;
  left: 50%;
  width: 13px;
  height: 13px;
  border: 2px solid #a56c24;
  border-radius: 50%;
  background: var(--gold-bright);
  transform: translateX(-50%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.34);
}

.beat-dots {
  min-height: 16px;
  margin: -1px 0 19px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.beat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: 70ms ease;
}

.beat-dot.accent {
  width: 10px;
  height: 10px;
}

.beat-dot.lit {
  background: var(--gold-bright);
  box-shadow: 0 0 16px rgba(245, 211, 139, 0.85);
  transform: scale(1.22);
}

.range-control {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  color: rgba(255, 248, 238, 0.66);
  font-size: 0.72rem;
}

.range-control output {
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  height: 28px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--gold) var(--fill, 30%), rgba(255, 255, 255, 0.17) var(--fill, 30%));
}

input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7px;
  appearance: none;
  border: 2px solid var(--wood-deep);
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.17);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--gold);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid var(--wood-deep);
  border-radius: 50%;
  background: var(--gold-bright);
}

.control-grid {
  margin-top: 19px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compact-control {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
}

.compact-control legend {
  padding: 0 6px;
  color: rgba(255, 248, 238, 0.56);
  font-size: 0.68rem;
}

.mini-stepper,
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
}

.mini-stepper strong {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.mini-stepper button,
.segmented button {
  min-height: 36px;
  border-radius: 9px;
}

.segmented {
  gap: 5px;
}

.segmented button.active {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--wood-deep);
  font-weight: 800;
}

.transport-row {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 74px 1fr 74px;
  align-items: center;
  gap: 12px;
}

.tap-button {
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.075);
  color: #fff8ee;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.play-button {
  justify-self: center;
  width: 78px;
  height: 78px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
  color: var(--wood-deep);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 1.42rem;
}

.play-button.playing {
  background: #fff6e5;
}

.volume-control {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px;
}

.volume-control input {
  width: 54px;
}

.practice-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.practice-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.user-chip {
  max-width: 180px;
  min-height: 46px;
  padding: 5px 12px 5px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-strong);
  cursor: pointer;
}

.user-chip > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sage-soft);
  color: var(--sage);
  font-weight: 800;
}

.timer-card,
.manual-card,
.summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--paper-strong) 92%, transparent);
  box-shadow: 0 14px 42px rgba(61, 38, 23, 0.07);
}

.timer-card {
  margin-top: 20px;
  padding: 24px;
}

.manual-card,
.summary-card {
  margin-top: 16px;
  padding: 20px;
}

.card-heading,
.summary-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.card-heading h3,
.summary-topline h3 {
  margin: 5px 0 0;
  font-size: 1.08rem;
}

.timer-status {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--sage);
  font-size: 0.7rem;
  font-weight: 800;
}

.timer-status.running {
  background: #f7dfb3;
  color: #754b12;
}

.activity-fields,
.manual-form {
  display: grid;
  gap: 12px;
}

.activity-fields {
  margin-top: 19px;
  grid-template-columns: 1fr 1fr;
}

label > span:not(.visually-hidden),
.manual-form label > span {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

select,
input[type="text"],
input[type="number"],
input[type="date"] {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: var(--paper);
  color: var(--ink);
}

select:focus,
input:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sage) 18%, transparent);
}

select:disabled,
input:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.timer-display {
  margin: 24px 0 20px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(2.9rem, 8vw, 4.55rem);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: -0.06em;
}

.timer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.timer-actions .text-button {
  grid-column: 1 / -1;
  justify-self: center;
}

.primary-button,
.save-button,
.add-button,
.text-button {
  min-height: 44px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
}

.primary-button {
  border: 0;
  background: var(--wood);
  color: #fff8ee;
}

.save-button,
.add-button {
  border: 0;
  background: var(--sage);
  color: #fff;
}

.text-button {
  padding-inline: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

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

.helper-text {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.manual-form {
  margin-top: 15px;
  grid-template-columns: 1.1fr 0.7fr 1fr;
  align-items: end;
}

.manual-form .custom-activity {
  grid-column: 1 / -1;
}

.manual-form .add-button {
  grid-column: 1 / -1;
}

.summary-topline {
  align-items: center;
}

.summary-topline h3 strong {
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: 2rem;
  font-weight: 600;
}

.date-picker input {
  width: 142px;
  min-height: 40px;
}

.breakdown {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.breakdown-item {
  padding: 13px;
  border-radius: 13px;
  background: var(--sage-soft);
}

.breakdown-item strong,
.breakdown-item span {
  display: block;
}

.breakdown-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.87rem;
}

.breakdown-item span {
  margin-top: 4px;
  color: var(--sage);
  font-size: 0.76rem;
  font-weight: 800;
}

.empty-message {
  grid-column: 1 / -1;
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.session-list {
  margin-top: 17px;
  border-top: 1px solid var(--line);
}

.session-item {
  padding: 13px 1px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px 16px;
  border-bottom: 1px solid var(--line);
}

.session-item:last-child {
  border-bottom: 0;
}

.session-item strong {
  font-size: 0.9rem;
}

.session-item .duration {
  color: var(--sage);
  font-weight: 850;
}

.session-item small {
  grid-column: 1 / -1;
  color: var(--muted);
}

footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 max(30px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.72rem;
}

.profile-dialog {
  width: min(440px, calc(100% - 30px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--paper-strong);
  color: var(--ink);
  box-shadow: 0 30px 100px rgba(21, 13, 9, 0.35);
}

.profile-dialog::backdrop {
  background: rgba(28, 18, 12, 0.68);
  backdrop-filter: blur(6px);
}

.profile-dialog form {
  padding: 30px;
}

.dialog-mark {
  width: 52px;
  height: 52px;
  margin-bottom: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--wood);
  color: var(--gold-bright);
  font-family: Georgia, serif;
  font-size: 1.35rem;
}

.profile-dialog h2 {
  margin: 7px 0 8px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: 1.75rem;
}

.profile-dialog p:not(.eyebrow):not(.form-error) {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.65;
}

.profile-dialog label {
  display: block;
}

.form-error {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 0.78rem;
}

.dialog-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-actions .primary-button {
  padding-inline: 20px;
}

.toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  max-width: min(420px, calc(100% - 34px));
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--gold) 75%, white);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    max-width: 620px;
  }

  .metronome-case {
    position: static;
  }

  .practice-column {
    margin-top: 14px;
  }
}

@media (max-width: 560px) {
  .topbar,
  .app-shell,
  footer {
    width: min(100% - 24px, 620px);
  }

  .top-actions a {
    display: none;
  }

  .app-shell {
    margin-top: 10px;
    gap: 20px;
  }

  .metronome-case {
    padding: 22px 17px;
    border-radius: 24px;
  }

  .tempo-stepper {
    grid-template-columns: 42px 1fr 42px;
    gap: 7px;
  }

  .tempo-stepper > button {
    width: 42px;
    height: 42px;
  }

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

  .practice-heading {
    align-items: center;
  }

  .user-chip {
    max-width: 145px;
  }

  .timer-card,
  .manual-card,
  .summary-card {
    padding: 17px;
  }

  .activity-fields {
    grid-template-columns: 1fr;
  }

  .timer-actions {
    grid-template-columns: 1fr;
  }

  .timer-actions .text-button {
    grid-column: auto;
  }

  .manual-form {
    grid-template-columns: 1fr 1fr;
  }

  .manual-form label:first-child,
  .manual-form .custom-activity,
  .manual-form .add-button {
    grid-column: 1 / -1;
  }

  .summary-topline {
    align-items: flex-end;
  }

  .date-picker input {
    width: 135px;
  }

  footer {
    flex-direction: column;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.guide-shell {
  width: min(780px, calc(100% - 32px));
  margin: 28px auto 60px;
}

.guide-hero {
  padding: clamp(26px, 6vw, 52px);
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, var(--wood-soft), var(--wood-deep));
  color: #fff8ee;
  box-shadow: var(--shadow);
}

.guide-hero .section-kicker {
  color: var(--gold-bright);
}

.guide-hero h1 {
  margin: 10px 0 12px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 1.08;
}

.guide-hero p {
  max-width: 610px;
  margin: 0;
  color: rgba(255, 248, 238, 0.72);
  line-height: 1.75;
}

.guide-section {
  margin-top: 18px;
  padding: clamp(21px, 5vw, 34px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper-strong);
}

.guide-section h2 {
  margin: 0 0 12px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: 1.5rem;
}

.guide-section h3 {
  margin: 24px 0 7px;
  font-size: 1rem;
}

.guide-section p,
.guide-section li {
  color: var(--muted);
  line-height: 1.75;
}

.guide-section ol,
.guide-section ul {
  padding-left: 1.35rem;
}

.guide-callout {
  padding: 14px 16px;
  border-radius: 13px;
  background: var(--sage-soft);
  color: var(--sage) !important;
  font-weight: 650;
}

.back-link {
  display: inline-flex;
  margin-top: 22px;
  color: var(--sage);
  font-weight: 800;
  text-decoration: none;
}
