/* ===================== Design Tokens ===================== */
:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f1f3f9;
    --border: #e3e6ef;
    --text: #1b1f2a;
    --text-muted: #5d6477;
    --text-subtle: #8a91a5;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef0ff;
    --on-primary: #ffffff;

    --success: #15803d;
    --success-soft: #e7f6ec;
    --warning: #b45309;
    --warning-soft: #fdf3e2;
    --danger: #dc2626;
    --danger-soft: #fdecec;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 4px 16px rgba(20, 24, 40, .06);
    --container: 1080px;

    --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1117;
        --surface: #171a23;
        --surface-2: #1e2230;
        --border: #2a2f3f;
        --text: #e8eaf2;
        --text-muted: #a4abbe;
        --text-subtle: #737b91;
        --primary: #818cf8;
        --primary-hover: #a5b4fc;
        --primary-soft: #23264a;
        --on-primary: #0f1117;
        --success: #4ade80;
        --success-soft: #16301f;
        --warning: #fbbf24;
        --warning-soft: #33280f;
        --danger: #f87171;
        --danger-soft: #3a1a1a;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1e2230;
    --border: #2a2f3f;
    --text: #e8eaf2;
    --text-muted: #a4abbe;
    --text-subtle: #737b91;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: #23264a;
    --on-primary: #0f1117;
    --success: #4ade80;
    --success-soft: #16301f;
    --warning: #fbbf24;
    --warning-soft: #33280f;
    --danger: #f87171;
    --danger-soft: #3a1a1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
}

body {
    font-family: var(--font);
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 32px 16px 64px;
}

.container--narrow { max-width: 800px; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ===================== Button ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

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

.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn--ghost { border-color: transparent; background: transparent; }

.btn--sm { height: 34px; padding: 0 12px; font-size: 13px; }

/* ===================== Form Field ===================== */
.field { display: flex; flex-direction: column; gap: 8px; }

.field__label-row { display: flex; justify-content: space-between; align-items: baseline; }

.field__label { font-weight: 700; font-size: 14px; }

.field__counter { font-size: 12px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.field__counter--over { color: var(--danger); }

.field__input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 15px;
    transition: border-color .15s, box-shadow .15s;
}
.field__input::placeholder { color: var(--text-subtle); }
.field__input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.field__input--error { border-color: var(--danger); }

.field__hint { font-size: 12px; color: var(--text-subtle); }

.field__error { font-size: 13px; color: var(--danger); }

/* ===================== Card ===================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ===================== Badge ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
    white-space: nowrap;
}
.badge::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor;
}
.badge--pending, .badge--processing { background: var(--warning-soft); color: var(--warning); }
.badge--done { background: var(--success-soft); color: var(--success); }
.badge--failed { background: var(--danger-soft); color: var(--danger); }
.badge--processing::before { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .25; } }

/* ===================== Page Title ===================== */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head__title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.page-head__desc { margin-top: 4px; color: var(--text-muted); font-size: 14px; }

/* ===================== Notice Banner ===================== */
.notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
    background: var(--warning-soft);
    font-size: 14px;
}
.notice__text strong { color: var(--warning); }

/* ===================== Toast ===================== */
.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translate(-50%, 16px);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--bg);
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    z-index: 100;
    pointer-events: none;
}
.toast--visible { opacity: 1; transform: translate(-50%, 0); }
