.root-key-section {
    --root-bg: #0d1117;
    --root-surface: rgba(18, 23, 31, 0.94);
    --root-surface-strong: rgba(21, 27, 36, 0.98);
    --root-border: rgba(154, 168, 181, 0.2);
    --root-text: #eef4f1;
    --root-muted: #a7b2bd;
    --root-accent: #9be15d;
    --root-accent-2: #5fd4ff;
    --root-warm: #f7ba6b;
    --root-danger: #ff8f8f;
    color: var(--root-text);
    background:
        linear-gradient(90deg, rgba(155, 225, 93, 0.08) 1px, transparent 1px),
        linear-gradient(rgba(95, 212, 255, 0.06) 1px, transparent 1px),
        radial-gradient(circle at 8% 0%, rgba(155, 225, 93, 0.16), transparent 28%),
        radial-gradient(circle at 92% 14%, rgba(95, 212, 255, 0.13), transparent 24%),
        linear-gradient(160deg, #080d12 0%, #111721 52%, #0a1016 100%);
    background-size: 54px 54px, 54px 54px, auto, auto, auto;
}

.root-key-section::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 86%);
}

.root-key-wrapper {
    max-width: 1560px;
}

.root-key-hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 18px;
    padding: 24px 28px;
    border: 1px solid rgba(155, 225, 93, 0.2);
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
        rgba(8, 12, 16, 0.76);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.3);
}

.root-key-hero-copy {
    max-width: 860px;
}

.root-key-kicker,
.root-key-card-head span,
.root-key-group-title,
.root-prompt-block-head span,
.root-key-overview-card span {
    display: block;
    color: var(--root-accent);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.root-key-hero h2,
.root-key-card-head h3 {
    margin: 0;
    color: var(--root-text);
    letter-spacing: -0.04em;
}

.root-key-hero h2 {
    margin-top: 10px;
    font-size: clamp(28px, 3vw, 44px);
    line-height: 1.04;
}

.root-key-hero p {
    margin: 14px 0 0;
    color: var(--root-muted);
    font-size: 15px;
    line-height: 1.8;
}

.root-key-hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.root-key-guard {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 24px;
    border: 1px solid rgba(255, 191, 122, 0.28);
    border-radius: 20px;
    background: rgba(255, 191, 122, 0.08);
    color: #f7d1a4;
}

.root-key-guard i {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 15px;
    background: rgba(255, 191, 122, 0.12);
    color: var(--root-warm);
    font-size: 20px;
}

.root-key-guard h3,
.root-key-guard p {
    margin: 0;
}

.root-key-panel {
    animation: rootKeyRise 0.38s ease both;
}

.root-key-status-strip {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid var(--root-border);
    border-radius: 16px;
    background: rgba(9, 13, 18, 0.7);
    color: var(--root-muted);
    font-size: 12px;
    font-weight: 700;
}

.root-key-status-strip [data-type="success"] {
    color: var(--root-accent);
}

.root-key-status-strip [data-type="error"] {
    color: #ff9b9b;
}

.root-key-layout {
    display: grid;
    grid-template-columns: minmax(360px, 0.85fr) minmax(420px, 0.95fr) minmax(520px, 1.35fr);
    gap: 16px;
    align-items: start;
}

.root-key-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
    border: 1px solid var(--root-border);
    border-radius: 22px;
    background: var(--root-surface-strong);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.24);
}

.root-key-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(139, 226, 138, 0.06), transparent 30%, rgba(103, 183, 255, 0.05));
}

.root-key-card > * {
    position: relative;
}

.root-key-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.root-key-card-head i {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: rgba(139, 226, 138, 0.12);
    color: var(--root-accent);
    font-size: 18px;
    flex: 0 0 auto;
}

.root-key-card-desc {
    margin: -4px 0 14px;
    color: var(--root-muted);
    font-size: 12px;
    line-height: 1.7;
}

.root-key-group + .root-key-group {
    margin-top: 18px;
}

.root-key-group-title {
    margin: 0 0 12px;
    color: var(--root-accent-2);
}

.root-key-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.root-key-form-grid label,
.root-prompt-stack label {
    display: block;
}

.root-key-form-grid span,
.root-prompt-stack > .root-prompt-block .root-prompt-block-head {
    margin-bottom: 8px;
}

.root-key-form-grid span {
    display: block;
    color: var(--root-muted);
    font-size: 12px;
    font-weight: 800;
}

