:root {
    --bg: #fff6f4;
    --surface: #fffdfc;
    --surface-soft: #fff1ec;
    --border: #f0d7d0;
    --text: #351816;
    --text-soft: #8d6763;
    --primary: #cb6b62;
    --primary-strong: #b5554e;
    --accent: #f4c9bf;
    --accent-strong: #df8d80;
    --danger: #c94747;
    --shadow-soft: 0 22px 48px rgba(80, 26, 20, 0.08);
}

html[data-theme="dark"] {
    --bg: #000000;
    --surface: #060606;
    --surface-soft: #101010;
    --border: #1d1d1d;
    --text: #f6f1ee;
    --text-soft: #a39a97;
    --primary: #f08d80;
    --primary-strong: #ffb0a6;
    --accent: #251717;
    --accent-strong: #5a3430;
    --danger: #ff7f7f;
    --shadow-soft: 0 22px 48px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Manrope", sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
}

code {
    padding: 0.18rem 0.4rem;
    border-radius: 10px;
    background: var(--surface-soft);
}

.page-shell {
    width: min(1200px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 22px;
}

.brand {
    display: inline-flex;
    align-items: center;
}

.brand-logo {
    width: clamp(60px, 9vw, 84px);
    height: auto;
    display: block;
}

h1,
h2,
h3 {
    letter-spacing: -0.04em;
}

.muted,
.mini-list-item small,
td small,
.modal-copy {
    color: var(--text-soft);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.page-content {
    display: grid;
    gap: 18px;
}

.panel,
.dropzone,
.auth-form,
.preview-panel,
.generic-preview {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
}

.panel,
.auth-form,
.preview-panel,
.generic-preview {
    padding: 18px;
}

.login-shell,
.compact-public {
    display: grid;
    gap: 20px;
}

.login-shell {
    max-width: 700px;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--primary-strong);
}

h1 {
    margin: 0 0 8px;
    font-size: clamp(1.8rem, 5vw, 3rem);
    line-height: 1.02;
}

h2 {
    margin: 0;
    font-size: clamp(1.05rem, 2.6vw, 1.25rem);
}

h3 {
    margin: 0;
    font-size: 1.2rem;
}

.stack-form,
.field,
.copy-stack,
.upload-strip,
.modal-links {
    display: grid;
    gap: 12px;
}

.field span {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.field input,
.copy-field input,
.slug-input input,
.message-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
}

.message-textarea {
    min-height: 132px;
    resize: vertical;
    line-height: 1.6;
    background:
        linear-gradient(180deg, var(--surface), var(--surface-soft));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}

.primary-button,
.ghost-button,
.danger-button,
.theme-toggle,
.link-button,
.copy-field button,
.action-button,
.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
}

.primary-button {
    background: var(--primary);
    color: white;
}

.ghost-button,
.theme-toggle,
.link-button,
.copy-field button,
.action-button,
.modal-close {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.danger-button {
    background: rgba(201, 71, 71, 0.12);
    border-color: rgba(201, 71, 71, 0.25);
    color: var(--danger);
}

.action-button {
    gap: 10px;
    min-height: 40px;
    padding-inline: 12px;
}

.action-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
}

.action-icon svg {
    width: 18px;
    height: 18px;
}

.alert {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.alert-success {
    background: rgba(77, 182, 118, 0.12);
    color: #317a4e;
}

.alert-error {
    background: rgba(201, 71, 71, 0.12);
    color: var(--danger);
}

.simple-intro p {
    margin: 0;
}

.dropzone {
    padding: 16px;
}

.dropzone-inner {
    display: grid;
    place-items: center;
    gap: 6px;
    min-height: 180px;
    padding: 20px;
    border: 2px dashed var(--accent-strong);
    border-radius: 14px;
    background: var(--surface-soft);
    text-align: center;
    cursor: pointer;
}

.dropzone.is-dragover .dropzone-inner {
    background: var(--accent);
}

.progress {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: var(--surface-soft);
    overflow: hidden;
}

.progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-strong));
}

