:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efe7d8;
  --border: #ddd2bb;
  --border-strong: #c2b39c;
  --text: #241d15;
  --text-muted: #6b5f4f;
  --text-faint: #9a8d78;
  --accent: #c97f1c;
  --accent-strong: #a8690f;
  --accent-soft: #f3e2c4;
  --success: #3e7a5c;
  --success-soft: #dfeae2;
  --danger: #b3432f;
  --shadow: 0 1px 2px rgba(30, 22, 10, 0.06), 0 8px 24px -12px rgba(30, 22, 10, 0.16);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f;
    --surface: #201b14;
    --surface-2: #292219;
    --border: #3c3324;
    --border-strong: #4f4430;
    --text: #f0ebe0;
    --text-muted: #b3a690;
    --text-faint: #7d7261;
    --accent: #e3a344;
    --accent-strong: #f0b665;
    --accent-soft: #3a2c13;
    --success: #6fae8b;
    --success-soft: #1e2e26;
    --danger: #e08674;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px -12px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17140f; --surface: #201b14; --surface-2: #292219; --border: #3c3324;
  --border-strong: #4f4430; --text: #f0ebe0; --text-muted: #b3a690; --text-faint: #7d7261;
  --accent: #e3a344; --accent-strong: #f0b665; --accent-soft: #3a2c13;
  --success: #6fae8b; --success-soft: #1e2e26; --danger: #e08674;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px -12px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Gothic A1", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

.page { max-width: 760px; margin: 0 auto; padding: 40px 20px 72px; display: flex; flex-direction: column; gap: 20px; }

header.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.eyebrow { font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-strong); font-weight: 500; margin-bottom: 8px; }
h1 { font-family: "Gowun Batang", serif; font-weight: 700; font-size: clamp(26px, 4vw, 34px); margin: 0 0 6px; letter-spacing: -.01em; text-wrap: balance; }
.titleblock p { margin: 0; color: var(--text-muted); font-size: 14.5px; }

.admin-area { display: flex; align-items: center; gap: 10px; }
.admin-status { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }
#admin-name { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; }

.admin-btn { padding: 9px 15px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; flex: none; }
.admin-btn:hover { background: var(--surface-2); }
.admin-btn.ghost { border-color: transparent; color: var(--text-muted); }

.date-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-nav button { flex: none; white-space: nowrap; }
.date-nav > button:not(.admin-btn) { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); font-size: 15px; cursor: pointer; }
.date-nav button:hover { color: var(--text); background: var(--surface-2); }
.date-chip { font-family: "IBM Plex Mono", monospace; font-size: 13.5px; font-weight: 500; padding: 6px 14px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); white-space: nowrap; flex: none; }
.date-chip.today { outline: 1.5px solid var(--accent); }

.summary { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.summary-count { display: flex; align-items: baseline; gap: 8px; }
.summary-count .num { font-family: "Gothic A1", sans-serif; font-weight: 800; font-size: 48px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--accent-strong); }
.summary-count .unit { font-size: 15px; color: var(--text-muted); font-weight: 500; }
.summary-label { font-size: 12.5px; color: var(--text-faint); margin-top: 4px; }
.summary-split { text-align: right; font-size: 13.5px; color: var(--text-muted); line-height: 1.7; }
.summary-split b { color: var(--text); font-variant-numeric: tabular-nums; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; width: 220px; max-width: 100%; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px 22px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; margin: 0; font-weight: 700; }
.hint { font-size: 12.5px; color: var(--text-faint); }
.badge-public, .badge-admin { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }
.badge-public { background: var(--success-soft); color: var(--success); }
.badge-admin { background: var(--accent-soft); color: var(--accent-strong); }

.roster { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 480px) { .roster { grid-template-columns: 1fr; } }

.person { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; user-select: none; transition: border-color .15s ease, background .15s ease; }
.person:hover { border-color: var(--border-strong); }
.box { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--text-faint); flex: none; display: flex; align-items: center; justify-content: center; }
.box svg { width: 13px; height: 13px; display: none; }
.person.checked { background: var(--accent-soft); border-color: var(--accent); }
.person.checked .box { background: var(--accent); border-color: var(--accent); }
.person.checked .box svg { display: block; }
.person.checked .box svg path { stroke: #2b1b04; }
.person.checked .name { color: var(--accent-strong); font-weight: 700; }
.name { font-size: 14.5px; font-weight: 500; }

.note { margin-top: 12px; font-size: 12.5px; color: var(--text-faint); }

.mealplan-body { display: flex; flex-direction: column; gap: 12px; }
.mealplan-empty { font-size: 13.5px; color: var(--text-faint); padding: 20px 0; text-align: center; }
.mealplan-body img { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); display: block; }
.mealplan-body iframe { width: 100%; height: 480px; border: 1px solid var(--border); border-radius: 10px; }
.mealplan-link { align-self: flex-start; }

.history-row { display: flex; align-items: baseline; gap: 14px; padding: 10px 0; border-top: 1px solid var(--border); }
.history-row:first-of-type { border-top: none; padding-top: 2px; }
.history-date { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; color: var(--text-muted); width: 84px; flex: none; }
.history-count { font-weight: 800; font-size: 14.5px; width: 34px; flex: none; font-variant-numeric: tabular-nums; color: var(--text); }
.history-names { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }
.history-empty { font-size: 13px; color: var(--text-faint); }

.staff-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.staff-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.staff-row > span:first-child { font-size: 14px; font-weight: 500; }
.staff-row-actions { display: flex; align-items: center; gap: 4px; }
.reorder-btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); font-size: 11px; cursor: pointer; padding: 4px 8px; border-radius: 6px; line-height: 1; }
.reorder-btn:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.reorder-btn:disabled { opacity: .35; cursor: default; }
.delete-btn { border: none; background: none; color: var(--danger); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px 8px; }
.delete-btn:hover { text-decoration: underline; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.field input, .field select {
  padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.submit-row { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.form-msg { font-size: 12.5px; color: var(--text-muted); margin-right: auto; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--success); }

.btn-primary { padding: 9px 18px; border-radius: 9px; border: none; background: var(--accent); color: #2b1b04; font-weight: 700; font-size: 13.5px; cursor: pointer; font-family: inherit; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost { padding: 9px 16px; border-radius: 9px; border: 1px solid var(--border-strong); background: none; color: var(--text-muted); font-size: 13.5px; cursor: pointer; font-family: inherit; }

.modal { position: fixed; inset: 0; background: rgba(20, 15, 5, 0.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-box { background: var(--surface); border-radius: 16px; padding: 24px; width: 100%; max-width: 340px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.modal-box h3 { margin: 0; font-size: 17px; }
