/* board — 관리·제어 화면 공통 (어두운 관제 톤) */
:root {
  --bg: #0F172A;
  --bg-2: #111c33;
  --card: #1E293B;
  --line: #334155;
  --text: #E2E8F0;
  --muted: #94A3B8;
  --dim: #64748B;
  --accent: #F59E0B;
  --accent-2: #FBBF24;
  --ok: #22C55E;
  --err: #F87171;
  --radius: 10px;
  --font: "IBM Plex Sans KR", "Pretendard", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); overflow-x: hidden; }
a { color: var(--accent-2); }
img { max-width: 100%; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* 상단 띠 */
.topbar { border-bottom: 1px solid var(--line); background: #0b1222; }
.topbar-in { display: flex; align-items: center; gap: 14px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--accent); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--muted); min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs .sep { color: var(--dim); }
.crumbs span:not(.sep) { color: var(--text); overflow-wrap: anywhere; }

main.wrap { padding-top: 24px; padding-bottom: 40px; min-height: 60vh; }
.foot { color: var(--dim); font-size: 12px; padding-top: 16px; padding-bottom: 24px; border-top: 1px solid #1e293b; }

h1 { font-size: 24px; line-height: 1.3; margin: 0 0 6px; overflow-wrap: anywhere; }
h2 { font-size: 18px; margin: 32px 0 12px; }
.lead, .muted { color: var(--muted); }
.lead { margin: 0 0 20px; }
.help { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.empty { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 20px; color: var(--muted); }

/* 버튼·입력 */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #273449; color: var(--text); font: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #31405a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111827; }
.btn.primary:hover { background: var(--accent-2); }
.btn.on { background: #b45309; border-color: var(--accent); color: #fff; }
.btn.danger { color: #fecaca; border-color: #7f1d1d; background: #3b1620; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.link { background: none; border-color: transparent; color: var(--accent-2); min-height: 44px; padding: 8px 4px; text-decoration: underline; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local] {
  min-height: 44px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #0b1222; color: var(--text); font: inherit; font-size: 16px; width: 100%; max-width: 100%;
}
input:disabled { opacity: .6; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }

/* 카드 목록 */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.list.cols { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.item {
  display: flex; align-items: center; gap: 14px; padding: 14px; min-height: 72px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
a.item:hover { border-color: var(--accent); }
.item .t { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.item .s { color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item .grow { flex: 1; min-width: 0; }
.item .chev { color: var(--dim); font-size: 22px; }

.logo-tile { flex: none; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 12px; }
.logo-tile img { width: 100%; height: 100%; display: block; }
.logo-letter { font-weight: 700; font-size: 22px; color: #0f172a; }

.poster { flex: none; width: 56px; height: 76px; border-radius: 6px; object-fit: cover; background: #0b1222; border: 1px solid var(--line); }
.poster.big { width: 96px; height: 130px; }
.poster.none { display: inline-flex; align-items: center; justify-content: center; color: var(--dim); font-size: 12px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.live { color: #111827; background: var(--accent); border-color: var(--accent); }
.badge.upcoming { color: #bfdbfe; border-color: #1d4ed8; }

.head { display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.head .grow { min-width: 0; }

/* 화면(시안) 카드 */
.screen-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.screen-card h3 { margin: 0; font-size: 18px; }
.screen-card p { margin: 0; color: var(--muted); font-size: 14px; }
.url { font-family: var(--mono); font-size: 13px; background: #0b1222; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; color: #cbd5e1; }

/* 설정 화면 구역 */
.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.section > h2 { margin: 0 0 4px; font-size: 18px; }
.section > .help:first-of-type { margin-top: 0; }
.msg { font-size: 14px; margin: 8px 0 0; min-height: 1em; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }
.msg.warn { color: var(--accent-2); }

/* 알림 */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #f8fafc; color: #0f172a; padding: 10px 18px; border-radius: 999px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- 제어판 (panel.js) — LED 화면·설정 화면 공용 ---- */
.pnl-auth { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.pnl-auth .field { flex: 1 1 220px; }
.pnl-auth.unlocked { align-items: center; color: var(--muted); font-size: 14px; }
.pnl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.pnl-card { background: #0f1a2e; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pnl-card .name { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.pnl-card .swatch { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.pnl-card .state { font-family: var(--mono); font-size: 14px; color: #cbd5e1; white-space: pre-line; }
.pnl-card .btns .btn { flex: 1 1 auto; }
.pnl-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--dim); margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--accent); }

/* 배경 그림 */
.bg-preview { width: 100%; aspect-ratio: 7 / 1; background: #0b1222; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 14px; }
.bg-preview img { width: 100%; height: 100%; object-fit: fill; display: block; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }

/* 코스 목록 편집 */
.ed-rows { display: grid; gap: 8px; margin-top: 12px; }
.ed-row { display: grid; grid-template-columns: minmax(64px, 1fr) minmax(90px, 2fr) minmax(72px, 1fr) auto; gap: 8px; align-items: end; }
.ed-row label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ed-row input { padding: 8px; }
.ed-row .btn { padding: 8px 10px; }
.ed-row:not(:first-child) label > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 480px) {
  h1 { font-size: 21px; }
  .poster.big { width: 72px; height: 98px; }
  .ed-row { grid-template-columns: 1fr 1.4fr 1fr auto; gap: 6px; }
}
