:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1d2330;
  --muted: #667085;
  --line: #e3e6ec;
  --accent: #2357d9;
  --accent-ink: #ffffff;
  --reward: #0f8a5f;
  --warn: #b54708;
  --a: #2357d9;
  --b: #c2410c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --surface: #1b2029;
    --ink: #e6e9ef;
    --muted: #98a2b3;
    --line: #2c3340;
    --accent: #6b8ff0;
    --accent-ink: #0b1020;
    --reward: #35c08d;
    --warn: #f79009;
    --a: #6b8ff0;
    --b: #fb923c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* display 를 정한 요소(.overlay 등)도 hidden 속성이면 반드시 숨긴다 */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  padding: 0 16px 40px;
}
h1 { font-size: 20px; margin: 20px 0 2px; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 20px 0 6px; }
.top p { margin: 0 0 16px; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 13px; }
code { font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } }

/* 앱 화면 */
.phone {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px 14px 70px;
  min-height: 640px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.06);
}
.phone-bar { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 8px; }
.group-line { font-size: 12px; color: var(--muted); padding: 0 4px 10px; }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--line); }
.badge.paid { background: var(--reward); color: #fff; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}
.phrase { font-size: 21px; line-height: 1.45; font-weight: 600; margin: 8px 0 10px; }
.situation { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.meaning { font-size: 15px; margin: 0 0 12px; min-height: 48px; }
.row { display: flex; justify-content: space-between; align-items: center; }
.row.gap { gap: 8px; justify-content: flex-start; }
.row.even > * { flex: 1; }
.row.wrap { flex-wrap: wrap; }
button {
  font: inherit;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  margin-top: 8px;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.reward { background: var(--reward); color: #fff; border-color: var(--reward); width: 100%; }
.card > button { width: 100%; }
.ai-out { white-space: pre-line; margin: 10px 0 0; padding: 10px; border-radius: 10px; background: var(--bg); font-size: 14px; }
.confirm { margin-top: 10px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; font-size: 14px; }
.confirm p { margin: 0; }

.overlay {
  position: absolute; inset: 0;
  background: rgb(0 0 0 / 0.45);
  display: flex; align-items: flex-end;
  padding: 14px;
  z-index: 5;
}
.overlay.dark { background: rgb(10 12 18 / 0.92); align-items: center; z-index: 6; }
.sheet { background: var(--surface); border-radius: 16px; padding: 16px; width: 100%; }
.sheet p { font-size: 14px; margin: 0 0 8px; }
.ad-box { width: 100%; color: #fff; text-align: center; }
.ad-box button { background: #2a2f3a; color: #fff; border-color: #444; }
.ad-box button.primary { background: var(--reward); border-color: var(--reward); }
.ad-kind { font-size: 13px; opacity: 0.8; }
.ad-art {
  margin: 14px 0; height: 260px; border-radius: 14px; display: grid; place-items: center;
  font-size: 22px; background: linear-gradient(135deg, #3b4a6b, #6b3b5e);
}
.ad-count { font-size: 14px; min-height: 22px; }
.toast {
  position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 8px 14px; border-radius: 99px; font-size: 13px; z-index: 7; white-space: nowrap;
}

/* 운영자 패널 */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  min-width: 0;
}
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { margin: 0 0 -1px; border-radius: 10px 10px 0 0; border-bottom-color: var(--line); }
.tabs button[aria-selected="true"] { border-color: var(--line); border-bottom-color: var(--surface); font-weight: 600; }
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px 14px;
  margin-bottom: 10px;
}
.grid-form label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.grid-form input, .grid-form select {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-top: 3px;
}
.grid-form .hint { font-size: 12px; color: var(--warn); }
.kv { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.kv strong { color: var(--ink); font-size: 15px; padding-top: 6px; }

.table-wrap { overflow-x: auto; margin-top: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
td.pos { color: var(--reward); }
td.neg { color: var(--warn); }
.callout { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 14px; }
.callout p { margin: 4px 0; }
.status { padding: 10px 12px; border-radius: 10px; background: var(--bg); margin-bottom: 10px; font-size: 14px; }
.chart { width: 100%; height: auto; margin-top: 12px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 6px; }
pre { background: var(--bg); padding: 10px; border-radius: 10px; font-size: 12px; overflow-x: auto; }
.log { font-size: 13px; padding-left: 22px; max-height: 260px; overflow-y: auto; }
.log li { margin-bottom: 3px; }
