:root {
    --page: #f1f4f8;
    --surface: #ffffff;
    --surface-muted: #f7f9fc;
    --text: #172033;
    --muted: #5f6b7c;
    --line: #d6dce6;
    --primary: #732b3e;
    --primary-hover: #5d2132;
    --primary-text: #ffffff;
    --accent: #2459a8;
    --positive: #18733b;
    --positive-soft: #edf8f1;
    --danger: #a1262d;
    --danger-soft: #fff0f1;
    --focus: #1d4ed8;
    --header-line: #5c2031;
    --eyebrow: #f3b6c6;
    --positive-text: #10582c;
    --danger-text: #7c1d24;
    --danger-line: #efc2c6;
    --interactive-hover: #eef5ff;
    --preview-background: #e9edf3;
    --preview-image-background: #dfe5ed;
    --privacy-background: #fbf2f5;
    --secondary-hover-line: #aab4c3;
    --code-background: #e9edf3;
    --code-text: #273449;
}

:root[data-theme="dark"] {
    --page: #111318;
    --surface: #1b1f27;
    --surface-muted: #242a34;
    --text: #f4f6fb;
    --muted: #adb6c6;
    --line: #3b4350;
    --primary: #87364d;
    --primary-hover: #a24360;
    --accent: #8db8ff;
    --positive: #62d58a;
    --positive-soft: #14291c;
    --danger: #e26770;
    --danger-soft: #32191c;
    --focus: #8ab7ff;
    --header-line: #b75d77;
    --eyebrow: #ffd0dc;
    --positive-text: #a0efba;
    --danger-text: #ffb4ba;
    --danger-line: #71333a;
    --interactive-hover: #25344b;
    --preview-background: #141820;
    --preview-image-background: #171c24;
    --privacy-background: #2d2025;
    --secondary-hover-line: #758092;
    --code-background: #11151c;
    --code-text: #dce5f2;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    background: var(--page);
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--page);
    color: var(--text);
    font: 15px/1.5 Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button,
label[for] {
    -webkit-tap-highlight-color: transparent;
}

.site-header {
    border-bottom: 1px solid var(--header-line);
    background: var(--primary);
    color: var(--primary-text);
}

.header-inner,
.page-shell,
.site-footer {
    width: min(960px, calc(100% - 32px));
    margin: 0 auto;
}

.header-inner {
    min-height: 92px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 0;
}

.eyebrow,
.section-label {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.eyebrow {
    color: var(--eyebrow);
}

.section-label {
    color: var(--accent);
}

h1,
h2 {
    letter-spacing: 0;
}

h1 {
    margin: 0;
    font-size: 25px;
    line-height: 1.2;
}

h2 {
    margin: 0;
    font-size: 21px;
    line-height: 1.25;
}

p {
    margin: 0;
}

.page-shell {
    min-height: calc(100vh - 156px);
    padding: 28px 0 40px;
}

.notice {
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 6px;
    background: var(--surface);
    padding: 12px 14px;
    font-weight: 700;
}

.notice-success,
.notice-upload {
    border-left-color: var(--positive);
    background: var(--positive-soft);
    color: var(--positive-text);
}

.notice-error {
    border-left-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger-text);
}

.upload-errors {
    margin-bottom: 18px;
    border: 1px solid var(--danger-line);
    border-left: 4px solid var(--danger);
    border-radius: 6px;
    background: var(--danger-soft);
    padding: 14px 16px;
    color: var(--danger-text);
}

.upload-errors h2 {
    font-size: 16px;
}

.upload-errors ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.login-panel,
.setup-panel,
.upload-workspace,
.result-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.login-panel,
.setup-panel {
    max-width: 590px;
    padding: 26px;
}

.login-panel > p:not(.section-label),
.setup-panel > p:not(.section-label) {
    margin-top: 9px;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

.login-form label,
.code-field label {
    font-size: 13px;
    font-weight: 800;
}

.password-row,
.code-field > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
}

input[type="password"],
input[type="text"] {
    min-width: 0;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    padding: 9px 11px;
}

.button {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    padding: 8px 14px;
    font-weight: 800;
}

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

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

.button-secondary {
    border-color: var(--line);
    background: var(--surface);
    color: var(--text);
}

.button-secondary:hover {
    border-color: var(--secondary-hover-line);
    background: var(--surface-muted);
}

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

.logout-form .button,
.button-header {
    border-color: rgba(255, 255, 255, .42);
    background: transparent;
    color: #ffffff;
}