.root-key-form-grid input,
.root-key-form-grid select,
.root-prompt-stack textarea {
    width: 100%;
    border: 1px solid rgba(237, 242, 247, 0.12);
    border-radius: 14px;
    background: rgba(6, 10, 14, 0.66);
    color: var(--root-text);
    font: inherit;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.root-key-form-grid input,
.root-key-form-grid select {
    min-height: 45px;
    padding: 0 14px;
}

.root-key-form-grid input:focus,
.root-key-form-grid select:focus,
.root-prompt-stack textarea:focus {
    border-color: rgba(139, 226, 138, 0.55);
    background: rgba(8, 12, 16, 0.9);
    box-shadow: 0 0 0 4px rgba(139, 226, 138, 0.1);
}

.root-prompt-stack {
    display: none;
    gap: 12px;
}

.root-prompt-stack.is-active {
    display: grid;
}

.root-prompt-block {
    padding: 14px;
    border: 1px solid rgba(237, 242, 247, 0.09);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.025);
}

.root-prompt-block--large textarea {
    min-height: 260px;
}

.root-prompt-block-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.root-prompt-block-head strong {
    color: var(--root-text);
    font-size: 14px;
}

.root-prompt-block-head span {
    margin: 0;
}

.root-prompt-stack textarea {
    min-height: 130px;
    padding: 14px;
    resize: vertical;
    line-height: 1.7;
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
}

.root-key-card--keys .root-key-form-grid {
    margin-top: 6px;
}

.root-key-mini-btn,
.root-chat-remove-btn,
.root-prompt-tab {
    border: 1px solid rgba(237, 242, 247, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: var(--root-text);
    cursor: pointer;
    font: inherit;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.root-key-mini-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 12px;
    color: #fff;
    background: rgba(15, 20, 16, 0.85);
    border: 1.5px solid var(--root-accent);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    backdrop-filter: blur(6px);
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.root-key-mini-btn i {
    color: var(--root-accent);
    font-size: 13px;
}

.root-key-mini-btn:hover {
    transform: translateY(-1px);
    background: rgba(25, 35, 28, 0.9);
    border-color: #b8f57a;
    box-shadow: 0 0 0 4px rgba(155, 225, 93, 0.12);
}

.root-prompt-tab:hover,
.root-chat-remove-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.root-chat-model-list {
    display: grid;
    gap: 12px;
    max-height: calc(100vh - 260px);
    overflow: auto;
    padding-right: 4px;
}

.root-chat-model-empty {
    padding: 18px;
    border: 1px dashed rgba(237, 242, 247, 0.18);
    border-radius: 16px;
    color: var(--root-muted);
    text-align: center;
}

.root-chat-model-item {
    padding: 14px;
    border: 1px solid rgba(237, 242, 247, 0.1);
    border-radius: 18px;
    background: rgba(5, 9, 13, 0.5);
}

.root-chat-model-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.root-chat-default-choice,
.root-chat-enabled-choice {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--root-muted);
    font-size: 12px;
    font-weight: 800;
}

.root-chat-default-choice input,
.root-chat-enabled-choice input {
    accent-color: var(--root-accent);
}

.root-chat-remove-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 10px;
    border-radius: 10px;
    color: var(--root-danger);
    font-size: 12px;
    font-weight: 800;
}

.root-chat-remove-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.root-chat-model-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.root-chat-model-grid label {
    display: block;
}

.root-chat-model-grid span {
    display: block;
    margin-bottom: 7px;
    color: var(--root-muted);
    font-size: 11px;
    font-weight: 900;
}

.root-chat-model-grid input {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid rgba(237, 242, 247, 0.12);
    border-radius: 12px;
    background: rgba(6, 10, 14, 0.66);
    color: var(--root-text);
    font: inherit;
    outline: none;
}

.root-chat-model-grid input:focus {
    border-color: rgba(95, 212, 255, 0.55);
    box-shadow: 0 0 0 4px rgba(95, 212, 255, 0.1);
}

.root-chat-model-wide {
    grid-column: 1 / -1;
}

.root-prompt-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding: 5px;
    border: 1px solid rgba(237, 242, 247, 0.1);
    border-radius: 16px;
    background: rgba(6, 10, 14, 0.54);
}

.root-prompt-tab {
    flex: 1;
    min-height: 36px;
    border-radius: 12px;
    color: var(--root-muted);
    font-size: 12px;
    font-weight: 900;
}

.root-prompt-tab.is-active {
    color: #071009;
    background: linear-gradient(135deg, var(--root-accent), #d7ff98);
    border-color: rgba(155, 225, 93, 0.5);
}

@keyframes rootKeyRise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1120px) {
    .root-key-hero,
    .root-key-layout {
        grid-template-columns: 1fr;
    }

    .root-key-hero {
        align-items: flex-start;
    }

    .root-key-hero-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .root-key-hero,
    .root-key-card {
        padding: 20px;
        border-radius: 20px;
    }

    .root-key-form-grid {
        grid-template-columns: 1fr;
    }

    .root-chat-model-grid {
        grid-template-columns: 1fr;
    }

    .root-prompt-tabs,
    .root-chat-model-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .root-key-status-strip {
        align-items: flex-start;
        flex-direction: column;
    }
}
