/* =====================================================================
   공통 구성 요소 — 상단 영역, 카드, 버튼, 입력창, 메뉴 목록, 하단 메뉴,
   확인창, 바텀시트, 알림, 화면 상태(불러오는 중·없음·오류), 좌석 배치도
   새 스타일을 만들기 전에 여기 있는지 먼저 확인하세요.
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--color-bg); color: var(--color-text);
  font-family: var(--font-family); font-size: var(--font-body); line-height: var(--line-height);
  -webkit-font-smoothing: antialiased; word-break: keep-all; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--radius-control); }
.page-title:focus, .page-title:focus-visible { box-shadow: none; }  /* 화면 이동 시 제목으로 옮기는 포커스(화면낭독기용)는 테두리 없이 */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; stroke-width: 1.75; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- 화면 틀 ---------- */
.app { max-width: 640px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app.has-nav { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
.page { padding: var(--space-2) var(--page-x) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.page-title { font-size: var(--font-title); font-weight: var(--weight-bold); margin: 0; }
.text-sub { color: var(--color-text-sub); font-size: var(--font-sub); }
.text-error { color: var(--color-error); }
.section-title { font-size: var(--font-sub); font-weight: var(--weight-bold); color: var(--color-text-sub); margin: var(--space-1) 0 0; }

/* ---------- 상단 영역 ---------- */
.app-header { position: sticky; top: 0; z-index: 10; min-height: var(--header-height); background: var(--color-surface);
  border-bottom: var(--border); display: flex; align-items: center; gap: var(--space-1); padding: 0 var(--space-1); }
.app-header .page-title { flex: 1; padding: 0 var(--space-1); }
.app-header .header-slot { min-width: var(--touch-min); display: flex; justify-content: flex-end; }
.icon-btn { min-width: var(--touch-min); min-height: var(--touch-min); display: inline-grid; place-items: center; border-radius: var(--radius-control); color: var(--color-text); }
.icon-btn:hover { background: var(--color-bg); }

/* ---------- 카드 ---------- */
.card { background: var(--color-surface); border: var(--border); border-radius: var(--radius-card); padding: 20px; }
.card-title { font-size: var(--font-card-title); font-weight: var(--weight-bold); margin: 0 0 var(--space-1); }
.card.flush { padding: 0; overflow: hidden; }
.card-row { display: flex; align-items: center; gap: var(--space-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-2); margin: 0; }
.kv dt { color: var(--color-text-sub); font-size: var(--font-sub); }
.kv dd { margin: 0; font-weight: var(--weight-medium); }

/* ---------- 버튼 ---------- */
.btn { min-height: var(--control-height); padding: 0 var(--space-2); border-radius: var(--radius-control);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  font-size: var(--font-body); font-weight: var(--weight-bold); text-align: center; transition: background .15s, color .15s; }
.btn { text-decoration: none; }
.btn-block { width: 100%; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover, .btn-primary:active { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn-secondary:hover, .btn-secondary:active { background: var(--color-primary-soft); }
.btn-text { color: var(--color-text-sub); font-weight: var(--weight-medium); min-height: var(--touch-min); }
.btn-danger-text { color: var(--color-error); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--color-disabled-bg); color: var(--color-disabled-text); border-color: transparent; cursor: not-allowed; }
.btn.is-loading { cursor: progress; }
.btn-sm { min-height: var(--touch-min); padding: 0 12px; font-size: var(--font-sub); }
.btn-row { display: flex; gap: var(--space-1); }
.btn-row > .btn { flex: 1; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 입력창 ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field-label { font-size: var(--font-sub); font-weight: var(--weight-bold); color: var(--color-text); }
.input, .select, .textarea { width: 100%; min-height: var(--control-height); padding: 0 var(--space-2); border-radius: var(--radius-control);
  border: 1px solid var(--color-border); background: var(--color-surface); font-size: var(--font-body); }
.textarea { padding: 12px var(--space-2); min-height: 120px; resize: vertical; }
.select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23666' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 16px center; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.field.has-error .input, .field.has-error .select { border-color: var(--color-error); }
.field-error { display: flex; gap: 6px; align-items: flex-start; color: var(--color-error); font-size: var(--font-sub); }
.field-error .icon { width: 16px; height: 16px; margin-top: 3px; }
.field-hint { color: var(--color-text-sub); font-size: var(--font-sub); }
.form { display: flex; flex-direction: column; gap: var(--space-2); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-1); }
.check { display: flex; align-items: center; gap: var(--space-1); min-height: var(--touch-min); }
.check input { width: 20px; height: 20px; accent-color: var(--color-primary); }

/* ---------- 메뉴 목록 ---------- */
.menu-list { list-style: none; margin: 0; padding: 0; background: var(--color-surface); border: var(--border); border-radius: var(--radius-card); overflow: hidden; }
.menu-list > li + li { border-top: var(--border); }
.menu-item { width: 100%; min-height: 56px; padding: 12px 20px; display: flex; align-items: center; gap: 12px; text-align: left; color: var(--color-text); text-decoration: none; }
.menu-item:hover { background: var(--color-bg); }
.menu-item:focus-visible { border-radius: 0; box-shadow: inset 0 0 0 2px var(--color-primary); }
.menu-item .menu-label { flex: 1; min-width: 0; }
.menu-item .menu-sub { display: block; color: var(--color-text-sub); font-size: var(--font-sub); }
.menu-item .chev { color: var(--color-text-sub); }
.menu-item.is-danger { color: var(--color-error); }

/* ---------- 목록 행 (데이터) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: var(--border); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; min-height: 64px; }
.list-row .main { flex: 1; min-width: 0; }
.list-row .title { font-weight: var(--weight-bold); }
.list-row .sub { color: var(--color-text-sub); font-size: var(--font-sub); }
.seat-badge { min-width: 48px; height: 40px; padding: 0 var(--space-1); border-radius: 10px; display: inline-grid; place-items: center;
  background: var(--color-primary-soft); color: var(--color-primary); font-weight: var(--weight-bold); flex: none; }
.seat-badge.is-muted { background: var(--color-bg); color: var(--color-text-sub); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--font-sub); padding: 2px 10px; border-radius: var(--radius-pill);
  border: var(--border); color: var(--color-text-sub); background: var(--color-surface); white-space: nowrap; }
.tag.is-primary { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-soft); }
.tag.is-error { border-color: var(--color-error); color: var(--color-error); }

/* ---------- 선택 칩 (날짜·시간) ---------- */
.chips { display: flex; gap: var(--space-1); overflow-x: auto; padding: 2px; margin: -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { min-height: var(--touch-min); min-width: 56px; padding: 6px 12px; border-radius: var(--radius-control); border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.3; flex: none; }
.chip small { font-size: 12px; color: var(--color-text-sub); }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-primary); font-weight: var(--weight-bold); }
.chip[aria-pressed="true"] small, .chip[aria-checked="true"] small { color: var(--color-primary); }
.chip:disabled { background: var(--color-disabled-bg); color: var(--color-disabled-text); border-color: transparent; cursor: not-allowed; }
.chips.is-fill > .chip { flex: 1; }

/* ---------- 하단 메뉴 ---------- */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--color-surface); border-top: var(--border); padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav ul { list-style: none; margin: 0 auto; padding: 0; max-width: 640px; display: flex; height: var(--nav-height); }
.bottom-nav li { flex: 1; display: flex; }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--color-text-sub); font-size: var(--font-sub); text-decoration: none; min-height: var(--touch-min); }
.bottom-nav a[aria-current="page"] { color: var(--color-primary); font-weight: var(--weight-bold); }
.bottom-nav a:focus-visible { border-radius: var(--radius-control); }

