/* sanghak.kr 웹메일 — Gmail 계열 3단 레이아웃, 모바일은 드로어 + 전환형 */

:root {
  color-scheme: light dark;
  --bg: #f2f3f5;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --panel-3: #eef0f3;
  --border: #e0e3e8;
  --border-strong: #cfd4db;
  --text: #191c20;
  --muted: #666e7a;
  --faint: #8b939e;
  --accent: #c2510a;
  --accent-text: #a34309;
  --accent-soft: #fdf0e6;
  --danger: #b42318;
  --shadow-1: 0 1px 2px rgba(16, 18, 22, 0.07);
  --shadow-2: 0 4px 12px rgba(16, 18, 22, 0.09), 0 16px 40px rgba(16, 18, 22, 0.09);
  --row-h: 54px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101215;
    --panel: #1a1d21;
    --panel-2: #21252a;
    --panel-3: #282d33;
    --border: #2c3238;
    --border-strong: #3c444c;
    --text: #e8eaee;
    --muted: #9aa3ae;
    --faint: #7e8792;
    --accent: #f0913f;
    --accent-text: #f4a862;
    --accent-soft: #33251a;
    --danger: #f97066;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.5), 0 16px 40px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
    "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ================= 공통 컨트롤 ================= */

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

.icon-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: none;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }

.field { margin-bottom: 11px; }
.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.field > input,
.field > textarea,
.field > select {
  width: 100%;
  padding: 7px 10px;
  font-size: 13.5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
}
.field > input:focus,
.field > textarea:focus,
.field > select:focus {
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.error { color: var(--danger); font-size: 13px; margin: 0; }
.error:empty { display: none; }

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

#login {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: -20%;
  z-index: 0;
  background:
    radial-gradient(38rem 30rem at 22% 18%, rgba(194, 81, 10, 0.14), transparent 62%),
    radial-gradient(34rem 28rem at 82% 88%, rgba(56, 108, 168, 0.12), transparent 62%);
  filter: blur(8px);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 392px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  padding: 30px 28px 24px;
  animation: rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .login-card { animation: none; }
}

