/* ==========================================================================
   Bandiro — 전역 스타일 (리셋 · 타이포 · 프리미티브 · 네비게이션 · 일반 페이지)
   워크스페이스(/p) 전용 스타일은 workspace.css 에 있다.
   ========================================================================== */

/* ---------- 리셋 ---------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh-ui);
  letter-spacing: -0.003em;
  color: var(--ink);
  background: var(--canvas);

  /* topbar + 본문 2행 그리드. .workspace가 top:49px를 하드코딩하던 것을 대체한다. */
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  height: 100dvh;
}

/* display를 지정한 클래스(.btn 등)가 UA의 [hidden] 규칙을 이기는 문제를 막는다 */
[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
ul, ol { list-style: none; }
table { border-collapse: collapse; }
svg { display: block; }

/* 포커스: 마우스 클릭에는 안 뜨고 키보드에만 뜬다 */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* 스크롤바 */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: var(--r-full);
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: content-box; }

/* ---------- 타이포 -------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 { line-height: var(--lh-tight); font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4, h5, h6 { font-size: var(--fs-md); }

.muted { color: var(--ink-3); font-size: var(--fs-sm); }
.error { color: var(--danger); font-size: var(--fs-sm); }

/* ---------- 아이콘 -------------------------------------------------------- */

.i {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.i-sm { width: 14px; height: 14px; }
.i-lg { width: 18px; height: 18px; }
#icon-sprite { display: none; }

/* ---------- 버튼 ---------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  border: 1px solid transparent; border-radius: var(--r);
  padding: 0.5rem 0.9rem;
  font-size: var(--fs-md); font-weight: 500; white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t), opacity var(--t);
}
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary { background: var(--accent); color: var(--ink-on-fill); box-shadow: var(--sh-1); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

/* 기본 보조 버튼 — 워크스페이스 전반의 주력 */
.btn-small {
  background: var(--surface); border-color: var(--line);
  color: var(--ink-2);
  font-size: var(--fs-sm); padding: 0.3rem 0.625rem;
  border-radius: var(--r-sm); box-shadow: var(--sh-1);
}
.btn-small:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); border-color: var(--line-strong); }
.btn-small.danger { color: var(--danger); border-color: var(--danger-line); }
.btn-small.danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-small.btn-primary {
  background: var(--accent); color: var(--ink-on-fill); border-color: var(--accent);
}
.btn-small.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

/* AI 액션 — 보라 계열은 오직 이 용도 */
.btn-ai, .btn-gen {
  color: var(--ai-strong); border-color: var(--ai-line); background: var(--surface);
}
.btn-ai:hover:not(:disabled), .btn-gen:hover:not(:disabled) {
  background: var(--ai-soft); border-color: var(--ai); color: var(--ai-strong);
}

.btn-confirm { color: var(--ok); border-color: var(--ok-line); }
.btn-confirm:hover:not(:disabled) { background: var(--ok-soft); }

/* 아이콘 전용 정사각 버튼 */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--r-sm);
  color: var(--ink-2); transition: background var(--t), color var(--t);
}
.btn-icon:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.btn-icon.is-active { background: var(--surface-3); color: var(--ink); }

/* ---------- 폼 ------------------------------------------------------------ */

.input, input[type="text"].input, textarea.input, select.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.5rem 0.7rem;
  font-size: var(--fs-md);
  line-height: var(--lh-ui);
  transition: border-color var(--t), box-shadow var(--t);
}
.input:hover { border-color: var(--line-strong); }
.input:focus-visible, .input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 16%, transparent);
}

/* ---------- 뱃지 ---------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center;
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: 0.01em;
  border-radius: var(--r-sm); padding: 0.1rem 0.35rem;
  background: var(--surface-3); color: var(--ink-2);
}

/* ==========================================================================
   상단 바
   ========================================================================== */

.topbar {
  grid-row: 1;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 0.75rem 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}