.upload-results,
.mini-list,
.chip-cloud,
.file-meta {
    display: grid;
    gap: 10px;
}

.upload-result,
.mini-list-item,
.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.stats-grid,
.split-grid,
.compact-public {
    display: grid;
    gap: 16px;
}

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

.split-grid,
.compact-public {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
    flex-direction: column;
    align-items: flex-start;
}

.stat-card span {
    color: var(--text-soft);
}

.stat-card strong {
    font-size: clamp(1.5rem, 4vw, 1.9rem);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.history-chart {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    min-height: 210px;
    align-items: end;
}

.history-bar {
    display: grid;
    justify-items: center;
    gap: 8px;
    min-width: 0;
}

.history-bar-fill {
    width: 100%;
    min-height: 12px;
    border-radius: 12px 12px 6px 6px;
    background: linear-gradient(180deg, var(--primary), var(--accent-strong));
}

.pill {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
}

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

.uploads-table {
    width: 100%;
    border-collapse: collapse;
}

.uploads-table th,
.uploads-table td {
    padding: 14px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.uploads-table th {
    text-align: left;
    color: var(--text-soft);
    font-size: 0.92rem;
}

.inline-form,
.slug-input,
.row-actions,
.link-actions,
.public-actions,
.copy-field,
.action-buttons,
.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.action-buttons {
    justify-content: flex-start;
}

.slug-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.slug-input span {
    color: var(--text-soft);
    word-break: break-all;
}

.slug-input input {
    min-width: 0;
    padding: 4px;
    border: 0;
    background: transparent;
}

.inline-link {
    word-break: break-word;
    color: var(--primary-strong);
}

.link-button {
    min-height: 36px;
    padding: 8px 10px;
}

.preview-panel,
.generic-preview {
    margin-top: 14px;
}

.media-preview,
.pdf-preview {
    width: 100%;
    border-radius: 14px;
    border: 0;
}

.media-preview {
    max-height: 520px;
    object-fit: contain;
    background: #000;
}

.pdf-preview {
    min-height: 520px;
}

.audio-preview {
    width: 100%;
}

.generic-preview {
    display: grid;
    place-items: center;
    min-height: 220px;
    text-align: center;
    gap: 8px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(10, 4, 4, 0.58);
    backdrop-filter: blur(8px);
}

.modal-card {
    width: min(100%, 620px);
    max-height: min(88vh, 760px);
    overflow: auto;
    padding: 22px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.modal-card-danger {
    border-color: rgba(201, 71, 71, 0.3);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.modal-close {
    width: 42px;
    min-width: 42px;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 8px;
}

.not-found {
    max-width: 520px;
    margin: 40px auto;
    text-align: center;
}

.hidden {
    display: none !important;
}

body.modal-open {
    overflow: hidden;
}

@media (max-width: 980px) {
    .compact-stats,
    .split-grid,
    .compact-public {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 780px) {
    .page-shell {
        width: min(100% - 18px, 1200px);
        padding-top: 12px;
    }

    .topbar,
    .mini-list-item,
    .upload-result,
    .section-heading,
    .topbar-actions,
    .modal-header,
    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .theme-toggle,
    .ghost-button,
    .danger-button,
    .primary-button,
    .link-button,
    .copy-field button,
    .action-button,
    .modal-close {
        width: 100%;
    }

    .uploads-table,
    .uploads-table thead,
    .uploads-table tbody,
    .uploads-table tr,
    .uploads-table td {
        display: block;
        width: 100%;
    }

    .uploads-table thead {
        display: none;
    }

    .uploads-table tr {
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }

    .uploads-table td {
        padding: 8px 0;
        border: 0;
    }

    .uploads-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        font-size: 0.78rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-soft);
    }

    .inline-form,
    .copy-field,
    .row-actions,
    .link-actions,
    .public-actions,
    .action-buttons {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .modal-card {
        width: 100%;
        padding: 18px;
        border-radius: 18px;
    }
}
