:root {
    --bg: #0f1114;
    --surface: #1a1d23;
    --border: #2a2f38;
    --text: #f4f5f7;
    --muted: #9aa3b2;
    --accent: #e8ff47;
    --accent-dim: rgba(232, 255, 71, 0.12);
    --danger: #ff6b6b;
    --danger-dim: rgba(255, 107, 107, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.page-bg {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-dim), transparent),
        radial-gradient(circle at 100% 100%, rgba(255, 255, 255, 0.03), transparent 40%);
    pointer-events: none;
}

.page-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.page-admin .page-shell {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.page-shell {
    position: relative;
    width: 100%;
    max-width: 1080px;
}

.auth-card,
.panel-card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.panel-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

@media (min-width: 900px) {
    .panel-header {
        align-items: center;
    }
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}

h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 0.5rem;
}

h1 span,
.accent {
    color: var(--accent);
}

.lead {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.section-head .lead {
    margin-bottom: 0;
}

.form {
    display: grid;
    gap: 1rem;
}

.field {
    display: grid;
    gap: 0.4rem;
}

.field span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

.field input {
    width: 100%;
    padding: 0.8rem 0.95rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.1rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #111;
}

.btn-primary:hover {
    filter: brightness(0.95);
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.92rem;
}

.alert-error {
    background: var(--danger-dim);
    border: 1px solid rgba(255, 107, 107, 0.35);
    color: #ffb4b4;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.card {
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.card-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.card p,
.card li {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text);
}

.user-meta {
    text-align: right;
    font-size: 0.9rem;
    color: var(--muted);
}

.user-meta strong {
    display: block;
    color: var(--text);
}

.role-pill {
    display: inline-block;
    margin-top: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.admin-nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
}

.admin-nav a:hover,
.admin-nav a.is-active {
    color: var(--accent);
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.section-head.compact {
    margin-bottom: 1rem;
}

.section-head h2 {
    font-size: 1.5rem;
    margin-bottom: 0.35rem;
}

.section-head-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
}

.section-card {
    margin-bottom: 1rem;
    padding: 1.25rem 1.5rem;
}

.section-actions {
    margin-top: 1rem;
}

.muted,
.field-hint {
    color: var(--muted);
    font-size: 0.9rem;
}

.field-hint {
    display: block;
    margin-top: 0.35rem;
}

.card-link {
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease;
}

.card-link:hover {
    border-color: var(--accent);
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.data-table a {
    color: var(--accent);
}

.field textarea,
.field select {
    width: 100%;
    padding: 0.8rem 0.95rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.field textarea {
    resize: vertical;
    min-height: 280px;
    line-height: 1.5;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
}

.status-pill {
    display: inline-flex;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-pill.is-on {
    background: var(--accent-dim);
    color: var(--accent);
}

.status-pill.is-off {
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
}

.alert-success {
    background: var(--accent-dim);
    border: 1px solid rgba(232, 255, 71, 0.35);
    color: var(--accent);
}

.code-block {
    margin-top: 0.75rem;
    padding: 1rem;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #d5dae3;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.subsection-title {
    margin: 1.25rem 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.form-section-title {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.settings-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.settings-nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
}

.settings-nav a:hover,
.settings-nav a.is-active {
    color: var(--accent);
}

.settings-grid {
    margin-top: 0.5rem;
}

.token-reveal .token-value {
    display: block;
    margin: 0.75rem 0;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    word-break: break-all;
    font-size: 0.9rem;
}

.inline-form {
    display: inline;
}

.btn-sm {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
}

.form-wide {
    max-width: none;
}

.form-grid-2 {
    display: grid;
    gap: 1rem;
}

@media (min-width: 768px) {
    .form-grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}

.form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.kv-section {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.kv-section-head {
    margin-bottom: 1rem;
}

.kv-section-head .form-section-title {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.kv-table-head,
.kv-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(200px, 2fr) auto;
    gap: 0.75rem;
    align-items: center;
}

.kv-table-head {
    margin-bottom: 0.5rem;
    padding: 0 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.kv-rows {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}

.kv-key,
.kv-value {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.kv-key:focus,
.kv-value:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.kv-remove {
    min-width: 2.5rem;
    padding-inline: 0.65rem;
}

@media (max-width: 640px) {
    .kv-table-head {
        display: none;
    }

    .kv-row {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "key remove"
            "value value";
        padding: 0.75rem;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--bg);
    }

    .kv-key { grid-area: key; }
    .kv-value { grid-area: value; }
    .kv-remove { grid-area: remove; }
}

.view-pill {
    display: inline-block;
    margin: 0 0.35rem 0.35rem 0;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
}

.capture-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.capture-card {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
}

.capture-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.capture-remove-field {
    margin-bottom: 0.75rem;
}

.capture-upload-field .dropify-wrapper {
    border-radius: 10px;
    border-color: var(--border);
    background: var(--bg);
    color: var(--text);
}

.capture-upload-field .dropify-wrapper:hover {
    background-image: linear-gradient(-45deg, var(--surface) 25%, transparent 25%, transparent 50%, var(--surface) 50%, var(--surface) 75%, transparent 75%, transparent);
}

.capture-upload-field .dropify-message span.file-icon {
    color: var(--accent);
}

.capture-upload-field .dropify-message p {
    color: var(--muted);
}

.capture-upload-field .dropify-clear,
.capture-upload-field .dropify-preview .dropify-infos .dropify-infos-inner p {
    color: var(--text);
}

.capture-upload-field .dropify-preview .dropify-infos {
    background: rgba(15, 17, 20, 0.75);
}

@media (max-width: 768px) {
    .capture-grid {
        grid-template-columns: 1fr;
    }
}

.form-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 900px) {
    .form-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.filters-form .form-footer {
    margin-top: 0.5rem;
}

.generation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.generation-card {
    display: block;
    padding: 0;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.generation-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.generation-thumb {
    aspect-ratio: 3 / 4;
    background: #000;
    overflow: hidden;
}

.generation-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.generation-meta {
    display: grid;
    gap: 0.25rem;
    padding: 0.85rem 1rem 1rem;
    font-size: 0.85rem;
}

.generation-detail {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    gap: 1rem;
    align-items: start;
}

.generation-detail-image img {
    display: block;
    width: 100%;
    border-radius: 10px;
    background: #000;
}

.meta-list {
    display: grid;
    gap: 0.75rem;
}

.meta-list > div {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.75rem;
    align-items: baseline;
}

.meta-list dt {
    color: var(--muted);
    font-size: 0.85rem;
}

.meta-list dd {
    margin: 0;
    word-break: break-word;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.drive-layout {
    gap: 1rem;
}

.drive-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    padding: 0.85rem 1rem;
    font-size: 0.92rem;
}

.drive-breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.drive-breadcrumb a:hover {
    text-decoration: underline;
}

.drive-breadcrumb-current {
    color: var(--text);
    font-weight: 600;
}

.drive-breadcrumb-sep {
    color: var(--muted);
}

.drive-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.drive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.85rem;
}

.drive-item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.95rem 1rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.drive-item:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.02);
}

.drive-item-icon {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    color: var(--accent);
}

.drive-item-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.drive-item-body {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.drive-item-body strong {
    word-break: break-word;
}

.drive-item-body time {
    font-size: 0.78rem;
}

.drive-folder .drive-item-icon {
    color: #8ab4f8;
}

@media (max-width: 900px) {
    .generation-detail {
        grid-template-columns: 1fr;
    }

    .form-grid-4 {
        grid-template-columns: 1fr;
    }
}
