/* 바로타이머 공통 스타일 */

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1c1c1e;
  --muted: #6c6b68;
  --line: #e2dfd7;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --break: #23897c;
  --long: #3a66c8;
  --warn: #d62828;
  --track: #ebe8e1;
  --overlay: rgba(20, 18, 15, 0.55);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --surface: #1c1c1f;
    --surface-2: #26262a;
    --text: #f2f2f0;
    --muted: #9c9ba0;
    --line: #2e2e33;
    --accent: #ff6b4a;
    --accent-ink: #1a0d08;
    --break: #3cc2b0;
    --long: #6f97f0;
    --warn: #ff5a5a;
    --track: #2a2a2f;
    --overlay: rgba(0, 0, 0, 0.7);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121214;
  --surface: #1c1c1f;
  --surface-2: #26262a;
  --text: #f2f2f0;
  --muted: #9c9ba0;
  --line: #2e2e33;
  --accent: #ff6b4a;
  --accent-ink: #1a0d08;
  --break: #3cc2b0;
  --long: #6f97f0;
  --warn: #ff5a5a;
  --track: #2a2a2f;
  --overlay: rgba(0, 0, 0, 0.7);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
  word-break: keep-all;
}

/* 일본어: 일본어 글꼴 우선, 띄어쓰기가 없으므로 keep-all 대신 일반 줄바꿈 */
:lang(ja) {
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Segoe UI", sans-serif;
}

:lang(ja) body {
  word-break: normal;
  line-break: strict;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding-inline: 20px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 100;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 8px;
}

:is(a, button, input, select, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 헤더 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  white-space: nowrap;
}

.logo svg {
  width: 26px;
  height: 26px;
}

.nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--text);
}

.nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.theme-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.theme-btn svg {
  width: 20px;
  height: 20px;
}

.lang-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}

.lang-picker:hover,
.lang-picker:focus-within {
  color: var(--text);
  background: var(--surface-2);
}

.lang-picker svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.lang-picker select {
  appearance: none;
  -webkit-appearance: none;
  max-width: 7.5em;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.lang-picker select:focus-visible {
  outline: none;
}

.lang-picker:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lang-picker option {
  background: var(--surface);
  color: var(--text);
}

/* 좁은 화면: 내비를 두 번째 줄로 내려 긴 언어(스페인어 등)도 넘치지 않게 */
@media (max-width: 720px) {
  .site-header .wrap {
    flex-wrap: wrap;
    height: auto;
    padding-block: 8px;
    row-gap: 4px;
  }
  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-content: center;
  }
  .lang-picker {
    margin-left: auto;
  }
  .nav a {
    padding: 5px 10px;
    font-size: 14px;
  }
}

/* ---------- 히어로 ---------- */

.hero {
  text-align: center;
  padding: 28px 0 0;
}

.hero h1 {
  margin: 0 0 4px;
  font-size: clamp(24px, 4vw, 32px);
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

/* ---------- 도구 카드 ---------- */

.tool {
  --mode: var(--accent);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 560px;
  margin: 20px auto 0;
  padding: 28px 20px 20px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.tool[data-mode="short"] {
  --mode: var(--break);
}

.tool[data-mode="long"] {
  --mode: var(--long);
}

.dial {
  position: relative;
  width: min(78vw, 340px);
  aspect-ratio: 1;
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 6;
}

.ring-track {
  stroke: var(--track);
}

.ring-progress {
  stroke: var(--mode);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s;
}

.tool.is-ending .ring-progress {
  stroke: var(--warn);
}

.dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14%;
  text-align: center;
}

.time {
  font-size: clamp(48px, 15vw, 76px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.05;
  white-space: nowrap;
}

.time.long {
  font-size: clamp(38px, 11vw, 58px);
}

.tool.is-ending .time {
  color: var(--warn);
}

.tool[data-state="paused"] .time {
  animation: blink 1.2s steps(2, jump-none) infinite;
}

.cs {
  margin-left: 2px;
  font-size: 0.45em;
  color: var(--muted);
}

.label-view,
.sub-view {
  max-width: 100%;
  min-height: 1.5em;
  overflow: hidden;
  color: var(--muted);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-view {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.35;
  white-space: normal;
}

/* 시간 입력 */

.setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.tool:not([data-state="idle"]) .setup {
  display: none;
}

.time-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.time-inputs label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.time-inputs input {
  width: 76px;
  padding: 10px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: 600 24px var(--font);
  font-variant-numeric: tabular-nums;
  text-align: center;
  -moz-appearance: textfield;
}

.time-inputs input::-webkit-outer-spin-button,
.time-inputs input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--mode, var(--accent));
  color: var(--mode, var(--accent));
}

/* 버튼 */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.btn {
  min-width: 96px;
  padding: 12px 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 600 16px var(--font);
  cursor: pointer;
  transition: transform 0.1s, background-color 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary,
.btn-primary:hover {
  min-width: 140px;
  border-color: var(--mode);
  background: var(--mode);
  color: var(--accent-ink);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  min-width: 0;
  padding: 12px;
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 420px) {
  .btn {
    min-width: 0;
    padding: 12px 18px;
  }
  .btn-primary {
    min-width: 108px;
  }
  .btn-icon {
    padding: 12px;
  }
  .tool {
    padding-inline: 14px;
  }
}

.btn-lg {
  padding: 14px 32px;
  font-size: 18px;
}

/* 설정 패널 */

.options {
  width: 100%;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.options summary {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  list-style: none;
  cursor: pointer;
}

.options summary::-webkit-details-marker {
  display: none;
}

.options summary::after {
  content: " ▾";
}

.options[open] summary::after {
  content: " ▴";
}

.options-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 14px;
  align-items: center;
  margin-top: 16px;
  font-size: 14px;
}

.options-grid > label {
  color: var(--muted);
}

.options-grid .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.options input[type="text"],
.options input[type="number"],
.options select {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.options input[type="text"] {
  width: 100%;
}

.options input[type="number"] {
  width: 72px;
}

.options input[type="range"] {
  flex: 1;
  min-width: 100px;
  accent-color: var(--mode);
}

.options input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--mode);
}

.btn-sm {
  min-width: 0;
  padding: 6px 12px;
  font-size: 13px;
}

.hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* 알람 오버레이 */

.alarm {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--overlay);
  animation: fade 0.2s ease-out;
}

