:root {
    --ink: #0b1220;
    --muted: #7b8798;
    --paper: #eef3f8;
    --surface: #ffffff;
    --panel: #121a2a;
    --line: #cbd6e2;
    --green: #12a594;
    --blue: #2d6cdf;
    --violet: #7c3aed;
    --orange: #f97316;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(45, 108, 223, .06) 1px, transparent 1px),
        linear-gradient(rgba(45, 108, 223, .05) 1px, transparent 1px),
        var(--paper);
    background-size: 32px 32px;
    line-height: 1.62;
}
a { color: inherit; }
.site-header {
    max-width: none;
    margin: 0;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: var(--panel);
    color: white;
    border-bottom: 1px solid #22304a;
}
.site-footer {
    max-width: 1180px;
    margin: 48px auto 0;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    color: var(--muted);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--green), var(--blue));
    color: white;
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 900;
}
.brand strong {
    display: block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 17px;
}
.brand small { display: block; color: #aeb8c7; font-size: 12px; }
nav, .footer-links { display: flex; gap: 8px; flex-wrap: wrap; }
nav a {
    color: #d9e4f2;
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    padding: 8px 10px;
    border-radius: 6px;
}
nav a:hover { background: #22304a; color: white; }
.footer-links a { color: var(--blue); text-decoration: none; font-weight: 800; }
.hero {
    max-width: 1180px;
    margin: 26px auto 34px;
    padding: 0 24px;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) 360px;
    gap: 22px;
    align-items: stretch;
}
.hero > div:first-child {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 34px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
}
.hero h1, .page-title h1 {
    font-size: clamp(2.4rem, 4.1rem, 4.1rem);
    line-height: 1;
    margin: 0 0 18px;
    max-width: 900px;
}
.hero p, .page-title p { color: var(--muted); font-size: 18px; max-width: 760px; }
.eyebrow {
    display: inline-flex;
    color: var(--blue);
    background: #e8f0ff;
    border: 1px solid #c8d9ff;
    border-radius: 999px;
    padding: 5px 10px;
    text-transform: uppercase;
    letter-spacing: 0;
    font-size: 12px;
    font-weight: 900;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 6px;
    background: var(--blue);
    color: white;
    text-decoration: none;
    font-weight: 900;
}
.button:hover { background: var(--violet); }
.button.secondary { background: var(--green); color: var(--ink); }
button.button { border: 0; cursor: pointer; font: inherit; }
.tool-panel {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
}
.tool-panel div {
    min-height: 104px;
    background: var(--panel);
    color: white;
    border: 1px solid #22304a;
    border-radius: 8px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.tool-panel div::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 16px;
    width: 44px;
    height: 8px;
    border-radius: 8px;
    background: var(--green);
    box-shadow: -56px 0 0 var(--blue), -112px 0 0 var(--violet);
    opacity: .8;
}
.tool-panel strong {
    display: block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 24px;
    margin-bottom: 6px;
}
.tool-panel span { color: #aeb8c7; }
.section, .page-title, .band {
    max-width: 1180px;
    margin: 0 auto;
    padding: 38px 24px;
}
.page-title {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 24px;
}
.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}
.section-heading h2, .band h2 {
    font-size: clamp(2rem, 3rem, 3rem);
    line-height: 1.08;
    margin: 0;
}
.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}
.thumb {
    min-height: 74px;
    background: var(--panel);
    display: flex;
    align-items: end;
    padding: 14px;
    border-bottom: 4px solid var(--accent);
}
.thumb span {
    color: #d9e4f2;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 900;
    text-transform: uppercase;
    font-size: 12px;
}
.card-body { padding: 18px; }
.card h2, .card h3 { margin: 8px 0 10px; line-height: 1.2; font-size: 21px; }
.card h2 a, .card h3 a { text-decoration: none; }
.card h2 a:hover, .card h3 a:hover { color: var(--blue); }
.card p { color: var(--muted); }
.meta {
    color: var(--green) !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 900;
}
.band {
    margin-top: 20px;
    margin-bottom: 42px;
    background: var(--panel);
    color: white;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 26px;
    align-items: center;
}
.band p { color: #aeb8c7; max-width: 700px; }
.article {
    max-width: 980px;
    margin: 0 auto;
    padding: 36px 24px;
}
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 18px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}
.breadcrumb a { color: var(--blue); font-weight: 900; text-decoration: none; }
.breadcrumb a:hover { color: var(--violet); }
.article-header {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}
.article-header h1 {
    font-size: clamp(2.25rem, 3.6rem, 3.6rem);
    line-height: 1.04;
    margin: 0 0 18px;
}
.article-header p:not(.eyebrow) { color: var(--muted); font-size: 19px; }
.article-content {
    max-width: 780px;
    margin: 28px auto 0;
    font-size: 18px;
}
.article-content h2 {
    font-size: 30px;
    line-height: 1.16;
    margin-top: 40px;
}
.contextual-links, .source-link {
    background: #ecfdf7;
    border: 1px solid #bdebdc;
    border-left: 5px solid var(--green);
    border-radius: 8px;
    padding: 16px 18px;
}
.contextual-links a, .source-link a { color: var(--blue); font-weight: 900; }
.expert-box {
    margin: 42px 0 10px;
    padding: 24px;
    background: var(--panel);
    color: white;
    border-radius: 8px;
}
.expert-box p { color: #aeb8c7; }
.expert-box h2 { margin-top: 0; }
.expert-box a { color: var(--green); font-weight: 900; }
.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}
.profile-grid > div {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
}
.profile-grid h2 { font-size: 26px; line-height: 1.15; }
.profile-grid li { margin-bottom: 10px; }
.narrow { max-width: 900px; }
.site-footer p { max-width: 560px; }

