:root {
    color-scheme: light;
    font-family: "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
    color: #172522;
    background: #f3f6f3;
    --ink: #172522;
    --muted: #60706b;
    --soft-ink: #3f514c;
    --surface: #ffffff;
    --surface-soft: #f8faf8;
    --line: #d9e2de;
    --line-strong: #b9c8c2;
    --brand: #12635c;
    --brand-dark: #084b46;
    --brand-soft: #dcefeb;
    --accent: #b9682a;
    --accent-soft: #fff0e2;
    --positive: #176c50;
    --positive-soft: #e0f3eb;
    --warning: #8a5500;
    --warning-soft: #fff4d9;
    --danger: #9a332d;
    --danger-soft: #fff0ed;
    --shadow: 0 18px 48px rgba(27, 57, 49, .08);
    --content-width: 74rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-width: 20rem;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 88% 3rem, rgba(211, 235, 227, .75), transparent 22rem),
        linear-gradient(180deg, #edf4f0 0, #f7f8f6 27rem, #f3f6f3 100%);
}

body, button, input, select, textarea { font: inherit; }

a { color: var(--brand-dark); }

a, button, input, select, textarea { -webkit-tap-highlight-color: transparent; }

img, svg { max-width: 100%; }

.skip-link {
    position: fixed;
    z-index: 100;
    top: .75rem;
    left: .75rem;
    padding: .75rem 1rem;
    color: #fff;
    background: var(--brand-dark);
    border-radius: .55rem;
    transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
    position: relative;
    z-index: 10;
    border-bottom: 1px solid rgba(185, 200, 194, .72);
    background: rgba(248, 251, 249, .88);
    backdrop-filter: blur(16px);
}

.header-inner,
main,
.site-footer {
    width: min(var(--content-width), calc(100% - 2.5rem));
    margin-inline: auto;
}

.header-inner {
    min-height: 5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: .8rem;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark,
.project-glyph,
.empty-state-icon,
.system-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: #fff;
    background: var(--brand);
    border-radius: .75rem;
    font-family: Georgia, "Microsoft JhengHei", serif;
    font-weight: 800;
}

.brand-mark { width: 2.55rem; height: 2.55rem; font-size: 1.2rem; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: -.015em; }
.brand small { display: block; margin-top: .1rem; color: var(--muted); font-size: .72rem; font-weight: 600; }

.primary-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .25rem;
}

.primary-nav a,
.nav-action {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    padding: .65rem .9rem;
    color: var(--soft-ink);
    background: transparent;
    border: 0;
    border-radius: .65rem;
    text-decoration: none;
    font-weight: 750;
    cursor: pointer;
}

.primary-nav a:hover,
.nav-action:hover { color: var(--brand-dark); background: var(--brand-soft); }
.primary-nav a[aria-current="page"] { color: var(--brand-dark); background: #fff; box-shadow: 0 0 0 1px var(--line); }
.primary-nav form { margin: 0; }

main { min-height: calc(100vh - 13rem); padding-block: 3rem 5rem; }

.site-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    padding-block: 2rem 2.75rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: .86rem;
}

.site-footer p { max-width: 35rem; margin: .25rem 0 0; line-height: 1.6; }
.site-footer > p { text-align: right; }

h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { line-height: 1.16; margin-top: 0; color: var(--ink); }
h1 { margin-bottom: 1rem; font-size: clamp(2.25rem, 5vw, 4.4rem); letter-spacing: -.052em; }
h2 { margin-bottom: .7rem; font-size: clamp(1.4rem, 3vw, 2rem); letter-spacing: -.03em; }
h3 { margin-bottom: .55rem; font-size: 1.1rem; letter-spacing: -.015em; }
p { line-height: 1.7; }

.eyebrow,
.panel-kicker {
    margin: 0 0 .6rem;
    color: var(--brand);
    font-size: .74rem;
    font-weight: 850;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(18rem, .65fr);
    align-items: center;
    gap: clamp(2rem, 6vw, 5.5rem);
    padding: clamp(1.5rem, 5vw, 4.5rem) 0 3rem;
}

.hero-copy { min-width: 0; }
.hero-lead,
.page-intro > div > p,
.system-lead {
    max-width: 45rem;
    margin: 0;
    color: var(--muted);
    font-size: clamp(1rem, 2vw, 1.18rem);
    line-height: 1.8;
}

.hero-actions,
.system-actions,
.submit-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .9rem 1.1rem;
    margin-top: 1.7rem;
}

