:root {
    color-scheme: light;
    --bg: #eef3f8;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d7dfeb;
    --line-strong: #b8c5d8;
    --primary: #0e7c70;
    --primary-dark: #075f56;
    --accent: #2563eb;
    --accent-soft: #e9f0ff;
    --danger: #b42318;
    --danger-bg: #fff1ef;
    --success: #067647;
    --shadow: 0 22px 65px rgba(23, 32, 51, 0.14);
    --shadow-soft: 0 12px 30px rgba(23, 32, 51, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(135deg, rgba(14, 124, 112, 0.12), transparent 34%), linear-gradient(315deg, rgba(37, 99, 235, 0.10), transparent 38%), var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.login-screen,
.app-shell {
    width: min(760px, 100%);
    margin: 0 auto;
    padding: 22px;
}

.login-screen {
    display: grid;
    min-height: 100vh;
    place-items: center;
}

.login-panel,
.upload-zone,
.result-section {
    border: 1px solid rgba(215, 223, 235, 0.92);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.login-panel {
    width: min(430px, 100%);
    padding: 30px;
}

.brand-mark {
    display: grid;
    width: 52px;
    height: 52px;
    margin-bottom: 20px;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, #0e7c70, #2563eb);
    color: #fff;
    font-weight: 900;
    box-shadow: 0 14px 26px rgba(14, 124, 112, 0.24);
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 6px;
    font-size: 30px;
    line-height: 1.12;
}

h2 {
    margin-bottom: 4px;
    font-size: 18px;
    line-height: 1.25;
}

p,
small,
.eyebrow,
.selected-list,
.helper-row,
.upload-status {
    color: var(--muted);
}

.form-stack {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

label span {
    display: block;
    margin-bottom: 7px;
    color: #344054;
    font-size: 14px;
    font-weight: 750;
}

input[type="text"],
input[type="password"],
.url-list {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none;
}

input[type="text"],
input[type="password"] {
    min-height: 48px;
    padding: 12px 13px;
}

input:focus,
.url-list:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14, 124, 112, 0.12);
}

.primary-button,
.ghost-button,
.danger-button,
.text-button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 850;
}

.primary-button {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 12px 16px;
    box-shadow: 0 14px 28px rgba(14, 124, 112, 0.24);
}

.primary-button:hover {
    filter: brightness(0.96);
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: .55;
    box-shadow: none;
}

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

.ghost-button {
    display: inline-grid;
    place-items: center;
    border: 1px solid #c7d7fe;
    background: var(--accent-soft);
    color: #1d4ed8;
    padding: 0 14px;
    text-decoration: none;
}

.ghost-button.small {
    min-height: 38px;
    white-space: nowrap;
    font-size: 13px;
}

.danger-button {
    display: inline-grid;
    place-items: center;
    border: 1px solid #fecdca;
    background: var(--danger-bg);
    color: var(--danger);
    padding: 0 14px;
}

.danger-button.small {
    min-height: 38px;
    white-space: nowrap;
    font-size: 13px;
}

.text-button {
    min-height: auto;
    background: transparent;
    color: var(--accent);
    padding: 0;
}

.alert {
    margin-top: 16px;
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--danger-bg);
    color: var(--danger);
    font-weight: 750;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 0 18px;
}

.topbar h1 {
    margin-bottom: 0;
}

