:root {
  --bg: #f4f8fc;
  --bg-2: #e0f2fe;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --sky: #38bdf8;
  --sky-deep: #0ea5e9;
  --ink: #0f172a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --ok: #22c55e;
  --settings: #5d8aa8;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Be Vietnam Pro", "Segoe UI", sans-serif;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0b1220;
  --bg-2: #122033;
  --card: #111827;
  --text: #e8eef7;
  --muted: #94a3b8;
  --line: #243044;
  --ink: #f8fafc;
  --settings: #3e627c;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: linear-gradient(145deg, var(--bg) 0%, var(--bg-2) 48%, var(--bg) 100%);
  min-height: 100vh;
}
a { color: #0369a1; }
html[data-theme="dark"] a { color: #7dd3fc; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.shell { width: min(28rem, calc(100% - 1.5rem)); margin: 0 auto; padding: 1rem 0 2.5rem; }
.shell.wide { width: min(56rem, calc(100% - 1.5rem)); }
.topbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.brand {
  font-weight: 700; text-decoration: none; color: var(--text); margin-right: auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu { position: relative; }
.menu > summary {
  list-style: none; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 0.35rem 0.75rem; font-size: 0.85rem; cursor: pointer;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; z-index: 20; margin-top: 0.35rem; min-width: 13rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 0.9rem;
  box-shadow: var(--shadow); padding: 0.4rem; max-height: 70vh; overflow: auto;
}
.menu-panel a, .menu-panel button {
  display: block; width: 100%; text-align: left; text-decoration: none; color: var(--text);
  background: transparent; border: 0; border-radius: 0.6rem; padding: 0.45rem 0.6rem;
}
.menu-panel a:hover, .menu-panel a[aria-current="page"] { background: rgba(56, 189, 248, 0.16); }
h1 { font-size: 1.7rem; line-height: 1.25; text-align: center; margin: 0.2rem 0 0.45rem; color: #0284c7; }
html[data-theme="dark"] h1 { color: #7dd3fc; }
.lede, .foot-note { color: var(--muted); font-size: 0.92rem; line-height: 1.55; text-align: center; }
.card {
  background: var(--card); border: 2px solid rgba(14, 165, 233, 0.18);
  border-radius: 1rem; box-shadow: var(--shadow);
}
.settings { background: var(--settings); color: white; border: 0; padding: 0; overflow: hidden; margin: 0.8rem 0; }
.settings summary, .panel-toggle {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem; padding: 0.95rem 1rem; background: transparent; color: white; border: 0; font-weight: 600;
}
.settings-body { padding: 0 1rem 1rem; display: grid; gap: 0.85rem; }
.settings h2 { font-size: 0.95rem; margin: 0 0 0.35rem; color: white; }
.settings .muted { color: rgba(255, 255, 255, 0.88); }
.time-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.time-picks label, .field { display: grid; gap: 0.25rem; font-size: 0.75rem; }
select, input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"] {
  width: 100%; background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 0.8rem; padding: 0.55rem 0.6rem;
}
.sound-grid, .preset-grid, .tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.chip, .preset, .btn {
  border-radius: 0.85rem; border: 2px solid var(--line); background: var(--card); color: var(--text);
  min-height: 2.5rem; padding: 0.35rem 0.6rem;
}
.chip.on, .preset.on, .btn.sky { background: var(--sky); border-color: var(--sky); color: white; }
.btn.sky:hover, .chip.on:hover, .preset.on:hover { background: var(--sky-deep); }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #1f2937; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: white; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 2rem; padding: 0.2rem 0.55rem; }
.stage { padding: 1.4rem 1rem 1.1rem; text-align: center; margin-bottom: 0.8rem; }
.digits {
  font-family: var(--mono); font-weight: 700; letter-spacing: -0.04em;
  font-size: clamp(3.4rem, 14vw, 4.6rem); margin: 0 0 0.8rem;
}
.digits.run { color: #0284c7; }
.digits.soon { color: var(--warn); }
.digits.done { color: var(--danger); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.controls { display: flex; justify-content: center; gap: 0.6rem; margin: 0.8rem 0 1rem; }
.controls .btn { height: 3.5rem; min-width: 3.5rem; border-radius: 1rem; }
.controls .start { min-width: 9rem; font-size: 1.05rem; font-weight: 700; }
.loop-btn { border-radius: 0.85rem; min-height: 2.5rem; padding: 0 0.9rem; border: 0; background: #e5e7eb; color: #374151; }
html[data-theme="dark"] .loop-btn { background: #334155; color: #e2e8f0; }
.loop-btn.on { background: var(--ok); color: white; }
.tips, details.fold, section.faq, section.howto { background: color-mix(in srgb, var(--card) 86%, #94a3b8); border: 1px solid var(--line); border-radius: 0.9rem; padding: 0.85rem 1rem; margin-top: 0.7rem; }
.tips h2, details.fold summary, section.faq h2, section.howto h2 { font-size: 0.95rem; margin: 0 0 0.35rem; }
section.howto ol { margin: 0.35rem 0 0; padding-inline-start: 1.25rem; }
section.howto li { margin: 0.35rem 0; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
.tips ul, .prose ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }
.tips li, .prose li, .prose p { color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
kbd { background: rgba(56, 189, 248, 0.18); border-radius: 0.3rem; padding: 0.05rem 0.3rem; font-family: var(--mono); }
.tool-grid a {
  text-decoration: none; color: var(--text); border: 1px solid var(--line); background: var(--card);
  border-radius: 0.8rem; padding: 0.55rem 0.7rem; font-size: 0.9rem;
}
.prose h2, .prose h3 { font-size: 1rem; margin: 0.8rem 0 0.3rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.grow { flex: 1; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 0.9rem; padding: 0.75rem; }
.stat b { display: block; font-family: var(--mono); font-size: 1.35rem; }
.stat span, .muted { color: var(--muted); font-size: 0.82rem; }
.ring {
  width: 15rem; height: 15rem; margin: 0 auto 0.8rem; border-radius: 50%;
  background: conic-gradient(from -90deg, var(--sky) calc(var(--p) * 1%), #d5e2ee 0);
  display: grid; place-items: center;
}
.ring i {
  width: 12.2rem; height: 12.2rem; border-radius: 50%; background: var(--card);
  display: grid; place-items: center; font-style: normal; text-align: center; padding: 0.6rem;
}
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.list li, .session {
  display: flex; gap: 0.45rem; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 0.8rem; padding: 0.45rem 0.6rem; background: var(--card);
}
.session input, .session select { width: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { border-bottom: 1px solid var(--line); padding: 0.4rem; text-align: left; }
.clock-face { width: min(16rem, 70vw); height: auto; display: block; margin: 0 auto 0.8rem; }
.hand { stroke: var(--text); stroke-linecap: round; }
.sec { stroke: var(--danger); }
#dim {
  position: fixed; inset: 0; background: #000; color: #94a3b8; display: grid; place-items: center; z-index: 30;
}
#dim[hidden] { display: none; }
.error { color: var(--danger); min-height: 1.2em; font-size: 0.85rem; }
.hidden { display: none !important; }
.slider { width: 100%; accent-color: var(--sky); }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; }
.hub-langs { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.35rem 0.8rem; }
.hub-langs a { font-size: 0.92rem; }
.crumbs { margin: 0 0 0.35rem; color: var(--muted); font-size: 0.82rem; }
.holiday-crumbs { display: flex; flex-wrap: wrap; gap: 0.3rem 0.45rem; align-items: baseline; }
.holiday-crumbs > * { unicode-bidi: isolate; }
.holiday-crumbs .crumb { display: inline-flex; gap: 0.35rem; align-items: baseline; max-width: 100%; }
.crumbs a { color: inherit; text-decoration: none; }
.holiday-top { flex-wrap: wrap; align-items: flex-start; }
.holiday-top .brand { flex: 0 0 auto; margin: 0; overflow: visible; text-overflow: clip; }
.crumbs a:hover { text-decoration: underline; }
section.faq h3 { font-size: 1rem; margin: 0.8rem 0 0.25rem; }
.site-footer { margin-top: 1.5rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.site-footer nav, .site-footer p { display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; margin: 0.35rem 0; }
.site-footer a { font-size: 0.82rem; }
@media (max-width: 640px) {
  .controls { flex-wrap: wrap; }
  h1 { font-size: 1.4rem; }
}
html[dir="rtl"] body { font-family: "Segoe UI", Tahoma, sans-serif; }
html[dir="rtl"] .digits, html[dir="rtl"] .stat b { direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] th, html[dir="rtl"] td { text-align: right; }
.holiday-note { color: var(--muted); font-size: 0.9rem; }