.alarm-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.alarm-icon {
  font-size: 56px;
  line-height: 1;
  animation: wiggle 0.4s ease-in-out infinite alternate;
}

.alarm-card h2 {
  margin: 16px 0 6px;
  font-size: 24px;
}

.alarm-card p {
  margin: 0 0 24px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* 토스트 */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  transform: translateX(-50%);
  animation: fade 0.2s ease-out;
}

/* 전체화면 */

.tool:fullscreen {
  justify-content: center;
  max-width: none;
  margin: 0;
  border-radius: 0;
  background: var(--bg);
  box-shadow: none;
}

.tool:fullscreen .dial {
  width: min(80vmin, 900px);
}

.tool:fullscreen .time {
  font-size: min(16vmin, 220px);
}

.tool:fullscreen .time.long {
  font-size: min(12vmin, 170px);
}

.tool:fullscreen .label-view {
  font-size: min(4vmin, 36px);
}

.tool:fullscreen :is(.setup, .options, .laps, .modes) {
  display: none;
}

/* 스톱워치 랩 */

.laps {
  width: 100%;
  max-height: 280px;
  overflow: auto;
}

.laps table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.laps th,
.laps td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.laps th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.laps :is(th, td):first-child {
  text-align: left;
}

.laps td:first-child {
  color: var(--muted);
}

.lap-fast td:nth-child(2) {
  color: var(--break);
  font-weight: 600;
}

.lap-slow td:nth-child(2) {
  color: var(--warn);
  font-weight: 600;
}

/* 뽀모도로 */

.modes {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}

.modes button {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 600 14px var(--font);
  cursor: pointer;
}

.modes button[aria-selected="true"] {
  background: var(--surface);
  color: var(--mode);
  box-shadow: var(--shadow);
}

.task-input {
  width: min(100%, 360px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: center;
}

.tool:fullscreen .task-input {
  display: none;
}

/* ---------- 본문 콘텐츠 (SEO) ---------- */

.content {
  max-width: 720px;
  margin: 56px auto 0;
  padding-bottom: 48px;
}

.content h2 {
  margin: 44px 0 12px;
  font-size: 21px;
  letter-spacing: -0.01em;
}

.content p {
  margin: 0 0 12px;
}

.content ol,
.content ul {
  margin: 0 0 12px;
  padding-left: 22px;
}

.content li {
  margin-bottom: 6px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 0 !important;
  list-style: none;
}

.feature-grid li {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.feature-grid strong {
  display: block;
  margin-bottom: 2px;
}

.feature-grid span {
  color: var(--muted);
  font-size: 14px;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

.keys {
  width: 100%;
  border-collapse: collapse;
}

.keys td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

kbd {
  display: inline-block;
  min-width: 28px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  font: 600 13px var(--font);
  text-align: center;
}

code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 0.9em;
}

.faq {
  margin-bottom: 10px;
  padding: 14px 18px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.faq summary {
  font-weight: 600;
  cursor: pointer;
}

.faq p {
  margin: 10px 0 0;
  color: var(--muted);
}

.site-footer {
  padding: 24px 0 calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-bottom: 8px;
}

/* ---------- 애니메이션 ---------- */

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

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes wiggle {
  from {
    transform: rotate(-12deg);
  }
  to {
    transform: rotate(12deg);
  }
}

@keyframes shake {
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

.shake {
  animation: shake 0.3s;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