/* ---------- 확인창 · 바텀시트 ---------- */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(32, 33, 36, .4); display: flex; align-items: flex-end; justify-content: center; }
.scrim.is-center { align-items: center; padding: var(--page-x); }
.dialog { width: 100%; max-width: 400px; background: var(--color-surface); border-radius: var(--radius-card); padding: var(--space-3) 20px 20px; box-shadow: var(--shadow-dialog); }
.dialog-title { font-size: var(--font-card-title); font-weight: var(--weight-bold); margin: 0 0 var(--space-1); }
.dialog-body { color: var(--color-text-sub); margin: 0 0 var(--space-3); white-space: pre-line; }
.sheet { width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--color-surface); border-radius: var(--radius-card) var(--radius-card) 0 0;
  padding: var(--space-1) 20px calc(var(--space-3) + env(safe-area-inset-bottom)); box-shadow: var(--shadow-dialog); }
.sheet-head { display: flex; align-items: center; gap: var(--space-1); min-height: var(--header-height); }
.sheet-head .dialog-title { flex: 1; margin: 0; }
.sheet-body { display: flex; flex-direction: column; gap: var(--space-2); }

/* ---------- 알림 ---------- */
.toast-area { position: fixed; left: 0; right: 0; top: calc(var(--header-height) + var(--space-1) + env(safe-area-inset-top)); z-index: 40; display: flex; justify-content: center; pointer-events: none; padding: 0 var(--page-x); }
.toast { display: flex; align-items: flex-start; gap: var(--space-1); max-width: 560px; background: var(--color-text); color: #fff; padding: 12px var(--space-2); border-radius: var(--radius-control); font-size: var(--font-sub); box-shadow: var(--shadow-dialog); }
.toast.is-error { background: var(--color-error); }
.toast .icon { width: 18px; height: 18px; margin-top: 2px; }

/* ---------- 화면 상태 ---------- */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-1); padding: var(--space-4) var(--space-2); color: var(--color-text-sub); }
.state .icon { width: 32px; height: 32px; color: var(--color-text-sub); }
.state.is-error .icon { color: var(--color-error); }
.state .state-title { color: var(--color-text); font-weight: var(--weight-bold); }
.state .btn { margin-top: var(--space-1); }
.skeleton { background: linear-gradient(90deg, var(--color-border) 0%, var(--color-bg) 50%, var(--color-border) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-control); }
@keyframes shimmer { to { background-position: -200% 0; } }
.notice-box { display: flex; gap: var(--space-1); align-items: flex-start; padding: 12px var(--space-2); border-radius: var(--radius-control); background: var(--color-primary-soft); color: var(--color-text); font-size: var(--font-sub); }
.notice-box .icon { color: var(--color-primary); margin-top: 2px; }
.notice-box.is-error { background: var(--color-surface); border: 1px solid var(--color-error); }
.notice-box.is-error .icon { color: var(--color-error); }

