/* O'CLOCK — 전체화면 LED 시계. 의도적인 단일 다크 테마(LED 시계는 검은 바탕이
   정체성이라 라이트 변형을 두지 않는다). 숫자는 폰트가 아니라 oclock.js가 그리는
   세븐세그먼트 SVG라서 CSP(self)와 폰트 로딩 문제에서 자유롭다. */
:root {
  --ground: #060608;
  --panel: #101118;
  --line: #262833;
  --muted: #8a8d99;
  --text: #e8eaf0;
  --acc: #baff29;
  --display: "Arial Black", "Pretendard Variable", Pretendard, sans-serif;
  --body: "Pretendard Variable", Pretendard, "Noto Sans KR", Arial, sans-serif;
}
:root[data-accent="cyan"] { --acc: #35e0ff; }
:root[data-accent="coral"] { --acc: #ff7048; }
:root[data-accent="amber"] { --acc: #ffd83d; }
:root[data-accent="white"] { --acc: #eef1f6; }

* { box-sizing: border-box; }
/* display:flex 지정이 UA의 [hidden]{display:none}보다 세서 명시적으로 눌러둔다 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--body);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ── 상단 크롬 ─────────────────────────────────────── */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  padding: 14px clamp(14px, 3vw, 28px);
  transition: opacity 0.35s ease;
}
.bar-left { display: flex; align-items: baseline; gap: 14px; }
.home-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 6px 4px;
}
.home-link:hover, .home-link:focus-visible { color: var(--acc); }
.wordmark {
  margin: 0;
  font: 900 18px/1 var(--display);
  letter-spacing: 0.08em;
  color: var(--text);
}
.wordmark::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 8px; background: var(--acc); }

.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 100%; }
.tab {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font: 700 14px/1 var(--body);
  padding: 10px 14px;
  cursor: pointer;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--ground); background: var(--acc); }
.tab:focus-visible, .pill:focus-visible, .solid-btn:focus-visible, .ghost-btn:focus-visible, .swatch:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

.bar-right { display: flex; align-items: center; gap: 16px; }
.swatches { display: flex; gap: 8px; }
.swatch {
  appearance: none;
  width: 18px; height: 18px;
  border: 1px solid var(--line);
  background: var(--sw);
  cursor: pointer;
  padding: 0;
}
.swatch.is-active { outline: 2px solid var(--text); outline-offset: 2px; }
.ghost-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font: 700 13px/1 var(--body);
  padding: 10px 14px;
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--acc); color: var(--acc); }

/* ── 스테이지 ─────────────────────────────────────── */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vh, 30px);
  padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
  min-height: 0;
}

.date-line {
  margin: 0;
  color: var(--muted);
  font-size: clamp(15px, 2.4vmin, 24px);
  letter-spacing: 0.14em;
}

.display-wrap { position: relative; display: flex; align-items: flex-start; }
.meridiem {
  position: absolute;
  right: 100%;
  top: 4%;
  margin-right: clamp(8px, 1.5vw, 20px);
  color: var(--acc);
  font: 900 clamp(13px, 2.4vmin, 24px)/1 var(--display);
  letter-spacing: 0.1em;
}

/* --units: oclock.js가 자릿수(콜론·점 포함 환산 폭)를 넣는다.
   숫자 높이 = 화면 폭/높이 중 먼저 닿는 쪽에 맞춘다. */
