/* =============================================================
   123Clock.online — global stylesheet
   ============================================================= */

:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --surface-2: #f0f3fa;
  --border:    #e2e7f0;
  --text:      #1a2233;
  --text-soft: #5a6479;
  --text-mut:  #8b93a7;
  --brand:     #2563eb;
  --brand-2:   #0ea5e9;
  --accent:    #7c3aed;
  --good:      #059669;
  --warn:      #d97706;
  --danger:    #dc2626;
  --header-bg: #0f172a;
  --header-fg: #e7ecf6;
  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(16,24,40,.05), 0 8px 24px rgba(16,24,40,.06);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --maxw:      1120px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

/* Dark theme applies only when the user opts in (default is light).
   The theme is stored in localStorage and set as data-theme on <html>. */
:root[data-theme="dark"] {
  --bg:        #0b1120;
  --surface:   #131c2e;
  --surface-2: #1a2438;
  --border:    #263149;
  --text:      #e7ecf6;
  --text-soft: #a7b0c5;
  --text-mut:  #7c869e;
  --brand:     #3b82f6;
  --brand-2:   #38bdf8;
  --accent:    #a78bfa;
  --header-bg: #070c17;
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 1.05rem + 1vw, 1.7rem); }
h3 { font-size: 1.12rem; }
p  { margin: 0 0 1rem; }

.icon { flex: none; vertical-align: middle; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header / nav ---------- */
.site-header {
  background: var(--header-bg);
  color: var(--header-fg);
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 6px 20px rgba(0,0,0,.18);
}
.header-inner { display: flex; align-items: center; gap: 18px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--header-fg); font-weight: 800; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; }
.brand-dot { color: var(--brand-2); font-weight: 700; }

.primary-nav { margin-left: auto; }
.primary-nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.primary-nav a {
  display: flex; align-items: center; gap: 7px;
  color: #cbd5e6; padding: 9px 12px; border-radius: 9px; font-size: .92rem; font-weight: 600;
  transition: background .15s, color .15s;
}
.primary-nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.primary-nav a.active { background: rgba(59,130,246,.22); color: #fff; }

.nav-toggle { display: none; margin-left: auto; background: none; border: 0; cursor: pointer;
  width: 42px; height: 42px; border-radius: 9px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--header-fg); margin: 4px auto; border-radius: 2px; transition: .2s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px; margin-left: 6px;
  background: none; border: 0; border-radius: 9px; cursor: pointer;
  color: var(--header-fg); transition: background .15s, color .15s;
}
.theme-toggle:hover { background: rgba(255,255,255,.07); color: #fff; }
.theme-toggle:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.theme-toggle .icon { grid-area: 1 / 1; }
/* Light theme (default): offer dark → show moon. Dark theme: offer light → show sun. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

@media (max-width: 860px) {
  .nav-toggle { display: block; margin-left: 0; }
  .theme-toggle { margin-left: auto; }
  .primary-nav {
    position: absolute; top: 62px; left: 0; right: 0; background: var(--header-bg);
    margin: 0; max-height: 0; overflow: hidden; transition: max-height .25s ease;
    box-shadow: 0 12px 24px rgba(0,0,0,.25);
  }
  .primary-nav.open { max-height: 70vh; }
  .primary-nav ul { flex-direction: column; padding: 8px 16px 16px; gap: 2px; }
  .primary-nav a { padding: 12px; font-size: 1rem; }
}

/* ---------- Layout blocks ---------- */
main.wrap { padding-block: 28px 48px; min-height: 60vh; }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin-bottom: .25em; }
.page-head p { color: var(--text-soft); max-width: 68ch; margin: 0; }

.breadcrumb { font-size: .85rem; color: var(--text-mut); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-mut); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.section { margin-top: 30px; }
.section > h2 { display: flex; align-items: center; gap: 9px; }
.muted { color: var(--text-soft); }
.small { font-size: .86rem; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--brand); color: #fff; border: 1px solid transparent;
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .95rem;
  font-family: inherit; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--border); }
.btn.small { padding: 7px 12px; font-size: .85rem; }
.btn.danger { background: var(--danger); }
.btn.good { background: var(--good); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .85rem; color: var(--text-soft); }
input, select, textarea {
  font-family: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 1px; border-color: var(--brand);
}
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .92rem; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data thead th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); position: sticky; top: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border); }
.badge.brand { background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand); border-color: transparent; }
.badge.good  { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); border-color: transparent; }

.notice { border-left: 4px solid var(--brand); background: var(--surface-2); padding: 12px 16px; border-radius: 0 10px 10px 0; }
.notice.warn { border-color: var(--warn); }

/* ---------- Hero (home) ---------- */
.hero {
  background: radial-gradient(1200px 400px at 15% -20%, rgba(124,58,237,.18), transparent 60%),
              radial-gradient(1000px 400px at 100% 0%, rgba(14,165,233,.18), transparent 55%),
              var(--surface);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  padding: clamp(24px, 3vw, 44px); margin-top: 6px;
}
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 30px; align-items: center; }
@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; } }
.hero h1 { margin-bottom: .3em; }
.hero p.lead { font-size: 1.1rem; color: var(--text-soft); margin-bottom: 1.2rem; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }

.bigclock { text-align: center; }
.bigclock .time { font-family: var(--mono); font-weight: 700; font-size: clamp(2.6rem, 1.5rem + 6vw, 4.4rem);
  letter-spacing: .02em; line-height: 1; color: var(--text); }