.button-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.button-header:hover,
.logout-form .button:hover {
    border-color: #ffffff;
    background: rgba(255, 255, 255, .1);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.upload-workspace {
    padding: 22px;
}

.workspace-heading,
.result-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.workspace-heading > p,
.result-heading > span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.upload-form {
    display: grid;
    gap: 18px;
}

.upload-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, .85fr);
    gap: 18px;
}

.drop-zone {
    min-height: 238px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 7px;
    border: 2px dashed #aab4c3;
    border-radius: 8px;
    background: var(--surface-muted);
    cursor: pointer;
    padding: 22px;
    text-align: center;
}

.drop-zone:hover,
.drop-zone.is-dragging {
    border-color: var(--accent);
    background: var(--interactive-hover);
}

.drop-zone input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.upload-symbol {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    font-size: 30px;
    font-weight: 400;
    line-height: 1;
}

.drop-zone strong {
    font-size: 17px;
}

.drop-zone span:last-of-type,
.file-summary {
    color: var(--muted);
    font-size: 13px;
}

.file-summary {
    min-height: 20px;
    margin-top: 7px;
}

.file-summary.is-error {
    color: var(--danger);
    font-weight: 800;
}

.preview-area {
    min-height: 238px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--preview-background);
    color: var(--muted);
    padding: 12px;
    text-align: center;
}

.preview-area.is-empty {
    display: grid;
    place-items: center;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 10px;
}

.preview-grid figure {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
}

.preview-grid img {
    width: 100%;
    aspect-ratio: 1;
    display: block;
    background: var(--preview-image-background);
    object-fit: contain;
}

.preview-grid figcaption {
    overflow: hidden;
    padding: 7px 8px;
    font-size: 11px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.privacy-check {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    border-left: 4px solid var(--primary);
    background: var(--privacy-background);
    padding: 13px 14px;
}

.privacy-check input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.form-actions p {
    max-width: 610px;
    color: var(--muted);
    font-size: 13px;
}

.result-panel {
    margin-top: 22px;
    padding: 22px;
}

.code-field {
    display: grid;
    gap: 6px;
    margin-top: 14px;
}

.code-field input,
.code-field textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-muted);
    color: var(--text);
    padding: 9px 11px;
    font: 13px/1.4 Menlo, Monaco, Consolas, monospace;
}

.code-field textarea {
    min-height: 42px;
    resize: vertical;
}

.result-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 14px;
    margin-top: 22px;
}

.result-item {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-muted);
}

.result-image-link {
    display: block;
    border-bottom: 1px solid var(--line);
    background: var(--preview-background);
}

.result-image-link img {
    width: 100%;
    aspect-ratio: 16 / 10;
    display: block;
    object-fit: contain;
}

.result-item-body {
    display: grid;
    gap: 4px;
    padding: 12px;
}

.result-item-body > strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-item-body > span {
    color: var(--muted);
    font-size: 12px;
}

.result-item-link {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
    margin-top: 7px;
}

.result-item-link input {
    min-width: 0;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    padding: 8px 10px;
    color: var(--text);
    font: 12px/1.4 Menlo, Monaco, Consolas, monospace;
}

.copy-status {
    min-height: 21px;
    margin-top: 10px;
    color: var(--positive);
    font-weight: 800;
}

.site-footer {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

.site-footer a {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

code {
    border-radius: 4px;
    background: var(--code-background);
    padding: 2px 5px;
    color: var(--code-text);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.drop-zone:focus-within {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

@media (max-width: 720px) {
    .header-inner,
    .workspace-heading,
    .result-heading,
    .form-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-inner {
        min-height: 0;
    }

    .header-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .upload-grid {
        grid-template-columns: 1fr;
    }

    .preview-area {
        min-height: 210px;
    }

    .form-actions .button,
    .header-actions .button,
    .header-actions form,
    .header-actions form .button,
    .logout-form,
    .logout-form .button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header-inner,
    .page-shell,
    .site-footer {
        width: min(100% - 22px, 960px);
    }

    .page-shell {
        padding-top: 18px;
    }

    .login-panel,
    .setup-panel,
    .upload-workspace,
    .result-panel {
        padding: 17px;
    }

    .password-row,
    .code-field > div,
    .result-item-link {
        grid-template-columns: 1fr;
    }

    .button {
        width: 100%;
    }

    h1 {
        font-size: 22px;
    }
}