.topbar-lead {
  display: flex; align-items: center; gap: 0.625rem;
  min-width: 0; flex: 1;
}
.topbar-right {
  display: flex; align-items: center; gap: 0.375rem;
  flex: none;
}

/* 브랜드 워드마크 */
.brand {
  display: inline-flex; align-items: center; gap: 0.45rem;
  color: var(--ink); flex: none;
}
.brand:hover { color: var(--ink); }
.brand-mark { color: var(--ai); }
.brand-mark .i { width: 17px; height: 17px; }
.brand-word {
  font-family: var(--font-brand);
  font-size: 1.0625rem; font-weight: 700; letter-spacing: 0.01em;
}
.brand:hover .brand-mark { color: var(--ai-strong); }

.topbar-sep { width: 1px; height: 18px; background: var(--line); flex: none; }

.pane-toggles { display: flex; align-items: center; gap: 0.1rem; }

/* 테마 토글 — 현재 테마에 맞는 아이콘 하나만 보인다 */
.icon-when-dark { display: none; }
:root[data-theme="dark"] .icon-when-light { display: none; }
:root[data-theme="dark"] .icon-when-dark { display: block; }

.user-email { font-size: var(--fs-sm); color: var(--ink-3); }

/* ---------- 드롭다운 메뉴 ------------------------------------------------- */

.menu-wrap { position: relative; }

.menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 200px; padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--sh-3);
  z-index: 60;
  animation: menu-in var(--t) both;
}
.menu[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }

.menu-item {
  display: flex; align-items: center; gap: 0.55rem;
  width: 100%; padding: 0.45rem 0.55rem;
  border-radius: var(--r-sm);
  font-size: var(--fs-md); color: var(--ink-2); text-align: left;
  transition: background var(--t), color var(--t);
}
.menu-item:hover { background: var(--surface-3); color: var(--ink); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item .i { color: var(--ink-3); }
.menu-item:hover .i { color: inherit; }
.menu-shortcut { margin-left: auto; font-size: var(--fs-xs); color: var(--ink-3); }
.menu-sep { height: 1px; background: var(--line-soft); margin: 0.3rem 0.2rem; }
.menu-label {
  padding: 0.35rem 0.55rem 0.2rem;
  font-size: var(--fs-xs); color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 주간 사용량 게이지 (§13) — 퍼센트만 보여준다. 숫자(원가·토큰)는 관리자 화면의 몫. */
.menu-usage { padding: 0.3rem 0.55rem 0.45rem; }
.menu-usage-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: 0.3rem;
}
.menu-usage-head #menu-usage-pct { font-size: var(--fs-xs); color: var(--ink-3); }
.menu-usage-bar {
  height: 0.3rem; border-radius: 999px; background: var(--surface-sunken);
  overflow: hidden;
}
.menu-usage-bar span {
  display: block; height: 100%; border-radius: inherit;
  background: var(--ok); transition: width var(--t);
}
.menu-usage-bar.low span { background: var(--danger); }
.menu-usage-note { margin-top: 0.3rem; font-size: var(--fs-xs); color: var(--ink-3); }

/* 창작 모델 세그먼트 — 게이지(자원) 옆에 두어 소모 속도와의 관계를 보여준다 */
.menu-slots {
  display: flex; gap: 0.25rem; margin-top: 0.45rem;
  padding: 0.15rem; border-radius: var(--r-sm); background: var(--surface-sunken);
}
.menu-slots button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.3rem;
  padding: 0.28rem 0.4rem; border-radius: calc(var(--r-sm) - 2px);
  font-size: var(--fs-xs); color: var(--ink-3);
  transition: background var(--t), color var(--t);
}
.menu-slots button.is-active {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--sh-1); font-weight: 600;
}
.menu-slots button.is-locked { cursor: default; }
.menu-slots button .i { width: 0.75rem; height: 0.75rem; }

