/* ================================================================
   css/app.css — 구공이공 작업실
   ================================================================ */
:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --line: #e3e6ee;
    --line-strong: #cfd4e0;
    --text: #1d2433;
    --text-sub: #5d6679;
    --muted: #8a93a6;
    --primary: #3554d1;
    --primary-soft: #eaeefc;
    --danger: #d23c3c;
    --ok: #1f8a54;
    --warn: #b7791f;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: 'Pretendard', -apple-system, 'Malgun Gothic', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.loading, .empty { padding: 48px 16px; text-align: center; color: var(--text-sub); }
.empty.small { padding: 20px; }

/* ---------- 버튼 ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 34px; padding: 0 14px;
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; text-decoration: none;
    cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: #f0f2f7; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #2a46b8; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #e9ecf3; }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: #fbeaea; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; height: 40px; }
.btn-add {
    width: 100%; justify-content: center; height: 42px;
    border-style: dashed; color: var(--text-sub); background: transparent;
}
.icon-btn {
    width: 28px; height: 28px; border-radius: 6px;
    border: 1px solid transparent; background: transparent;
    color: var(--text-sub); font: inherit; cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: #eef0f5; color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-danger:hover:not(:disabled) { background: #fbeaea; color: var(--danger); }

/* ---------- 입력 ---------- */
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f > span { font-size: 12px; font-weight: 600; color: var(--text-sub); }
input, select, textarea {
    font: inherit; color: var(--text);
    border: 1px solid var(--line-strong); border-radius: 8px;
    background: #fff; padding: 7px 10px; width: 100%;
}
textarea { resize: vertical; line-height: 1.7; min-height: 64px; overflow: hidden; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(53, 84, 209, .15);
}
.card-box {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- 상단 ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    height: 54px; padding: 0 20px;
    background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--text); white-space: nowrap; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.brand-name.big { font-size: 22px; text-align: center; }
