/* ===================================================================
   Timer · Stopwatch · Countdown — Tomato Hero + Red-LED device
   Cream world outside, dark-warm device with glowing red seven-seg.
   =================================================================== */

:root {
  --bg:           #faf6f1;
  --bg-2:         #f3eee5;
  --surface:      #ffffff;
  --surface-2:    #faf6ed;
  --surface-3:    #eee7d8;
  --border:       #e8dfcc;
  --border-soft:  #f0e9da;
  --text:         #1f1a14;
  --text-2:       #5c5547;
  --text-3:       #6e6557;
  --text-faint:   #b5ac9b;

  --accent:       #e85f4d;
  --accent-2:     #d44a39;
  --accent-soft:  rgba(232, 95, 77, 0.10);
  --accent-glow:  rgba(232, 95, 77, 0.55);

  --case-1:       #f3eee5;
  --case-2:       #e7dfcc;
  --case-3:       #cdc3ad;
  --screen-1:     #fff4ec;        /* cream LCD screen — light, not black */
  --screen-2:     #f6e6d6;
  --led-on:       #e85f4d;
  --led-dim:      rgba(232, 95, 77, 0.08);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.12);

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
             "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK",
             sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 235, 220, 0.55) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: -9999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px) clamp(12px, 3vw, 24px) 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 28px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-2);
}
.brand:hover { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover {
  color: var(--accent);
  background: var(--surface-2);
}

.lang-switcher {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  transition: border-color var(--transition);
}
.lang-switcher:hover { border-color: var(--text-3); }
.lang-switcher:focus { outline: none; border-color: var(--accent); }

.page-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 6px;
}
.page-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 28px;
}

/* ============ Mode tabs ============ */
.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 4px;
  width: max-content;
  margin: 0 auto 28px;
  box-shadow: var(--shadow-sm);
}
.mode-tab {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
  border-radius: var(--r-pill);
  transition: background var(--transition), color var(--transition);
}
.mode-tab:hover { color: var(--text); }
.mode-tab-active {
  background: var(--accent);
  color: #fff;
}
.mode-tab-active:hover { color: #fff; }

/* ============ Device (the LED clock body) ============ */
.device {
  margin: 0 auto 28px;
  max-width: 640px;
  perspective: 1200px;
}

.device-bezel {
  position: relative;
  border-radius: 28px;
  padding: clamp(20px, 4vw, 32px) clamp(20px, 5vw, 40px) clamp(24px, 4vw, 36px);
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(255,255,255,0.6) 0%, transparent 55%),
    linear-gradient(180deg, var(--case-1) 0%, var(--case-2) 100%);
  border: 1px solid var(--case-3);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.8),
    inset 0 -1px 0 rgba(0,0,0,0.06),
    0 1px 0 rgba(255,255,255,0.6),
    0 14px 32px rgba(120, 90, 60, 0.18),
    0 32px 72px rgba(120, 90, 60, 0.12);
}

/* Subtle plastic noise via multi-stop gradient */
.device-bezel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(0,0,0,0.012) 0 2px,
      rgba(255,255,255,0.015) 2px 4px
    );
  pointer-events: none;
  mix-blend-mode: overlay;
}

/* Screen (recessed cream LCD cavity) */
.device-screen {
  position: relative;
  border-radius: 18px;
  padding: clamp(24px, 6vw, 44px) clamp(20px, 5vw, 36px);
  background:
    radial-gradient(ellipse 90% 70% at 50% 35%, var(--screen-1) 0%, var(--screen-2) 100%);
  border: 1px solid rgba(40, 28, 20, 0.18);
  box-shadow:
    inset 0 2px 6px rgba(40, 28, 20, 0.28),
    inset 0 -1px 0 rgba(255, 255, 255, 0.5),
    inset 0 0 0 1px rgba(40, 28, 20, 0.10);
  overflow: hidden;
}
/* Subtle LCD scanlines on the cream screen */
.device-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg,
      rgba(40, 28, 20, 0.025) 0px,
      rgba(40, 28, 20, 0.025) 1px,
      transparent 1px,
      transparent 3px);
  pointer-events: none;
  border-radius: inherit;
}

/* Top glass gloss highlight */
.screen-glare {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, transparent 22%);
  pointer-events: none;
}

/* Seven-seg readout — tomato digits on the cream screen */
.seven-seg {
  position: relative;
  z-index: 1;
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums slashed-zero;
  font-size: clamp(56px, 14vw, 112px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-2);
  text-shadow:
    0 0 12px rgba(232, 95, 77, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.45);
  line-height: 1;
  padding: 6px 0 8px;
}

