@font-face {
    font-family: "Gilroy";
    src: url("fonts/Gilroy-Light.woff") format("woff"),
         url("fonts/Gilroy-Light.ttf") format("truetype");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #10275c;
    --text: #ffffff;
    --gold: #d1ab2c;
    --line: rgba(255, 255, 255, .2);
    --font: "Gilroy", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; color-scheme: dark; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    font-weight: 300;
    line-height: 1.3;
}

.astro {
    max-width: 1240px;
    margin: 0 auto;
    padding: clamp(14px, 4vw, 40px) clamp(10px, 3vw, 30px) 56px;
}

.sr {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* --- верхняя панель: страницы и язык --- */
.topnav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin: 0 0 clamp(10px, 1.6vw, 18px);
}
.pages, .lang { display: flex; flex-wrap: wrap; gap: 8px; }
.topnav a {
    padding: 6px 14px;
    color: var(--text);
    font-size: clamp(.9rem, 2.4vw, 1.05rem);
    line-height: 1.2;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 4px;
}
.topnav a:hover { border-color: var(--text); }
.topnav .pages a.ext { max-width: 100%; line-height: 1.25; border-color: rgba(209, 171, 44, .7); color: #f1d98a; }
.topnav .pages a.ext:hover { border-color: #f1d98a; background: rgba(209, 171, 44, .12); }
.topnav .pages a.ext .arr { font-size: .8em; opacity: .8; }
.topnav a.on { color: var(--bg); background: var(--text); border-color: var(--text); }
.topnav a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* --- блоки с тонкой рамкой, как в оригинале --- */
.box {
    margin: 0 0 clamp(14px, 2.6vw, 40px);
    padding: clamp(14px, 2.2vw, 22px);
    border: 1px solid var(--text);
    border-radius: 4px;
}

.epigraph {
    margin: 0 0 clamp(14px, 2.6vw, 40px);
    padding: clamp(14px, 2.2vw, 22px);
    background: rgba(255, 255, 255, .035);
    border-radius: 4px;
}
.epigraph p { margin: 0; font-weight: 300; }
.epigraph .quote { font-size: clamp(1.3rem, 3.2vw, 2.125rem); line-height: 1.2; }
.epigraph .author { margin-top: clamp(10px, 1.6vw, 18px); font-size: clamp(1rem, 2.5vw, 1.75rem); line-height: 1.25; }

.intro h2 {
    margin: 0 0 clamp(8px, 1.4vw, 16px);
    font-size: clamp(1.15rem, 3.2vw, 2.125rem);
    font-weight: 300;
    line-height: 1.2;
}
.intro p {
    margin: 0;
    padding-left: clamp(0px, 1vw, 10px);
    font-size: clamp(1rem, 2.3vw, 1.75rem);
    line-height: 1.25;
}

/* --- часы --- */
.clockbox {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px clamp(18px, 4vw, 56px);
}
.clockbox h3 {
    margin: 0;
    font-size: clamp(1.1rem, 3vw, 2.125rem);
    font-weight: 300;
    line-height: 1.25;
}
.segs {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px .35em;
    font-size: clamp(1rem, 4.9vw, 2.125rem);
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}
.seg { display: inline-flex; align-items: baseline; gap: .3em; white-space: nowrap; }
.seg:not(:last-child)::after { content: ":"; margin-left: .1em; }
.seg b { display: inline-block; font-weight: 300; text-align: center; }
.seg b[data-w="2"] { width: 1.2em; }
.seg b[data-w="3"] { width: 1.8em; }
.seg i { font-style: normal; }

@media (max-width: 479px) {
    #clk-lunar { display: grid; grid-template-columns: auto auto; justify-content: start; gap: 2px .6em; font-size: clamp(1rem, 5vw, 1.6rem); }
    #clk-lunar .seg:nth-child(2)::after { content: none; }
}

/* --- таблица календаря --- */
.grid {
    display: grid;
    gap: 1px;
    padding: 0;
    overflow: hidden;
    background: var(--line);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.col {
    min-width: 0;
    padding: 18px 8px 20px;
    text-align: center;
    background: var(--bg);
}
.col--zone, .col--wide, .col--time { grid-column: 1 / -1; }

.head { margin-bottom: 14px; }
.g {
    display: block;
    font-size: clamp(1.8rem, 3vw, 2.25rem);
    font-weight: 300;
    line-height: 1.1;
}
.cap {
    display: block;
    font-size: clamp(.9rem, 1.3vw, 1.1rem);
    line-height: 1.2;
}

.cell + .cell { margin-top: 14px; }
.pair { display: flex; justify-content: center; gap: clamp(16px, 8vw, 56px); }
.pair .cell + .cell { margin-top: 0; }

.lbl {
    display: block;
    margin-bottom: 3px;
    font-size: .75rem;
    line-height: 1.2;
}
.val {
    display: block;
    font-size: clamp(1.35rem, 5.4vw, 2rem);
    font-weight: 300;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.cos .lbl, .cos .val, .cos .num { color: var(--gold); }
.val.clk { font-size: clamp(1.1rem, 4.6vw, 1.4rem); }
.num { margin-right: 4px; font-size: .45em; vertical-align: super; }
.dn { text-transform: uppercase; }

/* выбор пояса: видна короткая подпись, поверх неё — прозрачный нативный select */
.zonepick {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 4px;
}
.zonepick .pin { color: var(--text); }
.zonepick .short {
    font-size: clamp(.95rem, 1.3vw, 1rem);
    font-weight: 400;
    white-space: nowrap;
    text-decoration: underline dashed rgba(255, 255, 255, .6);
    text-underline-offset: 4px;
}
.zonepick .chev { display: inline-block; transform: translateY(-3px); }
.zonepick select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    font-size: 16px;
    cursor: pointer;
}
.zonepick:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.zone button {
    display: block;
    margin: 10px auto 0;
    padding: 8px 16px;
    color: var(--bg);
    font: inherit;
    background: var(--text);
    border: 0;
    border-radius: 4px;
    cursor: pointer;
}

/* планшет: три колонки */
@media (min-width: 640px) {
    .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .col--zone, .col--wide { grid-column: auto; }
    .col--time { grid-column: span 2; }
    .lbl { font-size: .8rem; }
}

/* десктоп: девять колонок в одну строку, без разделителей, как в оригинале */
@media (min-width: 1100px) {
    .grid {
        gap: 0;
        padding: 22px 6px 14px;
        background: none;
        grid-template-columns:
            minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr)
            minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1.3fr);
    }
    .col, .col--zone, .col--wide, .col--time { grid-column: auto; background: none; padding: 0 4px 12px; }
    .cap { white-space: nowrap; }
    .pair { flex-direction: column; gap: 14px; }
    .val { font-size: clamp(1.15rem, 2.2vw, 1.9rem); }
    .val.clk { font-size: clamp(.9rem, 1.35vw, 1.1rem); }
    .lbl { font-size: .72rem; }
}

/* узкие телефоны (320–359) */
@media (max-width: 359px) {
    .col { padding: 14px 4px 16px; }
    .cap { font-size: .85rem; }
    .lbl { font-size: .7rem; }
}


/* --- описательная часть --- */
.about { margin-top: clamp(14px, 2.6vw, 40px); margin-bottom: 0; }
.about + .about { margin-top: clamp(14px, 2.6vw, 40px); }
.about h2 {
    margin: 0 0 clamp(10px, 1.6vw, 18px);
    font-size: clamp(1.15rem, 3.2vw, 2.125rem);
    font-weight: 300;
    line-height: 1.2;
}
.about h3 {
    margin: clamp(22px, 3vw, 34px) 0 8px;
    font-size: clamp(1.05rem, 2.4vw, 1.5rem);
    font-weight: 300;
    line-height: 1.25;
}
.about p, .about li, .about dd { font-size: clamp(.98rem, 2vw, 1.2rem); line-height: 1.5; }
.about b { font-weight: inherit; }
.about .lead { margin: 0 0 clamp(14px, 2.4vw, 26px); max-width: 80ch; }
.about .note { margin: 12px 0 0; color: rgba(255, 255, 255, .7); font-size: clamp(.88rem, 1.8vw, 1rem); line-height: 1.4; }
.cos { color: var(--gold); }

.legend { display: grid; margin: 0; }
.lg {
    display: grid;
    grid-template-columns: clamp(46px, 9vw, 84px) minmax(0, 1fr);
    column-gap: clamp(10px, 2vw, 22px);
    padding: clamp(12px, 1.8vw, 18px) 0;
    border-top: 1px solid var(--line);
}
.lg dt { margin: 0; text-align: center; }
.lg dd { margin: 0; max-width: 78ch; }
.lg .g { font-size: clamp(1.7rem, 4vw, 2.4rem); }
.lg .t { display: block; margin-bottom: 2px; font-size: 1.12em; }

.build { display: grid; gap: clamp(20px, 3vw, 40px); }
.facts { margin: 0; padding-left: 1.2em; max-width: 72ch; }
.facts li { margin: 0 0 .7em; padding-left: .2em; }
.months-wrap { min-width: 0; }
.months-wrap h3 { margin-top: 0; }
.months {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    font-variant-numeric: tabular-nums;
}
.months th, .months td {
    padding: 8px 10px 8px 0;
    border-top: 1px solid var(--line);
    font-size: clamp(.9rem, 1.9vw, 1.05rem);
    font-weight: 300;
    line-height: 1.3;
    text-align: left;
    vertical-align: baseline;
}
.months th:last-child, .months td:last-child { padding-right: 0; }
.months thead th {
    border-top: 0;
    border-bottom: 1px solid var(--text);
    color: rgba(255, 255, 255, .75);
    white-space: nowrap;
}
.months .no { width: 3.2em; color: var(--gold); white-space: nowrap; }
.months .abbr { width: 4.2em; color: rgba(255, 255, 255, .65); letter-spacing: .02em; white-space: nowrap; }
.months .name { overflow-wrap: anywhere; }
.months .mdays { text-align: right; white-space: nowrap; }
.months .mdays span { white-space: nowrap; }
.months .ext { display: block; color: rgba(255, 255, 255, .65); font-size: .88em; }

.plain { margin: 0; padding: 0; list-style: none; }
.plain li { padding: 8px 0; border-top: 1px solid var(--line); }
.plain li:first-child { border-top: 0; }

.about a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, .4);
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}
.about a:hover { color: var(--gold); text-decoration-color: var(--gold); }
.about a:focus-visible, .all summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 2px; }
.ft {
    display: inline-block;
    margin-left: .4em;
    padding: 0 .4em;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 3px;
    font-size: .7em;
    line-height: 1.5;
    vertical-align: .1em;
    white-space: nowrap;
}