.tool-hero { margin-top: 24px; }
.keyword-tool {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: start;
}
.tool-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}
.tool-card h2, .tool-card h3, .tool-card h4 { margin-top: 0; line-height: 1.18; }
.tool-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.tool-card-head span, #analysisStatus {
    color: var(--blue);
    font-weight: 900;
    font-size: 13px;
}
.full-span { grid-column: 1 / -1; }
.form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}
.form-row.compact { flex-wrap: wrap; }
input, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    color: var(--ink);
    padding: 10px 12px;
    font: inherit;
}
input[type="file"] { padding: 12px; margin-bottom: 12px; }
.inline-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 800;
    font-size: 13px;
}
.inline-control input { width: 88px; min-height: 40px; }
.tool-note, .empty-state { color: var(--muted); font-size: 14px; }
.metric-grid { display: grid; gap: 10px; }
.metric-grid div {
    background: var(--panel);
    color: white;
    border-radius: 8px;
    padding: 18px;
}
.metric-grid strong {
    display: block;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 32px;
    line-height: 1;
}
.metric-grid span { color: #aeb8c7; font-size: 13px; font-weight: 800; }
.cluster-results { display: grid; gap: 16px; }
.cluster-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #f8fbff;
}
.keyword-chips, .link-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 18px;
}
.keyword-chips span, .link-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    padding: 8px 10px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
}
.link-pill strong { color: var(--green); }
.link-pill small {
    color: var(--blue);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 900;
}

@media (max-width: 960px) {
    .hero { grid-template-columns: 1fr; }
    .tool-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: none; }
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .site-header, .site-footer, .band, .section-heading { display: flex; flex-direction: column; align-items: flex-start; }
    .tool-panel, .grid, .profile-grid, .keyword-tool { grid-template-columns: 1fr; }
    .hero h1, .page-title h1, .article-header h1 { font-size: 2.4rem; }
    .hero > div:first-child, .article-header { padding: 24px; }
    .form-row { flex-direction: column; align-items: stretch; }
}