.seven-seg.flashing {
  animation: ledFlash 0.32s steps(2, end) 6;
}
@keyframes ledFlash {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.25; }
}

.screen-sub {
  position: relative;
  z-index: 1;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.4em;
  color: rgba(160, 60, 45, 0.62);
  margin-top: 6px;
  text-transform: uppercase;
}

/* Smaller seven-seg for stopwatch / countdown */
.seven-seg.size-md { font-size: clamp(44px, 11vw, 88px); }
.seven-seg.size-sm { font-size: clamp(32px, 8vw, 60px); letter-spacing: 0.03em; }

/* Controls row inside device */
.device-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: clamp(20px, 4vw, 28px);
  flex-wrap: wrap;
}

.device-btn {
  position: relative;
  min-width: 96px;
  padding: 12px 22px;
  background: linear-gradient(180deg, #ffffff 0%, var(--case-1) 100%);
  border: 1px solid var(--case-3);
  border-radius: 14px;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.95),
    inset 0 -1px 0 rgba(0,0,0,0.04),
    0 1px 0 rgba(255,255,255,0.5),
    0 2px 4px rgba(120,90,60,0.18),
    0 6px 14px rgba(120,90,60,0.10);
  transition: transform 80ms ease-out, box-shadow 120ms ease-out;
}
.device-btn:hover {
  color: var(--accent-2);
}
.device-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.12),
    inset 0 -1px 0 rgba(255,255,255,0.4),
    0 1px 2px rgba(120,90,60,0.10);
}

.device-btn-primary {
  background: linear-gradient(180deg, #ff7f69 0%, var(--accent-2) 100%);
  color: #fff;
  border-color: #b53a2a;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.35),
    inset 0 -1px 0 rgba(0,0,0,0.10),
    0 2px 4px rgba(180,60,40,0.30),
    0 6px 14px rgba(180,60,40,0.18);
}
.device-btn-primary:hover { color: #fff; filter: brightness(1.05); }
.device-btn-primary:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.20),
    inset 0 -1px 0 rgba(255,255,255,0.18),
    0 1px 2px rgba(180,60,40,0.20);
}

.device-brand {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.35em;
  color: var(--text-faint);
  text-transform: uppercase;
}

/* ============ Presets ============ */
.presets {
  text-align: center;
  margin-bottom: 24px;
}
.presets-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 10px;
}
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.chip {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip-active:hover { color: #fff; }

/* ============ Laps ============ */
.laps {
  max-width: 640px;
  margin: 0 auto 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.laps-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 10px;
}
.lap-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.lap-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-soft);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
}
.lap-list li:last-child { border-bottom: none; }
.lap-list .lap-num { color: var(--text-3); }
.lap-empty {
  color: var(--text-3);
  font-size: 14px;
}

/* ============ Countdown config ============ */
.countdown-config {
  max-width: 640px;
  margin: 0 auto 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.cd-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 10px;
}
.cd-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cd-input {
  flex: 1 1 220px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text);
}
.cd-input:focus { outline: none; border-color: var(--accent); }
.cd-go {
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: var(--r-sm);
  transition: background var(--transition);
}
.cd-go:hover { background: var(--accent-2); }

/* ============ Info ============ */
.info {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 0 4px;
}
.info h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 26px 0 10px;
  color: var(--text);
}
.info p {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 10px;
}

.kb-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.kb-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text-2);
}
.kb-list kbd {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  box-shadow: inset 0 -1px 0 var(--border);
}

.popular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.popular-grid li { margin: 0; }
.popular-grid a {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.popular-grid a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(232, 95, 77, 0.10);
}
.popular-grid small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  margin-top: 2px;
}

/* ============ Footer ============ */
.site-footer {
  max-width: 720px;
  margin: 56px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
}
.site-footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

@media (max-width: 480px) {
  .device-bezel { padding: 18px 16px 28px; }
  .device-btn { min-width: 78px; padding: 10px 14px; font-size: 13px; }
  .device-brand { font-size: 8px; letter-spacing: 0.3em; }
  .preset-chips .chip { padding: 6px 11px; font-size: 12px; }
  .mode-tab { padding: 7px 14px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .seven-seg.flashing { animation: none; }
}

/* ===== Timer Hub ===== */
.timer-hub {
  max-width: 640px;
  margin: 48px auto 0;
  padding: 0 16px 40px;
}

.hub-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 28px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.timer-category {
  margin-bottom: 24px;
}

.cat-heading {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.timer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timer-chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.timer-chip:hover,
.timer-chip:focus-visible {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  outline: none;
}

@media (max-width: 480px) {
  .timer-hub { padding: 0 12px 32px; }
  .timer-chip { font-size: 12px; padding: 4px 10px; }
}
