/* ===========================================================
   EzyClock — design tokens (themeable via [data-theme])
   =========================================================== */
:root, [data-theme="lab"]{
  --bg: #F4F5F8;
  --panel: #FFFFFF;
  --panel-2: #F0F1F5;
  --hairline: #E3E5EA;
  --text: #14161A;
  --text-dim: #6B7280;
  --accent: #2F6FED;
  --accent-soft: rgba(47,111,237,0.10);
  --card-day-bg: #FBF6E9;
  --card-night-bg: #EFF1FA;
  --ghost-opacity: 0.05;
}

[data-theme="stealth"]{
  --bg: #0A0A0C;
  --panel: #17181D;
  --panel-2: #1D1E24;
  --hairline: #2B2D34;
  --text: #F2F3F5;
  --text-dim: #9A9DA6;
  --accent: #22D3EE;
  --accent-soft: rgba(34,211,238,0.14);
  --card-day-bg: #1D1E24;
  --card-night-bg: #17181D;
  --ghost-opacity: 0.05;
}

[data-theme="solar"]{
  --bg: #0F0C08;
  --panel: #1B140D;
  --panel-2: #241B10;
  --hairline: #34281A;
  --text: #F5EEE3;
  --text-dim: #A89A85;
  --accent: #F0A93B;
  --accent-soft: rgba(240,169,59,0.16);
  --card-day-bg: #241B10;
  --card-night-bg: #1B140D;
  --ghost-opacity: 0.06;
}

[data-theme="cyber"]{
  --bg: #0C0714;
  --panel: #18101F;
  --panel-2: #201729;
  --hairline: #342541;
  --text: #F1E9F7;
  --text-dim: #A594B0;
  --accent: #F0308F;
  --accent-soft: rgba(240,48,143,0.16);
  --card-day-bg: #201729;
  --card-night-bg: #18101F;
  --ghost-opacity: 0.06;
}

:root{
  --danger: #E0526A;
  --success: #35B573;
  --font-display: 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }

