/* ================================================================
   TimeGoii — Cinema of Time
   Refined editorial luxury · Atmospheric minimalism · 6 mood themes
   ================================================================ */

/* ----- Reset & Base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-feature-settings: "ss01", "cv11";
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 800ms cubic-bezier(0.4, 0, 0.2, 1), color 400ms ease;
  overflow-x: hidden;
  position: relative;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
em { font-style: italic; }

/* ----- Atmospheric body backdrop ----- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--mesh);
  pointer-events: none;
  z-index: 0;
  opacity: 1;
  transition: opacity 800ms ease;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.15 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
  mix-blend-mode: overlay;
}

/* ================================================================
   DESIGN TOKENS — 6 themes
   ================================================================ */
:root {
  /* Fonts */
  --font-display: "Fraunces", "Cormorant Garamond", Georgia, serif;
  --font-body:    "Outfit", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", "Geist Mono", ui-monospace, monospace;
  --font-thai:    "IBM Plex Sans Thai", "Sarabun", sans-serif;
  --font-arabic:  "Noto Naskh Arabic", "Amiri", serif;

  /* Layout */
  --max-w: 1280px;
  --content-w: 980px;
  --gutter: clamp(20px, 4vw, 48px);

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 24px;
  --r-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* THEME: Calm — first light */
  --bg:        #eef1f8;
  --bg-deep:   #e3e8f2;
  --surface:   rgba(255, 255, 255, 0.65);
  --surface-2: rgba(255, 255, 255, 0.45);
  --fg:        #0e1929;
  --fg-muted:  #4d5b71;
  --fg-faint:  #8794ab;
  --hairline:  rgba(14, 25, 41, 0.10);
  --hairline-strong: rgba(14, 25, 41, 0.18);
  --accent:    #3a6fd8;
  --accent-2:  #6b9dff;
  --accent-soft: rgba(58, 111, 216, 0.10);
  --glow:      rgba(58, 111, 216, 0.28);
  --mesh:
    radial-gradient(60% 50% at 20% 15%, rgba(120, 170, 255, 0.22), transparent 60%),
    radial-gradient(50% 45% at 80% 85%, rgba(180, 200, 255, 0.18), transparent 65%),
    linear-gradient(180deg, transparent 0%, rgba(220, 230, 250, 0.4) 100%);
}

/* THEME: Focus — late-night studio */
[data-theme="focus"] {
  --bg:        #14102a;
  --bg-deep:   #0d0a1f;
  --surface:   rgba(38, 31, 66, 0.55);
  --surface-2: rgba(28, 22, 52, 0.7);
  --fg:        #f3eeff;
  --fg-muted:  #b5a8d8;
  --fg-faint:  #8175a8;
  --hairline:  rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.15);
  --accent:    #c39df8;
  --accent-2:  #9d7df0;
  --accent-soft: rgba(195, 157, 248, 0.14);
  --glow:      rgba(195, 157, 248, 0.45);
  --mesh:
    radial-gradient(55% 45% at 25% 20%, rgba(160, 100, 240, 0.35), transparent 65%),
    radial-gradient(50% 40% at 80% 75%, rgba(110, 70, 200, 0.30), transparent 70%),
    radial-gradient(70% 50% at 50% 100%, rgba(60, 40, 120, 0.4), transparent 70%);
}

/* THEME: Energetic — sunrise gold */
[data-theme="energetic"] {
  --bg:        #fff4e6;
  --bg-deep:   #ffe9d2;
  --surface:   rgba(255, 255, 255, 0.7);
  --surface-2: rgba(255, 255, 255, 0.5);
  --fg:        #3a1e0c;
  --fg-muted:  #7a4a26;
  --fg-faint:  #b08967;
  --hairline:  rgba(58, 30, 12, 0.10);
  --hairline-strong: rgba(58, 30, 12, 0.18);
  --accent:    #e07a2c;
  --accent-2:  #ff9d4a;
  --accent-soft: rgba(224, 122, 44, 0.12);
  --glow:      rgba(224, 122, 44, 0.32);
  --mesh:
    radial-gradient(60% 50% at 20% 15%, rgba(255, 180, 120, 0.45), transparent 60%),
    radial-gradient(50% 40% at 80% 80%, rgba(255, 140, 90, 0.30), transparent 60%),
    linear-gradient(180deg, rgba(255, 220, 180, 0.3) 0%, transparent 50%);
}

