:root {
  color-scheme: light dark;
  --page-bg: #f4f6f5;
  --text: #17201e;
  --card-bg: #ffffff;
  --card-shadow: rgba(23, 32, 30, 0.07);
  --focus: #0b6ecf;
  --muted: #63706c;
  --body-text: #4f5d59;
  --link: #52605c;
  --switch-bg: #f1f4f3;
  --selected-bg: #dfece7;
  --selected-text: #0d4c3f;
  --pending: #b7791f;
  --pending-halo: #f7ead6;
  --ok: #147a5f;
  --ok-halo: #dcefe8;
  --off: #66736f;
  --off-halo: #e5e9e7;
  --bad: #b42318;
  --bad-halo: #f8dfdc;
  --primary-bg: #145c4b;
  --primary-text: #ffffff;
  --stop-bg: #e6efec;
  --stop-text: #244039;
  --outline-border: #cdd8d4;
  --outline-bg: #ffffff;
  --outline-text: #244039;
  --option-bg: #eef2f0;
  --input-border: #aab8b3;
  --input-bg: #ffffff;
  --apply-bg: #25332f;
  --apply-text: #ffffff;
  --accent: #145c4b;
  --notice-bg: #fff2f1;
  color: var(--text);
  background: var(--page-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18.667px;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  display: grid;
  /* 세로는 위 정렬로 고정한다. 가운데 정렬이면 타이머·알림음 영역이
     나타나고 사라질 때 카드 전체가 재중앙정렬되며 버튼이 위아래로 흔들린다. */
  place-items: start center;
  padding: 2rem 1.25rem;
  background: var(--page-bg);
  /* 한글은 음절이 아니라 단어(띄어쓰기) 단위로 줄바꿈한다. */
  word-break: keep-all;
  overflow-wrap: break-word;
}

button,
input {
  color: inherit;
  font: inherit;
  font-size: 1rem;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.app {
  width: min(100%, 42rem);
  padding: 2rem;
  border-radius: 1.4rem;
  background: var(--card-bg);
  box-shadow: 0 1rem 3rem var(--card-shadow);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

.brand a {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.tagline {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.theme-toggle {
  min-height: 2.75rem;
  padding: 0.4rem 0.8rem;
  border: 0;
  border-radius: 0.7rem;
  background: var(--switch-bg);
  font-weight: 600;
}

.language-switch {
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.2rem;
  border-radius: 0.7rem;
  background: var(--switch-bg);
}

.language-switch button {
  min-height: 2.35rem;
  padding: 0.4rem 0.65rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
}

.language-switch button[aria-pressed="true"],
.theme-toggle[aria-pressed="true"] {
  background: var(--selected-bg);
  color: var(--selected-text);
  font-weight: 750;
}

.status-panel {
  margin-top: 2.75rem;
}

.status-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: start;
}

.status-mark {
  width: 1rem;
  height: 1rem;
  margin-top: 0.4rem;
  border-radius: 50%;
  background: var(--pending);
  box-shadow: 0 0 0 0.3rem var(--pending-halo);
}

.status-panel[data-state="active"] .status-mark {
  background: var(--ok);
  box-shadow: 0 0 0 0.3rem var(--ok-halo);
}

.status-panel[data-state="idle"] .status-mark,
.status-panel[data-state="expired"] .status-mark {
  background: var(--off);
  box-shadow: 0 0 0 0.3rem var(--off-halo);
}

.status-panel[data-state="unsupported"] .status-mark,
.status-panel[data-state="error"] .status-mark {
  background: var(--bad);
  box-shadow: 0 0 0 0.3rem var(--bad-halo);
}

.status-copy h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.35rem);
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.status-copy p {
  margin: 0.75rem 0 0;
  color: var(--body-text);
  line-height: 1.55;
}

.status-times {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.5rem;
  margin: 1.65rem 0 0 2rem;
}

.time-label,
label {
  display: block;
  margin: 0 0 0.3rem;
  color: var(--muted);
  font-weight: 650;
}

.time-value {
  display: block;
  color: var(--text);
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.primary-action {
  width: 100%;
  min-height: 3.3rem;
  margin-top: 1.6rem;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 0.75rem;
  background: var(--primary-bg);
  color: var(--primary-text);
  font-weight: 800;
}

.primary-action[data-action="stop"] {
  background: var(--stop-bg);
  color: var(--stop-text);
}

.primary-action:disabled,
#chime-preview:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-action {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--outline-border);
  border-radius: 0.75rem;
  background: var(--outline-bg);
  color: var(--outline-text);
  font-weight: 700;
}

.action-hint {
  margin: 0.5rem 0 0;
  color: inherit;
  line-height: 1.45;
  opacity: 0.72;
}

.utility-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem 0.75rem;
  margin-top: 2.5rem;
}

.timer-section {
  margin-top: 3.25rem;
}

.section-title,
.faq h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.timer-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.timer-options button {
  min-height: 3rem;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 0.7rem;
  background: var(--option-bg);
  font-weight: 700;
}

.timer-options button[aria-pressed="true"] {
  background: var(--primary-bg);
  color: var(--primary-text);
}

.custom-duration {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
  margin-top: 1rem;
}

input {
  width: 100%;
  min-height: 3rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--input-border);
  border-radius: 0.65rem;
  background: var(--input-bg);
}

.apply-timer {
  min-height: 3rem;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 0.65rem;
  background: var(--apply-bg);
  color: var(--apply-text);
  font-weight: 750;
}

.chime-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
  margin-top: 1.5rem;
}

