:root {
  color-scheme: light dark;
  font-family: "Avenir Next", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --bg: #f5f1ea;
  --surface: rgba(255, 252, 247, 0.88);
  --surface-strong: #fffaf2;
  --text: #1c160f;
  --muted: #685d53;
  --line: rgba(57, 47, 36, 0.12);
  --shadow: 0 24px 48px rgba(42, 30, 20, 0.12);
  --focus: #0f766e;
  --accent: #c0553d;
  --accent-soft: rgba(192, 85, 61, 0.18);
  --accent-strong: rgba(192, 85, 61, 0.34);
  --accent-text: #fff8f3;
  --control-surface: rgba(255, 250, 242, 0.82);
  --secondary-accent: #3f7f73;
  --dial-track: #eadfce;
  --dial-face: #f8f7f3;
  --dial-bezel: #2a2b35;
  --dial-mark: #262732;
  --status-bg: rgba(255, 252, 247, 0.92);
}

body[data-theme="dark"] {
  --bg: #171310;
  --surface: rgba(29, 31, 37, 0.92);
  --surface-strong: #22252d;
  --text: #f7efe6;
  --muted: #b8aca0;
  --line: rgba(255, 244, 232, 0.12);
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.34);
  --focus: #6ee7d8;
  --accent: #a93e5e;
  --accent-soft: rgba(169, 62, 94, 0.16);
  --accent-strong: rgba(169, 62, 94, 0.52);
  --accent-text: #fff4f7;
  --control-surface: rgba(44, 36, 30, 0.9);
  --secondary-accent: #78b0a4;
  --dial-track: #343b49;
  --dial-face: #2f3745;
  --dial-bezel: #272b36;
  --dial-mark: #f1f2f5;
  --status-bg: rgba(28, 22, 18, 0.95);
}

body[data-mode="short-break"] {
  --accent: var(--secondary-accent);
  --accent-soft: rgba(63, 127, 115, 0.18);
}

body[data-theme="dark"][data-mode="short-break"] {
  --accent-soft: rgba(120, 176, 164, 0.18);
}

body[data-mode="long-break"] {
  --accent: #2f5e9f;
  --accent-soft: rgba(47, 94, 159, 0.18);
}

body[data-theme="dark"][data-mode="long-break"] {
  --accent: #82a6da;
  --accent-soft: rgba(130, 166, 218, 0.2);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
}

.topbar,
.layout {
  display: grid;
  gap: 1.5rem;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 1rem;
}

.eyebrow,
.section-label {
  margin: 0;
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.012em;
}

.title,
.settings-title,
.timer-mode {
  margin: 0.25rem 0 0;
}

.settings-title {
  font-weight: 600;
}

.settings-subtitle {
  margin: 0.35rem 0 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: saturate(120%);
}

.layout {
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
}

.timer-panel,
.settings-panel {
  padding: 1.75rem;
}

.timer-panel {
  border-radius: 36px;
}

.timer-header,
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dial-wrap {
  width: min(100%, 760px);
  margin: -0.25rem auto 0.35rem;
}

.analog-dial {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
}

.dial-bezel {
  fill: transparent;
}

.dial-face {
  fill: transparent;
}

.dial-shadow {
  fill: transparent;
}

.dial-track {
  fill: transparent;
  stroke: rgba(0, 0, 0, 0.04);
  stroke-width: 1.25;
}

.dial-fill {
  fill: var(--accent);
}

.dial-tick {
  stroke: var(--dial-mark);
  stroke-linecap: round;
}

.dial-tick-major {
  stroke-width: 1.9;
}

.dial-tick-minor {
  stroke-width: 1;
  opacity: 0.72;
}

.dial-number {
  fill: var(--dial-mark);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dial-arm {
  stroke: var(--dial-mark);
  stroke-width: 6;
  stroke-linecap: round;
}

.dial-knob-shadow {
  fill: rgba(0, 0, 0, 0.18);
}

.dial-knob {
  fill: var(--dial-mark);
}

body[data-theme="dark"] .dial-knob {
  fill: #212532;
}

body[data-theme="dark"] .dial-knob-shadow {
  fill: rgba(0, 0, 0, 0.28);
}

body[data-theme="dark"] .dial-arm {
  stroke: #212532;
}

.time-readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 0.7rem;
}

.digital-time {
  font-size: clamp(3rem, 8vw, 5.4rem);
  line-height: 0.94;
  font-weight: 700;
  margin: 0.15rem 0 0.2rem;
}

.work-counter {
  color: var(--muted);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: 0.015em;
  margin-top: 0.06rem;
}

.controls {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.15rem;
  width: min(100%, 28rem);
  margin-inline: auto;
}

.controls button,
.segment {
  border: 0;
  border-radius: 999px;
  min-height: 46px;
  padding: 0.85rem 1.15rem;
  transition: transform 160ms ease-out, opacity 160ms ease-out, background-color 160ms ease-out, color 160ms ease-out, box-shadow 160ms ease-out;
}

.segment:hover {
  transform: none;
}

.controls button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.primary-button {
  background: var(--accent);
  color: white;
  width: 100%;
  min-width: 0;
}

.primary-action {
  display: grid;
}

.primary-action > button {
  grid-area: 1 / 1;
}

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