/* THEME: Nature — forest morning */
[data-theme="nature"] {
  --bg:        #e8efe5;
  --bg-deep:   #d4e1d0;
  --surface:   rgba(255, 255, 255, 0.65);
  --surface-2: rgba(255, 255, 255, 0.45);
  --fg:        #142919;
  --fg-muted:  #3f5e44;
  --fg-faint:  #8aa28f;
  --hairline:  rgba(20, 41, 25, 0.10);
  --hairline-strong: rgba(20, 41, 25, 0.18);
  --accent:    #3a8c54;
  --accent-2:  #5fb27a;
  --accent-soft: rgba(58, 140, 84, 0.12);
  --glow:      rgba(58, 140, 84, 0.30);
  --mesh:
    radial-gradient(55% 45% at 25% 20%, rgba(140, 200, 150, 0.35), transparent 60%),
    radial-gradient(50% 40% at 75% 80%, rgba(90, 170, 130, 0.25), transparent 65%);
}

/* THEME: Night — pure void */
[data-theme="night"] {
  --bg:        #050608;
  --bg-deep:   #000000;
  --surface:   rgba(20, 22, 30, 0.7);
  --surface-2: rgba(12, 14, 22, 0.85);
  --fg:        #f0f2f8;
  --fg-muted:  #9ba3b5;
  --fg-faint:  #5d6578;
  --hairline:  rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --accent:    #8ab4ff;
  --accent-2:  #b5d0ff;
  --accent-soft: rgba(138, 180, 255, 0.10);
  --glow:      rgba(138, 180, 255, 0.40);
  --mesh:
    radial-gradient(55% 45% at 20% 25%, rgba(70, 100, 180, 0.20), transparent 70%),
    radial-gradient(50% 40% at 80% 75%, rgba(50, 80, 160, 0.18), transparent 75%);
}

/* THEME: Sunset — amber rose */
[data-theme="sunset"] {
  --bg:        #2a1018;
  --bg-deep:   #1a0810;
  --surface:   rgba(50, 25, 38, 0.6);
  --surface-2: rgba(40, 18, 30, 0.75);
  --fg:        #ffeae0;
  --fg-muted:  #e4b8a8;
  --fg-faint:  #a87f74;
  --hairline:  rgba(255, 234, 224, 0.10);
  --hairline-strong: rgba(255, 234, 224, 0.18);
  --accent:    #ff8a65;
  --accent-2:  #ffb088;
  --accent-soft: rgba(255, 138, 101, 0.14);
  --glow:      rgba(255, 138, 101, 0.45);
  --mesh:
    radial-gradient(55% 45% at 25% 20%, rgba(255, 130, 100, 0.30), transparent 65%),
    radial-gradient(50% 40% at 80% 80%, rgba(220, 80, 110, 0.28), transparent 70%),
    radial-gradient(70% 50% at 50% 100%, rgba(120, 30, 60, 0.4), transparent 70%);
}

/* Mix Thai/Arabic fonts via :lang() */
:lang(th) { font-family: var(--font-thai); }
:lang(ar) { font-family: var(--font-arabic); }

/* ================================================================
   LAYOUT PRIMITIVES
   ================================================================ */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
  position: relative;
  z-index: 2;
}
.hidden { display: none !important; }

