:root {
    --bg: #f5ebdf;
    --panel: rgba(255, 250, 244, 0.94);
    --panel-soft: rgba(255, 252, 248, 0.9);
    --border: rgba(88, 47, 23, 0.14);
    --text: #261710;
    --muted: #715949;
    --accent: #c85624;
    --danger: #b03d3d;
    --shadow: 0 22px 48px rgba(72, 34, 9, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(135deg, #f6efe4 0%, #efd2b2 100%);
    color: var(--text);
    font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
}

.admin-shell {
    width: min(1480px, calc(100% - 1.5rem));
    margin: 0 auto;
    padding: 1rem 0 1.2rem;
}

.admin-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 1.2rem;
}

.eyebrow {
    margin: 0 0 0.3rem;
    color: var(--accent);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.lead {
    color: var(--muted);
    max-width: 58rem;
    line-height: 1.45;
}

.section-card,
.subsection-card {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--panel-soft);
    padding: 1rem;
}

.editor-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 1rem;
}

.editor-sidebar,
.editor-main {
    min-width: 0;
}

.sidebar-header,
.section-header,
.subsection-header {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: start;
}

.compact-header {
    margin-bottom: 1rem;
}

.stack-form {
    display: grid;
    gap: 0.8rem;
    max-width: 24rem;
}

label {
    display: grid;
    gap: 0.35rem;
    font-weight: 700;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(88, 47, 23, 0.18);
    background: white;
    padding: 0.72rem 0.85rem;
    color: var(--text);
}

button {
    border: 0;
    border-radius: 999px;
    padding: 0.7rem 1rem;
    background: linear-gradient(135deg, var(--accent) 0%, #df7c32 100%);
    color: #fffaf4;
    cursor: pointer;
    font-weight: 700;
}

button.secondary-button {
    background: rgba(255, 249, 242, 0.98);
    color: var(--text);
    border: 1px solid rgba(88, 47, 23, 0.16);
}

button.danger {
    background: linear-gradient(135deg, var(--danger) 0%, #c26161 100%);
}

button.subtle-danger {
    background: rgba(255, 240, 240, 0.96);
    color: var(--danger);
    border: 1px solid rgba(176, 61, 61, 0.2);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.message {
    min-height: 1.4rem;
    color: var(--muted);
    margin-bottom: 0;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.meta-grid-wide {
    grid-column: 1 / -1;
}

.table-wrap {
    overflow: auto;
    border: 1px solid rgba(88, 47, 23, 0.12);
    border-radius: 18px;
    background: white;
}

.cards-wrap {
    max-height: 62vh;
}

.cards-table input[data-card-field="name"] {
    min-width: 220px;
}

.cards-table input[data-card-field="image"] {
    min-width: 360px;
}

.cards-table .stat-input {
    min-width: 120px;
}

.editor-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.editor-table th,
.editor-table td {
    padding: 0.55rem;
    border-bottom: 1px solid rgba(88, 47, 23, 0.08);
    text-align: left;
    vertical-align: top;
}

.editor-table th {
    position: sticky;
    top: 0;
    background: #fff8f0;
    z-index: 1;
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.editor-table td input,
.editor-table td select {
    min-width: 100%;
    padding: 0.55rem 0.65rem;
    border-radius: 12px;
}

.row-index {
    width: 56px;
    color: var(--muted);
    font-weight: 700;
}

.custom-deck-list,
.builtin-deck-list {
    display: grid;
    gap: 0.7rem;
}

.custom-deck-list {
    margin-top: 0.9rem;
}

.custom-deck-item,
.builtin-deck-list article {
    padding: 0.85rem 0.95rem;
    border-radius: 18px;
    border: 1px solid rgba(88, 47, 23, 0.12);
    background: rgba(255, 249, 242, 0.88);
}

.custom-deck-item {
    width: 100%;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.custom-deck-item:hover,
.custom-deck-item:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(200, 86, 36, 0.26);
    box-shadow: 0 12px 24px rgba(72, 34, 9, 0.08);
}

.custom-deck-item.active {
    border-color: rgba(200, 86, 36, 0.38);
    background: rgba(255, 244, 232, 0.96);
}

.custom-deck-meta,
.builtin-deck-meta {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.builtin-deck-actions {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-start;
}

.sidebar-actions {
    margin-top: 0.9rem;
    display: grid;
    gap: 0.6rem;
}

.inline-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: end;
}

.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;
}

.is-hidden {
    display: none;
}

@media (max-width: 1100px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .admin-shell {
        width: min(100% - 1rem, 1480px);
        padding-top: 0.7rem;
    }

    .meta-grid,
    .sidebar-header,
    .section-header,
    .subsection-header {
        display: grid;
        grid-template-columns: 1fr;
    }

    .inline-actions,
    .sidebar-actions {
        justify-content: stretch;
    }

    .inline-actions button,
    .sidebar-actions button,
    .stack-form button {
        width: 100%;
    }
}