/* admin 전용 스타일.
   shared/style.css 는 TV 1920×1080 기준(폰트 72px 등)이라 여기서는 쓰지 않고,
   색 토큰만 동일하게 맞춰 프로젝트 톤을 유지합니다. */

:root {
  --bg-base: #FFF9F4;
  --bg-card: #FFFFFF;
  --bg-soft: #FFF1E6;
  --text-primary: #3D3D3D;
  --text-secondary: #7A7A7A;
  --text-muted: #B5B5B5;
  --accent-coral: #FFB5A7;
  --accent-mint: #B5EAD7;
  --accent-lemon: #FFE5B4;
  --accent-lavender: #C7CEEA;
  --border-soft: #F0E6DC;
  --border-medium: #E0D5C9;
  --shadow-card: 0 4px 16px rgba(80, 60, 40, 0.08);
  --shadow-pop: 0 8px 32px rgba(80, 60, 40, 0.14);
  --danger: #C4553F;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --side-w: 264px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  word-break: keep-all;
}

/* ── 공통 컨트롤 ─────────────────────────────── */
.btn {
  font-family: inherit; font-weight: 700; font-size: 15px;
  border: none; border-radius: 100px; padding: 10px 20px;
  background: var(--bg-soft); color: var(--text-primary);
  cursor: pointer; transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-card); }
.btn:active:not(:disabled) { transform: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent-coral); }
.btn-ghost { background: #fff; border: 2px solid var(--border-medium); }
.btn-sm { font-size: 14px; padding: 8px 16px; }
.btn-block { width: 100%; }
.btn-danger { background: #fff; border: 2px solid var(--danger); color: var(--danger); }

.inp, textarea.inp, select.inp {
  font-family: inherit; font-size: 15px; color: var(--text-primary);
  width: 100%; padding: 9px 13px;
  border: 2px solid var(--border-medium); border-radius: 12px;
  background: #fff; transition: border-color .15s var(--ease);
}
.inp:focus { outline: none; border-color: var(--accent-coral); }
textarea.inp { resize: vertical; min-height: 74px; line-height: 1.55; }
.inp.num { width: 96px; }

.linkbtn {
  background: none; border: none; padding: 0;
  font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer; text-decoration: none;
  display: inline-block;
}
.linkbtn:hover { color: var(--text-primary); }

/* hidden 속성이 어떤 display 규칙보다 우선하도록 — .gate(display:grid) 등이 hidden을 무시하던 버그 수정 */
[hidden] { display: none !important; }

/* ── 로그인 ─────────────────────────────────── */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg-base); z-index: 40; padding: 24px;
}
.gate-box {
  background: var(--bg-card); border-radius: 24px; box-shadow: var(--shadow-pop);
  padding: 36px 32px; width: min(400px, 100%);
  display: flex; flex-direction: column; gap: 12px;
}
.gate-box h1 { margin: 0; font-size: 24px; font-weight: 800; }
.gate-sub { margin: 0 0 6px; font-size: 14px; color: var(--text-secondary); }
.gate-err {
  background: #FDECE8; color: var(--danger); border-radius: 10px;
  padding: 9px 13px; font-size: 14px; font-weight: 600;
}

/* ── 레이아웃 ───────────────────────────────── */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
@media (max-width: 860px) { .app { grid-template-columns: 1fr; } }

.side {
  border-right: 2px solid var(--border-soft); background: #fff;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 16px; position: sticky; top: 0; height: 100vh;
}
@media (max-width: 860px) { .side { position: static; height: auto; } }

.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.brand { font-size: 16px; font-weight: 800; }

.ds-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; }
.ds-item {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  font-family: inherit; font-size: 14.5px; font-weight: 600; text-align: left;
  background: none; border: none; border-radius: 12px; padding: 10px 12px;
  cursor: pointer; color: var(--text-primary); transition: background .15s var(--ease);
}
.ds-item:hover { background: var(--bg-soft); }
.ds-item.on { background: var(--accent-coral); }
.ds-item .tag {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 100px;
  background: var(--accent-mint); color: #2C6B50; white-space: nowrap;
}
.ds-item .tag.warn { background: var(--accent-lemon); color: #8A6100; }

.side-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 2px solid var(--border-soft); }
.hint { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.55; }

.main { padding: 24px 28px 96px; min-width: 0; }
.empty { color: var(--text-muted); padding: 80px 0; text-align: center; font-size: 16px; }