.login-mark {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: grid; place-items: center;
  margin-bottom: 18px;
  color: #fff;
  background: linear-gradient(140deg, #e8813a, #c2510a);
  box-shadow: 0 4px 14px rgba(194, 81, 10, 0.3);
}
.login-mark svg { width: 24px; height: 24px; }

.login-card h1 { margin: 0 0 5px; font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.login-card .sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon {
  position: absolute;
  left: 10px;
  width: 16px; height: 16px;
  color: var(--faint);
  pointer-events: none;
  transition: color 0.15s ease;
}
.input-wrap input {
  width: 100%;
  padding: 8px 10px 8px 33px;
  font-size: 13.5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.input-wrap input:focus {
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-wrap:focus-within .input-icon { color: var(--accent); }

.peek {
  position: absolute; right: 4px;
  border: none; background: none;
  color: var(--muted); font-size: 12px;
  padding: 5px 8px; border-radius: 6px; cursor: pointer;
}
.peek:hover { color: var(--accent-text); background: var(--accent-soft); }

.login-submit { margin-top: 18px; padding: 9px 14px; border-radius: 8px; font-size: 13.5px; }
#login-error:not(:empty) {
  margin-top: 14px; padding: 9px 11px;
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
  border-radius: 9px; font-size: 12.5px;
}

/* ================= 레이아웃 ================= */

#app {
  display: grid;
  /* 기본: 목록이 남은 폭을 전부 쓴다. 메일을 열면 3단으로 갈라진다. */
  grid-template-columns: 170px 1fr;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}
#app:not(.has-msg) .read-pane { display: none; }
#app.has-msg { grid-template-columns: 170px minmax(320px, 420px) 1fr; }

#sidebar, .list-pane, .read-pane { min-width: 0; }

/* ---------- 사이드바 ---------- */

#sidebar {
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  padding: 11px 7px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 7px; padding: 0 4px; }
.brand-mark {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #e8813a, #c2510a);
}
.brand-mark svg { width: 15px; height: 15px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand-text strong { font-size: 13px; letter-spacing: -0.01em; }
.brand-text .who {
  font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.compose-btn { padding: 7px 10px; border-radius: 8px; font-size: 12.5px; }

.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group h3 {
  margin: 0 6px 5px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--faint);
}

.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%;
  padding: 5px 9px;
  font-size: 12.5px;
  border: none; background: none;
  border-radius: 8px;
  cursor: pointer; text-align: left;
  color: var(--text);
}
.nav-item:hover { background: var(--panel-3); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-item.active .count { color: var(--accent-text); }
.nav-add, .sidebar-foot .nav-item { color: var(--muted); font-size: 13px; }

.sidebar-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 1px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* ---------- 목록 ---------- */

.list-pane {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 5px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.search-wrap { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.search-wrap .input-icon { width: 15px; height: 15px; left: 9px; }
.search-wrap input {
  width: 100%;
  padding: 6px 10px 6px 31px;
  font-size: 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
}
.search-wrap input:focus {
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.bulkbar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
}
/* hidden 속성이 display:flex 보다 우선하도록 (UA 스타일시트는 특이도가 낮다) */
.bulkbar[hidden] { display: none; }

.bulk-count { font-size: 12.5px; font-weight: 600; color: var(--accent-text); }
.bulk-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

.list-header {
  flex-shrink: 0;
  display: flex; align-items: baseline; gap: 7px;
  padding: 8px 12px 7px;
  border-bottom: 1px solid var(--border);
}
.list-header h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: -0.01em; }
.list-header .sub { font-size: 11.5px; color: var(--faint); }

#list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.msg-row {
  position: relative;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: start;
  gap: 9px;
  width: 100%;
  min-height: var(--row-h);
  padding: 9px 12px;
  border: none; border-bottom: 1px solid var(--border);
  background: none;
  text-align: left; cursor: pointer;
}
.msg-row:hover { background: var(--panel-2); }
.msg-row.selected { background: var(--accent-soft); }
.msg-row.checked { background: var(--panel-3); }

.check {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  cursor: pointer;
}
.check:hover { background: var(--panel-3); }
.check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.avatar {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700;
  color: #fff;
  user-select: none;
}

.msg-main { min-width: 0; }
.msg-line1 { display: flex; align-items: baseline; gap: 8px; }
.msg-who {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px;
}
.msg-when {
  flex-shrink: 0;
  font-size: 11.5px; color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.msg-subject {
  margin-top: 0;
  font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-snippet {
  margin-top: 0;
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-row.unread .msg-who,
.msg-row.unread .msg-subject { font-weight: 700; }
.msg-row.unread::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
}

.msg-tags { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.tag {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--panel-3);
  color: var(--muted);
}
.tag.star { color: var(--accent-text); background: var(--accent-soft); }

/* 호버 시 나타나는 행 액션 (포인터가 있는 기기에서만) */
.row-actions {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 2px;
  padding: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow-1);
}
@media (hover: hover) and (pointer: fine) {
  .msg-row:hover .row-actions { display: flex; }
}
.row-actions .icon-btn { width: 30px; height: 30px; font-size: 14px; }

.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty .hint { font-size: 12px; color: var(--faint); margin-top: 8px; }

/* ---------- 읽기 ---------- */

.read-pane { background: var(--panel); overflow-y: auto; }

.read-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px 12px;
}
.read-top { display: flex; align-items: flex-start; gap: 6px; }
.read-top .icon-btn { margin-top: -3px; }
.read-from-addr { color: var(--faint); font-weight: 400; font-size: 12px; margin-left: 5px; }

.read-head h2 {
  flex: 1;
  margin: 0 0 10px;
  font-size: 17px; font-weight: 700; letter-spacing: -0.015em;
  word-break: break-word;
}
.read-from { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.read-from .avatar { width: 30px; height: 30px; font-size: 12.5px; }
.read-from-text { min-width: 0; }
.read-from-name { font-weight: 600; font-size: 13.5px; }
.meta { color: var(--muted); font-size: 12px; word-break: break-all; }
.actions { display: flex; gap: 5px; flex-wrap: wrap; }

.read-body { padding: 16px 20px 44px; overflow-wrap: break-word; }
.read-body pre { white-space: pre-wrap; font-family: inherit; margin: 0; font-size: 14px; }
.read-body iframe {
  width: 100%; min-height: 58vh;
  border: none; background: #fff; border-radius: 10px;
}

.attachments {
  margin-top: 16px; padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
}
.attachments h4 { margin: 0 0 9px; font-size: 12px; color: var(--muted); }
.attachments a {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 6px 5px 0; padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text); text-decoration: none;
  font-size: 12.5px; background: var(--panel);
}
.attachments a:hover { border-color: var(--accent); color: var(--accent-text); }
.attachments .size { color: var(--faint); }

/* ---------- 모달 ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 12, 15, 0.45);
}

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 12, 15, 0.5);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  padding: 22px;
  max-height: 92dvh;
  overflow-y: auto;
}
.modal-sm { max-width: 400px; }
.dlg-msg { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.55; }
.modal-md { max-width: 680px; }
.modal-lg { max-width: 940px; }

/*
 * 관리자 모달은 화면의 80% x 80% 로 고정한다.
 * 탭을 바꿔도 모달 크기가 흔들리지 않도록, 내용 영역만 안쪽에서 스크롤한다.
 */
.modal-admin {
  width: 80vw;
  height: 80dvh;
  max-width: none;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-admin .modal-head { flex-shrink: 0; margin-bottom: 14px; }
.modal-admin .admin-tabs { flex-shrink: 0; margin-bottom: 14px; }
.modal-admin #admin-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-admin .modal-actions { flex-shrink: 0; }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; }
.modal h3 { margin: 0 0 18px; font-size: 17px; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* 작성 에디터 */
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 6px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 7px 7px 0 0;
  background: var(--panel-2);
}
.tool {
  min-width: 27px; height: 27px;
  padding: 0 8px;
  display: grid; place-items: center;
  border: 1px solid transparent; background: none;
  border-radius: 7px; cursor: pointer;
  color: var(--muted); font-size: 13px;
}
.tool:hover { background: var(--panel-3); color: var(--text); }
.tool.on { background: var(--accent-soft); color: var(--accent-text); }
.tool-sep { width: 1px; margin: 4px 3px; background: var(--border); }

.editor {
  min-height: 180px;
  max-height: 46dvh;
  overflow-y: auto;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 0 0 7px 7px;
  background: var(--panel-2);
  outline: none;
  font-size: 13.5px;
}
.editor:focus { background: var(--panel); border-color: var(--accent); }
.editor blockquote {
  margin: 8px 0; padding-left: 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}
.editor:empty::before {
  content: attr(data-placeholder);
  color: var(--faint);
}

/* 관리자 */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-tab {
  padding: 7px 13px;
  border: 1px solid var(--border); background: var(--panel-2);
  border-radius: 999px; cursor: pointer; font-size: 13px;
}
.admin-tab.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td {
  text-align: left; padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.grid th { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
table.grid tr:last-child td { border-bottom: none; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat {
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
}
.stat .k { font-size: 11.5px; color: var(--muted); }
.stat .v { font-size: 21px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }

.note {
  padding: 11px 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12.5px; color: var(--muted);
  margin-bottom: 16px;
}

.toast {
  position: fixed; z-index: 100;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow-2); font-size: 13px;
  max-width: calc(100vw - 32px);
}

/* FAB — 모바일에서만 */
.fab {
  display: none;
  position: fixed; z-index: 30;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border: none; border-radius: 18px;
  background: var(--accent); color: #fff;
  font-size: 22px; cursor: pointer;
  box-shadow: var(--shadow-2);
}

.drawer-only { display: none; }

/* ================= 반응형 ================= */

@media (max-width: 1240px) {
  #app { grid-template-columns: 158px 1fr; }
  #app.has-msg { grid-template-columns: 158px minmax(290px, 360px) 1fr; }
}

/* 태블릿: 사이드바를 드로어로, 목록 + 본문 2단 유지 */
@media (max-width: 1000px) {
  #app { grid-template-columns: 1fr; }
  #app.has-msg { grid-template-columns: minmax(290px, 380px) 1fr; }
  .drawer-only { display: grid; }

  #sidebar {
    position: fixed; z-index: 45;
    top: 0; bottom: 0; left: 0;
    width: 190px;
    padding-top: max(14px, env(safe-area-inset-top));
    box-shadow: var(--shadow-2);
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }
  #app.drawer-open #sidebar { transform: none; }
  .compose-btn { display: none; }

  /* 터치 화면에서는 탭 영역을 44px 에 가깝게 확보한다 */
  #sidebar { padding: 12px 10px; }
  .nav-item { padding: 11px 12px; font-size: 13.5px; }
  .nav-group { gap: 2px; }
}

/* 모바일: 목록 ↔ 본문 전환, FAB 노출 */
@media (max-width: 700px) {
  #app, #app.has-msg { grid-template-columns: 1fr; }
  .list-pane { border-right: none; }

  #app.reading .list-pane { display: none; }
  #app:not(.reading) .read-pane { display: none; }
  #app.reading .fab { display: none; }

  .fab { display: grid; place-items: center; }

  .topbar { padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .read-head { padding: 14px 16px 12px; padding-top: max(14px, env(safe-area-inset-top)); }
  .read-head h2 { font-size: 17px; }
  .read-body { padding: 16px 16px 48px; }
  .read-body iframe { min-height: 50dvh; }

  /* 손가락으로 누르기 좋게 */
  :root { --row-h: 60px; }
  .msg-row { padding: 10px 10px; }

  /* 체크박스 탭 영역 확대 */
  .check { width: 38px; height: 38px; }
  .check input { width: 18px; height: 18px; }
  .icon-btn { width: 38px; height: 38px; }
  .btn { padding: 7px 12px; }

  .modal-backdrop { padding: 0; place-items: stretch; }
  .modal {
    max-width: none; max-height: none;
    min-height: 100dvh;
    border: none; border-radius: 0;
    padding: max(18px, env(safe-area-inset-top)) 16px 24px;
  }
  /* 확인/입력 모달은 전체화면으로 만들지 않는다 */
  .modal-backdrop:has(.modal-sm) { padding: 20px; place-items: center; }
  .modal-sm {
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
  }
  .modal-sm .modal-head,
  .modal-sm .modal-actions {
    position: static;
    margin: 0 0 12px;
    padding: 0;
    border: none;
  }
  .modal-sm .modal-actions { margin: 14px 0 0; }

  /* 관리자 모달은 좁은 화면에서도 80% x 80% 를 유지한다 */
  .modal-backdrop:has(.modal-admin) { padding: 20px; place-items: center; }
  .modal-admin {
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
  }
  .modal-admin .modal-head,
  .modal-admin .modal-actions {
    position: static;
    margin: 0 0 12px;
    padding: 0;
    border: none;
  }
  .modal-admin .modal-actions { margin: 12px 0 0; }
  .editor { max-height: none; min-height: 38dvh; }

  /* 헤더/푸터를 고정해 긴 폼에서도 제목과 버튼이 항상 보이게 한다 */
  .modal-head {
    position: sticky; top: 0; z-index: 2;
    margin: 0 -16px 16px;
    padding: 0 16px 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
  }
  .modal-actions {
    position: sticky; bottom: 0; z-index: 2;
    margin: 16px -16px 0;
    padding: 10px 16px max(10px, env(safe-area-inset-bottom));
    background: var(--panel);
    border-top: 1px solid var(--border);
  }

  .login-card { padding: 30px 22px 24px; border-radius: 16px; }
}

@media (max-width: 380px) {
  .bulk-actions { gap: 4px; }
  .bulk-actions .btn { padding: 5px 8px; font-size: 12px; }
}
