:root {
    --primary: #ff4757;
    --primary-dark: #ff3838;
    --primary-soft: #ff6b7a;
    --bg-dark: #0f1419;
    --bg-card: #1a1f2e;
    --bg-alt: #242d3b;
    --text-main: #ffffff;
    --text-muted: #b8c5d6;
    --line: #30455b;
    --ok: #7de3a7;
    --error: #ffc0c0;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: 'Trebuchet MS', 'Gill Sans', 'Segoe UI', sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(circle at 15% 10%, rgba(255, 71, 87, 0.22), transparent 32%),
        radial-gradient(circle at 88% 0%, rgba(255, 107, 122, 0.14), transparent 30%),
        linear-gradient(135deg, var(--bg-dark), #161c28 60%, #131925);
    background-attachment: fixed;
    padding: 26px 16px 42px;
}

.page-wrap {
    width: min(1080px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 16px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.eyebrow {
    margin: 0;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--primary-soft);
}

h1 {
    margin: 5px 0 8px;
    font-size: clamp(1.8rem, 2vw + 1rem, 2.8rem);
}

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

.home-link {
    text-decoration: none;
    color: var(--text-main);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.04);
}

.home-link:hover {
    border-color: var(--primary-soft);
}

.grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.card {
    background: linear-gradient(155deg, var(--bg-card), var(--bg-alt));
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
}

h2 {
    margin: 0 0 10px;
}

label {
    display: block;
    margin: 10px 0 6px;
    color: var(--text-muted);
}

input[type='text'],
input[type='file'],
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.24);
    color: var(--text-main);
    padding: 10px 12px;
}

input[type='file'] {
    padding: 8px;
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 34px;
}

.inline-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.inline-row .btn {
    margin-top: 0;
    flex-shrink: 0;
}

.inline-row input {
    margin: 0;
}

.theme-form {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed rgba(255, 255, 255, 0.14);
}

.theme-admin {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed rgba(255, 255, 255, 0.14);
}

.theme-admin h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.themes-board {
    display: grid;
    gap: 8px;
}

.theme-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.theme-row.is-archived {
    border-style: dashed;
    opacity: 0.86;
}

.theme-row-info {
    min-width: 0;
}

.theme-row-title {
    margin: 0;
    font-weight: 700;
}

.theme-row-meta {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.theme-row-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 11px 14px;
    margin-top: 12px;
    font-weight: 800;
    cursor: pointer;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #ffffff;
}

.btn.subtle {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn.danger {
    background: rgba(255, 120, 120, 0.12);
    color: #ffd3d3;
    border: 1px solid rgba(255, 130, 130, 0.32);
}

.btn.tiny {
    margin-top: 0;
    padding: 7px 10px;
    font-size: 0.8rem;
    border-radius: 8px;
    font-weight: 700;
}

.btn:hover {
    filter: brightness(1.08);
}

.feedback {
    margin: 10px 0 0;
    min-height: 1.3em;
}

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

.feedback.success {
    color: var(--ok);
}

.feedback.error {
    color: var(--error);
}

.hint {
    color: var(--text-muted);
    margin: 8px 0 0;
    font-size: 0.92rem;
}

.list-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.list-head p {
    margin: 0;
    color: var(--primary-soft);
    font-weight: 700;
}

.list-head-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-head-right label {
    margin: 0;
    font-size: 0.9rem;
}

.list-head-right select {
    width: auto;
    min-width: 180px;
    padding: 8px 30px 8px 10px;
}

.list-head-right p {
    min-width: 64px;
    text-align: right;
}

.theme-filters {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.theme-filter-btn {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-radius: 999px;
    padding: 7px 11px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.84rem;
}

.theme-filter-btn.is-active {
    border-color: var(--primary-soft);
    background: rgba(255, 107, 122, 0.2);
}

.table-wrap {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: auto;
}

table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

th {
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: rgba(0, 0, 0, 0.2);
}

tbody tr:last-child td {
    border-bottom: none;
}

.empty-row td {
    text-align: center;
    color: var(--text-muted);
}

.actions-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.edit-panel {
    margin-top: 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.22);
}

.edit-panel h3 {
    margin: 0 0 8px;
}

.hidden {
    display: none !important;
}

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

@media (max-width: 640px) {
    body {
        padding: 18px 12px 28px;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .inline-row {
        flex-direction: column;
        align-items: stretch;
    }

    .list-head-right {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .list-head-right select {
        min-width: 0;
        width: 100%;
    }

    .actions-cell {
        flex-direction: column;
        align-items: stretch;
    }

    .theme-row {
        flex-direction: column;
        align-items: stretch;
    }

    .theme-row-actions {
        flex-wrap: wrap;
    }
}