/* ================================================================
   NAVIGATION — asymmetric editorial
   ================================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  background: linear-gradient(180deg, var(--bg) 0%, transparent 100%);
  border-bottom: 1px solid var(--hairline);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand__mark {
  font-size: 1.4rem;
  line-height: 1;
  color: var(--accent);
  transform: translateY(2px);
}
.brand__name em {
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
}
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-list {
  display: flex;
  gap: 2px;
}
.nav-item {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-muted);
  transition: color 200ms var(--ease), background 200ms var(--ease);
  position: relative;
}
.nav-item:hover { color: var(--fg); }
.nav-item.active {
  color: var(--fg);
  background: var(--accent-soft);
}
.nav-toggle {
  display: none;
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  align-items: center; justify-content: center;
  color: var(--fg);
}
.nav-toggle:hover { background: var(--accent-soft); }
.nav-toggle__icon {
  width: 18px; height: 14px;
  position: relative;
}
.nav-toggle__icon::before,
.nav-toggle__icon::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 1.5px;
  background: currentColor;
  transition: transform 200ms;
}
.nav-toggle__icon::before { top: 2px; }
.nav-toggle__icon::after  { bottom: 2px; }

/* Language switcher */
.lang-switch { position: relative; }
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-muted);
  border: 1px solid var(--hairline);
  transition: border-color 200ms, color 200ms;
}
.lang-toggle:hover { color: var(--fg); border-color: var(--hairline-strong); }
.lang-toggle__chev {
  display: inline-block;
  width: 8px; height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  margin-left: 2px;
}
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.lang-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.lang-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  color: var(--fg-muted);
  text-align: left;
  transition: background 150ms, color 150ms;
}
.lang-option:hover { background: var(--accent-soft); color: var(--fg); }
.lang-option__code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
  text-transform: uppercase;
}
.lang-option.current { color: var(--accent); background: var(--accent-soft); }

/* ================================================================
   HERO — the main event
   ================================================================ */
.hero {
  min-height: 78vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0 40px;
  text-align: center;
  position: relative;
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 24px;
  opacity: 0;
  animation: rise 800ms var(--ease) 100ms forwards;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   CLOCK STAGE
   ================================================================ */
.clock-stage {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}
.clock-stage::before {
  content: "";
  position: absolute;
  width: min(70vw, 700px);
  aspect-ratio: 1;
  background: radial-gradient(circle, var(--glow) 0%, transparent 65%);
  filter: blur(40px);
  z-index: 0;
  animation: drift 24s var(--ease) infinite alternate;
}
@keyframes drift {
  0%   { transform: translate(-30px, -10px) scale(1); }
  100% { transform: translate(30px, 10px) scale(1.05); }
}
.clock-display {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fullscreen mode */
.clock-stage.fullscreen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  padding: 0;
}
.clock-stage.fullscreen .clock-display { padding: 24px; }

/* ----- DIGITAL view ----- */
.clock-digital {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  opacity: 0;
  animation: rise 900ms var(--ease) 200ms forwards;
}
.clock-time {
  font-family: var(--font-mono);
  font-size: clamp(4.5rem, 16vw, 11rem);
  font-weight: 300;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 60px var(--glow);
}
.clock-time::selection { background: var(--accent); color: var(--bg); }
.clock-ampm {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.02em;
  min-height: 1.4em;
}
.clock-date {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  font-weight: 400;
  color: var(--fg-muted);
  letter-spacing: -0.01em;
}

/* ----- ANALOG view ----- */
.clock-analog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.clock-svg {
  width: clamp(280px, 50vw, 460px);
  aspect-ratio: 1;
  filter: drop-shadow(0 0 40px var(--glow));
}
.clock-face {
  fill: var(--surface);
  stroke: var(--hairline-strong);
  stroke-width: 0.6;
}
.tick {
  stroke: var(--fg-muted);
  stroke-linecap: round;
}
.tick-hour { stroke-width: 1.4; stroke: var(--fg); }
.tick-min  { stroke-width: 0.6; opacity: 0.5; }
.hand { stroke-linecap: round; }
.hand-hour { stroke: var(--fg); stroke-width: 3.5; }
.hand-min  { stroke: var(--fg); stroke-width: 2.2; }
.hand-sec  { stroke: var(--accent); stroke-width: 1.2; }
.clock-center { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; }

/* ----- FLIP view ----- */
.clock-flip { padding: 16px 0; }
.flip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
}
.flip-sep {
  font-size: clamp(2.5rem, 8vw, 5rem);
  color: var(--accent);
  font-weight: 200;
  line-height: 1;
  padding-bottom: 0.4em;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}
