:root {
    color-scheme: dark;
    --bg: #0d0f12;
    --bg-raised: #13161a;
    --surface: #181c21;
    --surface-strong: #20252b;
    --surface-soft: #15191d;
    --border: #30363d;
    --border-strong: #444b53;
    --text: #f2f0ea;
    --text-muted: #a9afb6;
    --text-dim: #7f8790;
    --amber: #d3a856;
    --amber-strong: #e4b865;
    --amber-soft: rgba(211, 168, 86, 0.12);
    --success: #70b58c;
    --success-soft: rgba(112, 181, 140, 0.12);
    --danger: #e07b75;
    --danger-soft: rgba(224, 123, 117, 0.1);
    --info: #8ba9c7;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --content: 1120px;
    --ease: 160ms ease;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg);
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 15% 0%, rgba(211, 168, 86, 0.06), transparent 32rem),
        linear-gradient(180deg, #101317 0%, var(--bg) 55%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body.modal-open {
    overflow: hidden;
}

button,
input,
textarea {
    color: inherit;
    font: inherit;
}

button,
a,
input,
textarea {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--amber-strong);
}

img {
    display: block;
    max-width: 100%;
}

svg {
    display: block;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 3px solid rgba(228, 184, 101, 0.75);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    left: 12px;
    top: 12px;
    z-index: 100;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--amber-strong);
    color: #17130d;
    font-weight: 700;
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

.site-shell {
    width: min(100% - 32px, var(--content));
    margin: 0 auto;
}

.site-header {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 0.94rem;
    font-weight: 750;
    letter-spacing: 0.12em;
    text-decoration: none;
    text-transform: uppercase;
}

.brand-mark {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid rgba(211, 168, 86, 0.52);
    border-radius: 8px;
    background: var(--amber-soft);
    color: var(--amber-strong);
}

.brand-mark svg {
    width: 17px;
    height: 17px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--amber-strong);
    font-size: 0.75rem;
    font-weight: 750;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3 {
    line-height: 1.2;
}

h1 {
    margin-bottom: 16px;
    font-size: clamp(2rem, 9vw, 4rem);
    font-weight: 720;
    letter-spacing: -0.045em;
}

h2 {
    margin-bottom: 10px;
    font-size: clamp(1.35rem, 5vw, 1.8rem);
    letter-spacing: -0.02em;
}

h3 {
    margin-bottom: 8px;
    font-size: 1rem;
}

.lead,
.section-copy {
    color: var(--text-muted);
}

.lead {
    max-width: 640px;
    margin-bottom: 0;
    font-size: 1.05rem;
}

.muted {
    color: var(--text-muted);
}

.fine-print {
    margin: 8px 0 0;
    color: var(--text-dim);
    font-size: 0.84rem;
}

.mono {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(24, 28, 33, 0.94);
    box-shadow: var(--shadow);
}

.panel-body {
    padding: 20px;
}

.panel-header {
    padding: 20px 20px 0;
}

.field {
    margin-bottom: 20px;
}

.field-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

label,
.label {
    display: block;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 680;
}

.character-count {
    color: var(--text-dim);
    font-size: 0.8rem;
    white-space: nowrap;
}

.text-input,
.textarea {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #101317;
    color: var(--text);
    transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

.text-input {
    padding: 0 14px;
}

.textarea {
    min-height: 190px;
    padding: 13px 14px;
    line-height: 1.6;
    resize: vertical;
}

.textarea.compact {
    min-height: 112px;
}

.text-input:hover,
.textarea:hover {
    border-color: #59616b;
}

.text-input:focus,
.textarea:focus {
    border-color: var(--amber);
    background: #0d1013;
    box-shadow: 0 0 0 3px rgba(211, 168, 86, 0.12);
    outline: 0;
}

.text-input::placeholder,
.textarea::placeholder {
    color: #69717a;
}

.input-large {
    height: 58px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 1.15rem;
    letter-spacing: 0.05em;
}

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 720;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition: background var(--ease), border-color var(--ease), color var(--ease), opacity var(--ease);
}

