/* =====================================================
   BLACKOUT AI — Apple-concept design system
   ===================================================== */
:root {
    --bg: #fbfbfd;
    --surface: #ffffff;
    --text: #1d1d1f;
    --text-dim: #6e6e73;
    --hairline: #d2d2d7;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --danger: #ff3b30;
    --ok: #34c759;
    --warn: #ff9500;
    --radius: 18px;
    --radius-sm: 12px;
    --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
        "SF Pro KR", "SF Pro Display", "Apple SD Gothic Neo", "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 17px;
    line-height: 1.5;
    letter-spacing: -0.017em;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ---------- Nav ---------- */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(251, 251, 253, 0.82);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 22px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-logo {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text);
}
.nav-logo:hover { text-decoration: none; }
.nav-logo span { color: var(--accent); }
.nav-menu {
    display: flex;
    align-items: center;
    gap: 22px;
    font-size: 14px;
}
.nav-menu a { color: var(--text); opacity: 0.85; }
.nav-menu a:hover { opacity: 1; text-decoration: none; }
.nav-user { color: var(--text-dim); font-size: 14px; }
.nav-cta {
    background: var(--accent);
    color: #fff !important;
    padding: 6px 16px;
    border-radius: 980px;
    opacity: 1 !important;
}
.nav-cta:hover { background: var(--accent-hover); }

/* ---------- Layout ---------- */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 22px 80px;
}
.footer {
    border-top: 1px solid var(--hairline);
    padding: 28px 22px 44px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

/* ---------- Flash ---------- */
.flash {
    max-width: 640px;
    margin: 16px auto 0;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    text-align: center;
    animation: flash-in 0.3s ease;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } }
.flash-success { background: #e8f8ee; color: #1d7a3d; }
.flash-error { background: #fdecec; color: #c92a22; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 28px 0 44px; }
.hero h1 {
    font-size: clamp(32px, 5vw, 48px);
    font-weight: 700;
    letter-spacing: -0.025em;
}
.hero p { margin-top: 10px; color: var(--text-dim); font-size: clamp(16px, 2.2vw, 19px); }

/* ---------- Masonry gallery ---------- */
.masonry { columns: 4 260px; column-gap: 18px; }
.card {
    display: block;
    position: relative;
    margin-bottom: 18px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    break-inside: avoid;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    text-decoration: none;
}
.card img { width: 100%; height: auto; }
.card-overlay {
    position: absolute;
    inset: auto 0 0 0;
    padding: 36px 14px 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.62));
    color: #fff;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.card:hover .card-overlay { opacity: 1; }
.card-title {
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.9;
}

/* ---------- Chips ---------- */
.chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 980px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-dim);
    white-space: nowrap;
}
.card-meta .chip { background: rgba(255, 255, 255, 0.22); color: #fff; }
.chip-auto { background: #e8f1fd; color: var(--accent); }
.chip-ok { background: #e8f8ee; color: #1d7a3d; }
.chip-warn { background: #fff3e0; color: #b96a00; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 90px 0; color: var(--text-dim); }
.empty .btn { margin-top: 20px; }
.empty-inline { color: var(--text-dim); padding: 30px 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    border: 1px solid var(--hairline);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    padding: 8px 20px;
    border-radius: 980px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.btn:hover { background: #f2f2f4; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fdecec; }
.btn-lg { padding: 12px 32px; font-size: 17px; }
.btn-sm { padding: 4px 14px; font-size: 13px; }

/* ---------- Detail ---------- */
.detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 32px;
    align-items: start;
}
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.detail-image {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.detail-image img { width: 100%; height: auto; }
.detail-info { display: flex; flex-direction: column; gap: 18px; }
.detail-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.detail-sub {
    margin-top: 6px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    color: var(--text-dim);
    font-size: 14px;
}
.detail-sub .uploader { color: var(--text); font-weight: 600; }

.info-block {
    background: var(--surface);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.info-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.info-text {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 220px;
    overflow-y: auto;
}
.copy-btn {
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 12px;
    padding: 3px 12px;
    border-radius: 980px;
    cursor: pointer;
}
.copy-btn:hover { background: rgba(0, 0, 0, 0.09); }
.copy-btn.copied { background: #e8f8ee; color: #1d7a3d; }

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}
.meta-item {
    background: var(--bg);
    border-radius: 10px;
    padding: 8px 10px;
}
.meta-key { font-size: 11px; color: var(--text-dim); }
.meta-val { font-size: 14px; font-weight: 600; word-break: break-all; }

.raw-meta summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dim);
}
.raw-meta pre {
    margin-top: 10px;
    background: #f5f5f7;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 260px;
    overflow-y: auto;
}

/* ---------- Forms ---------- */
.form-page, .auth-page { max-width: 640px; margin: 0 auto; }
.auth-page { max-width: 380px; padding-top: 30px; }
.form-page h1, .auth-page h1 {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: center;
}
.auth-page h1 .accent { color: var(--accent); }
.form-desc { margin: 10px 0 26px; color: var(--text-dim); font-size: 15px; text-align: center; }

.form { display: flex; flex-direction: column; gap: 16px; margin-top: 26px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.field em { font-style: normal; font-weight: 400; opacity: 0.75; }
.field input, .field textarea, .field select,
.admin-toolbar input, .admin-toolbar select {
    font-family: var(--font);
    font-size: 16px;
    padding: 11px 14px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}
.field textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row:has(> :nth-child(3)) { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .field-row, .field-row:has(> :nth-child(3)) { grid-template-columns: 1fr; } }

.auth-form .btn-lg { margin-top: 6px; }
.auth-alt { text-align: center; font-size: 14px; color: var(--text-dim); }

/* ---------- Dropzone ---------- */
.dropzone {
    border: 2px dashed var(--hairline);
    border-radius: var(--radius);
    background: var(--surface);
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #f5faff; }
.dropzone-hint { display: flex; flex-direction: column; gap: 6px; padding: 30px; color: var(--text-dim); }
.dropzone-hint strong { color: var(--text); font-size: 16px; }
.dropzone-hint span { font-size: 13px; }
.dropzone-preview { max-height: 420px; width: auto; margin: 0 auto; }

/* ---------- Pager ---------- */
.pager-wrap { margin-top: 36px; display: flex; justify-content: center; }
.pager-wrap ul {
    list-style: none;
    display: flex;
    gap: 6px;
}
.pager-wrap li a, .pager-wrap li span {
    display: inline-block;
    min-width: 36px;
    text-align: center;
    padding: 7px 10px;
    border-radius: 980px;
    font-size: 14px;
    color: var(--text);
}
.pager-wrap li a:hover { background: rgba(0, 0, 0, 0.05); text-decoration: none; }
.pager-wrap li.active span, .pager-wrap li a[aria-current] {
    background: var(--accent);
    color: #fff;
}

/* =====================================================
   Admin
   ===================================================== */
.admin-body {
    display: grid;
    grid-template-columns: 230px 1fr;
    min-height: 100vh;
    background: var(--bg);
}
@media (max-width: 800px) { .admin-body { grid-template-columns: 1fr; } .admin-side { position: static; } }

.admin-side {
    background: rgba(255, 255, 255, 0.7);
    border-right: 1px solid var(--hairline);
    padding: 26px 18px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.admin-logo { font-size: 18px; font-weight: 700; color: var(--text); }
.admin-logo:hover { text-decoration: none; }
.admin-logo span { color: var(--accent); }
.admin-logo small {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-dim);
    margin-top: 2px;
}
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a {
    color: var(--text);
    font-size: 15px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
}
.admin-nav a:hover { background: rgba(0, 0, 0, 0.05); text-decoration: none; }
.admin-nav a.active { background: var(--accent); color: #fff; }
.admin-side-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: var(--text-dim);
}
.admin-me { color: var(--text); font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.admin-main { padding: 36px 40px 80px; min-width: 0; }
.admin-main .flash { margin: 0 0 20px; max-width: none; text-align: left; }
.admin-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 24px; }
.admin-subtitle { font-size: 18px; font-weight: 700; margin: 36px 0 14px; }
.admin-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.admin-title-row .admin-title { margin-bottom: 0; }

.admin-toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-toolbar input[type="search"] { flex: 1; min-width: 200px; }

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}
.stat-tile {
    background: var(--surface);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius);
    padding: 20px 22px;
}
.stat-num { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { margin-top: 2px; font-size: 13px; color: var(--text-dim); }

.recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
.recent-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
    color: var(--text);
}
.recent-card:hover { text-decoration: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1); }
.recent-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.recent-info { padding: 8px 10px; display: flex; flex-direction: column; }
.recent-info span {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recent-info small { font-size: 11px; color: var(--text-dim); }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    font-size: 14px;
}
.admin-table th, .admin-table td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    vertical-align: middle;
}
.admin-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    background: #f8f8fa;
}
.admin-table tr:last-child td { border-bottom: none; }
.table-thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; }
.td-dim { color: var(--text-dim); }
.td-actions { white-space: nowrap; }
.td-actions form { display: inline-block; margin-left: 4px; }
.th-actions { text-align: right; }
.td-actions { text-align: right; }

.admin-form { max-width: 480px; }
.perm-set { border: none; }
.perm-checks { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 15px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }

.admin-login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 22px;
}
.admin-login-body .auth-page { width: 100%; }