/* ==========================================================================
   본문 컨테이너
   ========================================================================== */

.app-main { grid-row: 2; min-height: 0; overflow-y: auto; }
.app-main > .container { max-width: 940px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }

/* ==========================================================================
   로그인
   ========================================================================== */

.login-card {
  max-width: 380px; margin: 12vh auto 0; text-align: center;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 3rem 2.25rem 2.5rem;
}
.login-mark { color: var(--ai); display: flex; justify-content: center; margin-bottom: 1rem; }
.login-mark .i { width: 30px; height: 30px; stroke-width: 1.4; }
.login-card h1 { font-family: var(--font-brand); font-size: 1.75rem; letter-spacing: 0.01em; }
.login-card .subtitle { color: var(--ink-3); font-size: var(--fs-md); margin: 0.4rem 0 2rem; }
.login-card .btn { width: 100%; }

/* ==========================================================================
   대시보드
   ========================================================================== */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap;
}
.page-head h1 { font-size: var(--fs-2xl); }
.page-head .muted { margin-top: 0.25rem; }

.create-form { display: flex; gap: 0.5rem; }
.create-form .input { min-width: 240px; }

/* ---------- 서가 ---------------------------------------------------------- */
/* 작품 목록은 책장이다. 표지는 작품 id로 절차적 생성한다(static/js/covers.js).
   표지 안쪽 색은 테마와 무관한 리터럴이고, 그 바깥은 전부 토큰을 쓴다. */

.shelf {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2.2rem 1.7rem; list-style: none; padding: 0; margin: 0;
}

/* 책 전체(표지 + 책장 단면)가 함께 기울어야 입체로 읽힌다.
   캡션은 표지 밖(프레임 아래)이라 같이 기울지 않는다 — 글자는 읽혀야 한다. */
.book { min-width: 0; }
.book-frame {
  position: relative; aspect-ratio: 2 / 3;
  transition: transform var(--t);
  transform-origin: left center;
}
.book:hover .book-frame, .book:focus-within .book-frame {
  transform: perspective(900px) rotateY(-7deg) translateY(-4px);
}

/* 자수와 기간은 늘 보인다 — 표지를 가리지 않는 자리에서 */
.book-caption {
  display: flex; flex-direction: column; gap: 0.05rem;
  margin-top: 0.6rem; padding-left: 2px;
  font-size: var(--fs-2xs); color: var(--ink-3); line-height: 1.45;
}
.book-dates { font-variant-numeric: tabular-nums; }

.book-inner {
  position: absolute; inset: 0; display: block;
  border-radius: 3px 6px 6px 3px;
  overflow: hidden; color: var(--cover-ink, #fff);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 18px -6px rgba(0, 0, 0, .45);
  transition: box-shadow var(--t);
}
.book-inner:hover, .book-inner:focus-visible { color: var(--cover-ink, #fff); }
.book:hover .book-inner, .book:focus-within .book-inner {
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4), 0 18px 34px -8px rgba(0, 0, 0, .6);
}
.book-art, .book-art svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* 책등 — 얇은 띠 하나가 '면'을 '책'으로 만든다 */
.book-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 11px; z-index: 3;
  background: linear-gradient(90deg, rgba(0, 0, 0, .42), rgba(0, 0, 0, .14) 55%, rgba(255, 255, 255, .07));
}

/* 책장 두께 — 쓴 분량만큼 오른쪽으로 쌓인다. 표지 밖(형제)이라 잘리지 않는다. */
.book-pages { position: absolute; top: 4px; bottom: 4px; right: 0; }
.book-pages i {
  position: absolute; top: 0; bottom: 0; width: 3px; border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, #d8cfc0, #a99e8c);
  box-shadow: 1px 0 2px rgba(0, 0, 0, .25);
}

/* 표지에 남는 글자는 제목뿐이다. 띠지는 표지 밖 캡션(.book-caption)으로 내려갔다. */
.book-title {
  position: absolute; z-index: 2; left: 20px; right: 14px; bottom: 18px;
  font-size: var(--fs-md); font-weight: 700; line-height: 1.35;
  letter-spacing: -0.01em; word-break: keep-all;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .45);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}

