* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #F5F1EA; --bg2: #FDFCF9; --bg3: #EDE7DC;
  --line: #E2DACB; --text: #1F1D1A; --dim: #77705F;
  --accent: #D97757; --accent2: #C4643F; --ok: #2F7D4F; --warn: #B07C22; --err: #C3402F;
  --serif: "Nanum Myeongjo", "Noto Serif KR", Georgia, serif;
  --sans: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; border: none; border-radius: 10px; }
input, select { font-family: inherit; }
.hidden { display: none !important; }

/* ---------- 상단바 ---------- */
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 26px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(245,241,234,.94); backdrop-filter: blur(8px); z-index: 10;
}
.brand { font-family: var(--serif); font-size: 23px; font-weight: 800; letter-spacing: -.3px; cursor: pointer; }
.brand span { color: var(--accent); }
.top-right { display: flex; gap: 10px; align-items: center; }
.credit-badge {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 15px; font-size: 13px; color: var(--dim);
}
.credit-badge b { color: var(--accent2); font-weight: 700; }

/* ---------- 공통 ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 30px 20px 90px; }
h1 { font-family: var(--serif); font-size: 28px; margin-bottom: 8px; letter-spacing: -.4px; }
h2 { font-family: var(--serif); font-size: 19px; margin-bottom: 14px; }
.sub { color: var(--dim); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }
.primary {
  background: var(--accent); color: #fff; padding: 13px 24px; font-size: 15px; font-weight: 700;
  border-radius: 12px; box-shadow: 0 1px 2px rgba(31,29,26,.12); transition: background .15s;
}
.primary:hover { background: var(--accent2); }
.primary:disabled { opacity: .5; cursor: default; }
.ghost {
  background: var(--bg2); color: var(--dim); border: 1px solid var(--line);
  padding: 8px 14px; font-size: 13px; border-radius: 10px;
}
.ghost:hover { color: var(--text); border-color: var(--dim); }
.danger { color: var(--err); border-color: rgba(195,64,47,.35); }
.card {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 24px;
  box-shadow: 0 1px 3px rgba(31,29,26,.05);
}
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select {
  width: 100%; background: #fff; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 15px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,119,87,.15); }
label { display: block; font-size: 13px; color: var(--dim); margin: 15px 0 6px; font-weight: 600; }

/* ---------- 로그인 ---------- */
.auth-wrap { max-width: 430px; margin: 7vh auto 0; }
.auth-logo { font-family: var(--serif); text-align: center; font-size: 38px; font-weight: 800; margin-bottom: 10px; }
.auth-logo span { color: var(--accent); }
.auth-tag { text-align: center; color: var(--dim); font-size: 14.5px; margin-bottom: 32px; line-height: 1.6; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--dim); }
.auth-switch a { color: var(--accent2); cursor: pointer; font-weight: 600; }
.auth-wrap .primary { width: 100%; margin-top: 22px; }

/* ---------- 새 프로젝트 ---------- */
.new-grid { display: grid; grid-template-columns: 1fr 310px; gap: 18px; }
@media (max-width: 800px) { .new-grid { grid-template-columns: 1fr; } }
.opt-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--bg3); font-size: 14px; }
.opt-row:last-child { border-bottom: none; }
.opt-row select { width: 132px; padding: 8px 10px; font-size: 13px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--bg3); border: 1px solid var(--line); border-radius: 999px; transition: .15s; }
.slider:before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(18px); }
.tpl-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.tpl-chip {
  padding: 8px 15px; border-radius: 999px; border: 1px solid var(--line); background: #fff;
  color: var(--dim); font-size: 13px; cursor: pointer; transition: all .12s;
}
.tpl-chip.on { border-color: var(--accent); color: #fff; background: var(--accent); font-weight: 600; }
.upload-zone {
  border: 2px dashed var(--line); border-radius: 14px; padding: 26px; text-align: center;
  color: var(--dim); font-size: 14px; cursor: pointer; margin-top: 14px; background: #fff; transition: border-color .15s;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); color: var(--text); }
.row2 { display: flex; gap: 10px; }
.row2 > div { flex: 1; }

/* ---------- 프로젝트 목록 ---------- */
.proj-list { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.proj-item {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 16px;
  padding: 17px 22px; cursor: pointer; transition: all .15s;
}
.proj-item:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(31,29,26,.07); }
.proj-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.proj-meta { color: var(--dim); font-size: 12.5px; }
.status { font-size: 12px; font-weight: 700; padding: 5px 13px; border-radius: 999px; white-space: nowrap; }
.st-done { background: rgba(47,125,79,.12); color: var(--ok); }
.st-error { background: rgba(195,64,47,.12); color: var(--err); }
.st-work { background: rgba(176,124,34,.12); color: var(--warn); }
.st-queued { background: var(--bg3); color: var(--dim); }

/* ---------- 프로젝트 상세 ---------- */
.back-link { color: var(--dim); font-size: 13px; cursor: pointer; margin-bottom: 14px; display: inline-block; }
.back-link:hover { color: var(--accent2); }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.clips-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 18px; margin-top: 24px; }
.clip-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 1px 3px rgba(31,29,26,.06); }
.clip-thumb { position: relative; aspect-ratio: 9/16; background: #14110d; cursor: pointer; }
.clip-thumb img, .clip-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-thumb .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 40px; color: rgba(255,255,255,.9); background: rgba(0,0,0,.1);
}
.clip-score {
  position: absolute; top: 8px; right: 8px; background: rgba(20,17,13,.78); color: #F2B84B;
  font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px;
}
.clip-body { padding: 13px 15px; }
.clip-title { font-size: 13.5px; font-weight: 700; line-height: 1.45; min-height: 38px; }
.clip-meta { color: var(--dim); font-size: 12px; margin: 6px 0 10px; }
.clip-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.clip-actions .ghost { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

/* ---------- 모달 ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(31,29,26,.5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 26px; width: 100%; max-width: 530px; max-height: 92vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.player-modal { max-width: 400px; padding: 12px; background: #14110d; border: none; }
.player-modal video { width: 100%; border-radius: 10px; display: block; }

/* ---------- 진행 표시 ---------- */
.progress-strip { display: flex; gap: 7px; margin-top: 20px; flex-wrap: wrap; }
.pstep { flex: 1; min-width: 92px; text-align: center; font-size: 12px; color: var(--dim); padding: 10px 4px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); }
.pstep.on { color: #fff; border-color: var(--accent); background: var(--accent); animation: pulse 1.4s infinite; font-weight: 700; }
.pstep.done { color: var(--ok); border-color: rgba(47,125,79,.4); }
@keyframes pulse { 50% { opacity: .6; } }

/* ---------- 관리자 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 14px; }
th { text-align: left; color: var(--dim); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--bg3); }
td input { width: 70px; padding: 6px 8px; font-size: 13px; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #1F1D1A; border: none; color: #F5F1EA;
  padding: 13px 24px; border-radius: 12px; font-size: 14px; z-index: 99;
  box-shadow: 0 8px 30px rgba(31,29,26,.35);
}
.toast.err { background: var(--err); color: #fff; }

.empty { text-align: center; color: var(--dim); padding: 60px 0; font-size: 14px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--dim); border-top-color: transparent; border-radius: 50%; animation: rot .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes rot { to { transform: rotate(360deg); } }
