:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #6b7280;
    --line: #d8dee9;
    --blue: #1f6feb;
    --blue-dark: #164fb4;
    --green: #0f9f6e;
    --red: #d13f3f;
    --shadow: 0 20px 55px rgba(27, 39, 60, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(31, 111, 235, 0.08), rgba(15, 159, 110, 0.08)),
        var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

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

.topbar,
.login-panel,
.upload-panel,
.files-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px;
    margin-bottom: 18px;
}

.login-panel {
    width: min(430px, 100%);
    margin: 8vh auto 0;
    padding: 28px;
}

.upload-panel,
.files-panel {
    padding: 22px;
    margin-top: 18px;
}

.upload-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.upload-head h2 {
    color: var(--ink);
    font-size: 1.7rem;
}

#selectedTopCount {
    color: var(--muted);
    font-weight: 800;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.03;
    letter-spacing: 0;
}

h2 {
    font-size: 1.1rem;
}

.eyebrow {
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
    margin-top: 10px;
}

.login-form,
#uploadForm {
    display: grid;
    gap: 14px;
}

.login-form {
    margin-top: 22px;
}

.upload-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 0.48fr);
    gap: 20px;
    align-items: start;
}

label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-size: 0.92rem;
    font-weight: 700;
}

input[type="text"],
input[type="password"],
input:not([type]) {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    padding: 13px 14px;
    outline: none;
}

select {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    min-height: 44px;
    padding: 0 12px;
}

input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.12);
}

input[type="checkbox"] {
    accent-color: var(--blue);
}

#fileInput {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
}

.drop-zone {
    display: grid;
    place-items: center;
    min-height: 230px;
    border: 2px dashed #9fb1c8;
    border-radius: 8px;
    background: #f8fbff;
    cursor: pointer;
    text-align: center;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone strong,
.drop-zone small {
    display: block;
}

.drop-zone small {
    color: var(--muted);
    margin-top: -18px;
}

.drop-zone.is-dragging {
    border-color: var(--green);
    background: #f1fff9;
    transform: translateY(-1px);
}

.drop-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    font-size: 1.8rem;
    font-weight: 400;
}

.selected-file {
    display: none;
    min-height: 24px;
    color: var(--muted);
    font-size: 0.94rem;
    overflow-wrap: anywhere;
}

.upload-controls {
    display: flex;
    align-items: end;
    gap: 12px;
}

.upload-controls button {
    flex: 1;
    min-height: 56px;
    font-size: 1.06rem;
    background: #12806f;
}

.upload-controls button:hover {
    background: #0d6a5c;
}

button {
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    cursor: pointer;
    font-weight: 800;
    min-height: 44px;
    padding: 0 18px;
    transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

button:hover {
    background: var(--blue-dark);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.ghost {
    background: #eef3f8;
    color: #243244;
}

.ghost:hover {
    background: #e1e8f0;
}

.notice,
.message {
    border-radius: 6px;
    padding: 12px 14px;
    margin-top: 16px;
}

.notice {
    display: grid;
    gap: 4px;
}

.error {
    background: #fff1f1;
    border: 1px solid #ffc7c7;
    color: #9e2b2b;
}

.message {
    min-height: 0;
}

.message.success {
    background: #ecfdf6;
    border: 1px solid #b9efd9;
    color: #08734e;
}

.message.error {
    margin-top: 16px;
}

.progress-meta,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    color: var(--muted);
    font-size: 0.92rem;
}

.section-head > div {
    display: grid;
    gap: 4px;
}

.progress-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8edf5;
    margin-top: 8px;
}

#progressBar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--green));
    transition: width 180ms ease;
}

.queue-panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
    padding: 16px;
}

.queue-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    max-height: 420px;
    overflow: auto;
    padding-right: 3px;
}

.queue-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    padding: 12px 12px 12px 14px;
}

.queue-row.is-complete {
    border-color: #b9efd9;
    background: #f4fff9;
}

.queue-row.is-failed {
    border-color: #ffc7c7;
    background: #fff7f7;
}

.queue-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.queue-title {
    min-width: 0;
}

.queue-main strong {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.98rem;
}

.queue-status {
    display: inline-block;
    border-radius: 999px;
    background: #edf4ff;
    color: #1f4f99;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 4px 8px;
    margin-top: 10px;
    white-space: nowrap;
}

.queue-row.is-complete .queue-status {
    background: #dbf8ea;
    color: #08734e;
}

.queue-row.is-failed .queue-status {
    background: #ffe4e4;
    color: #9e2b2b;
}

.queue-detail {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    margin-top: 4px;
}

.queue-progress {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8edf5;
    margin-top: 10px;
}

.queue-progress span {
    display: block;
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--green));
    transition: width 180ms ease;
}

.queue-row.is-failed .queue-progress span {
    background: var(--red);
}

.remove-queue-btn,
.clear-btn {
    background: #fff;
    color: var(--muted);
    border: 1px solid var(--line);
}

.remove-queue-btn {
    display: grid;
    flex: 0 0 38px;
    place-items: center;
    width: 38px;
    min-height: 38px;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
}

.remove-queue-btn:hover,
.clear-btn:hover {
    background: #f6f8fb;
    color: var(--ink);
}

.queue-row.is-server .remove-queue-btn,
.queue-row.is-r2 .remove-queue-btn,
.queue-row.is-complete .remove-queue-btn {
    display: none;
}

.files-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.file-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.small-btn {
    min-height: 38px;
    padding: 0 14px;
}

.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfe;
}

.file-check-wrap {
    display: grid;
    flex: 0 0 24px;
    place-items: center;
}

.file-check {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.file-main {
    flex: 1 1 auto;
    min-width: 0;
}

.file-main strong,
.file-main small {
    display: block;
}

.file-main strong {
    overflow-wrap: anywhere;
}

.file-main small {
    color: var(--muted);
    margin-top: 6px;
}

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

.copy-btn {
    background: var(--green);
}

.copy-btn:hover {
    background: #0b8058;
}

.delete-btn {
    background: #fff0f0;
    color: var(--red);
    border: 1px solid #ffc4c4;
}

.delete-btn:hover {
    background: #ffe4e4;
}

.empty-state {
    color: var(--muted);
    margin-top: 22px;
    text-align: center;
}

[hidden] {
    display: none !important;
}

@media (max-width: 680px) {
    .shell {
        width: min(100% - 22px, 980px);
        padding: 18px 0;
    }

    .topbar,
    .upload-head,
    .file-row {
        align-items: stretch;
        flex-direction: column;
    }

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

    .file-actions {
        width: 100%;
    }

    .file-actions button {
        flex: 1;
    }

    .file-toolbar {
        justify-content: stretch;
    }

    .file-toolbar button {
        flex: 1;
    }
}