/* 표지 바꾸기·삭제만 hover로 나타난다. 링크 안에 버튼을 중첩하지 않는다. */
.book-frame > .btn-cover, .book-frame > .btn-delete {
  position: absolute; z-index: 4; top: 6px;
  width: 26px; height: 26px; opacity: 0;
  background: rgba(0, 0, 0, .5); color: #fff; backdrop-filter: blur(3px);
}
.book-frame > .btn-delete { right: 6px; }
.book-frame > .btn-cover { right: 36px; }
.book-frame > .btn-cover .i, .book-frame > .btn-delete .i { width: 14px; height: 14px; }
.book:hover .btn-cover, .book .btn-cover:focus-visible,
.book:hover .btn-delete, .book .btn-delete:focus-visible { opacity: 1; }
.btn-cover:hover { color: var(--ink); background: var(--surface); }
.btn-delete:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- 휴지통 · 표시 옵션 ---------- */
/* 삭제는 되돌릴 수 있어야 한다(규칙 6). 휴지통은 서가 아래, 목록은 모달에서만. */

.head-meta { display: flex; align-items: center; gap: 0.5rem; }
/* 조용한 칩 버튼 — 머리말의 표시 옵션과 서가 아래 휴지통이 같은 무게를 쓴다 */
.head-chip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.15rem 0.4rem; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--ink-3); cursor: pointer;
  font-size: var(--fs-xs); font-family: inherit;
  transition: background var(--t), color var(--t);
}
.head-chip:hover { background: var(--surface-3); color: var(--ink-2); }
.head-chip.is-on { color: var(--ink); background: var(--surface-3); }
.head-chip .i { width: 15px; height: 15px; }

.shelf-foot { margin-top: 2.5rem; }

/* 비밀서가에서 올라온 책 — 켰을 때만 보이는 표시라 폭로가 되지 않는다 */
.book-secret {
  position: absolute; z-index: 4; top: 6px; left: 17px;
  width: 22px; height: 22px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .5); color: #fff; backdrop-filter: blur(3px);
}
.book-secret .i { width: 13px; height: 13px; }

.trash-list { list-style: none; margin: 0.2rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.trash-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
}
.trash-info { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1; }
.trash-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-meta { font-size: var(--fs-xs); }
.trash-actions { display: flex; gap: 0.4rem; flex: none; }
.btn-purge { color: var(--danger); }
.btn-purge:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger-line); }

/* 영구 삭제 확인 — 제목을 손으로 적게 한다 */
.purge-label { display: block; margin: 0.9rem 0 0; font-size: var(--fs-sm); color: var(--ink-2); }
.purge-input { margin-top: 0.35rem; }
.purge-keep {
  display: flex; gap: 0.45rem; align-items: flex-start;
  margin: 0.9rem 0 0.3rem; font-size: var(--fs-sm); color: var(--ink-2); line-height: var(--lh-ui);
}
.purge-keep input { margin-top: 0.2rem; flex: none; }