.secondary-button {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--line);
  width: 100%;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

body[data-theme="dark"] .secondary-button {
  background: color-mix(in srgb, var(--surface-strong) 88%, white 3%);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.14);
}

.settings-grid {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.55rem;
}

.time-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 0.55rem;
}

.time-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.1rem 0;
}

.time-card-label {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
}

.time-card input[type="number"] {
  text-align: left;
  font-size: 1.8rem;
  line-height: 1;
  min-height: 4.6rem;
  padding: 0.95rem 1rem;
}

.field,
.toggle-field {
  display: grid;
  gap: 0.55rem;
}

.row-field {
  grid-template-columns: minmax(176px, 1.08fr) minmax(208px, 0.92fr);
  align-items: center;
  column-gap: 1rem;
}

.row-field > span {
  font-weight: 600;
}

.toggle-field-switch {
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 3.25rem;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: relative;
  display: inline-flex;
  width: 3.4rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--control-surface);
  border: 1px solid var(--line);
  transition: transform 160ms ease-out, background-color 160ms ease-out, box-shadow 160ms ease-out, opacity 160ms ease-out;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 0.18rem;
  left: 0.2rem;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  transition: transform 160ms ease-out, background-color 160ms ease-out;
}

.switch input:checked + .switch-track {
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.1);
}

.switch input:checked + .switch-track::after {
  transform: translateX(1.35rem);
  background: #fff7f2;
}

body[data-theme="dark"] .switch input:checked + .switch-track {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.details-panel {
  display: grid;
  gap: 0.9rem;
  padding: 0.1rem 0 0;
  margin-top: 0.15rem;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.field-inline input[type="number"] {
  width: 100%;
}

input[type="number"],
input[type="range"] {
  width: 100%;
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 50px;
  padding: 0.8rem 0.95rem;
}

.theme-switcher {
  display: flex;
  align-items: center;
}

input[type="range"] {
  padding-inline: 0.25rem;
  --range-progress: 60%;
}

input[type="range"] {
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 0.45rem;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0,
    var(--accent) var(--range-progress),
    color-mix(in srgb, var(--surface-strong) 74%, rgba(0, 0, 0, 0.18)) var(--range-progress),
    color-mix(in srgb, var(--surface-strong) 74%, rgba(0, 0, 0, 0.18)) 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 999px;
  margin-top: -0.3rem;
  background: var(--accent);
  border: 2px solid color-mix(in srgb, white 82%, var(--accent));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
}

input[type="range"]::-moz-range-track {
  height: 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 74%, rgba(0, 0, 0, 0.18));
}

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

body[data-theme="dark"] input[type="range"]::-webkit-slider-runnable-track {
  background: linear-gradient(
    to right,
    var(--accent) 0,
    var(--accent) var(--range-progress),
    rgba(255, 244, 232, 0.18) var(--range-progress),
    rgba(255, 244, 232, 0.18) 100%
  );
}

body[data-theme="dark"] input[type="range"]::-moz-range-track {
  background: rgba(255, 244, 232, 0.18);
}

input[type="range"]::-moz-range-thumb {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid color-mix(in srgb, white 82%, var(--accent));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
}

.field-unit {
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
}

#sound-volume-output {
  min-width: 3.4ch;
  text-align: right;
}

.toggle-field {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.toggle-field > span:first-child,
.details-panel .row-field > span,
.details-panel .toggle-field > span:first-child {
  font-weight: 600;
}

.segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.24rem;
  border-radius: 999px;
  background: var(--control-surface);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.segment {
  background: transparent;
  color: var(--muted);
  position: relative;
  overflow: hidden;
}

.segment[data-selected="true"] {
  background: var(--accent-strong);
  color: var(--accent-text);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.1);
  animation: segment-select 180ms ease-out;
}

.infinity-segment {
  font-size: 1.15rem;
  line-height: 1;
}

body[data-theme="dark"] .segment[data-selected="true"] {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.2);
}

.controls button:focus-visible,
.segment:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.icon-segment {
  padding: 0.7rem;
  min-width: 46px;
}

.icon-segment svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes segment-select {
  0% {
    transform: scale(0.96);
    opacity: 0.82;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
  color: var(--text);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  transition: background-color 160ms ease-out, box-shadow 160ms ease-out, transform 160ms ease-out;
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.theme-icon {
  position: absolute;
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}

.theme-toggle[data-theme="light"] .theme-icon-sun,
.theme-toggle[data-theme="dark"] .theme-icon-moon {
  opacity: 1;
  transform: scale(1);
}

@media (max-width: 900px) {
  .row-field {
    grid-template-columns: 1fr;
  }

  .field-inline,
  .segmented-control {
    width: 100%;
  }

  .theme-switcher {
    justify-content: flex-end;
  }
}

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

.text-balance {
  text-wrap: balance;
}

.text-pretty {
  text-wrap: pretty;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .topbar,
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar,
  .timer-header,
  .settings-header {
    align-items: start;
  }

  .timer-panel,
  .settings-panel {
    padding: 1.3rem;
  }

  .controls {
    width: 100%;
  }

  .time-settings {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
}

@media (min-width: 901px) {
  .app-shell {
    zoom: 0.8;
  }
}

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