.eyebrow {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.upload-zone,
.result-section {
    padding: 18px;
}

.panel-heading,
.section-title,
.helper-row,
.upload-actions,
.link-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.link-actions {
    justify-content: flex-end;
    gap: 8px;
}

.panel-heading {
    margin-bottom: 14px;
}

.panel-heading p,
.section-title p {
    margin-bottom: 0;
    font-size: 13px;
}

.session-pill {
    flex: 0 0 auto;
    border: 1px solid #a7f3d0;
    border-radius: 999px;
    background: #ecfdf3;
    color: var(--success);
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 850;
}

#images {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.pick-area {
    display: grid;
    min-height: 178px;
    margin-bottom: 14px;
    place-items: center;
    border: 2px dashed var(--line-strong);
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff, #f7fbff);
    padding: 24px;
    text-align: center;
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.pick-area:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

.pick-area strong,
.pick-area small {
    display: block;
}

.pick-area strong {
    font-size: 18px;
}

.pick-icon {
    display: grid;
    width: 58px;
    height: 58px;
    margin-bottom: 12px;
    place-items: center;
    border-radius: 8px;
    background: #172033;
    color: #fff;
    font-size: 36px;
    line-height: 1;
    box-shadow: 0 16px 28px rgba(23, 32, 51, 0.18);
}

.upload-actions {
    align-items: stretch;
}

.upload-actions .ghost-button {
    min-width: 104px;
}

.preview-grid {
    display: flex;
    min-height: 126px;
    margin-top: 14px;
    align-items: center;
    justify-content: center;
    gap: 12px;
    overflow-x: auto;
    border: 2px dashed #8d85d9;
    border-radius: 8px;
    background: #eef0ff;
    padding: 18px;
}

.preview-empty {
    width: 100%;
    color: #6b63b5;
    text-align: center;
    font-size: 14px;
}

.preview-card {
    position: relative;
    flex: 0 0 auto;
    width: 92px;
    text-align: center;
}

.preview-card img {
    display: block;
    width: 92px;
    height: 92px;
    object-fit: cover;
    overflow: hidden;
    border: 1px solid rgba(23, 32, 51, 0.18);
    border-radius: 6px;
    background: #d7dfeb;
    box-shadow: 0 10px 22px rgba(23, 32, 51, 0.14);
}

.size-badge,
.state-badge {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.92);
    color: #344054;
    padding: 2px 7px;
    font-size: 12px;
    font-weight: 850;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(23, 32, 51, 0.12);
}

.size-badge {
    top: 8px;
}

.state-badge {
    top: 36px;
    background: rgba(37, 99, 235, 0.92);
    color: #fff;
}

.state-badge.done {
    background: rgba(6, 118, 71, 0.92);
}

.state-badge.error {
    background: rgba(180, 35, 24, 0.94);
}

.thumb-progress {
    position: absolute;
    left: 8px;
    bottom: 27px;
    width: 0;
    max-width: 76px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #84cc16);
    box-shadow: 0 1px 5px rgba(23, 32, 51, 0.25);
}

.preview-card.error img {
    outline: 2px solid var(--danger);
}

.remove-preview {
    margin-top: 4px;
    border: 0;
    background: transparent;
    color: #6b63b5;
    cursor: pointer;
    font-size: 13px;
}

.progress-wrap {
    height: 10px;
    margin-top: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: #e4e9f2;
}

.progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width .2s ease;
}

.upload-status {
    min-height: 20px;
    margin-top: 10px;
    font-size: 13px;
}

.result-section {
    margin-top: 16px;
}

.section-title {
    align-items: flex-start;
    margin-bottom: 12px;
}

.url-list {
    display: block;
    min-height: 220px;
    max-height: 45vh;
    resize: vertical;
    padding: 13px 14px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.65;
    white-space: pre;
    overflow: auto;
}

.helper-row {
    margin-top: 10px;
    font-size: 13px;
}

.error-list {
    margin-top: 12px;
    border: 1px solid #fecdca;
    border-radius: 8px;
    background: var(--danger-bg);
    color: var(--danger);
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 560px) {
    .login-screen,
    .app-shell {
        padding: 14px;
    }

    .login-panel,
    .upload-zone,
    .result-section {
        padding: 16px;
    }

    .topbar h1 {
        font-size: 25px;
    }

    .panel-heading,
    .section-title {
        align-items: flex-start;
    }

    .section-title {
        display: grid;
    }

    .link-actions {
        justify-content: start;
    }

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

    .url-list {
        min-height: 250px;
        font-size: 12px;
    }

    .preview-grid {
        justify-content: flex-start;
        padding: 14px;
    }
}