.brand-sub { font-size: 13px; color: var(--text-sub); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-email { color: var(--text-sub); font-size: 13px; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.pill-demo { background: #fff4e0; color: #8a5a10; }

.view { padding: 20px; max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 20px; }
.page-sub { color: var(--text-sub); font-size: 13px; }

/* ---------- 진행판 ---------- */
.board {
    display: grid; grid-template-columns: repeat(6, minmax(210px, 1fr));
    gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start;
}
.col {
    background: #eceef4; border-radius: var(--radius);
    min-height: 220px; display: flex; flex-direction: column;
    border: 2px solid transparent; transition: border-color .15s, background .15s;
}
.col.over { border-color: var(--primary); background: var(--primary-soft); }
.col-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px 6px; font-weight: 700; font-size: 13px; color: var(--text-sub);
}
.col-head .count {
    background: #fff; border-radius: 999px; padding: 0 8px;
    font-size: 12px; color: var(--text-sub);
}
.col[data-stage="done"] .col-head { color: var(--ok); }
.col-body { display: flex; flex-direction: column; gap: 8px; padding: 6px 8px 10px; flex: 1; }
.col-empty {
    border: 1px dashed var(--line-strong); border-radius: 8px;
    padding: 18px 8px; text-align: center; color: var(--muted); font-size: 12px;
}
.card {
    display: block; background: #fff; border: 1px solid var(--line);
    border-radius: 8px; padding: 10px 12px; text-decoration: none; color: var(--text);
    box-shadow: var(--shadow); cursor: grab;
    transition: transform .1s, box-shadow .15s, border-color .15s;
}
.card:hover { border-color: var(--line-strong); box-shadow: 0 4px 14px rgba(20, 30, 60, .08); }
.card.dragging { opacity: .45; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--text-sub); }
.card-no { font-weight: 700; color: var(--primary); }
.card-title { font-weight: 700; margin-top: 4px; line-height: 1.4; word-break: keep-all; }
.card-foot { display: flex; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.card-foot .yt { color: var(--danger); font-weight: 600; }

.tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.pillar-0 { background: #e6f4ea; color: #1f6b3b; }
.pillar-1 { background: #f3e8fd; color: #6b2fa6; }
.pillar-2 { background: #e5eefc; color: #234f9e; }
.pillar-3 { background: #fdecea; color: #a12a2a; }

/* ---------- 영상 상세 ---------- */
.ep-toolbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 14px;
}
.save-status { font-size: 12px; font-weight: 600; color: var(--muted); padding-left: 4px; }
.save-status[data-state="busy"] { color: var(--warn); }
.save-status[data-state="error"] { color: var(--danger); }
.save-status[data-state="ok"]::before { content: '● '; color: var(--ok); }

.ep-meta { padding: 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; }
.meta-top { display: grid; grid-template-columns: 90px 1fr; gap: 12px; }
.f-title input { font-size: 18px; font-weight: 700; padding: 8px 12px; }
.meta-grid { display: grid; grid-template-columns: 110px 140px 140px 160px 1fr; gap: 12px; }

.ep-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.script-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.script-head h2 { font-size: 16px; }
.hint { font-size: 12px; color: var(--muted); }
#blocks { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.block {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px 14px;
}
.block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.block-idx {
    flex: none; width: 24px; height: 24px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
    font-size: 12px; font-weight: 800; display: grid; place-items: center;
}
.block-section {
    border-color: transparent; background: transparent;
    font-weight: 700; font-size: 15px; padding: 4px 6px; max-width: 260px;
}
.block-section:hover { border-color: var(--line); }
.block-stat { font-size: 12px; color: var(--muted); white-space: nowrap; }
.block-tools { margin-left: auto; display: flex; gap: 2px; }
.block-body { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 12px; }
.f-note textarea { background: #fafbfd; font-size: 13px; }

.side { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 12px; }
.side-fields { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.stats { padding: 14px 16px; }
.stat-main { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat-sub { color: var(--text-sub); font-size: 13px; }
.meter { position: relative; height: 8px; background: #eceef4; border-radius: 99px; margin: 12px 0 8px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--warn); border-radius: 99px; transition: width .2s; }
.meter-fill.ok { background: var(--ok); }
.meter-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(0, 0, 0, .25); }
.stat-note { font-size: 12px; color: var(--text-sub); }

/* ---------- 로그인 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 360px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-sub { text-align: center; color: var(--text-sub); margin: -6px 0 4px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 1em; margin: 0; text-align: center; }
.setup-error { max-width: 440px; padding: 24px; }
.setup-error h2 { font-size: 18px; margin-bottom: 8px; }

/* ---------- 창·알림 ---------- */
.modal-back {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(15, 20, 35, .45); display: grid; place-items: center; padding: 20px;
}
.modal {
    width: 100%; max-width: 720px; max-height: 86vh;
    background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-text {
    flex: 1; min-height: 320px; border: 0; border-radius: 0; resize: none;
    padding: 16px 18px; font-size: 14px; line-height: 1.8; overflow: auto;
}
.modal-text:focus { box-shadow: none; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
    background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 8px;
    font-size: 13px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
    transition: opacity .3s, transform .3s;
}
.toast-error { background: var(--danger); }
.toast-warn { background: #8a5a10; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 1100px) {
    .ep-body { grid-template-columns: 1fr; }
    .side { position: static; }
    .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .meta-grid .f-wide { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
    .view { padding: 14px; }
    .topbar { padding: 0 14px; }
    .user-email, .brand-sub { display: none; }
    .pill-demo { font-size: 11px; padding: 3px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
    .board { grid-template-columns: repeat(6, 78vw); scroll-snap-type: x mandatory; }
    .col { scroll-snap-align: start; }
    .block-body { grid-template-columns: 1fr; }
    .meta-top { grid-template-columns: 70px 1fr; }
    .ep-toolbar .btn { height: 32px; padding: 0 10px; font-size: 13px; }
}