.flip-cell {
  position: relative;
  width: clamp(74px, 14vw, 140px);
  height: clamp(108px, 20vw, 196px);
  perspective: 800px;
}
.flip-card {
  position: absolute;
  left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(3rem, 9vw, 6.5rem);
  font-weight: 200;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  backface-visibility: hidden;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.04);
}
.flip-card--top {
  top: 0;
  align-items: flex-end;
  padding-bottom: 0.04em;
  border-bottom: 1px solid var(--hairline-strong);
  transform-origin: bottom center;
}
.flip-card--bot {
  bottom: 0;
  align-items: flex-start;
  padding-top: 0.04em;
  transform-origin: top center;
}
.flip-card--top-next, .flip-card--bot-next { display: none; }
.flip-card--top-next {
  top: 0; align-items: flex-end; padding-bottom: 0.04em;
  border-bottom: 1px solid var(--hairline-strong);
  transform-origin: bottom center;
  transform: rotateX(180deg);
  z-index: 2;
}
.flip-card--bot-next {
  bottom: 0; align-items: flex-start; padding-top: 0.04em;
  transform-origin: top center;
  transform: rotateX(-180deg);
  z-index: 2;
}
.flip-cell.flipping .flip-card--top {
  animation: flipTop 0.5s ease-in forwards;
}
.flip-cell.flipping .flip-card--bot-next {
  display: flex;
  animation: flipBotNext 0.5s ease-out 0.25s forwards;
}
@keyframes flipTop    { to { transform: rotateX(-180deg); } }
@keyframes flipBotNext{ to { transform: rotateX(0deg); } }

/* ----- WORD view ----- */
.clock-word {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(200px, 35vw, 360px);
  padding: 24px;
}
.word-text {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2rem, 6.2vw, 4.6rem);
  line-height: 1.15;
  text-align: center;
  color: var(--fg);
  max-width: 18ch;
  letter-spacing: -0.02em;
  text-shadow: 0 0 40px var(--glow);
}

/* ----- BINARY view ----- */
.clock-binary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
}
.bin-grid {
  display: flex;
  gap: clamp(10px, 2vw, 22px);
  align-items: center;
}
.bin-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bin-cell {
  width: clamp(22px, 4.2vw, 38px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  transition: background 150ms var(--ease), box-shadow 200ms var(--ease);
}
.bin-cell.on {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--glow);
}
.bin-legend {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--fg-faint);
  display: flex;
  gap: clamp(14px, 3vw, 30px);
  margin-top: 4px;
}
.bin-legend span { width: clamp(22px, 4.2vw, 38px); text-align: center; }

/* ================================================================
   CONTROLS — segmented pill with sliding indicator
   ================================================================ */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px 16px;
  padding: 32px 0 24px;
}
.seg-group {
  display: inline-flex;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
}
.seg {
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 0.825rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--fg-muted);
  transition: color 200ms var(--ease);
  position: relative;
  z-index: 1;
  white-space: nowrap;
}
.seg:hover { color: var(--fg); }
.seg[aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent);
  box-shadow: 0 4px 14px var(--glow);
}

/* Inline toggles */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: border-color 200ms, color 200ms;
  user-select: none;
}
.toggle:hover { border-color: var(--hairline-strong); color: var(--fg); }
.toggle input {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  width: 28px; height: 16px;
  border-radius: var(--r-pill);
  background: var(--hairline-strong);
  cursor: pointer;
  transition: background 200ms var(--ease);
}
.toggle input::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bg);
  transition: transform 200ms var(--ease);
}
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(12px); }
.toggle:has(input:checked) { color: var(--fg); border-color: var(--accent-soft); }

/* Ghost button (Speak / Fullscreen) */
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--fg-muted);
  backdrop-filter: blur(12px);
  transition: border-color 200ms, color 200ms, transform 100ms;
}
.ghost-btn:hover { color: var(--fg); border-color: var(--hairline-strong); }
.ghost-btn:active { transform: scale(0.97); }