.bigclock .time .sec { color: var(--brand-2); }
.bigclock .meta { color: var(--text-soft); margin-top: 10px; font-size: 1rem; }
.bigclock .date { color: var(--text-mut); font-size: .95rem; }

/* ---------- Tool cards ---------- */
.tool-card { display: flex; flex-direction: column; gap: 10px; padding: 20px; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s, border-color .15s; }
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); text-decoration: none; }
.tool-card .ic { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px;
  background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.tool-card h3 { margin: 0; color: var(--text); }
.tool-card p { margin: 0; color: var(--text-soft); font-size: .92rem; }

/* ---------- World clock ---------- */
.clock-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.clock-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); }
.clock-tile .city { font-weight: 700; font-size: 1.02rem; }
.clock-tile .country { color: var(--text-mut); font-size: .8rem; }
.clock-tile .lt { font-family: var(--mono); font-size: 1.9rem; font-weight: 700; margin: 8px 0 2px; letter-spacing: .01em; }
.clock-tile .lt .sec { color: var(--brand-2); font-size: 1.2rem; }
.clock-tile .offset { font-size: .78rem; color: var(--text-soft); display: flex; justify-content: space-between; gap: 8px; }
.clock-tile .dayflag { font-size: .72rem; }

.local-banner { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; box-shadow: var(--shadow-sm); margin-bottom: 22px; }
.local-banner .lt { font-family: var(--mono); font-size: 2.1rem; font-weight: 700; }
.local-banner .lt .sec { color: var(--brand-2); }

/* ---------- Calendar ---------- */
.cal { width: 100%; border-collapse: separate; border-spacing: 6px; }
.cal th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-soft); padding: 6px; }
.cal td { text-align: right; vertical-align: top; height: 78px; width: 14%; border-radius: 10px;
  background: var(--surface-2); border: 1px solid transparent; padding: 8px 10px; font-variant-numeric: tabular-nums; }
.cal td.pad { background: transparent; }
.cal td .dnum { font-weight: 700; font-size: 1.05rem; }
.cal td.today { background: color-mix(in srgb, var(--brand) 16%, var(--surface)); border-color: var(--brand); }
.cal td.today .dnum { color: var(--brand); }
.cal td.weekend { background: color-mix(in srgb, var(--accent) 7%, var(--surface-2)); }
.cal .wk { background: transparent; color: var(--text-mut); font-size: .78rem; text-align: center; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-nav { display: flex; gap: 8px; align-items: center; }

.year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 900px) { .year-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .year-grid { grid-template-columns: 1fr; } }
.mini-cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
.mini-cal h3 { text-align: center; font-size: 1rem; }
.mini-cal table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.mini-cal td, .mini-cal th { text-align: center; padding: 3px; color: var(--text-soft); }
.mini-cal td.d { color: var(--text); }
.mini-cal td.today { background: var(--brand); color: #fff; border-radius: 6px; font-weight: 700; }

/* ---------- Sun / Moon ---------- */
.astro-hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); }
.stat .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--text-mut); font-size: .82rem; }

.moonwrap { display: flex; align-items: center; gap: 18px; }
.moon-visual { --illum: .5; width: 96px; height: 96px; border-radius: 50%; flex: none;
  background: #10131c; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 6px 18px rgba(0,0,0,.3); position: relative; overflow: hidden; }
.daylight-bar { height: 12px; border-radius: 999px; background: linear-gradient(90deg, #1e293b, #f59e0b, #fde68a, #f59e0b, #1e293b);
  position: relative; margin: 10px 0; }

/* ---------- Timer / stopwatch ---------- */
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 5px; border-radius: 12px; width: fit-content; margin-bottom: 20px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; color: var(--text-soft); font-weight: 600; padding: 9px 16px; border-radius: 9px; cursor: pointer; font-family: inherit; font-size: .92rem; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tabpanel[hidden] { display: none; }

.bigtime { font-family: var(--mono); font-weight: 700; font-size: clamp(3rem, 1.5rem + 9vw, 6rem); text-align: center; letter-spacing: .02em; line-height: 1.05; }
.bigtime.done { color: var(--danger); animation: flash 1s steps(2) infinite; }
@keyframes flash { 50% { opacity: .35; } }
.bigtime .ms { color: var(--brand-2); font-size: .5em; }
.timer-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.lap-list { list-style: none; padding: 0; margin: 18px auto 0; max-width: 420px; }
.lap-list li { display: flex; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); font-family: var(--mono); }

/* ---------- Result blocks (calculators) ---------- */
.result { margin-top: 18px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.result h3 { margin-top: 0; }
.result .big { font-size: 1.8rem; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; }
.kv dt { color: var(--text-soft); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; }
.subtabs a { padding: 8px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); font-weight: 600; font-size: .88rem; }
.subtabs a.active { background: var(--brand); color: #fff; border-color: transparent; }
.subtabs a:hover { text-decoration: none; }

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Utilities ---------- */
.flex { display: flex; }
.between { justify-content: space-between; }
.items-center { align-items: center; }
.gap { gap: 12px; }
.wrap-flex { flex-wrap: wrap; }
.mt0 { margin-top: 0; } .mt { margin-top: 14px; } .mb0 { margin-bottom: 0; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
