/* app/static/css/app.css */
:root {
    color-scheme: light dark;
    --bg-gradient: linear-gradient(135deg, #f4f7fb 0%, #edf1ff 50%, #e6f7ff 100%);
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-shadow: 0 24px 60px -30px rgba(15, 23, 42, 0.45);
    --border-soft: rgba(120, 144, 156, 0.25);
    --primary: #2563eb;
    --accent: #3b82f6;
    --text: #0f172a;
    --muted: #475569;
    --success: #12805a;
    --error: #b91c1c;
    font-family: "Pretendard Variable", Pretendard, 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
    box-sizing: border-box;
}

body.app {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px 48px;
    background: var(--bg-gradient);
    color: var(--text);
}

.container {
    width: min(880px, 100%);
}

.site-footer {
    margin-top: 40px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
}

.site-footer a {
    color: inherit;
    font-weight: 600;
    text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus {
    text-decoration: underline;
}

.hero {
    text-align: center;
    margin-bottom: 28px;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2rem, 2.6vw + 1.2rem, 2.75rem);
    letter-spacing: -0.02em;
}

.hero p {
    margin: 12px auto 0;
    max-width: 560px;
    color: var(--muted);
    font-size: 1.05rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 22px;
    padding: clamp(24px, 2vw + 16px, 40px);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-soft);
}

.dropzone {
    position: relative;
    display: block;
    text-align: center;
    border: 2px dashed rgba(37, 99, 235, 0.35);
    border-radius: 18px;
    padding: 48px 24px;
    background: rgba(37, 99, 235, 0.05);
    transition: all .2s ease;
    cursor: pointer;
    overflow: hidden;
}

.dropzone:hover,
.dropzone.is-dragover {
    border-color: rgba(37, 99, 235, 0.65);
    background: rgba(37, 99, 235, 0.12);
    box-shadow: 0 12px 30px -20px rgba(37, 99, 235, 0.75);
}

.dropzone input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-inner {
    pointer-events: none;
}

.global-controls {
    margin-top: 24px;
    padding: 18px 20px;
    border-radius: 18px;
    background: rgba(148, 163, 184, .12);
    border: 1px solid rgba(148, 163, 184, .3);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.global-controls-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
}

.global-controls-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.global-controls-description {
    font-size: .85rem;
    color: var(--muted);
}

.global-controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.global-controls-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: .85rem;
    color: var(--muted);
}

.global-controls-grid label span {
    font-weight: 600;
    color: var(--text);
}

.upload-limit {
    margin-top: 12px;
    color: var(--muted);
    font-size: .9rem;
}

.drop-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    margin-bottom: 12px;
    border-radius: 16px;
    background: white;
    color: var(--accent);
    font-size: 28px;
    box-shadow: 0 12px 40px -18px rgba(37, 99, 235, .55);
}

.file-list {
    margin: 20px 0 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-list.empty {
    border: 1px dashed var(--border-soft);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    font-size: .95rem;
    background: rgba(148, 163, 184, .12);
}

.file-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(200px, 160px);
    gap: 16px;
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .88);
    border: 1px solid rgba(148, 163, 184, .24);
    box-shadow: 0 10px 28px -24px rgba(15, 23, 42, .4);
    transition: transform .18s ease, box-shadow .18s ease;
    will-change: transform;
}

.file-row.dragging {
    opacity: .65;
    box-shadow: 0 16px 40px -28px rgba(37, 99, 235, .35);
}

.file-row.is-animating {
    box-shadow: 0 18px 36px -26px rgba(37, 99, 235, .45);
}

.file-row.drag-over-top::before,
.file-row.drag-over-bottom::after {
    content: "";
    position: absolute;
    left: 16px;
    right: 16px;
    height: 4px;
    border-radius: 999px;
    background: rgba(37, 99, 235, .6);
}

.file-row.drag-over-top::before {
    top: -6px;
}

.file-row.drag-over-bottom::after {
    bottom: -6px;
}

.file-main {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

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

.file-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: .85rem;
    color: var(--muted);
}

.field-label {
    font-weight: 600;
    color: var(--text);
}

.file-options {
    display: flex;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.file-field select.option-select,
.file-field input.range-input {
    width: 100%;
}

.option-select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, .45);
    background: rgba(255, 255, 255, .9);
    font-size: .9rem;
    color: var(--text);
}

.option-select:focus {
    border-color: rgba(37, 99, 235, .6);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(37, 99, 235, .25);
    background: rgba(37, 99, 235, .08);
    color: var(--accent);
    cursor: grab;
    touch-action: none;
    transition: background .2s ease, border-color .2s ease, transform .2s ease;
}

.drag-handle:hover {
    background: rgba(37, 99, 235, .18);
    border-color: rgba(37, 99, 235, .35);
    transform: translateY(-1px);
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.drag-handle span {
    pointer-events: none;
    font-size: 1rem;
    letter-spacing: 2px;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .95rem;
    color: var(--muted);
}

.file-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(37, 99, 235, .1);
    color: var(--accent);
    font-weight: 600;
}

.file-name {
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-variant-numeric: tabular-nums;
}

.file-actions {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
}

.icon-btn {
    border: none;
    background: rgba(37, 99, 235, .12);
    color: var(--accent);
    padding: 6px 10px;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .2s, background .2s;
}

.icon-btn:hover {
    background: rgba(37, 99, 235, .22);
    transform: translateY(-1px);
}

.icon-btn.danger {
    background: rgba(239, 68, 68, .14);
    color: #dc2626;
}

.icon-btn.danger:hover {
    background: rgba(239, 68, 68, .2);
}

.range-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, .48);
    background: rgba(248, 250, 252, .8);
    font-size: .95rem;
    color: var(--text);
}

.range-input:focus {
    border-color: rgba(37, 99, 235, .6);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
    color: var(--text);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-top: 24px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 600;
    color: var(--text);
}

.form-grid input[type=text],
.form-grid select {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, .45);
    background: rgba(255, 255, 255, .9);
    font-size: .95rem;
    color: var(--text);
}

.actions {
    margin-top: 28px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.actions button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

button.primary {
    border: none;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    padding: 12px 26px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
    box-shadow: 0 12px 30px -18px rgba(37, 99, 235, .65);
}

button.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 15px 35px -15px rgba(37, 99, 235, .7);
}

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

button.ghost {
    border: 1px solid rgba(148, 163, 184, .5);
    background: transparent;
    color: var(--muted);
    padding: 11px 18px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
}

button.ghost:hover:not(:disabled) {
    background: rgba(148, 163, 184, .14);
    color: var(--text);
    border-color: rgba(148, 163, 184, .7);
}

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

.button-icon {
    width: 1.15em;
    height: 1.15em;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hint {
    color: var(--muted);
    font-size: .92rem;
}

.status {
    min-height: 1.2em;
    margin-top: 8px;
    font-size: .95rem;
    color: var(--muted);
}

.status.success {
    color: var(--success);
}

.status.error {
    color: var(--error);
}

.status.pending {
    color: var(--accent);
}

@media (max-width: 640px) {
    body.app {
        padding: 24px 12px;
    }

    .file-row {
        grid-template-columns: 1fr;
    }

    .file-actions {
        margin-top: 8px;
    }
}