.chime-control label {
  margin: 0;
}

.chime-control input[type="range"] {
  flex: 1 1 8rem;
  width: auto;
  min-height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  accent-color: var(--accent);
}

#chime-volume-value {
  min-width: 2.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

#chime-preview {
  min-height: 2.6rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--outline-border);
  border-radius: 0.6rem;
  background: var(--outline-bg);
  color: var(--outline-text);
  font-weight: 700;
}

.faq {
  margin-top: 3.25rem;
}

.faq-list {
  margin: 1.25rem 0 0;
}

.faq-item + .faq-item {
  margin-top: 1.4rem;
}

.faq-item dt {
  color: var(--text);
  font-weight: 700;
}

.faq-item dd {
  margin: 0.4rem 0 0;
  color: var(--body-text);
  line-height: 1.65;
}

.site-footer {
  margin-top: 2.75rem;
  text-align: center;
}

.site-footer a {
  color: var(--link);
  font-weight: 650;
}

.noscript {
  padding: 1rem;
  border-radius: 0.7rem;
  background: var(--notice-bg);
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: 2rem;
  background: #070d0b;
  color: #5e6a65;
}

.ambient:focus-visible {
  outline: none;
}

.ambient.cursor-hidden {
  cursor: none;
}

.ambient-clock {
  max-width: 100%;
  font-size: clamp(2.5rem, 11vw, 8.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}

.ambient-remaining {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  color: #4f5b56;
}

.ambient-label {
  font-weight: 650;
}

.ambient-remaining-time {
  font-size: clamp(1.5rem, 5vw, 2.75rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ambient-note {
  max-width: 34rem;
  margin: 0;
  text-align: center;
  line-height: 1.5;
}

.ambient-hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 1.75rem;
  margin: 0;
  text-align: center;
  color: #45504b;
}

.ambient.cursor-hidden .ambient-hint {
  visibility: hidden;
}

/* 다크 테마: 기본은 시스템 설정, 버튼으로 바꾸면 data-theme이 우선한다(저장 없음).
   색은 위 :root와 아래 두 블록의 변수로만 바꾼다. 두 블록의 값은 같아야 한다. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page-bg: #0d1211;
    --text: #e3ebe8;
    --card-bg: #171e1c;
    --card-shadow: rgba(0, 0, 0, 0.45);
    --focus: #5aa9f0;
    --muted: #9aa8a3;
    --body-text: #b4c1bc;
    --link: #a9b8b2;
    --switch-bg: #232c29;
    --selected-bg: #2f4a41;
    --selected-text: #cfeee2;
    --pending: #b7791f;
    --pending-halo: #3a2f1a;
    --ok: #34c091;
    --ok-halo: #1b3a30;
    --off: #8a9893;
    --off-halo: #2a3230;
    --bad: #f0685c;
    --bad-halo: #3d201d;
    --primary-bg: #2a9a7c;
    --primary-text: #04130e;
    --stop-bg: #2a3532;
    --stop-text: #d4e2dd;
    --outline-border: #3a4642;
    --outline-bg: #1e2725;
    --outline-text: #d4e2dd;
    --option-bg: #242d2a;
    --input-border: #4a5854;
    --input-bg: #101715;
    --apply-bg: #d4e2dd;
    --apply-text: #10201b;
    --accent: #34c091;
    --notice-bg: #3d201d;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0d1211;
  --text: #e3ebe8;
  --card-bg: #171e1c;
  --card-shadow: rgba(0, 0, 0, 0.45);
  --focus: #5aa9f0;
  --muted: #9aa8a3;
  --body-text: #b4c1bc;
  --link: #a9b8b2;
  --switch-bg: #232c29;
  --selected-bg: #2f4a41;
  --selected-text: #cfeee2;
  --pending: #b7791f;
  --pending-halo: #3a2f1a;
  --ok: #34c091;
  --ok-halo: #1b3a30;
  --off: #8a9893;
  --off-halo: #2a3230;
  --bad: #f0685c;
  --bad-halo: #3d201d;
  --primary-bg: #2a9a7c;
  --primary-text: #04130e;
  --stop-bg: #2a3532;
  --stop-text: #d4e2dd;
  --outline-border: #3a4642;
  --outline-bg: #1e2725;
  --outline-text: #d4e2dd;
  --option-bg: #242d2a;
  --input-border: #4a5854;
  --input-bg: #101715;
  --apply-bg: #d4e2dd;
  --apply-text: #10201b;
  --accent: #34c091;
  --notice-bg: #3d201d;
}

@media (max-width: 560px) {
  body {
    padding: 0;
  }

  .app {
    min-height: 100vh;
    padding: 1.25rem;
    border-radius: 0;
    box-shadow: none;
  }

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

  .custom-duration {
    grid-template-columns: 1fr 1fr;
  }

  .apply-timer {
    grid-column: 1 / -1;
  }
}
