.kg-page { color: #374151; }
.kg-hero {
    background: linear-gradient(135deg, #0f2444 0%, #1a4080 50%, #0d6efd 100%);
    color: #fff; padding: 56px 0 44px; text-align: center;
}
.kg-hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: 12px; }
.kg-hero p { max-width: 680px; margin: 0 auto; opacity: .9; line-height: 1.6; }

.kg-wrap { max-width: 1400px; margin: 0 auto; padding: 20px 16px 56px; }
.kg-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.kg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kg-search { flex: 1 1 220px; max-width: 320px; padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 999px; font-size: .95rem; }
.kg-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.kg-chip, .kg-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: .85rem;
    border: 1px solid #d1d5db; border-radius: 999px; background: #fff; cursor: pointer; color: #374151;
}
.kg-chip[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.kg-btn:disabled { opacity: .4; cursor: default; }
.kg-primary {
    padding: 8px 18px; border: 0; border-radius: 999px; background: #0d6efd; color: #fff;
    font-weight: 600; font-size: .9rem; cursor: pointer;
}
.kg-primary:hover { background: #0b5ed7; }
.kg-primary:disabled { opacity: .4; cursor: default; }
.kg-check { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; cursor: pointer; }
.kg-link { background: none; border: 0; padding: 0; color: #0d6efd; font-weight: 600; cursor: pointer; text-decoration: underline; }
.kg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.kg-stats { margin-left: auto; font-size: .85rem; color: #6b7280; }
.kg-page button:focus-visible, .kg-page input:focus-visible, .kg-page summary:focus-visible { outline: 3px solid #ffd43b; outline-offset: 2px; }

.kg-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
.kg-stage {
    position: relative; height: 76vh; min-height: 460px; border-radius: 14px; overflow: hidden;
    background: radial-gradient(circle at 50% 50%, #14213d 0%, #0b1220 70%);
    border: 1px solid #1f2d4d; box-shadow: 0 0 40px rgba(13, 110, 253, .12) inset;
}
.kg-canvas { position: absolute; inset: 0; }
.kg-error { color: #e5edf8; padding: 24px; }
.kg-controls { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.kg-controls button {
    width: 38px; height: 38px; border: 1px solid #2c3e66; border-radius: 8px; background: rgba(15, 28, 54, .9);
    color: #e5edf8; font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.kg-controls button:hover { background: #1c3160; }

.kg-tour {
    position: absolute; left: 12px; bottom: 12px; z-index: 3; width: min(380px, calc(100% - 24px));
    background: rgba(255, 255, 255, .97); border-radius: 12px; padding: 14px 16px; box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.kg-tour[hidden] { display: none; }
.kg-tour-head { display: flex; justify-content: space-between; font-size: .8rem; color: #6b7280; margin-bottom: 4px; }
.kg-tour strong { font-size: 1.05rem; color: #111827; }
.kg-tour p { margin: 6px 0 12px; line-height: 1.5; font-size: .92rem; }
.kg-tour-nav { display: flex; justify-content: space-between; gap: 8px; }

.kg-panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 20px; max-height: 76vh; overflow-y: auto; position: relative; }
.kg-panel h2 { font-size: 1.3rem; font-weight: 700; margin: 8px 0; color: #111827; }
.kg-panel h3 { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; margin: 20px 0 8px; }
.kg-panel p { line-height: 1.6; margin: 0; }
.kg-cat { display: inline-block; color: #0b1220; font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.kg-close { display: none; position: absolute; right: 12px; top: 8px; border: 0; background: none; font-size: 1.8rem; line-height: 1; cursor: pointer; color: #6b7280; }
.kg-rels { list-style: none; padding: 0; margin: 0; }
.kg-rel { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; border: 0; background: none; padding: 8px 6px; border-radius: 8px; cursor: pointer; color: inherit; }
.kg-rel:hover { background: #eff6ff; }
.kg-rel .kg-dot { margin-top: 6px; }
.kg-rel strong { display: block; font-size: .92rem; }
.kg-rel em { display: block; font-style: normal; font-size: .82rem; color: #6b7280; }

.kg-index { margin-top: 40px; }
.kg-index h2 { font-size: 1.4rem; font-weight: 700; }
.kg-index details { border-top: 1px solid #e5e7eb; padding: 10px 0; }
.kg-index summary { cursor: pointer; font-weight: 700; }
.kg-index li { margin: 6px 0; line-height: 1.5; }
.kg-index li li { font-size: .88rem; color: #6b7280; margin: 2px 0; }

@media (max-width: 992px) {
    .kg-main { grid-template-columns: 1fr; }
    .kg-stage { height: 64vh; }
    .kg-stats { margin-left: 0; }
    /* Bottom sheet */
    .kg-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1050; max-height: 55vh; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); transform: translateY(105%); transition: transform .25s; }
    .kg-panel.kg-open { transform: translateY(0); }
    .kg-close { display: block; }
}
@media (prefers-reduced-motion: reduce) {
    .kg-panel { transition: none; }
}

.kg-examples { margin: 0; padding-left: 20px; font-size: .9rem; }
.kg-examples li { margin: 3px 0; }
.kg-hint { margin-top: 16px !important; font-size: .82rem; color: #6b7280; }

.kg-wiki { display: inline-block; margin-top: 10px; font-size: .88rem; font-weight: 600; color: #0d6efd; }
.kg-modal { border: 0; border-radius: 16px; padding: 28px; width: min(560px, calc(100% - 32px)); max-height: 85vh; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); color: #374151; }
.kg-modal::backdrop { background: rgba(8, 14, 28, .65); backdrop-filter: blur(2px); }
.kg-modal h2 { font-size: 1.5rem; font-weight: 700; margin: 10px 0; color: #111827; }
.kg-modal h3 { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; margin: 20px 0 8px; }
.kg-modal p { line-height: 1.65; margin: 0; }
.kg-modal-x { position: absolute; right: 14px; top: 10px; border: 0; background: none; font-size: 1.8rem; line-height: 1; cursor: pointer; color: #6b7280; }
.kg-modal-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kg-modal-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.kg-modal-actions .kg-wiki { margin: 0; }
