:root {
    --bg: #0b0b09;
    --panel: #11110e;
    --panel2: #15140f;
    --text: #d8cfba;
    --muted: #8f897a;
    --amber: #c89b58;
    --amber-hi: #e0ba7a;
    --green: #7e9385;
    --line: rgba(205,183,139,.14);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% -20%, rgba(200,155,88,.07), transparent 38%),
        linear-gradient(180deg, #0d0d0b, #080806 75%);
    color: var(--text);

    font-family:
        ui-monospace,
        "SFMono-Regular",
        Menlo,
        Monaco,
        Consolas,
        monospace;

    letter-spacing: .015em;
    line-height: 1.7;
}

/* очень мягкий CRT, почти незаметный */
body::after {
    content: "";
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    opacity: .10;
    background:
        repeating-linear-gradient(
            0deg,
            transparent 0,
            transparent 3px,
            rgba(255,255,255,.04) 4px
        );
}

.container {
    width: min(1020px, calc(100% - 40px));
    margin: 0 auto;
}

/* HEADER */

header {
    border-bottom: 1px solid var(--line);
}

.header-inner {
    min-height: 76px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.logo {
    margin-right: auto;
    color: var(--text);
    text-decoration: none;
    font-size: .83rem;
    font-weight: 600;
    letter-spacing: .18em;
}

.logo span {
    color: var(--amber);
}

nav {
    display: flex;
    gap: 22px;
    flex-wrap: wrap;
}

nav a:not(.logo) {
    color: var(--muted);
    text-decoration: none;
    font-size: .68rem;
    letter-spacing: .11em;
    text-transform: uppercase;
}

nav a:hover {
    color: var(--amber-hi);
}

/* STATUS */

.system-bar {
    border-bottom: 1px solid var(--line);
    color: var(--green);
    padding: 8px 0;
    font-size: .61rem;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.system-bar-inner {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.status-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    margin-right: 7px;
    vertical-align: 1px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 7px rgba(200,155,88,.6);
}

/* HERO */

.hero {
    max-width: 780px;
    padding: 105px 0 90px;
}

.terminal-prefix {
    color: var(--green);
    font-size: .62rem;
    letter-spacing: .17em;
    margin-bottom: 20px;
    text-transform: uppercase;
}

h1 {
    margin: 0 0 28px;
    color: #e0d7c4;
    font-size: clamp(2.5rem, 7vw, 5.3rem);
    line-height: 1.00;
    font-weight: 400;
    letter-spacing: -.035em;
}

.lead {
    max-width: 670px;
    margin: 0;
    color: var(--muted);
    font-size: .98rem;
    line-height: 1.9;
}

/* CONTENT */

.section {
    padding: 25px 0 90px;
}

.section-head {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 24px;
    color: var(--green);
    font-size: .61rem;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.section-head::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(245px,1fr));
    gap: 14px;
}

.card {
    display: block;
    padding: 24px;
    min-height: 170px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.012);
    color: var(--text);
    text-decoration: none;
    transition: .16s ease;
}

.card:hover {
    border-color: rgba(200,155,88,.35);
    background: rgba(200,155,88,.025);
}

.card h3 {
    margin: 0 0 12px;
    font-size: .94rem;
    font-weight: 500;
    color: #d8ceb8;
}

.card p {
    margin: 0;
    color: var(--muted);
    font-size: .82rem;
}

.code {
    display: block;
    margin-bottom: 20px;
    color: var(--green);
    font-size: .58rem;
    letter-spacing: .16em;
}

/* ARTICLES */

.article {
    max-width: 770px;
    padding: 78px 0 110px;
}

.article-header {
    margin-bottom: 52px;
}

.article h1 {
    font-size: clamp(2.3rem,6vw,4.4rem);
}

.article h2 {
    margin: 48px 0 16px;
    color: var(--amber);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: .06em;
}

.article p {
    color: #a79f8e;
    margin: 0 0 21px;
}

.archive-box {
    margin: 24px 0;
    padding: 22px 24px;
    border-left: 1px solid var(--amber);
    background: rgba(200,155,88,.018);
}

.dragon-id {
    color: var(--green);
    font-size: .58rem;
    letter-spacing: .15em;
}

/* FOOTER */

