/* ============================================================
   hijrical GUI — modern dark theme
   ============================================================ */
:root {
  --bg: #0b1220;
  --bg2: #0f1830;
  --panel: #131d36;
  --panel2: #18244180;
  --card: #15203c;
  --line: #25325a;
  --line-soft: #1e294a;
  --text: #e8edf9;
  --muted: #94a3c4;
  --faint: #6b7aa3;
  --accent: #2dd4bf;
  --accent2: #38bdf8;
  --gold: #f5c451;
  --gold-soft: #f5c45122;
  --moon-dark: #243150;
  --moon-lit: #f6e7b8;
  --feast: #f472b6;
  --holy: #c084fc;
  --observance: #38bdf8;
  --fast: #34d399;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 700px at 85% -10%, #1b2a52 0%, transparent 55%),
    radial-gradient(900px 600px at 0% 0%, #16233f 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
body[dir="rtl"] { font-family: "Segoe UI", "Tahoma", system-ui, sans-serif; }

#app { max-width: 1140px; margin: 0 auto; padding: 22px 20px 60px; }
code { background: #0c1426; padding: 1px 6px; border-radius: 6px; color: var(--accent); font-size: .85em; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 30px; width: 54px; height: 54px; display: grid; place-items: center;
  background: linear-gradient(150deg, #20305a, #122144);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: inset 0 0 24px #2dd4bf22;
}
.brand h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.header-controls { display: flex; align-items: center; gap: 12px; }
.engine-chip {
  display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; font-size: 13.5px; transition: border-color .15s, transform .1s;
}
.engine-chip:hover { border-color: var(--accent); }
.engine-chip:active { transform: scale(.98); }
.engine-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.engine-chip.astro .engine-dot { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.chev { color: var(--faint); }

.lang-switch { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.lang-switch button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: .15s;
}
.lang-switch button.active { background: linear-gradient(120deg, var(--accent), var(--accent2)); color: #04121a; }

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 20px;
  background: var(--panel2); border: 1px solid var(--line-soft); border-radius: 14px; padding: 6px;
}
.tabs button {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  background: transparent; color: var(--muted); padding: 9px 15px; border-radius: 10px;
  font-size: 13.8px; font-weight: 600; transition: .15s;
}
.tabs button span:first-child { font-size: 15px; }
.tabs button:hover { color: var(--text); background: #1a2747; }
.tabs button.active { background: linear-gradient(120deg, #1f3a5f, #233a63); color: #fff; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- panels / cards ---------- */
.panel { display: none; animation: fade .25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.cards2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card {
  background: linear-gradient(180deg, var(--card), #121b33);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.card.soft { background: linear-gradient(180deg, #14213f, #101933); }
.card h2 { font-size: 16px; margin: 0 0 16px; display: flex; align-items: center; gap: 9px; }
.card h2 span:first-child { font-size: 18px; }
.card h3 { font-size: 14px; margin: 4px 0 10px; display: flex; align-items: center; gap: 8px; color: var(--text); }
hr { border: 0; border-top: 1px dashed var(--line); margin: 20px 0 16px; }

label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
label:first-child { margin-top: 0; }
.mono-hint { color: var(--faint); font-weight: 400; font-family: ui-monospace, "Cascadia Code", monospace; font-size: 11px; }

input, select {
  width: 100%; background: #0c1426; border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #2dd4bf22; }
input[type="number"] { -moz-appearance: textfield; }

.row3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 10px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.endcol { display: flex; align-items: flex-end; }
.endcol .btn { width: 100%; }

.btnrow { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  border: 1px solid var(--line); background: #16223f; color: var(--text);
  padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px;
  font-weight: 600; transition: .15s; font-family: inherit;
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(120deg, var(--accent), var(--accent2)); color: #04121a; border: 0; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.block { width: 100%; margin-top: 16px; }

/* ---------- result blocks ---------- */
.result { margin-top: 16px; }
.result:empty { margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kv .k { color: var(--muted); font-size: 13px; }
.kv .v { color: var(--text); font-size: 13.5px; text-align: right; font-variant-numeric: tabular-nums; }
.hero {
  background: linear-gradient(120deg, #163056, #122443);
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px;
  text-align: center;
}
.hero .big { font-size: 24px; font-weight: 700; letter-spacing: .3px; }
.hero .small { color: var(--muted); font-size: 13px; margin-top: 4px; }
.hero .holiday-tag { margin-top: 10px; }
.err { color: var(--danger); background: #f8717112; border: 1px solid #f8717155; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.hint { color: var(--faint); font-size: 12.5px; margin: 4px 0 12px; line-height: 1.5; }

.holiday-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 4px 11px; border-radius: 999px; background: var(--gold-soft); color: var(--gold);
  border: 1px solid #f5c45144;
}
.tag-feast { background: #f472b61a; color: var(--feast); border-color: #f472b644; }
.tag-holy_night { background: #c084fc1a; color: var(--holy); border-color: #c084fc44; }
.tag-observance { background: #38bdf81a; color: var(--observance); border-color: #38bdf844; }
.tag-fast { background: #34d3991a; color: var(--fast); border-color: #34d39944; }

/* ---------- engine popover ---------- */
.popover-backdrop, .modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 7, 14, .82);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.popover-backdrop[hidden], .modal-backdrop[hidden] { display: none; }
.engine-panel[hidden] { display: none; }
.popover, .modal {
  background: linear-gradient(180deg, #16213d, #111a31); border: 1px solid var(--line);
  border-radius: 18px; width: 440px; max-width: 100%; padding: 22px; box-shadow: var(--shadow);
  position: relative; animation: pop .2s ease;
}
.modal { width: 460px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.pop-head h3 { margin: 0; font-size: 16px; }
.x { border: 0; background: #1b2747; color: var(--muted); width: 32px; height: 32px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.x:hover { color: #fff; background: #243567; }
.modal .x { position: absolute; top: 16px; inset-inline-end: 16px; }

.seg { display: flex; background: #0c1426; border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 9px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px; transition: .15s; font-family: inherit; }
.seg button.active { background: linear-gradient(120deg, var(--accent), var(--accent2)); color: #04121a; }
.seg.small button { padding: 7px; font-size: 12.5px; }
.engine-panel { margin-top: 6px; }
.custom-obs { margin-top: 8px; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.cal-title { text-align: center; flex: 1; }
.cal-title h2 { margin: 0; font-size: 19px; }
.navbtn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 22px; cursor: pointer; transition: .15s; }
.navbtn:hover { border-color: var(--accent); color: var(--accent); }
.badge { display: inline-block; margin-top: 6px; font-size: 11px; color: var(--faint); border: 1px solid var(--line); padding: 2px 9px; border-radius: 999px; }
.cal-jump { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-jump input { width: 90px; } .cal-jump select { width: auto; } .cal-jump label { margin: 0; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-grid[hidden], .year-grid[hidden] { display: none; }
.cal-grid .dow { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; padding: 6px 0; }
.cell {
  aspect-ratio: 1 / 1; border: 1px solid var(--line-soft); border-radius: 12px; padding: 8px;
  background: #0e1730; display: flex; flex-direction: column; cursor: default; position: relative;
  transition: .15s; min-height: 64px;
}
.cell.empty { background: transparent; border-color: transparent; }
.cell.has { cursor: pointer; }
.cell.has:hover { border-color: var(--accent); transform: translateY(-2px); }
.cell .dnum { font-size: 16px; font-weight: 700; }
.cell .greg { font-size: 10.5px; color: var(--faint); margin-top: auto; }
.cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cell.today .dnum { color: var(--accent); }
.cell.hol { background: linear-gradient(180deg, #1a1d33, #15182c); }
.cell .dot { position: absolute; top: 8px; inset-inline-end: 8px; width: 9px; height: 9px; border-radius: 50%; }
.cell .hname { font-size: 9.5px; line-height: 1.15; margin-top: 3px; font-weight: 600; opacity: .92; max-height: 24px; overflow: hidden; }
.dot.k-feast, .hcol-feast { background: var(--feast); } .hcol-feast { color: var(--feast); }
.dot.k-holy_night, .hcol-holy_night { background: var(--holy); } .hcol-holy_night { color: var(--holy); }
.dot.k-observance, .hcol-observance { background: var(--observance); } .hcol-observance { color: var(--observance); }
.dot.k-fast, .hcol-fast { background: var(--fast); } .hcol-fast { color: var(--fast); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 16px; justify-content: center; color: var(--muted); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- holidays ---------- */
.upcoming { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.up-card { background: #101a34; border: 1px solid var(--line); border-radius: 14px; padding: 14px; position: relative; overflow: hidden; }
.up-card::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; }
.up-card.b-feast::before { background: var(--feast); } .up-card.b-holy_night::before { background: var(--holy); }
.up-card.b-observance::before { background: var(--observance); } .up-card.b-fast::before { background: var(--fast); }
.up-card .nm { font-weight: 700; font-size: 14.5px; }
.up-card .dt { color: var(--muted); font-size: 12.5px; margin: 4px 0 8px; }
.countdown { font-size: 13px; font-weight: 700; }
.countdown.soon { color: var(--gold); }
.countdown.past { color: var(--faint); }

.hol-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.holiday-list { display: flex; flex-direction: column; gap: 10px; }
.hrow {
  display: flex; align-items: center; gap: 14px; background: #101a34; border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 12px 16px; cursor: pointer; transition: .15s;
}
.hrow:hover { border-color: var(--accent); }
.hrow .hl-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; background: #0c1426; flex-shrink: 0; }
.hrow .hl-main { flex: 1; min-width: 0; }
.hrow .hl-name { font-weight: 700; font-size: 14.5px; }
.hrow .hl-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.hrow .hl-cd { text-align: end; flex-shrink: 0; }

/* ---------- crescent ---------- */
.cr-result { margin-top: 18px; }
.cr-verdict { text-align: center; padding: 20px; border-radius: 14px; margin-bottom: 16px; border: 1px solid var(--line); }
.cr-verdict.yes { background: linear-gradient(120deg, #0e3328, #10241f); border-color: #34d39955; }
.cr-verdict.no { background: linear-gradient(120deg, #331516, #241012); border-color: #f8717155; }
.cr-verdict .icon { font-size: 40px; }
.cr-verdict .txt { font-size: 19px; font-weight: 800; margin-top: 4px; }
.cr-verdict.yes .txt { color: var(--fast); } .cr-verdict.no .txt { color: var(--danger); }
.cr-verdict .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.metric { background: #0e1730; border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 14px; }
.metric .ml { color: var(--muted); font-size: 11.5px; }
.metric .mv { font-size: 19px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metric .mu { font-size: 11px; color: var(--faint); }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 0; }
.chips button { border: 1px dashed var(--line); background: #0e1730; color: var(--muted); padding: 5px 11px; border-radius: 999px; cursor: pointer; font-size: 12px; transition: .15s; font-family: inherit; }
.chips button:hover { border-color: var(--accent); color: var(--accent); border-style: solid; }

/* ---------- languages tables ---------- */
.loc-block { border: 1px solid var(--line-soft); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.loc-head2 { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #101a34; }
.loc-head2 .nm { font-weight: 700; } .loc-head2 .cd { color: var(--faint); font-size: 12px; }
.loc-body { padding: 14px 16px; display: none; }
.loc-block.open .loc-body { display: block; }
.loc-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.pill { background: #0e1730; border: 1px solid var(--line-soft); border-radius: 8px; padding: 4px 9px; font-size: 12px; }
.loc-sec { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; margin: 10px 0 6px; }

/* ---------- day modal ---------- */
.modal h3 { margin: 0 0 4px; font-size: 20px; }
.dm-greg { color: var(--muted); margin-bottom: 14px; font-size: 13.5px; }
.dm-desc { background: #0e1730; border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px; font-size: 13.5px; line-height: 1.6; margin: 12px 0; }
.dm-cd { font-size: 15px; font-weight: 700; text-align: center; padding: 12px; border-radius: 12px; background: var(--gold-soft); color: var(--gold); }
.dm-cd.past { background: #6b7aa31a; color: var(--muted); }

.foot { text-align: center; color: var(--faint); font-size: 12px; margin-top: 28px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .cards2 { grid-template-columns: 1fr; }
  .row4 { grid-template-columns: 1fr 1fr; }
  .brand h1 { font-size: 17px; }
  .cell { min-height: 52px; padding: 6px; }
  .cell .hname { display: none; }
}
[dir="rtl"] .kv .v { text-align: left; }
[dir="rtl"] .up-card::before { inset-inline-start: auto; }

/* ============================================================
   v2 additions: robustness, theme, year view, tools, compare, map
   ============================================================ */

/* --- header robustness: never let the chip overflow --- */
.header-controls { flex-wrap: wrap; justify-content: flex-end; }
.engine-chip { max-width: 320px; }
#engineLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 16px;
  display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* --- tabs: horizontal scroll instead of messy wrap on narrow --- */
.tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.tabs button { flex: 0 0 auto; }
@media (max-width: 760px) { .tabs button span:last-child { font-size: 12.5px; } }

/* --- calendar header view toggle + actions --- */
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-toggles { display: flex; gap: 10px; flex-wrap: wrap; }
.cal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toggle-line { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 14px 0 0; color: var(--text); font-weight: 600; font-size: 13px; }
.toggle-line input { width: auto; accent-color: var(--accent); cursor: pointer; }
.time-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 10px; }
.time-row[hidden] { display: none; }
.chip-coords { font-size: 12.5px; color: var(--muted); padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
.view-seg { display: flex; background: #0c1426; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.view-seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12.5px; font-family: inherit; }
.view-seg button.active { background: linear-gradient(120deg, var(--accent), var(--accent2)); color: #04121a; }

/* --- year view --- */
.year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.mini-month { background: #0e1730; border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px; }
.mini-month h4 { margin: 0 0 8px; font-size: 13.5px; text-align: center; color: var(--text); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.mini-grid .mdow { font-size: 8.5px; color: var(--faint); text-align: center; }
.mcell { aspect-ratio: 1; display: grid; place-items: center; font-size: 10.5px; border-radius: 5px; color: var(--muted); position: relative; }
.mcell.has { color: var(--text); cursor: pointer; }
.mcell.has:hover { background: #1a2747; }
.mcell.today { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); font-weight: 700; }
.mcell.hol { font-weight: 700; }
.mcell.k-feast { color: var(--feast); } .mcell.k-holy_night { color: var(--holy); }
.mcell.k-observance { color: var(--observance); } .mcell.k-fast { color: var(--fast); }
.mcell.hol::after { content: ""; position: absolute; bottom: 1px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
@media (max-width: 900px) { .year-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .year-grid { grid-template-columns: repeat(2, 1fr); } }

/* --- compare table --- */
.cmp-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; }
.cmp-table th, .cmp-table td { padding: 9px 10px; text-align: start; border-bottom: 1px solid var(--line-soft); }
.cmp-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.cmp-table td.num { font-variant-numeric: tabular-nums; text-align: end; }
.cmp-yes { color: var(--fast); font-weight: 700; }
.cmp-no { color: var(--faint); }
.cmp-badge { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; }
.cmp-badge.y { background: var(--fast); } .cmp-badge.n { background: #46506f; }
.cmp-summary { font-size: 14px; color: var(--muted); margin-top: 8px; }
.cmp-summary-num { font-size: 19px; font-weight: 800; color: var(--accent); }

/* --- crescent moon visual --- */
.cr-verdict .moon-wrap { display: flex; justify-content: center; margin-bottom: 8px; }
.moon-svg { width: 76px; height: 76px; filter: drop-shadow(0 0 16px color-mix(in srgb, var(--moon-lit) 60%, transparent)); }
.cr-verdict.no .moon-svg { filter: drop-shadow(0 0 12px rgba(248, 113, 113, .35)); }

/* --- map modal --- */
.map-modal { width: 640px; max-width: 100%; }
#leafletMap { height: 360px; border-radius: 12px; margin: 12px 0; background: #0e1730; }
.map-fallback { padding: 16px; text-align: center; color: var(--muted); }
.map-coords { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); }
.map-coords b { color: var(--text); font-variant-numeric: tabular-nums; }
.leaflet-container { font-family: inherit; }

/* --- boot overlay (Pyodide loading) --- */
.boot-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(900px 600px at 50% 0%, #16233f 0%, var(--bg) 60%);
}
.boot-overlay[hidden] { display: none; }
.boot-box { text-align: center; max-width: 360px; padding: 24px; }
.boot-moon { font-size: 56px; animation: bootpulse 1.8s ease-in-out infinite; }
@keyframes bootpulse { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.12); opacity: 1; } }
.boot-title { font-size: 20px; font-weight: 800; margin-top: 10px; letter-spacing: .3px; }
.boot-status { color: var(--accent); font-weight: 600; margin-top: 12px; font-size: 14px; }
.boot-sub { color: var(--faint); font-size: 12.5px; margin-top: 8px; line-height: 1.5; }
.boot-bar { height: 4px; border-radius: 999px; background: #1a2747; overflow: hidden; margin-top: 16px; }
.boot-bar span { display: block; height: 100%; width: 40%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); animation: bootslide 1.4s ease-in-out infinite; }
@keyframes bootslide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* --- tools tab --- */
.tool-out { margin-top: 14px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: #0e1730; border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px; text-align: center; }
.stat .sv { font-size: 24px; font-weight: 800; color: var(--accent); }
.stat .sl { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ============================================================
   Light theme
   ============================================================ */
body.light {
  --bg: #eef2fb; --bg2: #e6ecfa; --panel: #ffffff; --panel2: #ffffffcc;
  --card: #ffffff; --line: #d4dcef; --line-soft: #e4e9f6; --text: #16203a;
  --muted: #5a688f; --faint: #8b97b8; --shadow: 0 16px 36px -20px rgba(40, 60, 110, .35);
  --moon-dark: #cdd7ec; --moon-lit: #e8a93a;
}
body.light {
  background:
    radial-gradient(1100px 640px at 85% -10%, #dbe6ff 0%, transparent 55%),
    radial-gradient(820px 540px at 0% 0%, #e3ecff 0%, transparent 45%),
    var(--bg);
}
body.light code { background: #eef2fb; }
body.light input, body.light select { background: #f6f8fe; }
body.light .seg, body.light .view-seg, body.light .lang-switch, body.light .engine-chip,
body.light .navbtn, body.light .icon-btn, body.light .tabs, body.light .cell,
body.light .mini-month, body.light .up-card, body.light .hrow, body.light .metric,
body.light .stat, body.light .pill, body.light .dm-desc, body.light .result .hero { background: #f6f8fe; }
body.light .cell { background: #f1f4fc; }
body.light .x { background: #e4e9f6; color: var(--muted); }
body.light .hero, body.light .result .hero { background: linear-gradient(120deg, #e7eeff, #eaf1ff); }
body.light .card { background: #ffffff; }
body.light .card.soft { background: #f4f7ff; }
body.light .btn { background: #eef2fb; }
body.light .popover, body.light .modal { background: #ffffff; }
body.light .cmp-table th, body.light .cmp-table td { border-color: var(--line-soft); }
body.light .popover-backdrop, body.light .modal-backdrop { background: rgba(40, 60, 110, .35); }

/* ============================================================
   Print
   ============================================================ */
@media print {
  body { background: #fff; color: #000; }
  .topbar, .tabs, .foot, .cal-jump, .cal-actions, .navbtn, .engine-chip, .header-controls, .btn, .icon-btn { display: none !important; }
  #app { max-width: 100%; padding: 0; }
  .panel { display: none !important; }
  .panel.active { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .cell, .mini-month { border: 1px solid #ccc; background: #fff !important; }
  .cell .dnum, .mcell { color: #000 !important; }
  .holiday-tag, .dot, .mcell.hol::after { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .cal-grid { gap: 2px; }
}
