:root {
    --bg: #f4f6fb;
    --bg-elev: #ffffff;
    --bg-soft: #eef2f9;
    --text: #1f2937;
    --text-muted: #5b6574;
    --heading: #0f172a;
    --border: #e3e8f0;
    --grid: rgba(15, 23, 42, 0.08);
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --link: #1d4ed8;
    --green: #1f9948;
    --yellow: #e6b400;
    --red: #d23434;
    --ink: #1f2937;
    --header-bg: linear-gradient(135deg, #4f8bf6 0%, #6c5ce7 100%);
    --header-text: #ffffff;
    --table-stripe: #f6f8fc;
    --table-hover: #e8eef9;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 6px 18px rgba(15, 23, 42, 0.06);
    --radius: 14px;
    --radius-sm: 10px;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0e1117;
    --bg-elev: #161b22;
    --bg-soft: #1c2230;
    --text: #e6ecf2;
    --text-muted: #9aa3b2;
    --heading: #f4f7fb;
    --border: #2a313b;
    --grid: rgba(230, 236, 242, 0.08);
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --link: #7cb1ff;
    --green: #2ecc71;
    --yellow: #facc15;
    --red: #f87171;
    --ink: #a3acba;
    --header-bg: linear-gradient(135deg, #1e3a8a 0%, #4c1d95 100%);
    --header-text: #f4f7fb;
    --table-stripe: #1a212b;
    --table-hover: #232b39;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color .25s ease, color .25s ease;
    padding: 24px 16px 64px;
}

main, .page {
    max-width: 960px;
    margin: 0 auto;
}

h1, h2, h3 {
    color: var(--heading);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 1.6em 0 0.6em;
    line-height: 1.25;
}

h1 { font-size: 1.8em; }
h2 { font-size: 1.35em; }
h3 { font-size: 1.1em; }

a {
    color: var(--link);
    text-decoration: none;
    transition: color .15s ease;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 28px auto;
    max-width: 800px;
}

p { margin: 0.6em 0; }

/* ---------- Card ---------- */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 32px;
    margin: 20px auto;
    max-width: 900px;
}

/* ---------- Hero / current price ---------- */
.hero {
    background: var(--header-bg);
    color: var(--header-text);
    border-radius: var(--radius);
    padding: 32px 24px 28px;
    margin: 0 auto 24px;
    max-width: 900px;
    text-align: center;
    box-shadow: var(--shadow);
}
.hero h1 {
    color: var(--header-text);
    margin: 0 0 8px;
    font-size: 1.55em;
    font-weight: 600;
    opacity: 0.95;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.hero h1 .logo-mark {
    width: 1.4em;
    height: 1.4em;
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}
.hero .price-big {
    font-size: 3.2em;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.05;
    margin: 6px 0 4px;
}
.hero .price-meta {
    opacity: 0.92;
    font-size: 0.98em;
    margin-top: 6px;
}
.hero .price-meta b { font-weight: 600; }
.hero #countdown {
    display: inline-block;
    font-size: 1.4em;
    font-weight: 700;
    padding: 2px 10px;
    margin: 0 2px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
    letter-spacing: 0.5px;
}

/* Hero background colored by current price level (matches gauge zones). */
.hero.level-low {
    background: linear-gradient(135deg, var(--green) 0%, #1a7a3a 100%);
}
.hero.level-medium {
    background: linear-gradient(135deg, var(--yellow) 0%, #b08a00 100%);
    color: #1f2937;
}
.hero.level-medium h1,
.hero.level-medium .price-meta { color: #1f2937; }
.hero.level-high {
    background: linear-gradient(135deg, var(--red) 0%, #8a1f1f 100%);
}
.hero.level-unknown {
    background: linear-gradient(135deg, #9aa3b2 0%, #5b6574 100%);
}

/* ---------- Generic info text classes (preserved from original) ---------- */
.info { text-align: center; }
.info2 {
    text-align: center;
    font-size: 1.5em;
    color: var(--text-muted);
}
.info3 {
    text-align: center;
    font-size: 2.5em;
    font-weight: 700;
    color: var(--heading);
}
.info-text {
    text-align: center;
    max-width: 760px;
    margin: 0 auto;
    color: var(--text-muted);
    line-height: 1.65;
}

/* Section heading variant (above charts) */
.section-title {
    text-align: center;
    margin: 36px auto 14px;
    font-size: 1.35em;
}

/* ---------- API endpoint blocks ---------- */
.endpoint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    max-width: 760px;
    margin: 12px auto;
    padding: 12px 16px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.endpoint:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.endpoint-method {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.endpoint-url {
    flex: 1 1 auto;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.95em;
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}
.endpoint-url:hover { text-decoration: underline; }
.endpoint-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.78em;
    font-weight: 600;
    flex-shrink: 0;
}
.endpoint.deprecated .endpoint-url { text-decoration: line-through; opacity: 0.7; }
.endpoint.deprecated .endpoint-method { background: var(--text-muted); }
.endpoint.deprecated .endpoint-tag { color: var(--red); border-color: var(--red); }

.values-list {
    max-width: 760px;
    margin: 12px auto 0;
    padding-left: 22px;
    color: var(--text-muted);
    line-height: 1.7;
}
.values-list li b { color: var(--heading); }

/* ---------- Notice / alert ---------- */
.notice {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(210, 52, 52, 0.1);
    color: var(--red);
    font-size: 0.92em;
    font-weight: 500;
    margin: 6px 0;
}

/* ---------- Gauge ---------- */
#demo {
    height: 300px;
    width: 300px;
    display: block;
    margin: 8px auto 0;
}
#preview-textfield {
    width: 300px;
    text-align: center;
    font-size: 2em;
    font-weight: 700;
    color: var(--heading);
    font-family: inherit;
    display: block;
    margin: 0 auto 8px;
}

/* ---------- Chart container ---------- */
.container {
    height: 320px;
    width: 100%;
    max-width: 760px;
    display: block;
    margin: 0 auto 8px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px 12px;
}
.container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ---------- Tables ---------- */
.table {
    width: 100%;
    max-width: 760px;
    margin: 18px auto;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.table th, .table td {
    padding: 10px 14px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}
.table th:first-child, .table td:first-child { text-align: left; }
.table th {
    background: var(--bg-soft);
    color: var(--heading);
    font-weight: 600;
    font-size: 0.95em;
    text-align: right;
}
.table th:first-child { text-align: left; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--table-hover); }

#prices {
    width: 100%;
    max-width: 760px;
    margin: 18px auto;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-elev);
    box-shadow: var(--shadow-sm);
    font-family: inherit;
}
#prices td, #prices th {
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    text-align: right;
}
#prices th:first-child, #prices td:first-child { text-align: left; }
#prices tr:nth-child(even) td { background-color: var(--table-stripe); }
#prices tr:hover td { background-color: var(--table-hover); }
#prices th {
    padding: 12px 14px;
    text-align: right;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    border-bottom: none;
}
#prices th:first-child { text-align: left; }
#prices tr:last-child td { border-bottom: none; }

