:root {
  --paper: #f3f1eb;
  --ink: #20211e;
  --muted: #74756f;
  --line: #d8d5cd;
  --panel: #e8e5dc;
  --white: #fffef9;
  --acid: #dff43c;
  --acid-deep: #c8dc24;
  --orange: #ff8a3d;
  --red: #e94b3c;
  --green: #2f7658;
  --shadow: 0 18px 50px rgba(48, 47, 42, 0.09);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans SC", system-ui, sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(32, 33, 30, 0.24);
  outline-offset: 3px;
}

.shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-bottom: 1px solid var(--line);
}

.header-actions,
.section-heading,
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-actions {
  gap: 22px;
}

.local-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(47, 118, 88, 0.1);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.icon-button:hover {
  background: var(--white);
  transform: rotate(8deg);
}

.icon-button svg,
.timer-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.launch-section {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 0 72px;
}

.section-kicker,
footer {
  margin: 0;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.launch-panel {
  width: min(100%, 520px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.field-label {
  display: block;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mode-caption {
  color: var(--muted);
  font-size: 12px;
}

.mode-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 28px;
}

.mode-picker button {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.mode-picker button:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.mode-picker button.is-selected {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
}

.mode-symbol {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
}

.mode-picker button.is-selected .mode-symbol {
  color: var(--acid);
}

.duration-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.duration-caption {
  color: var(--muted);
  font-size: 12px;
}

.duration-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 16px;
  margin: 8px 0 14px;
}

.duration-row output {
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 68px;
  line-height: 1;
  font-weight: 500;
}

.step-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.step-button:hover {
  border-color: var(--ink);
  background: var(--paper);
}

.presets {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 22px;
}

.presets button {
  height: 34px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: var(--paper);
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  cursor: pointer;
}

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

.presets button.is-selected {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
}

.start-button {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--acid);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.launch-actions {
  width: 100%;
}

.cue-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cue-button {
  min-height: 88px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.cue-button:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.cue-button:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.cue-button.cue-in {
  background: #e9f3e8;
}

.cue-button.cue-out {
  background: #fff0e5;
}

.cue-action-code {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
}

.cue-button strong {
  font-size: 16px;
  font-weight: 700;
}

.start-button:hover {
  background: #e8fa55;
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.start-button:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.play-icon {
  width: 0;
  height: 0;
  margin-left: 7px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid var(--ink);
}

.shortcut {
  color: rgba(32, 33, 30, 0.5);
  font-family: "DM Mono", monospace;
  font-size: 16px;
}

.timers-section {
  padding: 66px 0 80px;
  border-top: 1px solid var(--line);
}

.section-heading {
  align-items: flex-end;
  margin-bottom: 28px;
}

.section-heading h2,
.drawer-header h2 {
  margin: 6px 0 0;
  font-size: 27px;
  font-weight: 600;
}

.section-heading h2 span {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 20px;
  background: var(--ink);
  color: var(--acid);
  vertical-align: 4px;
  font-family: "DM Mono", monospace;
  font-size: 12px;
}

.clear-button {
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

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

.timer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.timer-card {
  position: relative;
  min-height: 370px;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color 220ms ease, background 220ms ease, transform 220ms ease;
}

.timer-card:hover {
  transform: translateY(-3px);
}

.timer-card.is-warning {
  border-color: var(--orange);
  background: #fff8ee;
}

.timer-card.is-urgent {
  border-color: var(--red);
  background: #fff3f0;
}

.timer-card.is-overrun {
  border-color: var(--red);
  background: #fff3f0;
}

.timer-card.is-finished {
  background: var(--panel);
}

.timer-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: var(--progress-color, var(--acid-deep));
  transform: scaleX(var(--progress, 1));
  transform-origin: left;
  transition: transform 1s linear, background 220ms ease;
}

.card-top,
.card-actions,
.timer-status {
  display: flex;
  align-items: center;
}

.card-top {
  justify-content: space-between;
  gap: 16px;
}

.timer-index {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.timer-status {
  gap: 7px;
  font-size: 12px;
}

.timer-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.timer-card.is-running .timer-status {
  color: var(--green);
}

.timer-card.is-overrun .timer-status {
  color: var(--red);
}

.timer-card.is-running .timer-status::before {
  animation: breathe 1.8s infinite;
}

.timer-card.is-paused .timer-status {
  color: var(--orange);
}

.timer-card.is-finished .timer-status {
  color: var(--muted);
}

.timer-name {
  min-height: 29px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 30px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 19px;
  font-weight: 600;
}

.cue-code {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 24px;
  padding: 0 7px;
  border-radius: 3px;
  background: rgba(47, 118, 88, 0.12);
  color: var(--green);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
}

.mode-out .cue-code {
  background: rgba(255, 138, 61, 0.14);
  color: #b34f18;
}

.mode-timer .cue-code {
  background: rgba(32, 33, 30, 0.09);
  color: var(--ink);
}

.timer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  margin-top: 12px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.timer-display {
  margin: 16px 0 24px;
  font-family: "DM Mono", monospace;
  font-size: clamp(44px, 5vw, 62px);
  line-height: 1;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.timer-card.is-urgent .timer-display {
  color: var(--red);
}

.timer-card.is-overrun .timer-display {
  color: var(--red);
}

.timer-card.is-urgent.is-running .timer-display,
.timer-card.is-overrun.is-running .timer-display {
  animation: urgent-pulse 1s infinite;
}

.card-actions {
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.timer-action {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.timer-action:hover {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
}

.timer-action.primary {
  flex: 1;
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
}

.timer-action.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.empty-clock {
  position: relative;
  width: 74px;
  height: 74px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.empty-clock::before,
.empty-clock span {
  content: "";
  position: absolute;
  left: 36px;
  top: 14px;
  width: 1px;
  height: 23px;
  background: var(--ink);
  transform-origin: bottom;
}

.empty-clock span {
  transform: rotate(115deg);
}

.empty-state p {
  margin: 0 0 7px;
  font-weight: 600;
}

.empty-state > span {
  color: var(--muted);
  font-size: 13px;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 25px 0 32px;
  border-top: 1px solid var(--line);
}

.settings-drawer {
  position: fixed;
  z-index: 20;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

.settings-drawer.is-open {
  visibility: visible;
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(32, 33, 30, 0.38);
  opacity: 0;
  transition: opacity 220ms ease;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(420px, 92vw);
  height: 100%;
  padding: 34px;
  background: var(--white);
  box-shadow: -20px 0 50px rgba(32, 33, 30, 0.16);
  transform: translateX(100%);
  transition: transform 260ms ease;
}

.settings-drawer.is-open .drawer-backdrop {
  opacity: 1;
}

.settings-drawer.is-open .drawer-panel {
  transform: translateX(0);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.setting-row:first-of-type {
  margin-top: 24px;
  border-top: 1px solid var(--line);
}

.setting-row span {
  display: grid;
  gap: 5px;
}

.setting-row strong {
  font-size: 14px;
  font-weight: 600;
}

.setting-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.setting-row input {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  margin: 0;
  border-radius: 20px;
  background: var(--line);
  appearance: none;
  cursor: pointer;
  transition: background 160ms ease;
}

.setting-row input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(32, 33, 30, 0.2);
  transition: transform 160ms ease;
}

.setting-row input:checked {
  background: var(--ink);
}

.setting-row input:checked::after {
  transform: translateX(18px);
  background: var(--acid);
}

.setting-row input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.reminder-map {
  display: grid;
  gap: 0;
  margin-top: 38px;
}

.reminder-map div {
  display: grid;
  grid-template-columns: 15px 70px 1fr;
  align-items: center;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.reminder-map strong {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 500;
}

.reminder-map small {
  color: var(--muted);
  font-size: 12px;
}

.reminder-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.reminder-dot.calm { background: var(--green); }
.reminder-dot.warn { background: var(--orange); }
.reminder-dot.urgent { background: var(--red); }

.toast-region {
  position: fixed;
  z-index: 30;
  right: 24px;
  bottom: 24px;
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  width: min(360px, calc(100vw - 48px));
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 13px;
  padding: 16px 18px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow);
  animation: toast-in 220ms ease both;
}

.toast::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--acid);
}

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  margin-bottom: 3px;
  font-size: 14px;
}

.toast span {
  color: #c9c8c2;
  font-size: 12px;
}

@keyframes breathe {
  50% { opacity: 0.35; }
}

@keyframes urgent-pulse {
  50% { opacity: 0.58; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
}

@media (max-width: 900px) {
  .launch-section {
    padding: 48px 0 64px;
  }

  .launch-panel {
    width: min(100%, 520px);
  }

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

@media (max-width: 620px) {
  .shell {
    width: min(100% - 30px, 1180px);
  }

  .topbar {
    height: 72px;
  }

  .local-status {
    display: none;
  }

  .launch-section {
    padding: 32px 0 48px;
  }

  .launch-panel {
    padding: 22px;
  }

  .start-button {
    min-height: 78px;
  }

  .cue-button {
    min-height: 96px;
  }

  .duration-row output {
    font-size: 60px;
  }

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

  .timer-card {
    min-height: 350px;
  }

  .timer-display {
    font-size: 58px;
  }

  footer {
    gap: 14px;
    flex-direction: column;
  }

  .drawer-panel {
    padding: 26px 22px;
  }
}

@media (max-width: 380px) {
  .cue-actions {
    grid-template-columns: 1fr;
  }
}

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