.all { margin-top: clamp(18px, 2.6vw, 28px); border: 1px solid var(--line); border-radius: 4px; }
.all summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    font-size: clamp(1.05rem, 2.4vw, 1.5rem);
    cursor: pointer;
    list-style: none;
}
.all summary::-webkit-details-marker { display: none; }
.all summary::before {
    content: "";
    flex: none;
    width: .45em; height: .45em;
    border-right: 1.5px solid var(--text);
    border-bottom: 1.5px solid var(--text);
    transform: rotate(-45deg);
}
.all[open] summary::before { transform: rotate(45deg); }
.all .note { margin: 0; padding: 0 14px; }
.art { margin: 8px 0 0; padding: 0 14px 14px 2.6em; }
.art li { padding: 6px 0; break-inside: avoid; }
.art li::marker { color: rgba(255, 255, 255, .55); font-size: .85em; }

@media (min-width: 900px) {
    .build { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
    .art { columns: 2; column-gap: 40px; }
}


/* ячейки цифр живых часов и счётчиков: фиксированная ширина — без «дрожания» (см. assets/app.js, setNum) */
.dg { display: inline-block; width: .58em; font-style: normal; text-align: center; }
.ch { font-style: normal; }
.tk { display: inline-block; text-align: right; white-space: nowrap; }
.epn { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

/* ---- AJAX-подгрузка (nav.js): тонкая полоса загрузки сверху ---- */
html.ajax-busy::before {
    content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 10000; pointer-events: none;
    background: #d1ab2c; transform-origin: left; animation: ajaxbar 1.1s ease-in-out infinite;
}
@keyframes ajaxbar { 0% { transform: scaleX(0); opacity: 1; } 60% { transform: scaleX(.8); opacity: 1; } 100% { transform: scaleX(1); opacity: .25; } }
@media (prefers-reduced-motion: reduce) { html.ajax-busy::before { animation: none; } }

/* ---- «Лунное время»: главный заголовок страницы ---- */
.lunar-h1 {
    max-width: 30em; margin: 28px auto 24px; color: #fff; font-size: clamp(19px, 2.5vw, 31px); font-weight: 400;
    line-height: 1.32; letter-spacing: .07em; text-align: center; text-transform: uppercase; text-shadow: 0 0 14px rgba(77, 192, 255, .45);
}