/* ── 에디터 ─────────────────────────────────── */
.ed-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 5;
  background: var(--bg-base); padding: 4px 0 14px;
  border-bottom: 2px solid var(--border-soft); margin-bottom: 20px;
}
.ed-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.ed-sub { margin: 2px 0 0; font-size: 13.5px; color: var(--text-secondary); }
.ed-actions { display: flex; align-items: center; gap: 8px; }
.save-state { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.save-state.dirty { color: var(--danger); }

.meta-box {
  background: var(--bg-soft); border-radius: 16px; padding: 14px 18px;
  display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; margin-bottom: 20px;
}
.meta-box .fld { display: flex; flex-direction: column; gap: 4px; }
.meta-box label { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); }

.items { display: flex; flex-direction: column; gap: 14px; }

.item {
  background: var(--bg-card); border-radius: 18px; box-shadow: var(--shadow-card);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 12px;
}
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item-no { font-size: 15px; font-weight: 800; color: var(--accent-coral); }
.item-tools { display: flex; gap: 4px; }
.icon-btn {
  background: none; border: 2px solid var(--border-medium); border-radius: 10px;
  width: 30px; height: 30px; cursor: pointer; font-size: 13px; line-height: 1;
  color: var(--text-secondary); font-family: inherit;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text-primary); }
.icon-btn.del:hover { border-color: var(--danger); color: var(--danger); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld.wide { grid-column: 1 / -1; }
.fld label { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); }
.strlist { display: flex; gap: 8px; flex-wrap: wrap; }
.strlist .inp { flex: 1; min-width: 130px; }
.numlist { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.numlist .lbl { font-size: 12px; color: var(--text-muted); font-weight: 700; }

/* ── 미디어 위젯 ─────────────────────────────── */
.media {
  border: 2px dashed var(--border-medium); border-radius: 14px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
  background: #fff;
}
.media.has { border-style: solid; border-color: var(--accent-mint); }
.media-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.media-name { font-size: 13px; color: var(--text-secondary); word-break: break-all; flex: 1; min-width: 120px; }
.media audio { width: 100%; max-width: 420px; }
.prog { height: 6px; border-radius: 100px; background: var(--bg-soft); overflow: hidden; display: none; }
.prog.on { display: block; }
.prog i { display: block; height: 100%; background: var(--accent-coral); width: 0%; transition: width .2s linear; }

/* ── 확대 영역 에디터 (zoom-quiz) ────────────── */
.zoom-edit { display: flex; flex-direction: column; gap: 10px; }
.frame {
  width: 100%; aspect-ratio: 1080 / 620; border-radius: 14px; overflow: hidden;
  position: relative; background: var(--bg-soft); border: 2px solid var(--border-soft);
  cursor: crosshair;
}
.frame img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transition: transform .35s var(--ease);
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.frame .missing {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--text-secondary); font-size: 14px; text-align: center; padding: 16px;
}
.marker {
  position: absolute; width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid var(--accent-coral); background: rgba(255, 181, 167, .35);
  transform: translate(-50%, -50%); pointer-events: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,.85);
}
.stage-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-btn {
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  padding: 7px 14px; border-radius: 100px;
  border: 2px solid var(--border-medium); background: #fff; cursor: pointer;
  color: var(--text-primary);
}
.stage-btn.on { background: var(--accent-mint); border-color: transparent; }
.origin-badge {
  font-size: 12.5px; font-weight: 700; background: var(--bg-soft);
  border-radius: 100px; padding: 6px 12px; white-space: nowrap;
}
.zoom-help { font-size: 12.5px; color: var(--text-muted); margin: 0; }

/* ── 픽셀 미리보기 (pixel-quiz) ──────────────── */
.pixel-edit { display: flex; flex-direction: column; gap: 10px; }
.pixel-edit canvas {
  width: 100%; max-width: 530px; height: auto; display: block;
  border-radius: 14px; border: 2px solid var(--border-soft); background: var(--bg-soft);
}

/* ── 토스트 ─────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--text-primary); color: #fff;
  padding: 11px 22px; border-radius: 100px; font-size: 14.5px; font-weight: 600;
  z-index: 60; box-shadow: var(--shadow-pop); max-width: 90vw;
}
.toast.err { background: var(--danger); }

/* ── 미디어 관리 ─────────────────────────────── */
.media-files { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 10px 16px; box-shadow: var(--shadow-card);
}
.file-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-primary); text-decoration: none; font-weight: 600;
}
.file-name:hover { text-decoration: underline; }
.file-size { flex: none; color: var(--text-muted); font-size: 13px; }