/* ---------- 좌석 배치도 ---------- */
.seatmap-tools { display: flex; align-items: center; justify-content: space-between; gap: var(--space-1); }
.zoom { display: flex; align-items: center; gap: 4px; border: var(--border); border-radius: var(--radius-control); background: var(--color-surface); }
.zoom output { min-width: 44px; text-align: center; font-size: var(--font-sub); color: var(--color-text-sub); }
.seatmap-viewport { overflow: auto; border: var(--border); border-radius: var(--radius-card); background: var(--color-surface); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.seatmap { position: relative; container-type: inline-size; margin: 0; }
.seatmap .fixture { position: absolute; display: grid; place-items: center; background: var(--color-bg); color: var(--color-text-sub); border-radius: 6px; font-size: 3cqw; }
.seatmap .door { position: absolute; display: grid; place-items: center; writing-mode: vertical-rl; color: var(--color-text-sub); font-size: 2.6cqw; border-left: 2px dashed var(--color-border); }
.seat { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4cqw;
  border-radius: 1.6cqw; border: 1px solid var(--seat-available-border); background: var(--seat-available-bg); color: var(--color-text);
  line-height: 1.1; padding: 0 .4cqw; overflow: hidden; transition: background .15s, border-color .15s; }
.seat .seat-no { font-size: 3.6cqw; font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.seat .seat-tag { display: flex; align-items: center; gap: .3cqw; font-size: 2.3cqw; white-space: nowrap; max-width: 100%; overflow: hidden; }
.seat .seat-tag svg { width: 2.8cqw; height: 2.8cqw; flex: none; stroke-width: 2.4; }
/* 100% 보기에서는 아이콘만 (글자는 확대하면 보이고, 화면낭독기는 aria-label로 읽음) */
.seatmap.is-compact .seat .seat-tag .txt { display: none; }
.seatmap.is-compact .seat .seat-tag svg { width: 3.4cqw; height: 3.4cqw; }
.seat:focus-visible { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-primary); z-index: 2; }
.seat.is-selected { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.seat.is-taken { background: var(--seat-taken-bg); border-color: var(--seat-taken-bg); color: var(--color-text-sub); }
.seat.is-mine { background: var(--color-primary-soft); border: 2px solid var(--color-primary); color: var(--color-primary); }
.seat.is-blocked { background: var(--seat-blocked-bg); border-color: var(--seat-blocked-bg); color: var(--color-text-sub);
  background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(102,102,102,.12) 6px 7px); }
.seat.is-taken, .seat.is-blocked { cursor: not-allowed; }
.seat.is-plain { cursor: default; }
/* 관리자: 이름 표시 */
.seat .seat-name { font-size: 2.8cqw; font-weight: var(--weight-medium); white-space: nowrap; max-width: 100%; overflow: hidden; }
.seat.att-P { background: var(--color-primary-soft); border: 2px solid var(--color-primary); color: var(--color-primary); }
.seat.att-L { background: var(--color-surface); border: 2px dashed var(--color-text-sub); color: var(--color-text); }
.seat.att-A { background: var(--color-surface); border: 2px solid var(--color-error); color: var(--color-error); }
.seat.att-N { background: var(--color-surface); border: 1px solid var(--color-text-sub); }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); margin: 0; padding: 0; list-style: none; font-size: var(--font-sub); color: var(--color-text-sub); }
.legend li { display: flex; align-items: center; gap: var(--space-1); }
.legend .swatch { width: 28px; height: 24px; border-radius: 6px; display: inline-grid; place-items: center; border: 1px solid var(--seat-available-border); background: var(--seat-available-bg); flex: none; }
.legend .swatch svg { width: 14px; height: 14px; stroke-width: 2.4; }
.legend .swatch.is-selected { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.legend .swatch.is-taken { background: var(--seat-taken-bg); border-color: var(--seat-taken-bg); color: var(--color-text-sub); }
.legend .swatch.is-mine { background: var(--color-primary-soft); border: 2px solid var(--color-primary); color: var(--color-primary); }
.legend .swatch.is-blocked { background: var(--seat-blocked-bg); border-color: var(--seat-blocked-bg); color: var(--color-text-sub); }
.legend .swatch.att-P { background: var(--color-primary-soft); border: 2px solid var(--color-primary); color: var(--color-primary); }
.legend .swatch.att-L { border: 2px dashed var(--color-text-sub); }
.legend .swatch.att-A { border: 2px solid var(--color-error); color: var(--color-error); }

/* 상태 버튼 묶음 (출석/지각/결석) */
.seg-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1); }
.seg-buttons .btn[aria-pressed="true"] { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* 캘린더 */
.cal-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.cal-grid .wd { text-align: center; font-size: var(--font-sub); color: var(--color-text-sub); padding-bottom: 4px; }
.cal-cell { min-height: 52px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: var(--font-sub); }
.cal-cell.is-out { color: var(--color-border); }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--color-primary); }
.cal-cell .marks { font-size: 12px; color: var(--color-text-sub); white-space: nowrap; }
.cal-cell .marks b { color: var(--color-primary); }
.cal-cell .marks .a { color: var(--color-error); }