.led-row {
  --units: 4.8;
  --dh: min(44vh, calc(92vw / var(--units)));
  display: flex;
  align-items: flex-end;
  gap: calc(var(--dh) * 0.055);
  height: var(--dh);
  filter: drop-shadow(0 0 calc(var(--dh) * 0.1) color-mix(in srgb, var(--acc) 45%, transparent));
}
.led-row svg { height: 100%; width: auto; display: block; }
.led-row svg.small-unit { height: 64%; }
.led-row .seg { fill: var(--acc); opacity: 0.055; }
.led-row .seg.on { opacity: 1; }
.led-row .colon-dot { fill: var(--acc); opacity: 0.055; }
.led-row .colon-dot.on { opacity: 1; }
/* 콜론 깜빡임은 시계/알람에서만 — 스톱워치의 소수점까지 깜빡이면 산만하다 */
body[data-mode="clock"] .led-row .colon-dot.on,
body[data-mode="alarm"] .led-row .colon-dot.on { animation: colon-blink 1s steps(1) infinite; }
@keyframes colon-blink { 50% { opacity: 0.15; } }

.context-line {
  margin: 0;
  min-height: 1.4em;
  color: var(--muted);
  font-size: clamp(13px, 2vmin, 18px);
  letter-spacing: 0.06em;
}
.context-line b { color: var(--acc); font-weight: 700; }

/* ── 컨트롤 ───────────────────────────────────────── */
.controls { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; transition: opacity 0.35s ease; }
.controls-stack { flex-direction: column; gap: 14px; }
.preset-row, .field-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }

.pill {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font: 600 13px/1 var(--body);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.pill:hover { color: var(--text); border-color: var(--muted); }
.pill.is-on { color: var(--ground); background: var(--acc); border-color: var(--acc); font-weight: 700; }
.pill-admin { border-style: dashed; }

.solid-btn {
  appearance: none;
  border: 1px solid var(--acc);
  background: var(--acc);
  color: var(--ground);
  font: 800 14px/1 var(--body);
  padding: 12px 22px;
  cursor: pointer;
}
.solid-btn:hover { filter: brightness(1.1); }

.field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.field input {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font: 700 16px/1.2 var(--body);
  padding: 10px 12px;
  width: 74px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.field input[type="time"] { width: auto; }
.field input:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; border-color: var(--acc); }
/* 다크 바탕에서 네이티브 스피너/시계 아이콘이 안 보이는 브라우저 대비 */
.field input::-webkit-calendar-picker-indicator { filter: invert(0.8); }

.laps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 22vh;
  overflow-y: auto;
  min-width: min(320px, 80vw);
}
.laps li {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--line);
  padding: 6px 4px;
}
.laps li b { color: var(--text); font-weight: 700; }
.laps li:first-child b { color: var(--acc); }

.hint { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; opacity: 0.7; transition: opacity 0.35s ease; }

/* ── 전체화면 · 대기 상태: 크롬을 걷어내고 숫자만 남긴다 ── */
body.is-idle .bar,
body.is-idle .controls,
body.is-idle .hint,
body.is-idle .context-line { opacity: 0; pointer-events: none; }
body.is-idle { cursor: none; }
body.is-fullscreen .led-row { --dh: min(58vh, calc(96vw / var(--units))); }

/* ── 알람/타이머 울림 오버레이 ───────────────────────── */
.ring-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: color-mix(in srgb, var(--ground) 82%, var(--acc));
  animation: ring-pulse 1s ease-in-out infinite;
}
.ring-overlay[hidden] { display: none; }
.ring-title { margin: 0; font: 900 clamp(34px, 8vmin, 80px)/1.1 var(--display); color: var(--text); letter-spacing: 0.04em; }
.ring-sub { margin: 0; color: var(--text); font-size: clamp(15px, 2.6vmin, 22px); opacity: 0.85; }
.ring-actions { display: flex; gap: 12px; margin-top: 10px; }
@keyframes ring-pulse { 50% { background: color-mix(in srgb, var(--ground) 62%, var(--acc)); } }

@media (prefers-reduced-motion: reduce) {
  .led-row .colon-dot.on { animation: none; }
  .ring-overlay { animation: none; }
}

@media (max-width: 640px) {
  .bar { padding: 10px 12px; }
  .wordmark { font-size: 15px; }
  .bar-right { margin-left: auto; }
  .ghost-btn span { display: none; }
  .hint { display: none; }
}