.hero-panel,
.query-tips {
    min-width: 0;
    padding: clamp(1.35rem, 3vw, 2rem);
    background: rgba(255, 255, 255, .86);
    border: 1px solid rgba(185, 200, 194, .8);
    border-radius: 1.25rem;
    box-shadow: var(--shadow);
}

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: .9rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.steps li > span {
    width: 1.8rem;
    height: 1.8rem;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--brand-dark);
    background: var(--brand-soft);
    border-radius: 50%;
    font-weight: 850;
    font-size: .8rem;
}
.steps strong, .steps small { display: block; }
.steps small { margin-top: .25rem; color: var(--muted); line-height: 1.5; }

section {
    min-width: 0;
    margin: 1.35rem 0;
    padding: clamp(1.25rem, 3vw, 2.2rem);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 1.2rem;
    box-shadow: 0 12px 35px rgba(27, 57, 49, .045);
}

.section-heading,
.project-card-top,
.reference-heading,
.label-row,
.page-intro {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.section-heading > div,
.reference-heading > h3,
.page-intro > div { min-width: 0; }
.section-heading-compact { margin-bottom: .3rem; }
.section-intro { max-width: 50rem; margin: 0 0 1.35rem; color: var(--muted); }

.button,
button,
.card-action {
    border: 0;
    border-radius: .65rem;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
}

.button,
button {
    min-height: 2.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: .78rem 1.12rem;
    cursor: pointer;
}

.button-primary,
button { color: #fff; background: var(--brand); box-shadow: 0 8px 20px rgba(18, 99, 92, .18); }
.button-primary:hover,
button:hover { color: #fff; background: var(--brand-dark); }
.button-secondary { color: var(--brand-dark); background: var(--brand-soft); }
.button-secondary:hover { background: #c8e6df; }
.button-disabled,
button:disabled { color: #f6f8f7; background: #75847f; box-shadow: none; cursor: not-allowed; }
.text-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    font-weight: 800;
    text-underline-offset: .2rem;
}
.action-explanation { max-width: 25rem; color: var(--muted); font-size: .86rem; line-height: 1.5; }

.status-badge,
.current-label,
.kind,
.count-label,
.privacy-label,
.environment-label {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: .45rem;
    padding: .38rem .65rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 850;
    line-height: 1.2;
}

.status-badge > span { width: .52rem; height: .52rem; border-radius: 50%; background: currentColor; }
.status-ready { color: #0d6045; background: var(--positive-soft); }
.status-empty { color: #765000; background: var(--warning-soft); }
.status-unavailable { color: #8b332d; background: var(--danger-soft); }
.current-label, .kind, .privacy-label { color: var(--brand-dark); background: var(--brand-soft); }
.count-label { color: var(--soft-ink); background: #eef2f0; }
.environment-label { color: #704100; background: var(--warning-soft); }

.service-checks {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.service-checks li {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .9rem;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: .75rem;
}

.check-icon {
    width: 1.75rem;
    height: 1.75rem;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
    font-size: .78rem;
    font-weight: 900;
}

.is-positive .check-icon { color: var(--positive); background: var(--positive-soft); }
.is-negative .check-icon { color: var(--danger); background: var(--danger-soft); }
.service-checks strong, .service-checks small { display: block; }
.service-checks strong { font-size: .88rem; }
.service-checks small { margin-top: .2rem; color: var(--muted); font-size: .77rem; }

.notice {
    display: flex;
    align-items: flex-start;
    gap: .5rem 1rem;
    padding: 1rem 1.15rem;
    margin: 1rem 0;
    border: 1px solid var(--line-strong);
    border-left-width: 4px;
    border-radius: .7rem;
    line-height: 1.6;
}
.notice strong { flex: 0 0 auto; }
.notice-warning { color: #674200; background: var(--warning-soft); border-color: #e4c277; }
.notice-neutral { color: var(--soft-ink); background: var(--surface-soft); border-color: var(--line-strong); }

.public-access-banner {
    display: flex;
    justify-content: center;
    gap: .6rem;
    padding: .65rem 1.25rem;
    color: #0d6045;
    background: var(--positive-soft);
    border-bottom: 1px solid #9bcdbb;
    font-size: .9rem;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.project-card {
    min-width: 0;
    min-height: 15rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.25rem;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: .95rem;
}
.project-card.project-current { background: linear-gradient(145deg, #f8fcfa, #edf7f3); border-color: #9fcac0; }
.project-card h3 { margin-bottom: .35rem; font-size: 1.22rem; }
.project-glyph { width: 2.4rem; height: 2.4rem; background: var(--brand-soft); color: var(--brand-dark); }
.project-id, .reference-path {
    margin: 0;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .78rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.card-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.75rem;
    color: var(--brand-dark);
}
.card-action:hover { text-decoration: underline; text-underline-offset: .18rem; }
.card-action-disabled { color: var(--muted); cursor: not-allowed; }

.empty-state {
    display: flex;
    align-items: center;
    gap: 1.15rem;
    margin-top: 1rem;
    padding: 1.35rem;
    background: var(--surface-soft);
    border: 1px dashed var(--line-strong);
    border-radius: .9rem;
}
.empty-state-icon { width: 3rem; height: 3rem; color: var(--brand-dark); background: var(--brand-soft); }
.empty-state h3 { margin-bottom: .25rem; }
.empty-state p { margin: 0; color: var(--muted); }

.page-intro { align-items: flex-end; padding: 1.2rem 0 1.7rem; }
.page-intro h1 { font-size: clamp(2.15rem, 5vw, 3.8rem); }
.context-chip {
    min-width: min(100%, 14rem);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem .9rem;
    background: rgba(255,255,255,.82);
    border: 1px solid var(--line);
    border-radius: .85rem;
}
.context-chip > span { width: 2rem; height: 2rem; display: inline-grid; place-items: center; color: var(--brand-dark); background: var(--brand-soft); border-radius: .55rem; font-weight: 850; }
.context-chip small, .context-chip strong { display: block; }
.context-chip small { color: var(--muted); font-size: .7rem; }
.context-chip strong { margin-top: .15rem; font-size: .88rem; }

.query-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, .34fr); align-items: start; gap: 1.2rem; }
.query-layout > section, .query-layout > aside { margin-top: 0; }
.query-tips { box-shadow: none; }
.query-tips ul { margin: 1rem 0 0; padding: 0; list-style: none; }
.query-tips li { padding: .85rem 0; border-top: 1px solid var(--line); }
.query-tips strong, .query-tips span { display: block; }
.query-tips span { margin-top: .25rem; color: var(--muted); font-size: .86rem; line-height: 1.55; }

.field-group { margin-top: 1.15rem; }
label { display: block; margin: 0 0 .5rem; font-weight: 800; }
.label-row { align-items: center; }
.label-row > span { color: var(--muted); font-size: .8rem; }
input, textarea, select {
    width: 100%;
    display: block;
    padding: .82rem .9rem;
    color: var(--ink);
    background: #fff;
    border: 1px solid #aebdb7;
    border-radius: .65rem;
}
textarea { min-height: 12rem; line-height: 1.65; resize: vertical; }
textarea::placeholder { color: #7a8884; }
textarea:disabled, select:disabled { color: #68736f; background: #eef1ef; border-color: #c7d0cc; cursor: not-allowed; }
input:disabled { color: #68736f; background: #eef1ef; border-color: #c7d0cc; cursor: not-allowed; }
.field-hint { margin: .45rem 0 0; color: var(--muted); font-size: .79rem; line-height: 1.55; }
.validation { display: block; margin-top: .42rem; color: var(--danger); font-size: .84rem; font-weight: 700; }
.validation:empty { display: none; }
.validation-summary ul { margin: 0; padding-left: 1.2rem; }
.validation-box { padding: .8rem; background: var(--danger-soft); border: 1px solid #efc3bd; border-radius: .6rem; }

.query-progress { display: inline-flex; align-items: center; gap: .6rem; color: var(--soft-ink); font-size: .88rem; }
.query-progress[hidden] { display: none; }
.progress-spinner { width: 1.15rem; height: 1.15rem; border: 2px solid #b6cac4; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-state { display: flex; align-items: flex-start; gap: 1rem; box-shadow: none; }
.result-state-icon { width: 2.6rem; height: 2.6rem; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: .75rem; font-weight: 900; }
.result-state h2 { margin-bottom: .35rem; }
.result-state p { margin: .25rem 0 0; }
.result-guidance { color: var(--muted); }
.result-empty { border-color: #dbc490; background: #fffbf2; }
.result-empty .result-state-icon { color: var(--warning); background: var(--warning-soft); }
.result-warning { border-color: #e7bdb8; background: #fff8f6; }
.result-warning .result-state-icon { color: var(--danger); background: var(--danger-soft); }
.result-unavailable { border-color: #c4d0cc; background: #f6f8f7; }
.result-unavailable .result-state-icon { color: var(--soft-ink); background: #e7ece9; }

.answer-section { border-color: #a8cec4; }
.answer { padding-top: .5rem; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.82; font-size: 1.02rem; }
.reference-list { display: grid; gap: .8rem; margin-top: 1rem; }
.reference-card { min-width: 0; display: flex; align-items: flex-start; gap: .9rem; padding: 1rem; background: var(--surface-soft); border: 1px solid var(--line); border-radius: .85rem; }
.reference-number { width: 1.75rem; height: 1.75rem; display: inline-grid; place-items: center; flex: 0 0 auto; color: var(--brand-dark); background: var(--brand-soft); border-radius: .5rem; font-size: .75rem; font-weight: 900; }
.reference-content { min-width: 0; flex: 1; }
.reference-heading { align-items: center; }
.reference-heading h3 { margin: 0; }
.reference-snippet { margin: .6rem 0 0; color: var(--soft-ink); font-size: .9rem; line-height: 1.65; }

.card-actions { display: grid; gap: .15rem; }

.graph-app { padding: clamp(1rem, 2vw, 1.6rem); }
.graph-heading { align-items: center; }
.graph-stats { display: flex; align-items: center; gap: .55rem; }
.graph-stats span {
    min-width: 5.5rem;
    padding: .55rem .7rem;
    color: var(--soft-ink);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: .65rem;
    text-align: center;
    font-size: .78rem;
}
.graph-stats strong { display: block; color: var(--ink); font-size: 1.1rem; }

.graph-controls {
    display: grid;
    grid-template-columns: minmax(11rem, .8fr) minmax(15rem, 1.2fr) minmax(10rem, .7fr) auto;
    align-items: end;
    gap: .75rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: .9rem;
}
.graph-controls .field-group { margin: 0; }
.graph-control-buttons { display: flex; align-items: center; gap: .4rem; }
.graph-control-buttons button { min-width: 2.8rem; min-height: 2.8rem; padding: .65rem .75rem; white-space: nowrap; }
.graph-status {
    margin: .8rem 0;
    padding: .65rem .8rem;
    color: var(--soft-ink);
    background: #f1f5f3;
    border-radius: .6rem;
    font-size: .86rem;
}
.graph-app[aria-busy="true"] .graph-status { color: var(--brand-dark); background: var(--brand-soft); }

.graph-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(17rem, .31fr); gap: .9rem; }
.graph-stage-wrap {
    position: relative;
    min-width: 0;
    min-height: 35rem;
    overflow: hidden;
    background:
        radial-gradient(circle at center, rgba(220, 239, 235, .62), transparent 24rem),
        linear-gradient(#edf2ef 1px, transparent 1px),
        linear-gradient(90deg, #edf2ef 1px, transparent 1px),
        #fbfcfb;
    background-size: auto, 2rem 2rem, 2rem 2rem, auto;
    border: 1px solid var(--line);
    border-radius: .9rem;
}
.knowledge-graph { width: 100%; min-height: 35rem; display: block; touch-action: none; cursor: grab; }
.knowledge-graph.is-dragging { cursor: grabbing; }
.graph-edge { stroke: #a9bdb7; stroke-width: 2; vector-effect: non-scaling-stroke; transition: opacity .15s ease, stroke .15s ease; }
.graph-edge.is-connected { stroke: var(--accent); stroke-width: 3; }
.graph-edge.is-dimmed { opacity: .12; }
.graph-node { cursor: pointer; transition: opacity .15s ease; }
.graph-node circle { fill: #fff; stroke: var(--brand); stroke-width: 4; vector-effect: non-scaling-stroke; }
.graph-node text { fill: var(--ink); font-size: 14px; font-weight: 750; pointer-events: none; }
.graph-node.is-neighbor circle { fill: var(--brand-soft); }
.graph-node.is-selected circle { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 6; }
.graph-node.is-dimmed { opacity: .18; }
.graph-node:focus-visible { outline: none; }
.graph-node:focus-visible circle { stroke: #d97706; stroke-width: 7; }

.graph-empty-panel {
    position: absolute;
    inset: 50% auto auto 50%;
    width: min(28rem, calc(100% - 2rem));
    padding: 1.4rem;
    transform: translate(-50%, -50%);
    color: var(--soft-ink);
    background: rgba(255, 255, 255, .94);
    border: 1px solid var(--line-strong);
    border-radius: .9rem;
    box-shadow: var(--shadow);
    text-align: center;
}
.graph-empty-panel[hidden] { display: none; }
.graph-empty-panel > span { width: 2.8rem; height: 2.8rem; display: inline-grid; place-items: center; color: var(--brand-dark); background: var(--brand-soft); border-radius: .7rem; font-weight: 900; }
.graph-empty-panel h3 { margin: .75rem 0 .3rem; }
.graph-empty-panel p { margin: 0; color: var(--muted); }

.graph-side-panel { min-width: 0; display: grid; align-content: start; gap: .8rem; }
.graph-side-panel section { margin: 0; padding: 1rem; border-radius: .9rem; box-shadow: none; }
.graph-detail dl { margin: .8rem 0 0; }
.graph-detail dl > div { padding: .65rem 0; border-top: 1px solid var(--line); }
.graph-detail dt { color: var(--muted); font-size: .72rem; font-weight: 800; }
.graph-detail dd { margin: .22rem 0 0; overflow-wrap: anywhere; font-size: .88rem; }
.graph-detail-path { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.graph-node-list-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.graph-node-list { max-height: 25rem; overflow: auto; margin: .8rem 0 0; padding: 0; list-style: none; }
.graph-node-list li + li { margin-top: .38rem; }
.graph-node-list-button {
    width: 100%;
    min-height: 3.4rem;
    display: block;
    padding: .65rem .75rem;
    color: var(--ink);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    box-shadow: none;
    text-align: left;
}
.graph-node-list-button:hover { color: var(--brand-dark); background: var(--brand-soft); }
.graph-node-list-button.is-selected { color: #6f3d14; background: var(--accent-soft); border-color: #d99a67; }
.graph-node-list-button strong, .graph-node-list-button span { display: block; }
.graph-node-list-button span { margin-top: .18rem; color: var(--muted); font-size: .74rem; }

.system-page { width: min(38rem, 100%); margin: 2rem auto; }
.system-card { padding: clamp(1.5rem, 5vw, 3rem); text-align: center; }
.system-card h1 { font-size: clamp(2rem, 6vw, 3.35rem); }
.system-icon { width: 4rem; height: 4rem; margin-bottom: 1.25rem; font-size: 1.5rem; box-shadow: 0 10px 24px rgba(18, 99, 92, .18); }
.system-icon-warning { color: var(--danger); background: var(--danger-soft); box-shadow: none; }
.system-lead { margin-inline: auto; }
.system-card .notice { margin-top: 1.5rem; text-align: left; }
.system-actions { justify-content: center; }
.development-panel { box-shadow: none; }
.development-panel h2 { margin-top: .8rem; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible { outline: 3px solid #d97706; outline-offset: 3px; }

@media (max-width: 62rem) {
    .service-checks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .query-layout { grid-template-columns: 1fr; }
    .query-tips { display: none; }
    .graph-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .graph-control-buttons { align-self: end; }
    .graph-layout { grid-template-columns: 1fr; }
    .graph-side-panel { grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); }
}

@media (max-width: 46rem) {
    .header-inner { min-height: 4.5rem; align-items: flex-start; flex-direction: column; gap: .6rem; padding-block: .8rem; }
    .primary-nav { width: 100%; justify-content: flex-start; flex-wrap: wrap; padding-bottom: .1rem; }
    .primary-nav a, .nav-action { min-height: 2.55rem; white-space: nowrap; }
    main { padding-block: 1.7rem 3.5rem; }
    .hero { grid-template-columns: 1fr; gap: 1.3rem; padding-top: 1.2rem; }
    .hero-panel { box-shadow: none; }
    .page-intro { align-items: flex-start; flex-direction: column; }
    .context-chip { width: 100%; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .section-heading .status-badge, .section-heading .count-label { align-self: flex-start; }
    .site-footer { flex-direction: column; gap: .6rem; }
    .site-footer > p { text-align: left; }
    .graph-intro { align-items: flex-start; }
    .graph-controls { grid-template-columns: 1fr; }
    .graph-control-buttons { flex-wrap: wrap; }
    .graph-side-panel { grid-template-columns: 1fr; }
    .graph-stage-wrap, .knowledge-graph { min-height: 28rem; }
}

@media (max-width: 30rem) {
    .header-inner, main, .site-footer { width: min(100% - 1.25rem, var(--content-width)); }
    .brand small { display: none; }
    h1 { font-size: 2.15rem; }
    section, .hero-panel, .query-tips { border-radius: .9rem; }
    .service-checks { grid-template-columns: 1fr; }
    .hero-actions, .submit-row, .system-actions { align-items: stretch; flex-direction: column; }
    .hero-actions .button, .submit-row button, .system-actions .button { width: 100%; }
    .notice, .empty-state, .result-state { flex-direction: column; }
    .notice strong { flex-basis: auto; }
    .reference-heading { align-items: flex-start; flex-direction: column; }
    .privacy-label { display: none; }
    .graph-stats { width: 100%; }
    .graph-stats span { flex: 1; }
    .graph-control-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .graph-control-buttons button { width: 100%; }
    .graph-stage-wrap, .knowledge-graph { min-height: 23rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
