/* Shared admin shell: one header, one bottom tab bar, one set of tokens for every admin page.
   Built for iPhone first (393 pt wide, notch and home indicator), works on desktop too. */
:root {
  --bg: #f6f7f9; --surface: #fff; --border: #e5e7eb; --text: #111827; --muted: #6b7280;
  --primary: #2563eb; --primary-soft: #eff6ff; --primary-ink: #1d4ed8;
  --on: #15803d; --on-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --danger: #b91c1c; --danger-soft: #fee2e2;
  --radius: 14px; --radius-sm: 10px;
  --header-h: 52px; --tabbar-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body.shell {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px; line-height: 1.45;
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
/* iOS zooms into any text field under 16px: keep every field at 16px */
body.shell input:not([type=checkbox]):not([type=radio]):not([type=range]),
body.shell select, body.shell textarea { font-size: 16px; }

/* ---------- header ---------- */
.shell-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--header-h) + var(--safe-top)); padding: var(--safe-top) 12px 0 16px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(246, 247, 249, .88); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.shell-header h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-header .actions { display: flex; align-items: center; gap: 6px; }

/* ---------- bottom tab bar ---------- */
.shell-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, .92); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid rgba(0, 0, 0, .08);
}
.shell-tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.shell-tabs a svg { width: 24px; height: 24px; }
.shell-tabs a[aria-current="page"] { color: var(--primary); }

/* ---------- content ---------- */
.shell-main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h2, .section-title { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.section-title { margin: 20px 4px 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: none; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

/* ---------- controls ---------- */
.btn {
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--danger); border-color: #fca5a5; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { width: 44px; padding: 0; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .45; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-family: inherit;
}
.seg { display: flex; background: #e9eaee; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; min-height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: var(--muted); }
.pill.on { background: var(--on-soft); color: var(--on); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.err { background: var(--danger-soft); color: var(--danger); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
details.card > summary { cursor: pointer; font-weight: 700; list-style: none; min-height: 28px; }
details.card > summary::after { content: "펼치기"; float: right; color: var(--muted); font-size: 13px; font-weight: 600; }
details.card[open] > summary::after { content: "접기"; }

/* ---------- toast ---------- */
.shell-toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); transform: translateX(-50%) translateY(8px);
  max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: 999px; background: #111827; color: #fff;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
}
.shell-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.shell-toast.err { background: var(--danger); }

/* ---------- login ---------- */
.shell-login { max-width: 360px; margin: 18vh auto 0; text-align: center; padding: 24px; }
.shell-login h2 { margin: 0 0 6px; font-size: 22px; }

@media (min-width: 900px) {
  .shell-tabs { left: 50%; right: auto; width: 520px; transform: translateX(-50%); border: 1px solid rgba(0, 0, 0, .08); border-bottom: 0; border-radius: 16px 16px 0 0; }
}

/* sticky header must not cover anchor targets */
[id] { scroll-margin-top: calc(var(--header-h) + var(--safe-top) + 8px); }
