:root {
    color-scheme: dark;
    --bg: #070a12;
    --panel: rgba(255, 255, 255, .09);
    --panel-strong: rgba(255, 255, 255, .14);
    --border: rgba(255, 255, 255, .18);
    --text: #f5f8ff;
    --muted: #aeb8cc;
    --accent: #45d6b5;
    --accent-strong: #1fb494;
    --danger: #ff5d73;
    --shadow: 0 28px 90px rgba(0, 0, 0, .45);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(69, 214, 181, .22), transparent 30rem),
        linear-gradient(135deg, #070a12 0%, #111827 48%, #17121f 100%);
    color: var(--text);
}

button,
input,
textarea {
    font: inherit;
}

button {
    min-height: 48px;
    border: 0;
    border-radius: 12px;
    padding: 0 18px;
    color: var(--text);
    cursor: pointer;
    transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

button:hover {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
    transform: none;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(4, 8, 18, .58);
    color: var(--text);
    outline: none;
}

input {
    min-height: 48px;
    padding: 0 14px;
}

textarea {
    resize: vertical;
    padding: 14px;
    line-height: 1.5;
}

input:focus,
textarea:focus {
    border-color: rgba(69, 214, 181, .75);
    box-shadow: 0 0 0 4px rgba(69, 214, 181, .12);
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 36px 0;
}

.hidden {
    display: none !important;
}

.brand-row,
.room-header,
.section-head,
.button-row,
.room-url-row,
.room-actions,
.toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-row {
    margin-bottom: 42px;
    color: var(--muted);
    font-weight: 700;
}

.brand-row small {
    margin-left: 6px;
    color: rgba(245, 248, 255, .56);
    font-size: 12px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #83a9ff);
    color: #061014;
}

.hero {
    min-height: calc(100vh - 72px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-grid,
.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 430px;
    gap: 24px;
    align-items: start;
}

.intro h1 {
    max-width: 780px;
    margin: 0 0 18px;
    font-size: clamp(42px, 7vw, 88px);
    line-height: 1;
    letter-spacing: 0;
}

.intro p {
    max-width: 660px;
    margin: 0;
    color: var(--muted);
    font-size: 20px;
    line-height: 1.55;
}

.panel,
.qr-panel {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}

.panel {
    padding: 20px;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 6px;
    margin-bottom: 18px;
    border-radius: 14px;
    background: rgba(0, 0, 0, .22);
}

.tab {
    min-height: 44px;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
}

.tab.is-active {
    background: var(--panel-strong);
    color: var(--text);
}

.stack {
    display: none;
    gap: 14px;
}

.stack.active-form {
    display: grid;
}

label span,
.composer > label,
.eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.primary {
    background: linear-gradient(135deg, var(--accent), #7ca5ff);
    color: #041015;
    font-weight: 800;
}

.secondary {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .08);
}

.compact-button {
    min-height: 40px;
    padding: 0 14px;
}

.danger {
    background: rgba(255, 93, 115, .14);
    color: #ffd9df;
    border: 1px solid rgba(255, 93, 115, .34);
}

.copy-button {
    flex: 1;
    min-height: 58px;
    background: var(--accent);
    color: #041015;
    font-size: 18px;
    font-weight: 900;
}

.message {
    min-height: 22px;
    margin: 14px 0 0;
    color: var(--muted);
}

.message.error {
    color: #ffb3bd;
}

.room-header {
    justify-content: space-between;
    margin-bottom: 18px;
}

.room-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.room-header h1 {
    margin: 0;
    font-size: 46px;
    letter-spacing: .08em;
}

.status-pill {
    padding: 10px 14px;
    border: 1px solid rgba(69, 214, 181, .32);
    border-radius: 999px;
    background: rgba(69, 214, 181, .12);
    color: #a7ffe8;
    font-weight: 800;
}

.room-url-row {
    margin-bottom: 24px;
}

.room-url-row input {
    flex: 1;
}

.workspace-grid {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 1fr);
}

.composer {
    display: grid;
    gap: 14px;
}

.section-head {
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-head h2 {
    margin: 0;
    font-size: 20px;
}

.section-head span {
    color: var(--muted);
    font-size: 14px;
}

.toggle-row {
    justify-content: flex-start;
    margin: -2px 0 14px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
}

.toggle-row input {
    width: 20px;
    min-height: 20px;
    accent-color: var(--accent);
}

.toggle-row span {
    display: inline;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
}

.latest-text {
    min-height: 210px;
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0 0 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(0, 0, 0, .24);
    line-height: 1.5;
}

.fallback-copy {
    display: none;
    margin-bottom: 14px;
}

.fallback-copy.is-visible {
    display: block;
}

.button-row {
    align-items: stretch;
}

.files-panel,
.history-panel {
    margin-top: 24px;
}

.file-upload-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-bottom: 14px;
}

.file-list,
.history-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.file-item,
.history-item {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(0, 0, 0, .2);
}

.file-meta,
.history-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.file-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
}

.file-details {
    color: var(--muted);
    font-size: 13px;
}

.file-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-item time {
    color: var(--muted);
    font-size: 13px;
}

.history-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.file-action,
.history-copy {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid rgba(69, 214, 181, .32);
    border-radius: 10px;
    background: rgba(69, 214, 181, .12);
    color: #a7ffe8;
    font-size: 13px;
    font-weight: 800;
}

.file-action.danger-small {
    border-color: rgba(255, 93, 115, .34);
    background: rgba(255, 93, 115, .14);
    color: #ffd9df;
}

.qr-panel {
    display: grid;
    gap: 10px;
    place-items: center;
    width: 220px;
    min-height: 248px;
    margin: 24px auto 0;
    padding: 18px;
    color: var(--muted);
    box-shadow: none;
}

.qr-code {
    display: grid;
    place-items: center;
    width: 180px;
    height: 180px;
    padding: 10px;
    border-radius: 14px;
    background: #f7fbff;
}

.qr-code svg {
    width: 100%;
    height: 100%;
    display: block;
}

.qr-panel span {
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 20;
    max-width: min(420px, calc(100% - 40px));
    padding: 14px 16px;
    border: 1px solid rgba(69, 214, 181, .32);
    border-radius: 14px;
    background: rgba(9, 17, 31, .92);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    color: var(--text);
    font-weight: 800;
}

.toast.error {
    border-color: rgba(255, 93, 115, .42);
    color: #ffd9df;
}

@media (max-width: 860px) {
    .app-shell {
        width: min(100% - 20px, 720px);
        padding: 18px 0;
    }

    .hero {
        min-height: auto;
        padding: 24px 0;
    }

    .brand-row {
        margin-bottom: 28px;
    }

    .hero-grid,
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .intro h1 {
        font-size: 42px;
    }

    .intro p {
        font-size: 17px;
    }

    .room-header,
    .room-url-row,
    .file-upload-row,
    .button-row,
    .section-head,
    .room-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .room-header h1 {
        font-size: 38px;
    }

    .copy-button {
        width: 100%;
    }
}
