:root {
  --bg: #f3f0e6;
  --card: #fbf9f2;
  --ink: #2f3326;
  --ink-soft: #6b7057;
  --olive: #5a6740;
  --olive-deep: #465232;
  --sage: #8a9a6b;
  --line: #ddd8c6;
  --star: #a9b47e;
  --danger: #a05545;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #20241b;
    --card: #2a2f23;
    --ink: #e9e6d8;
    --ink-soft: #a6ac93;
    --olive: #9cab7c;
    --olive-deep: #b4c294;
    --sage: #7c8b5f;
    --line: #3a4030;
    --star: #b4c184;
    --danger: #cf8a7a;
  }
}
:root[data-theme="dark"] {
  --bg: #20241b;
  --card: #2a2f23;
  --ink: #e9e6d8;
  --ink-soft: #a6ac93;
  --olive: #9cab7c;
  --olive-deep: #b4c294;
  --sage: #7c8b5f;
  --line: #3a4030;
  --star: #b4c184;
  --danger: #cf8a7a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Serif KR', 'Nanum Myeongjo', serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 메인 (index) ---------- */
/* 문서 스크롤 잠금: 주소창 접힘으로 인한 고정 footer 흔들림 방지 */
body.lock {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
.stage {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(64px + env(safe-area-inset-bottom));
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.branch { width: 120px; height: 48px; margin-bottom: 8px; color: var(--sage); }
.quote-card {
  max-width: 560px;
  width: 100%;
  text-align: center;
}
.quote {
  font-size: clamp(22px, 5.6vw, 30px);
  line-height: 1.72;
  font-weight: 600;
  margin: 18px 0 26px;
  word-break: keep-all;
  white-space: pre-line;
}
.quote, .meta { transition: opacity .3s ease, transform .3s ease; }
.quote.shift-l, .meta.shift-l { opacity: 0; transform: translateX(-28px); }
.quote.shift-r, .meta.shift-r { opacity: 0; transform: translateX(28px); }
.source {
  color: var(--ink-soft);
  font-size: 15px;
  letter-spacing: .02em;
}
.source::before { content: '— '; }
.source:empty::before { content: ''; }
.stars { margin-top: 10px; color: var(--star); font-size: 14px; letter-spacing: .35em; }
.hint {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  height: 32px;
  line-height: 32px;
  text-align: center;
  z-index: 10;
}
.footer-link {
  display: inline-block;
  padding: 0 10px;
  color: var(--olive);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  opacity: .8;
}

/* ---------- 관리 (admin) ---------- */
.wrap { max-width: 640px; margin: 0 auto; padding: 20px 16px 60px; }
h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--olive-deep);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 20px;
}
h1 svg { width: 44px; height: 20px; color: var(--sage); }
a.back { color: var(--ink-soft); text-decoration: none; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}
label { display: block; font-size: 13px; color: var(--ink-soft); margin: 12px 0 6px; }
textarea, input[type="text"], input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 11px 12px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
button {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  padding: 11px 20px;
  background: var(--olive);
  color: #f6f4e9;
  cursor: pointer;
}
button.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
button.small { padding: 6px 12px; font-size: 13px; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.row { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.msg { font-size: 13.5px; color: var(--danger); min-height: 18px; margin-top: 10px; }
.msg.ok { color: var(--olive); }

.star-pick { display: flex; gap: 6px; }
.star-pick button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 16px;
}
.star-pick button.on { border-color: var(--olive); color: var(--olive-deep); background: var(--card); }

.item { padding: 14px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .t { line-height: 1.65; word-break: keep-all; white-space: pre-line; }
.item .s { color: var(--ink-soft); font-size: 13px; margin-top: 6px; }
.item .st { color: var(--star); letter-spacing: .25em; font-size: 12px; }
.item .btns { margin-top: 8px; display: flex; gap: 8px; }
.count { color: var(--ink-soft); font-size: 13px; margin: 4px 2px 10px; }