/* ================================================================
   INFO PANEL — mono labels
   ================================================================ */
.info-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin: 32px auto 0;
  max-width: var(--content-w);
}
.info-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 24px;
  background: var(--surface);
  backdrop-filter: blur(12px);
}
.info-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.info-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.info-cell--sync {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}
.info-cell--sync .info-label { min-width: auto; }
.info-cell--sync .info-value { font-size: 0.825rem; color: var(--fg-muted); }
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg-faint);
  opacity: 0.35;
  flex-shrink: 0;
  transition: background 300ms, opacity 300ms;
}
.sync-dot.synced {
  background: #44c97d;
  opacity: 1;
  box-shadow: 0 0 12px rgba(68, 201, 125, 0.6);
  animation: syncPulse 2.4s ease-in-out infinite;
}
@keyframes syncPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(68, 201, 125, 0.4); }
  50%      { box-shadow: 0 0 16px rgba(68, 201, 125, 0.85); }
}

/* ================================================================
   THEMES SECTION — refined swatch row
   ================================================================ */
.themes-section {
  margin-top: 80px;
  padding: 48px 0;
  border-top: 1px solid var(--hairline);
}
.themes-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  color: var(--fg-faint);
  margin-bottom: 32px;
}
.themes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  max-width: var(--content-w);
  margin: 0 auto;
}
.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 22px 18px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: border-color 200ms var(--ease), transform 200ms var(--ease);
  overflow: hidden;
}
.theme-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--swatch-bg);
  opacity: 0.6;
  z-index: 0;
}
.theme-card:hover {
  border-color: var(--hairline-strong);
  transform: translateY(-2px);
}
.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 12px 32px var(--glow);
}
.theme-swatch {
  position: relative;
  z-index: 1;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: var(--swatch-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.theme-name {
  position: relative; z-index: 1;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.1rem;
  color: var(--swatch-fg);
}
.theme-desc {
  position: relative; z-index: 1;
  font-size: 0.78rem;
  color: var(--swatch-fg);
  opacity: 0.75;
}
/* Per-theme swatch colors */
.theme-card[data-theme-btn="calm"]      { --swatch-bg: linear-gradient(135deg,#eef1f8 0%,#d8e3ff 100%); --swatch-color:#3a6fd8; --swatch-fg:#0e1929; }
.theme-card[data-theme-btn="focus"]     { --swatch-bg: linear-gradient(135deg,#14102a 0%,#3a2670 100%); --swatch-color:#c39df8; --swatch-fg:#f3eeff; }
.theme-card[data-theme-btn="energetic"] { --swatch-bg: linear-gradient(135deg,#fff4e6 0%,#ffd0a0 100%); --swatch-color:#e07a2c; --swatch-fg:#3a1e0c; }
.theme-card[data-theme-btn="nature"]    { --swatch-bg: linear-gradient(135deg,#e8efe5 0%,#a8d4b0 100%); --swatch-color:#3a8c54; --swatch-fg:#142919; }
.theme-card[data-theme-btn="night"]     { --swatch-bg: linear-gradient(135deg,#050608 0%,#1a2138 100%); --swatch-color:#8ab4ff; --swatch-fg:#f0f2f8; }
.theme-card[data-theme-btn="sunset"]    { --swatch-bg: linear-gradient(135deg,#2a1018 0%,#7a2540 100%); --swatch-color:#ff8a65; --swatch-fg:#ffeae0; }

/* ================================================================
   FOOTER
   ================================================================ */
.site-footer {
  margin-top: 80px;
  padding: 32px 0 40px;
  border-top: 1px solid var(--hairline);
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--fg-muted);
}
.footer-brand em {
  font-family: var(--font-display);
  font-style: italic;
}
.footer-tag {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--fg-faint);
}
.footer-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* ================================================================
   TOOL PAGES (stopwatch / timer / world-clock / about)
   ================================================================ */
.tool-hero {
  padding: 80px 0 40px;
  text-align: center;
}
.tool-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 18px;
}
.tool-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin-bottom: 12px;
}
.tool-title em { font-style: italic; }
.tool-subtitle {
  font-size: 1.05rem;
  color: var(--fg-muted);
  max-width: 52ch;
  margin: 0 auto;
}

/* Stopwatch display */
.sw-display {
  font-family: var(--font-mono);
  font-size: clamp(3.5rem, 12vw, 8rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  text-align: center;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  margin: 32px 0;
  text-shadow: 0 0 50px var(--glow);
}
.sw-ms {
  font-size: 0.45em;
  color: var(--fg-muted);
  font-weight: 300;
}

/* Timer */
.timer-inputs {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: 32px 0;
  flex-wrap: wrap;
}
.timer-input {
  width: clamp(80px, 16vw, 130px);
  text-align: center;
  font-family: var(--font-mono);
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 300;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  color: var(--fg);
  outline: none;
  transition: border-color 200ms, box-shadow 200ms;
}
.timer-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timer-input-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-top: 6px;
  text-align: center;
}
.timer-input-group { display: flex; flex-direction: column; }
.timer-sep {
  font-family: var(--font-mono);
  font-size: clamp(2.2rem, 6vw, 4rem);
  color: var(--fg-faint);
  font-weight: 200;
  padding: 0 4px;
  align-self: flex-start;
  padding-top: 14px;
}
.timer-display {
  font-family: var(--font-mono);
  font-size: clamp(4rem, 14vw, 9rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  text-align: center;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  margin: 24px 0;
  text-shadow: 0 0 60px var(--glow);
}
.timer-status {
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--fg-muted);
}

/* Primary action buttons */
.btn-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.btn-primary {
  padding: 14px 36px;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--r-pill);
  font-size: 0.925rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow: 0 8px 24px var(--glow);
  transition: transform 100ms var(--ease), box-shadow 200ms;
}
.btn-primary:hover { box-shadow: 0 12px 32px var(--glow); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  padding: 14px 28px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  color: var(--fg);
  border-radius: var(--r-pill);
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 200ms, background 200ms;
}
.btn-secondary:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Laps list */
.laps {
  max-width: 520px;
  margin: 40px auto 0;
}
.laps-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
  text-align: center;
  margin-bottom: 16px;
}
.lap {
  display: grid;
  grid-template-columns: 60px 1fr 1fr;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.lap--best { color: #44c97d; }
.lap--worst { color: #ff7a7a; }
.lap-no { color: var(--fg-faint); font-size: 0.78rem; }

/* World clock cards */
.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin: 32px 0;
}
.world-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  backdrop-filter: blur(12px);
  position: relative;
  transition: border-color 200ms, transform 200ms;
}
.world-card:hover { border-color: var(--hairline-strong); transform: translateY(-2px); }
.world-city {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--fg);
}
.world-time {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.world-offset {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
}
.world-remove {
  position: absolute;
  top: 12px; right: 12px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--fg-faint);
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 150ms;
}
.world-card:hover .world-remove { opacity: 1; }
.world-add {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 130px;
  background: transparent;
  border: 1.5px dashed var(--hairline-strong);
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
  color: var(--fg-muted);
  transition: border-color 200ms, color 200ms;
}
.world-add:hover { border-color: var(--accent); color: var(--accent); }

/* About prose */
.prose {
  max-width: 620px;
  margin: 0 auto;
  padding: 32px 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--fg-muted);
}
.prose p { margin-bottom: 1.2em; }
.prose p:first-child::first-letter {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 3.2em;
  float: left;
  line-height: 0.9;
  padding-right: 8px;
  color: var(--accent);
}
.prose-feedback {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
  color: var(--fg-faint);
  text-align: center;
  margin-top: 24px;
}

/* ================================================================
   MODAL (world-clock add city)
   ================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
  animation: modalIn 240ms var(--ease-back);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--hairline);
}
.modal-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 0.95rem;
  outline: none;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 12px;
}
.modal-item {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  text-align: left;
  color: var(--fg);
  transition: background 100ms;
}
.modal-item:hover { background: var(--accent-soft); }
.modal-item-tz { color: var(--fg-faint); font-family: var(--font-mono); font-size: 0.78rem; }

/* ================================================================
   AD SLOTS
   ================================================================ */
.ad-slot { width: 100%; min-height: 0; }
.ad-slot:empty { display: none; }
.ad-slot--header { padding: 0 var(--gutter); max-width: var(--max-w); margin: 0 auto; }
.ad-slot--in-content { padding: 24px 0; }
.ad-slot--sticky {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  background: var(--bg);
  border-top: 1px solid var(--hairline);
  padding: 8px var(--gutter);
}
.ad-slot--footer { padding: 24px 0 12px; }

/* ================================================================
   SKELETON LOADER
   ================================================================ */
.skeleton {
  position: fixed; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--bg);
  z-index: 999;
  transition: opacity 600ms;
}
.skeleton.hidden { opacity: 0; pointer-events: none; }
.skeleton-mark {
  font-size: 3rem;
  color: var(--accent);
  animation: spinSoft 3s ease-in-out infinite;
}
@keyframes spinSoft {
  0%, 100% { transform: rotate(0deg); opacity: 0.7; }
  50%      { transform: rotate(180deg); opacity: 1; }
}
.skeleton-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--fg-muted);
  letter-spacing: -0.01em;
}

/* ================================================================
   TOAST
   ================================================================ */
.toast {
  position: fixed;
  top: 24px; right: 24px;
  padding: 14px 20px;
  background: var(--surface-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  color: var(--fg);
  z-index: 100;
  transform: translateX(150%);
  transition: transform 300ms var(--ease-back);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
.toast.show { transform: translateX(0); }
.toast.error { border-color: rgba(255, 100, 100, 0.4); color: #ff7a7a; }

/* ================================================================
   RTL adjustments
   ================================================================ */
[dir="rtl"] .toast { right: auto; left: 24px; transform: translateX(-150%); }
[dir="rtl"] .toast.show { transform: translateX(0); }
[dir="rtl"] .lang-menu { right: auto; left: 0; }
[dir="rtl"] .world-remove { right: auto; left: 12px; }
[dir="rtl"] .lang-toggle__chev { transform: rotate(135deg) translate(-2px, -2px); }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 820px) {
  .nav-list { display: none; }
  .nav-list.open {
    display: flex;
    position: absolute;
    top: 100%; left: var(--gutter); right: var(--gutter);
    flex-direction: column;
    padding: 8px;
    background: var(--surface-2);
    backdrop-filter: blur(20px);
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  }
  .nav-list.open .nav-item { padding: 12px 16px; }
  .nav-toggle { display: inline-flex; }
  .hero { min-height: 60vh; padding: 36px 0 24px; }
  .themes-section { margin-top: 48px; padding: 32px 0; }
  .controls { gap: 10px; }
  .seg { padding: 7px 12px; font-size: 0.78rem; }
  .info-panel { grid-template-columns: 1fr; }
  .site-footer .container { justify-content: center; text-align: center; }
  .site-footer .container > * { flex-basis: 100%; text-align: center; }
}

@media (max-width: 480px) {
  .flip-row { gap: 4px; }
  .flip-sep { font-size: clamp(2rem, 7vw, 3rem); padding-bottom: 0.3em; }
  .clock-time { font-size: clamp(4rem, 18vw, 7rem); }
  .timer-inputs { gap: 6px; }
  .timer-input { width: 72px; padding: 10px 4px; }
}

/* ================================================================
   PRINT
   ================================================================ */
@media print {
  body::before, body::after, .ad-slot, .site-header, .site-footer, .controls, .themes-section { display: none !important; }
  body { background: white; color: black; }
  .clock-time, .timer-display, .sw-display { text-shadow: none; color: black; }
}

/* ================================================================
   ACCESSIBILITY
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .clock-stage::before { animation: none; }
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