/* 확인창 안의 책 — "무엇을 지우는지"를 글자가 아니라 물건으로 보여 준다 */
.confirm-book { display: flex; align-items: center; gap: 0.9rem; margin: 0.2rem 0 0.4rem; }
.confirm-book-art {
  position: relative; flex: none; width: 56px; aspect-ratio: 2 / 3;
  border-radius: 2px 4px 4px 2px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 14px -6px rgba(0, 0, 0, .45);
}
.confirm-book-art svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.confirm-book-info { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.confirm-book-info strong { font-size: var(--fs-lg); word-break: keep-all; }
.confirm-book-info .muted { font-size: var(--fs-sm); }

/* ---------- 표지 고르기 ---------- */
/* 칸 하나하나가 그 축만 바꾼 진짜 표지다. 색 이름이나 아이콘으로 대신하지 않는다. */

.cover-picker { display: flex; gap: 1.25rem; padding: 0.4rem 0 0.2rem; }

.cover-preview {
  position: relative; flex: 0 0 auto; width: 152px; aspect-ratio: 2 / 3;
  border-radius: 3px 6px 6px 3px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 22px -8px rgba(0, 0, 0, .5);
}
.cover-preview-art, .cover-preview-art svg {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}
.cover-preview-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 9px; z-index: 2;
  background: linear-gradient(90deg, rgba(0, 0, 0, .42), rgba(0, 0, 0, .14) 55%, rgba(255, 255, 255, .07));
}
.cover-preview-title {
  position: absolute; z-index: 2; left: 16px; right: 12px; bottom: 14px;
  color: var(--cover-ink, #fff);
  font-size: var(--fs-md); font-weight: 700; line-height: var(--lh-tight);
  letter-spacing: -0.01em; word-break: keep-all;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .45);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}

.cover-axes { flex: 1 1 auto; min-width: 0; }
.cover-axes h4 { margin: 0 0 0.4rem; }
.cover-axes h4 + .cover-swatches { margin-bottom: 1rem; }
.cover-swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.4rem; }

.cover-swatch {
  padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 3px; line-height: 0;
  outline: 2px solid transparent; outline-offset: 2px;
  transition: outline-color var(--t), transform var(--t);
}
.cover-swatch:hover { transform: translateY(-2px); }
.cover-swatch.is-on { outline-color: var(--ink); }
.cover-swatch:focus-visible { outline-color: var(--focus); }
.cover-swatch-art { display: block; aspect-ratio: 2 / 3; border-radius: 3px; overflow: hidden; }
.cover-swatch-art svg { width: 100%; height: 100%; display: block; }

.modal-footer-gap { flex: 1 1 auto; }

@media (max-width: 560px) {
  .cover-picker { flex-direction: column; align-items: center; }
  .cover-axes { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .cover-swatch:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .book:hover .book-frame, .book:focus-within .book-frame { transform: none; }
}

.empty-state {
  text-align: center; padding: 4rem 1rem;
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
  color: var(--ink-2);
}
.empty-state .i { width: 26px; height: 26px; margin: 0 auto 0.75rem; color: var(--ink-3); stroke-width: 1.4; }
.empty-state .muted { margin-top: 0.4rem; }

/* ==========================================================================
   관리자
   ========================================================================== */

.admin-cards { display: flex; gap: 0.75rem; margin: 1.25rem 0 2rem; flex-wrap: wrap; }
.admin-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.1rem 1.4rem; font-size: var(--fs-sm); color: var(--ink-3); min-width: 150px;
  box-shadow: var(--sh-1);
}
.admin-num {
  font-size: 1.5rem; font-weight: 650; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}

.section-title { margin: 2rem 0 0.75rem; font-size: var(--fs-lg); }

.admin-table {
  width: 100%; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
}
.admin-table th, .admin-table td {
  padding: 0.6rem 0.9rem; text-align: left; border-bottom: 1px solid var(--line-soft);
}
.admin-table th {
  background: var(--surface-2); color: var(--ink-3);
  font-size: var(--fs-xs); font-weight: 600;
}
.admin-table .num { text-align: right; }
.admin-table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; border-radius: var(--r); }

/* 요금제 관리 폼 (§13) */
.billing-form .input { font-size: var(--fs-sm); padding: 0.3rem 0.5rem; }
.billing-form .input.num { width: 7rem; text-align: right; font-variant-numeric: tabular-nums; }
.billing-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin: 0.9rem 0 0.4rem;
}
.billing-row label {
  display: flex; flex-direction: column; gap: 0.3rem;
  font-size: var(--fs-xs); color: var(--ink-3);
}
.plan-form { display: flex; gap: 0.4rem; align-items: center; }
.plan-form .input { font-size: var(--fs-xs); padding: 0.25rem 0.4rem; width: auto; }
.plan-form .plan-expires {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap;
}

