:root {
    --bg: #eef3fb;
    --surface: #ffffff;
    --surface-2: #f8fbff;
    --surface-3: #f2f7ff;
    --border: #d8e0ed;
    --border-strong: #bccbe0;
    --text: #18263a;
    --muted: #60728e;
    --blue: #1f66ff;
    --blue-soft: #eaf2ff;
    --blue-mid: #98bbff;
    --ok: #0a7d4f;
    --err: #b6203b;
    --shadow: 0 18px 48px rgba(28, 48, 75, 0.10);
    --radius: 16px;
    --max-content: 1120px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    background:
        radial-gradient(circle at top right, rgba(31, 102, 255, 0.16), transparent 34rem),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
}

button,
input,
textarea {
    font: inherit;
}

code,
pre {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

img {
    max-width: 100%;
}

.app-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    border-right: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
    padding: 1rem;
    min-height: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.site-header {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.95rem;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    box-shadow: 0 10px 28px rgba(35, 58, 88, 0.06);
}

.brand-kicker,
.eyebrow {
    margin: 0 0 0.35rem;
    color: #1a4cae;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.site-header h1 {
    margin: 0;
    font-size: 1.28rem;
    letter-spacing: 0.01em;
}

.site-header p:last-child {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.site-nav {
    display: grid;
    gap: 0.38rem;
}

.site-nav a {
    border: 1px solid transparent;
    border-left: 3px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    padding: 0.62rem 0.68rem;
    display: flex;
    align-items: center;
    gap: 0.58rem;
    font-size: 0.95rem;
}

.site-nav a:hover {
    background: #f4f8ff;
    border-color: #e2ebfa;
}

.site-nav a.active {
    border-left-color: var(--blue);
    border-color: #d8e6ff;
    background: var(--blue-soft);
    color: #1543ab;
    font-weight: 700;
}

.nav-icon {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 7px;
    background: rgba(31, 102, 255, 0.08);
    color: #1f66ff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.sidebar-spacer {
    flex: 1;
    min-height: 0;
    border-top: 1px solid var(--border);
}

.site-footer {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.site-footer p {
    margin: 0.3rem 0;
}

.site-footer code {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.08rem 0.25rem;
}

.content {
    min-width: 0;
    padding: 1rem;
}

.center-zone {
    max-width: var(--max-content);
    margin: 0 auto;
    min-height: calc(100vh - 2rem);
    display: grid;
    align-content: start;
    gap: 1rem;
}

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-body {
    padding: clamp(1rem, 2vw, 1.45rem);
}

.hero {
    padding: clamp(1.25rem, 4vw, 2.2rem);
    background:
        linear-gradient(135deg, rgba(31, 102, 255, 0.13), rgba(255, 255, 255, 0.78)),
        var(--surface);
}

.hero h1,
.page-title h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 0.98;
    letter-spacing: -0.05em;
}

.hero p,
.page-title p {
    max-width: 780px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

.home-grid,
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.card,
.content-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    padding: 1rem;
    display: grid;
    gap: 0.62rem;
    text-decoration: none;
    color: var(--text);
    min-height: 100%;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.card:hover,
.content-card:hover {
    transform: translateY(-2px);
    border-color: var(--blue-mid);
    box-shadow: 0 16px 34px rgba(31, 102, 255, 0.12);
}

.card h2,
.content-card h2 {
    margin: 0;
    font-size: 1.08rem;
}

.card p,
.content-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.84rem;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.tag {
    border: 1px solid #b9d0ff;
    background: #eaf2ff;
    color: #123e9f;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
}

.page-title {
    padding: clamp(1rem, 3vw, 1.7rem);
    background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 0.95rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.search-input {
    width: min(100%, 360px);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0.62rem 0.72rem;
    outline: none;
    background: #fff;
}

.search-input:focus {
    border-color: #7aa7ff;
    box-shadow: 0 0 0 2px rgba(64, 132, 255, 0.16);
}

.empty-state {
    border: 1px dashed var(--border-strong);
    border-radius: 14px;
    padding: 1.2rem;
    background: #fbfdff;
    color: var(--muted);
}

.article {
    padding: clamp(1.05rem, 3vw, 2rem);
}

.article-header {
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
}

.article-header h1 {
    margin: 0.35rem 0 0.6rem;
    font-size: clamp(1.9rem, 5vw, 3.6rem);
    line-height: 1.02;
    letter-spacing: -0.04em;
}

.back-link {
    color: #1a4cae;
    text-decoration: none;
    font-weight: 800;
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

.markdown-body {
    line-height: 1.72;
    font-size: 1rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    line-height: 1.2;
    margin: 1.6em 0 0.5em;
    letter-spacing: -0.02em;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
    margin-top: 0;
}

.markdown-body p {
    margin: 0 0 1em;
}

.markdown-body a {
    color: #1f66ff;
    font-weight: 650;
}

.markdown-body pre {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem;
    background: #101827;
    color: #edf5ff;
}

.markdown-body code {
    border: 1px solid #d7e1ef;
    background: #f2f7ff;
    border-radius: 6px;
    padding: 0.08rem 0.28rem;
}

.markdown-body pre code {
    border: 0;
    background: transparent;
    padding: 0;
}

.markdown-body blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--blue);
    background: #f4f8ff;
    border-radius: 0 12px 12px 0;
    color: #314765;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    display: block;
    overflow-x: auto;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--border);
    padding: 0.52rem 0.62rem;
    text-align: left;
}

.markdown-body th {
    background: var(--surface-3);
}

.calculator-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.input-card {
    display: grid;
    gap: 0.35rem;
}

.input-card label {
    font-weight: 750;
}

.input-card small {
    color: var(--muted);
    line-height: 1.4;
}

.input-card input {
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 0.68rem 0.72rem;
    outline: none;
    background: #fff;
}

.input-card input:focus {
    border-color: #7aa7ff;
    box-shadow: 0 0 0 2px rgba(64, 132, 255, 0.16);
}

.result-panel {
    margin-top: 1rem;
    border: 1px solid #cfe0ff;
    background: linear-gradient(180deg, #f8fbff, #eef5ff);
    border-radius: 14px;
    padding: 1rem;
    display: grid;
    gap: 0.55rem;
}

.result-value {
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1;
    letter-spacing: -0.04em;
    font-weight: 850;
    color: #1745a8;
}

.result-subgrid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.7rem;
}

.result-tile {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 0.75rem;
}

.result-tile span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-tile strong {
    display: block;
    margin-top: 0.28rem;
    font-size: 1.05rem;
}

.formula {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.55;
}

.warning {
    color: var(--err);
    font-weight: 700;
}

@media (max-width: 920px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .site-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sidebar-spacer,
    .site-footer {
        display: none;
    }

    .home-grid,
    .card-grid,
    .calculator-grid,
    .result-subgrid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .content,
    .sidebar {
        padding: 0.72rem;
    }

    .site-nav {
        grid-template-columns: 1fr;
    }
}