body{
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

button{ font-family: inherit; }
input{ font-family: inherit; }

::selection{ background: var(--accent-soft); }

:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.app{
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===================== Header ===================== */
.topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0 22px;
  flex-wrap: wrap;
}

.brand{ display:flex; align-items:center; gap:12px; }
.brand-mark{
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg{ width: 20px; height: 20px; }
.brand-name{ font-weight: 800; font-size: 1.15rem; letter-spacing: 0.02em; }

.header-actions{ display: flex; gap: 10px; }

.btn-outline{
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-outline svg{ width: 15px; height: 15px; flex-shrink: 0; }
.btn-outline:hover{ border-color: var(--accent); color: var(--accent); }
.btn-outline.active{ border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Tab row */
.tabs-row{
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.tab-pill{
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text);
  padding: 11px 22px;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.tab-pill:hover{ border-color: var(--accent); }
.tab-pill.active{ background: var(--accent); border-color: var(--accent); color: #fff; }

/* ===================== Ad slots ===================== */
.ad-slot{
  border: 1px dashed var(--hairline);
  border-radius: 12px;
  background: var(--panel);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
  position: relative;
  overflow: hidden;
}
.ad-fallback-label{
  position: absolute;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-transform: uppercase;
  pointer-events: none;
}
.ad-top{ margin-bottom: 20px; }
.ad-footer{ margin-top: 28px; }

/* ===================== Stage / Panels ===================== */
.stage{ flex: 1; }

.panel{ display: none; animation: fadeUp .35s ease; }
.panel.active{ display: block; }

@keyframes fadeUp{
  from{ opacity:0; transform: translateY(6px); }
  to{ opacity:1; transform: translateY(0); }
}

/* ===================== Clock panel ===================== */
.clock-mode-switch{
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}
.mode-btn{
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.mode-btn.active{ color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.clock-stage{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 340px;
  overflow: hidden;
}

.clock-ghost{
  position: absolute;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(6rem, 22vw, 15rem);
  color: var(--text);
  opacity: var(--ghost-opacity);
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  transition: transform .15s ease-out;
  z-index: 0;
}

.clock-decor{
  position: absolute;
  width: min(560px, 90vw);
  height: min(560px, 90vw);
  z-index: 0;
  pointer-events: none;
}
.decor-ring{ fill: none; stroke: var(--accent); }
.decor-ring.r1{ stroke-width: 1; opacity: 0.18; stroke-dasharray: 4 10; }
.decor-ring.r2{ stroke-width: 1; opacity: 0.14; stroke-dasharray: 1 8; }
.decor-ring.r3{ stroke-width: 1.3; opacity: 0.25; stroke-dasharray: 260 480; }

.digital-face{ position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; }
.digital-readout{ display: flex; flex-direction: column; align-items: center; gap: 6px; }

.time-row{
  display: flex;
  align-items: flex-start;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.4rem, 13vw, 6.5rem);
  letter-spacing: -0.01em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sep-dot{
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.22em;
  width: 0.24em;
  margin: 0 0.06em;
  align-self: center;
}
.sep-dot::before, .sep-dot::after{
  content: '';
  width: 0.16em;
  height: 0.16em;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
}
.sec-sup{
  font-size: 0.32em;
  font-weight: 700;
  color: var(--accent);
  margin-left: 0.12em;
  margin-top: 0.15em;
}
.time-meridiem{ font-size: 0.8rem; letter-spacing: 0.15em; color: var(--accent); font-weight: 700; }
.date-line{ font-size: 0.9rem; color: var(--text); margin-top: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
.tz-line{ font-size: 0.72rem; color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; }

.analog-face{ position: relative; z-index: 1; }
.analog-face.hidden, .digital-face.hidden{ display: none; }
.analog-face .ring-bg{ fill: var(--panel); stroke: var(--hairline); stroke-width: 2; }
.analog-face .tick{ stroke: var(--text-dim); stroke-width: 1.5; }
.analog-face .tick.major{ stroke: var(--text); stroke-width: 2.5; }
.hand{ stroke-linecap: round; transform-origin: 150px 150px; }
.hour-hand{ stroke: var(--text); stroke-width: 6; }
.min-hand{ stroke: var(--text); stroke-width: 4; }
.sec-hand{ stroke: var(--accent); stroke-width: 2; }
.hub{ fill: var(--accent); }

.clock-controls{
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.switch-row{
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
  cursor: pointer;
}
.switch-row input{ accent-color: var(--accent); width: 16px; height: 16px; }

/* ===================== World panel ===================== */
.world-head{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.eyebrow{ font-size: 0.72rem; letter-spacing: 0.14em; color: var(--accent); font-weight: 700; text-transform: uppercase; margin-bottom: 6px; }
.section-title{ font-size: 1.6rem; font-weight: 800; margin: 0; }

.world-add-row{
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.world-add-row.hidden{ display: none; }
.world-add-row input{
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
}
.world-add-row input::placeholder{ color: var(--text-dim); }

.world-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.world-card{
  background: var(--card-day-bg);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 18px;
  position: relative;
  cursor: grab;
}
.world-card.night{ background: var(--card-night-bg); }
.world-card.dragging{ opacity: 0.4; }
.world-card .card-top{ display:flex; align-items:flex-start; justify-content:space-between; margin-bottom: 12px; }
.world-card .handle{ color: var(--text-dim); font-size: 0.8rem; letter-spacing: 2px; cursor: grab; }
.world-card .daynight-icon{ font-size: 1rem; line-height: 1; }
.world-card .city{ font-weight: 700; font-size: 1.02rem; }
.world-card .region{ font-size: 0.68rem; color: var(--text-dim); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 10px; }
.world-card .time{
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.world-card.night .time{ color: var(--accent); }
.world-card .status-label{ font-size: 0.65rem; color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 6px; }
.world-card .remove-btn{
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 0.9rem; line-height: 1;
  padding: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.world-card:hover .remove-btn{ opacity: 1; }
.world-card .remove-btn:hover{ color: var(--danger); }
.world-card .daynote{ font-size: 0.68rem; color: var(--accent); margin-top: 2px; }

.empty-hint{ color: var(--text-dim); font-size: 0.9rem; grid-column: 1 / -1; text-align: center; padding: 30px 0; }
.hint-text{ text-align: center; color: var(--text-dim); font-size: 0.75rem; margin-top: 20px; }

/* ===================== Stopwatch panel ===================== */
.sw-display{
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 12vw, 4.5rem);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  margin: 30px 0 22px;
}
.sw-controls{
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.lap-list{
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
  max-height: 260px;
  overflow-y: auto;
  border-top: 1px solid var(--hairline);
}
.lap-list li{
  display: flex;
  justify-content: space-between;
  padding: 10px 6px;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.85rem;
  font-family: var(--font-display);
}
.lap-list li .lap-num{ color: var(--text-dim); font-family: var(--font-body); }
.lap-list li.fastest .split{ color: var(--success); }
.lap-list li.slowest .split{ color: var(--danger); }

/* ===================== Countdown panel ===================== */
.cd-face-wrap{
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin-bottom: 24px;
}
.cd-readout{
  position: absolute;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.cd-inputs{
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 22px;
}
.cd-field{ display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cd-field label{ font-size: 0.7rem; color: var(--text-dim); letter-spacing: 0.06em; }
.cd-field input{
  width: 70px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text);
  padding: 10px 6px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 1rem;
}
.cd-inputs.running .cd-field input{ opacity: 0.5; pointer-events: none; }

.cd-controls{ display: flex; justify-content: center; gap: 12px; }

/* ===================== Buttons ===================== */
.btn-primary, .btn-secondary{
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn-primary{ background: var(--accent); color: #fff; }
.btn-secondary{ background: var(--panel-2); color: var(--text); border: 1px solid var(--hairline); }
.btn-primary:disabled, .btn-secondary:disabled{ opacity: 0.4; cursor: not-allowed; }
.btn-primary:active:not(:disabled), .btn-secondary:active:not(:disabled){ transform: scale(0.97); }
.btn-large{ padding: 14px 40px; font-size: 0.95rem; }

/* ===================== Footer ===================== */
.footer{
  text-align: center;
  color: var(--text-dim);
  font-size: 0.72rem;
  padding-top: 20px;
}

/* ===================== Customize drawer ===================== */
.drawer{ position: fixed; inset: 0; z-index: 50; }
.drawer[hidden]{ display: none; }
.drawer-scrim{ position: absolute; inset: 0; background: rgba(10,10,15,0.5); z-index: 1; }
.drawer-inner{
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: min(400px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--hairline);
  padding: 22px;
  overflow-y: auto;
  animation: slideIn .25s ease;
  z-index: 2;
}
@keyframes slideIn{ from{ transform: translateX(100%); } to{ transform: translateX(0); } }

.drawer-head{ display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.drawer-head h2{ font-size: 1.3rem; margin: 2px 0 0; font-weight: 800; }
.icon-btn{ background: none; border: none; color: var(--text-dim); font-size: 1.1rem; cursor: pointer; }

.drawer-tabs{ display: flex; gap: 6px; background: var(--panel-2); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.dtab{
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.dtab.active{ background: var(--panel); color: var(--text); }

.drawer-panel{ display: none; }
.drawer-panel.active{ display: block; }

.theme-grid{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.theme-card{
  border: 2px solid var(--hairline);
  border-radius: 14px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  background: var(--tc-bg);
  color: var(--tc-fg);
}
.theme-card.active{ border-color: var(--accent); }
.theme-card .dots{ display: flex; gap: 6px; margin-bottom: 10px; }
.theme-card .dots span{ width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.theme-card .theme-name{ font-weight: 700; font-size: 0.92rem; }
.theme-card .theme-desc{ font-size: 0.72rem; opacity: 0.65; margin-bottom: 10px; }
.theme-card .theme-preview{ font-family: 'JetBrains Mono', monospace; font-size: 1.3rem; font-weight: 700; }

.font-list{ display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.font-card{
  border: 2px solid var(--hairline);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.font-card.active{ border-color: var(--accent); background: var(--accent-soft); }
.font-card .font-label{ font-size: 0.68rem; letter-spacing: 0.1em; color: var(--text-dim); text-transform: uppercase; }
.font-card .font-preview{ font-size: 1.3rem; font-variant-numeric: tabular-nums; color: var(--text); }

.drawer-extra{ border-top: 1px solid var(--hairline); padding-top: 6px; }
.setting-row{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.85rem;
}
.setting-row input[type=checkbox]{ accent-color: var(--accent); width: 18px; height: 18px; }

/* ===================== Toast ===================== */
.toast{
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--hairline);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 100;
}
.toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===================== Reduced motion ===================== */
.reduce-motion .panel{ animation: none; }
.reduce-motion .ring-progress{ transition: none; }
.reduce-motion .hand{ transition: none; }
.reduce-motion .clock-ghost{ transition: none !important; transform: none !important; }

@media (prefers-reduced-motion: reduce){
  .panel{ animation: none; }
  .hand{ transition: none; }
  .clock-ghost{ transition: none; }
}

/* ===================== Kiosk / fullscreen mode ===================== */
body.kiosk-mode{ background: var(--bg); }

body.kiosk-mode .app{
  max-width: 100%;
  padding: 0 20px;
}

body.kiosk-mode .ad-slot,
body.kiosk-mode .footer{
  display: none;
}

body.kiosk-mode .stage{
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.kiosk-mode .panel{
  width: 100%;
}

body.kiosk-mode .topbar,
body.kiosk-mode .tabs-row{
  position: fixed;
  left: 0; right: 0;
  z-index: 40;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
body.kiosk-mode .topbar{ top: 0; margin: 0; padding: 20px 24px 10px; background: linear-gradient(to bottom, var(--bg) 60%, transparent); }
body.kiosk-mode .tabs-row{ top: 78px; margin: 0; padding: 0 24px 16px; background: linear-gradient(to bottom, var(--bg) 40%, transparent); }
body.kiosk-mode.show-controls .topbar,
body.kiosk-mode.show-controls .tabs-row{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

body.kiosk-mode .clock-stage{ min-height: 60vh; }
body.kiosk-mode .time-row{ font-size: clamp(3.4rem, 15vw, 9rem); }
body.kiosk-mode .sw-display{ font-size: clamp(3.5rem, 15vw, 8rem); }
body.kiosk-mode .cd-readout{ font-size: clamp(2.4rem, 9vw, 5rem); }
body.kiosk-mode .world-grid{ max-width: 900px; margin: 0 auto; }

@media (prefers-reduced-motion: reduce){
  body.kiosk-mode .topbar, body.kiosk-mode .tabs-row{ transition: none; }
}

@media (max-width: 640px){
  .header-actions .btn-outline span{ display: none; }
  .header-actions .btn-outline{ padding: 9px 12px; }
}