/* ===== 업로드: 타입 세그먼트 / 모델 멀티셀렉트 / 동영상 ===== */
.field-label { font-size: 13px; font-weight: 600; color: var(--text-dim); }

.seg { display: inline-flex; border: 1px solid var(--hairline); border-radius: 10px; overflow: hidden; }
.seg-item { position: relative; }
.seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.seg-item span {
    display: inline-block; padding: 9px 22px; font-size: 14px; font-weight: 600;
    cursor: pointer; color: var(--text-dim); background: transparent; transition: background 0.15s, color 0.15s;
}
.seg-item + .seg-item span { border-left: 1px solid var(--hairline); }
.seg-item input:checked + span { background: var(--accent); color: #fff; }

.card video { width: 100%; height: auto; display: block; }
.card { position: relative; }
.card-badge {
    position: absolute; top: 10px; left: 10px; padding: 3px 9px;
    font-size: 12px; font-weight: 700; border-radius: 999px;
    background: rgba(0, 0, 0, 0.62); color: #fff; pointer-events: none;
}
.detail-image video { width: 100%; height: auto; display: block; }
video.dropzone-preview { max-height: 420px; width: auto; margin: 0 auto; }

.tool-select { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: 8px 10px; border: 1px solid var(--hairline); border-radius: 10px; background: #fff; }
.tool-select:focus-within { border-color: var(--accent); }
.tool-select input#tool-search { flex: 1; min-width: 160px; border: none; outline: none; padding: 4px 2px; font-size: 14px; background: transparent; }
.tool-chips { display: contents; }
.tool-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px 4px 10px;
    font-size: 13px; font-weight: 600; border-radius: 999px;
    background: #e8f1fd; color: var(--accent);
}
.tool-chip-new { background: #e8f8ee; color: #1d7a3d; }
.tool-chip-x {
    border: none; background: transparent; cursor: pointer; font-size: 14px; line-height: 1;
    color: inherit; opacity: 0.65; padding: 0 4px;
}
.tool-chip-x:hover { opacity: 1; }
.tool-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
    max-height: 260px; overflow-y: auto; background: #fff;
    border: 1px solid var(--hairline); border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.tool-option { display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 9px 14px; font-size: 14px; cursor: pointer; }
.tool-option:hover { background: #f2f6fd; }
.tool-option small { font-size: 11px; color: var(--text-dim); opacity: 0.8; }
.tool-option-new { color: #1d7a3d; font-weight: 600; }

.tool-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-tag {
    padding: 4px 12px; font-size: 13px; font-weight: 600; border-radius: 999px;
    background: #e8f1fd; color: var(--accent);
}