footer {
    border-top: 1px solid var(--line);
    padding: 31px 0 46px;
    color: #5d594e;
    font-size: .58rem;
    letter-spacing: .13em;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.revision {
    display: flex;
    align-items: center;
    gap: 9px;
}

.secret-trigger {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #39372f;
    opacity: .7;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.secret-trigger.armed {
    background: var(--amber);
    box-shadow: 0 0 12px rgba(200,155,88,.55);
}

/* SECRET — hidden ВСЕГДА по умолчанию */

.secret[hidden] {
    display: none !important;
}

.secret {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(5,5,4,.88);
    backdrop-filter: blur(7px);
}

.secret-card {
    width: min(520px, 100%);
    padding: 30px;
    border: 1px solid rgba(200,155,88,.38);
    background: #0e0e0b;
    box-shadow: 0 24px 80px rgba(0,0,0,.55);
}

.secret-meta {
    color: var(--amber);
    font-size: .59rem;
    letter-spacing: .17em;
    margin-bottom: 26px;
}

.secret-symbol {
    margin: 8px 0 28px;
    color: var(--green);
    font-size: 2.2rem;
    letter-spacing: .25em;
}

.secret-title {
    color: #ddd1b9;
    font-size: 1rem;
    margin-bottom: 14px;
}

.secret-text {
    color: #918a79;
    font-size: .78rem;
    line-height: 1.8;
}

.secret-close {
    margin-top: 25px;
    padding: 9px 13px;
    border: 1px solid rgba(200,155,88,.35);
    background: transparent;
    color: var(--amber);
    font: inherit;
    font-size: .63rem;
}

@media(max-width:720px) {
    .header-inner {
        padding: 20px 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .logo {
        margin-right: 0;
    }

    .hero {
        padding: 72px 0 70px;
    }

    nav {
        gap: 11px 16px;
    }
}

/* iOS Easter egg trigger fix */
.revision {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;

    touch-action: manipulation;
    cursor: pointer;

    padding: 8px 4px;
}

.revision span,
.secret-trigger {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.secret-trigger {
    pointer-events: none;
}

.revision.tap-feedback .secret-trigger {
    background: var(--amber);
    box-shadow: 0 0 12px rgba(200,155,88,.65);
}

/* iOS Easter egg trigger fix */
.revision {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;

    touch-action: manipulation;
    cursor: pointer;

    padding: 8px 4px;
}

.revision span,
.secret-trigger {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.secret-trigger {
    pointer-events: none;
}

.revision.tap-feedback .secret-trigger {
    background: var(--amber);
    box-shadow: 0 0 12px rgba(200,155,88,.65);
}

/* iOS tap trigger */
.revision {
    position: relative;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation;
    cursor: pointer;
    padding: 12px 8px;
}

.revision * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
}

.secret-trigger {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border: 0;
    border-radius: 50%;
    background: #454238;
    opacity: 1;
    pointer-events: none;
    transition:
        background .08s linear,
        box-shadow .08s linear,
        transform .08s linear;
}

.revision.tap-feedback .secret-trigger {
    background: #e0ba7a !important;
    box-shadow:
        0 0 5px #e0ba7a,
        0 0 14px rgba(224,186,122,.85) !important;
    transform: scale(1.6);
}

/* ONLINE indicator */
.online-status {
    color: #86a77c !important;
}

.status-dot.online-dot {
    background: #86a77c !important;
    box-shadow:
        0 0 5px rgba(134,167,124,.85),
        0 0 11px rgba(134,167,124,.45) !important;
}


/* ======================================================
   THEME SWITCHER
   ====================================================== */

.theme-toggle {
    appearance: none;
    -webkit-appearance: none;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    flex: 0 0 auto;

    padding: 7px 9px;

    border: 1px solid var(--line, rgba(205,183,139,.14));

    background: transparent;

    color: var(--muted, #8f897a);

    font: inherit;
    font-size: .57rem;

    letter-spacing: .11em;
    text-transform: uppercase;

    cursor: pointer;

    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;

    touch-action: manipulation;
}

.theme-toggle:hover {
    color: var(--amber, #c89b58);
    border-color: rgba(200,155,88,.32);
}

.theme-toggle-dot {
    display: block;

    width: 6px;
    height: 6px;

    flex: 0 0 6px;

    border-radius: 50%;

    background: var(--amber, #c89b58);

    box-shadow:
        0 0 7px rgba(200,155,88,.35);
}


/* ======================================================
   LIGHT THEME
   Warm terminal / archival-paper palette
   ====================================================== */

html[data-theme="light"] {
    color-scheme: light;

    --bg: #e9e1d1;
    --panel: #e2d8c5;
    --panel2: #d8cdb8;

    --text: #332f28;
    --muted: #70695c;

    --amber: #98672f;
    --amber-hi: #80501e;

    --green: #59715e;
    --green-dim: #758477;

    --line: rgba(55,48,37,.16);
}


/* Page */

html[data-theme="light"] body {
    color: #332f28;

    background:
        radial-gradient(
            ellipse at 50% -18%,
            rgba(164,116,57,.08),
            transparent 42%
        ),
        linear-gradient(
            180deg,
            #eee7da 0%,
            #e5dccb 100%
        );
}


/* CRT effect becomes almost invisible in daylight */

html[data-theme="light"] body::before {
    opacity: .20;
}

html[data-theme="light"] body::after {
    opacity: .035;
}


/* Header */

html[data-theme="light"] header {
    background: rgba(233,225,209,.90);
    border-color: var(--line);
}

html[data-theme="light"] .logo {
    color: #3c372e;

    text-shadow: none;
}

html[data-theme="light"] nav a:not(.logo) {
    color: #6b6457;
}

html[data-theme="light"] nav a:hover {
    color: var(--amber);
}


/* Status */

html[data-theme="light"] .system-bar {
    color: var(--green);
    border-color: var(--line);
}

html[data-theme="light"] .online-status {
    color: #527259 !important;
}

html[data-theme="light"] .status-dot.online-dot,
html[data-theme="light"] .online-status .status-dot {
    background: #64896a !important;

    box-shadow:
        0 0 5px rgba(100,137,106,.65),
        0 0 10px rgba(100,137,106,.30) !important;
}


/* Typography */

html[data-theme="light"] h1 {
    color: #353027;
    text-shadow: none;
}

html[data-theme="light"] h2 {
    color: #8b5d2c;
}

html[data-theme="light"] h3 {
    color: #423c32;
}

html[data-theme="light"] .lead {
    color: #70695c;
}

html[data-theme="light"] .terminal-prefix,
html[data-theme="light"] .section-head,
html[data-theme="light"] .code,
html[data-theme="light"] .dragon-id {
    color: var(--green);
}


/* Cards */

html[data-theme="light"] .card {
    color: #332f28;

    border-color: rgba(55,48,37,.14);

    background:
        rgba(255,252,244,.22);
}

html[data-theme="light"] .card:hover {
    border-color: rgba(152,103,47,.34);

    background:
        rgba(255,250,239,.38);
}

html[data-theme="light"] .card h3 {
    color: #423c32;
}

html[data-theme="light"] .card p {
    color: #746d60;
}


/* Articles */

html[data-theme="light"] .article p,
html[data-theme="light"] .article li {
    color: #6d6659;
}

html[data-theme="light"] .article strong {
    color: #413a30;
}

html[data-theme="light"] .archive-box {
    border-color: #98672f;

    background:
        rgba(152,103,47,.035);
}


/* Traces */

html[data-theme="light"] .traces-intro {
    color: #71695c;
}

html[data-theme="light"] .traces-intro strong {
    color: #403a30;
}

html[data-theme="light"] .trace {
    border-color: rgba(55,48,37,.14);

    background:
        rgba(255,252,244,.18);
}

html[data-theme="light"] .trace-text {
    color: #403a31;
}

html[data-theme="light"] .trace-meta {
    color: #817969;
}

html[data-theme="light"] .trace-oldest {
    border-color: rgba(152,103,47,.30);
}

html[data-theme="light"] .traces-empty {
    color: #777061;

    border-color: rgba(55,48,37,.18);
}

html[data-theme="light"] .traces-input {
    color: #38332b;

    border-color: rgba(55,48,37,.18);

    background:
        rgba(255,252,244,.34);
}

html[data-theme="light"] .traces-input::placeholder {
    color: #8a8170;
}

html[data-theme="light"] .traces-input:focus {
    border-color: rgba(152,103,47,.46);
}

html[data-theme="light"] .traces-count {
    color: #817969;
}


/* Footer */

html[data-theme="light"] footer {
    color: #807767;
    border-color: var(--line);
}


/* Revision / easter egg trigger */

html[data-theme="light"] .archive-key,
html[data-theme="light"] .revision {
    color: #756d5e;
}

html[data-theme="light"] .secret-trigger {
    background: #918775;
}


/*
   Easter egg deliberately stays slightly darker than the page,
   but switches to a warm archival palette rather than black.
*/

html[data-theme="light"] .secret {
    background:
        rgba(91,82,66,.42);
}

html[data-theme="light"] .secret-card,
html[data-theme="light"] .secret-panel {
    color: #383229;

    background: #e9dfcc;

    border-color:
        rgba(152,103,47,.45);

    box-shadow:
        0 24px 80px rgba(55,45,32,.22);
}

html[data-theme="light"] .secret-meta,
html[data-theme="light"] .secret-label {
    color: #8a5b29;
}

html[data-theme="light"] .secret-title {
    color: #3d372e;
}

html[data-theme="light"] .secret-text,
html[data-theme="light"] .secret-message {
    color: #696154;
}

html[data-theme="light"] .secret-symbol,
html[data-theme="light"] .secret pre {
    color: #5a735f;
    text-shadow: none;
}

html[data-theme="light"] .secret-close {
    color: #835524;

    border-color:
        rgba(152,103,47,.38);

    background: transparent;
}


/* Theme button in light mode */

html[data-theme="light"] .theme-toggle {
    color: #665f52;

    border-color:
        rgba(55,48,37,.18);
}

html[data-theme="light"] .theme-toggle-dot {
    background: #98672f;

    box-shadow:
        0 0 5px rgba(152,103,47,.30);
}


/* Mobile */

@media (max-width: 720px) {
    .theme-toggle {
        padding: 7px 8px;
    }
}