/* ==========================================================================
   아바타 버튼
   ========================================================================== */

.avatar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 650; line-height: 1;
  border: 1px solid var(--line);
  transition: background var(--t), color var(--t), border-color var(--t);
}
.avatar-btn:hover, .avatar-btn.is-active {
  background: var(--ink); color: var(--ink-on-fill); border-color: var(--ink);
}

/* ==========================================================================
   모달 · 다이얼로그
   ========================================================================== */

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--scrim);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  animation: fade-in var(--t) both;
}
@keyframes fade-in { from { opacity: 0; } }

.modal {
  background: var(--surface); border-radius: var(--r-lg);
  width: min(580px, 100%); max-height: 84vh;
  display: flex; flex-direction: column;
  box-shadow: var(--sh-3);
  animation: modal-in var(--t-slow) both;
}
.modal-sm { width: min(420px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

.modal-title { padding: 1.1rem 1.35rem 0.5rem; font-size: var(--fs-lg); }
.modal-body { padding: 0.5rem 1.35rem; overflow-y: auto; flex: 1; }
.modal-body h4 {
  margin: 1rem 0 0.35rem; font-size: var(--fs-xs); color: var(--ink-3);
  letter-spacing: 0.03em; text-transform: uppercase;
}
.modal-footer {
  display: flex; gap: 0.5rem; padding: 1rem 1.35rem;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap; align-items: center;
}
.modal-footer-end { justify-content: flex-end; }

.dialog-message { color: var(--ink-2); line-height: 1.7; margin-bottom: 0.75rem; }
.dialog-input { margin-bottom: 0.4rem; }

.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #8e3b32; border-color: #8e3b32; }

/* ==========================================================================
   토스트
   ========================================================================== */

.toast-region {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column-reverse; gap: 0.5rem;
  pointer-events: none; width: max-content; max-width: min(460px, calc(100vw - 2rem));
}

.toast {
  display: flex; align-items: center; gap: 0.55rem;
  pointer-events: auto;
  background: var(--ink); color: var(--ink-on-fill);
  border-radius: var(--r); box-shadow: var(--sh-3);
  padding: 0.6rem 0.65rem 0.6rem 0.8rem;
  font-size: var(--fs-md);
  animation: toast-in var(--t-slow) both;
}
.toast.is-out { animation: toast-out var(--t) both; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(4px); } }

.toast-msg { flex: 1; min-width: 0; }
.toast .i { color: var(--ink-on-fill); opacity: 0.65; }
.toast-ok .i    { color: #8fd6a6; opacity: 1; }
.toast-warn .i  { color: #eecb87; opacity: 1; }
.toast-error .i { color: #f0a79c; opacity: 1; }

.toast-action {
  flex: none; font-size: var(--fs-sm); font-weight: 600;
  color: var(--ink-on-fill); text-decoration: underline; text-underline-offset: 2px;
  padding: 0.15rem 0.35rem; border-radius: var(--r-sm);
}
.toast-action:hover { background: rgba(255, 255, 255, 0.12); }
.toast-close {
  flex: none; display: inline-flex; padding: 0.25rem; border-radius: var(--r-sm);
  color: var(--ink-on-fill); opacity: 0.55; transition: opacity var(--t), background var(--t);
}
.toast-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }

/* ==========================================================================
   반응형 (일반 페이지)
   ========================================================================== */

@media (max-width: 640px) {
  .app-main > .container { padding: 1.5rem 1rem 3rem; }
  .create-form { width: 100%; }
  .create-form .input { min-width: 0; flex: 1; }
  .user-email { display: none; }
}