.button:hover {
    text-decoration: none;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.button-primary {
    border-color: var(--amber);
    background: var(--amber-strong);
    color: #17130d;
}

.button-primary:hover:not(:disabled) {
    background: #efc677;
}

.button-secondary {
    border-color: var(--border-strong);
    background: var(--surface-strong);
    color: var(--text);
}

.button-secondary:hover:not(:disabled) {
    border-color: #606975;
    background: #282e35;
}

.button-danger {
    border-color: rgba(224, 123, 117, 0.52);
    background: var(--danger-soft);
    color: #f1a09a;
}

.button-danger:hover:not(:disabled) {
    border-color: var(--danger);
    background: rgba(224, 123, 117, 0.16);
}

.button-quiet {
    border-color: transparent;
    background: transparent;
    color: var(--text-muted);
}

.button-quiet:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.button-block {
    width: 100%;
}

.button svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.button-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-message {
    min-height: 24px;
    margin: 10px 0 0;
    color: var(--danger);
    font-size: 0.9rem;
}

.index-main {
    padding: 44px 0 64px;
}

.index-hero {
    display: grid;
    gap: 32px;
    align-items: center;
}

.index-copy {
    max-width: 680px;
}

.access-panel {
    overflow: hidden;
}

.access-panel .panel-body {
    padding: 24px;
}

.access-form .field {
    margin-bottom: 14px;
}

.capabilities {
    display: grid;
    gap: 12px;
    margin-top: 44px;
}

.capability {
    min-height: 100%;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(20, 23, 27, 0.7);
}

.capability-index {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    border-radius: 7px;
    background: var(--amber-soft);
    color: var(--amber-strong);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.75rem;
    font-weight: 700;
}

.capability p {
    margin-bottom: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.detail-header {
    padding: 18px 0;
}

.back-link {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-weight: 650;
    text-decoration: none;
}

.back-link:hover {
    color: var(--text);
}

.back-link svg {
    width: 18px;
    height: 18px;
}

.vault-summary {
    padding: 28px 0 22px;
}

.vault-summary-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
}

.vault-number {
    margin: 0;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: clamp(2.25rem, 12vw, 4rem);
    font-weight: 650;
    letter-spacing: -0.05em;
}

.status-badge {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border: 1px solid;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-badge::before {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    content: "";
}

.status-available {
    border-color: rgba(112, 181, 140, 0.35);
    background: var(--success-soft);
    color: #8dcaa5;
}

.status-available::before {
    background: var(--success);
}

.status-locked {
    border-color: rgba(211, 168, 86, 0.35);
    background: var(--amber-soft);
    color: var(--amber-strong);
}

.status-locked::before {
    background: var(--amber);
}

.detail-grid {
    display: grid;
    gap: 18px;
    padding-bottom: 64px;
}

.workspace-panel {
    min-width: 0;
}

.section-heading {
    margin-bottom: 24px;
}

.section-heading p {
    margin-bottom: 0;
    color: var(--text-muted);
}

.info-card {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(20, 23, 27, 0.7);
}

.steps {
    display: grid;
    gap: 20px;
    margin: 22px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: steps;
}

.steps li {
    position: relative;
    min-height: 36px;
    padding-left: 46px;
    color: var(--text-muted);
    counter-increment: steps;
}

.steps li::before {
    position: absolute;
    left: 0;
    top: -2px;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    color: var(--amber-strong);
    content: counter(steps);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.75rem;
    font-weight: 700;
}

.notice {
    margin-bottom: 20px;
    padding: 14px 16px;
    border-left: 3px solid var(--info);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: rgba(139, 169, 199, 0.09);
    color: #bfcee0;
    font-size: 0.9rem;
}

.notice-warning {
    border-left-color: var(--amber);
    background: var(--amber-soft);
    color: #e7cb98;
}

.file-control {
    position: relative;
}

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.file-label {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border: 1px dashed #59616b;
    border-radius: var(--radius-sm);
    background: #111418;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 650;
    text-align: center;
    transition: border-color var(--ease), background var(--ease), color var(--ease);
}

.file-input:focus-visible + .file-label,
.file-label:hover {
    border-color: var(--amber);
    background: var(--amber-soft);
    color: var(--text);
}

.file-meta {
    min-height: 22px;
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.84rem;
    overflow-wrap: anywhere;
}

.image-preview,
.current-image {
    margin: 14px 0 0;
}

.image-frame {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #0c0e11;
}

.image-frame img {
    width: 100%;
    max-height: 320px;
    object-fit: contain;
}

.image-frame figcaption {
    padding: 9px 12px;
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.8rem;
}

.editor-actions {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.editor-danger-zone {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.unlock-panel {
    max-width: 680px;
}

.toast-region {
    position: fixed;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 80;
    width: min(calc(100% - 32px), 460px);
    pointer-events: none;
    transform: translateX(-50%);
}

.toast {
    padding: 13px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #242a31;
    box-shadow: 0 12px 38px rgba(0, 0, 0, 0.42);
    color: var(--text);
    font-size: 0.9rem;
    text-align: center;
}

.toast.error {
    border-color: rgba(224, 123, 117, 0.58);
    background: #322224;
}

.toast.success {
    border-color: rgba(112, 181, 140, 0.55);
    background: #1d2d25;
}

.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    overflow-y: auto;
    padding: 16px;
    background: rgba(5, 7, 9, 0.82);
}

.dialog {
    width: min(100%, 580px);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.dialog-header,
.dialog-body,
.dialog-footer {
    padding: 20px;
}

.dialog-header {
    border-bottom: 1px solid var(--border);
}

.dialog-header h2,
.dialog-header p,
.dialog-footer p {
    margin-bottom: 0;
}

.dialog-body {
    padding-top: 18px;
    padding-bottom: 18px;
}

.dialog-footer {
    border-top: 1px solid var(--border);
}

.dialog-footer .button-row {
    width: 100%;
}

.tab-list {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    border-radius: 10px;
    background: #101317;
}

.tab {
    flex: 1;
    min-height: 44px;
    padding: 8px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 700;
}

.tab[aria-selected="true"] {
    background: var(--surface-strong);
    color: var(--amber-strong);
}

.credential-value {
    min-height: 108px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.88rem;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 18px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.checkbox-row input {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    margin: 2px 0 0;
    accent-color: var(--amber);
}

.compat-main {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px 16px;
}

.compat-card {
    width: min(100%, 520px);
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.compat-card .brand-mark {
    width: 42px;
    height: 42px;
    margin: 0 auto 20px;
}

.compat-card h1 {
    margin-bottom: 10px;
    font-size: clamp(1.5rem, 7vw, 2.1rem);
    letter-spacing: -0.025em;
}

.compat-card p {
    color: var(--text-muted);
}

.progress-track {
    height: 3px;
    overflow: hidden;
    margin: 24px 0;
    border-radius: 999px;
    background: var(--border);
}

.progress-bar {
    width: 100%;
    height: 100%;
    background: var(--amber);
    transform: scaleX(0);
    transform-origin: left;
    animation: progress 600ms linear forwards;
}

@keyframes progress {
    to {
        transform: scaleX(1);
    }
}

.success-mark {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    margin: 0 auto 20px;
    border: 1px solid rgba(112, 181, 140, 0.42);
    border-radius: 50%;
    background: var(--success-soft);
    color: var(--success);
}

.success-mark svg {
    width: 24px;
    height: 24px;
}

@media (min-width: 640px) {
    .site-shell {
        width: min(100% - 48px, var(--content));
    }

    .index-main {
        padding-top: 72px;
    }

    .access-panel .panel-body,
    .panel-body {
        padding: 28px;
    }

    .panel-header {
        padding: 28px 28px 0;
    }

    .capabilities {
        grid-template-columns: repeat(3, 1fr);
    }

    .vault-summary-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .button-row,
    .editor-actions,
    .dialog-footer .button-row {
        flex-direction: row;
    }

    .editor-actions {
        display: flex;
        flex-wrap: wrap;
    }

    .editor-actions .button {
        flex: 1 1 150px;
    }

    .dialog-footer .button {
        flex: 1;
    }
}

@media (min-width: 860px) {
    .index-hero {
        grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
        gap: 64px;
    }

    .detail-grid {
        grid-template-columns: minmax(0, 1fr) 300px;
        align-items: start;
        gap: 24px;
    }

    .detail-aside {
        position: sticky;
        top: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