td { text-align: right; }

/* ---------- Year switcher ---------- */
.year-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 18px;
}
.year-pill {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    font-weight: 600;
    font-size: 0.95em;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
}
.year-pill:hover {
    background: var(--table-hover);
    border-color: var(--accent);
    color: var(--accent);
}
.year-pill:active {
    transform: translateY(1px);
}
.year-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    cursor: default;
    box-shadow: var(--shadow-sm);
}

/* ---------- CTA row ---------- */
.cta-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 32px 0 0;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1em;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
    border: 1px solid transparent;
    line-height: 1.2;
}
.btn-icon {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
    box-shadow: var(--shadow);
}
.btn-secondary {
    background: var(--bg-elev);
    color: var(--accent);
    border-color: var(--accent);
}
.btn-secondary:hover {
    background: var(--bg-soft);
    color: var(--accent-hover);
    border-color: var(--accent-hover);
}

/* ---------- Footer-style links cluster ---------- */
.links-row {
    text-align: center;
    margin: 16px 0 0;
    color: var(--text-muted);
    font-size: 0.95em;
}
.links-row a { margin: 0 6px; }

/* ---------- Theme toggle button ---------- */
#theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: background-color .2s, color .2s, border-color .2s, transform .2s;
    z-index: 1000;
    padding: 0;
}
#theme-toggle:hover {
    background: var(--bg-soft);
    transform: translateY(-1px);
}
#theme-toggle:active { transform: translateY(0); }
#theme-toggle svg { width: 22px; height: 22px; }
#theme-toggle .icon-moon { display: none; }
[data-theme="dark"] #theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] #theme-toggle .icon-sun { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    body { padding: 16px 10px 48px; }
    .card { padding: 20px 18px; border-radius: var(--radius-sm); }
    .hero { padding: 24px 18px 22px; }
    .hero .price-big { font-size: 2.4em; }
    .container { height: 260px; padding: 10px; }
    .table, #prices { font-size: 0.95em; }
    .table th, .table td, #prices th, #prices td { padding: 8px 10px; }
    h1 { font-size: 1.45em; }
    h2 { font-size: 1.2em; }
    #theme-toggle { top: 10px; right: 10px; width: 40px; height: 40px; }
}
