:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5f6673;
  --line: #e3e6eb;
  --accent: #1f6feb;
  --accent-soft: #e6efff;
  --price: #0b7a3e;
  --warn: #a15c00;
  --warn-soft: #fff3df;
  --danger: #c62828;
  --naver: #03c75a;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #1b1e24;
    --text: #eceef2;
    --muted: #9aa2af;
    --line: #2c313a;
    --accent: #5b9cff;
    --accent-soft: #1d2b44;
    --price: #4ccf85;
    --warn: #f0b35a;
    --warn-soft: #3a2d17;
    --danger: #ff6b6b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

header.top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: env(safe-area-inset-top);
  margin-bottom: 16px;
}

header.top h1 { font-size: 22px; margin: 0; flex: 1; }

header.top a.back {
  color: var(--accent);
  text-decoration: none;
  font-size: 15px;
  padding: 8px 8px 8px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.muted { color: var(--muted); font-size: 14px; }

button, .button {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  min-height: 46px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button.primary { background: var(--accent); color: #fff; width: 100%; font-weight: 600; }
button.primary:disabled { opacity: 0.6; }
button.secondary { background: var(--accent-soft); color: var(--accent); }
.button.naver { background: var(--naver); color: #fff; font-weight: 600; flex: 1; }
.button.call { background: var(--accent-soft); color: var(--accent); }

input[type="text"], input[type="password"], input[type="search"] {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }

.chips button {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.label { font-size: 14px; font-weight: 600; margin-top: 4px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--line); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tabs button { background: transparent; color: var(--muted); min-height: 40px; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 600; }

.status { margin: 12px 0; font-size: 15px; color: var(--muted); }
.status.error { color: var(--danger); }

.station-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.station-name { font-weight: 600; font-size: 17px; }
.station-price { color: var(--price); font-weight: 700; font-size: 22px; white-space: nowrap; }
.station-meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.stale { background: var(--warn-soft); color: var(--warn); }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.rank { color: var(--muted); font-weight: 600; margin-right: 6px; }

.place-list { display: grid; gap: 6px; margin-top: 8px; }
.place-list button {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  text-align: left;
  display: block;
  width: 100%;
}
.place-list .addr { display: block; color: var(--muted); font-size: 13px; }

.chosen { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  min-height: 96px;
  color: var(--text);
  text-decoration: none;
}
.tool strong { display: block; font-size: 16px; }
.tool span { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.tool.soon { opacity: 0.55; pointer-events: none; }
.group-title { font-size: 14px; color: var(--muted); font-weight: 600; margin: 20px 0 8px; }
.hidden { display: none !important; }

.saved-head { display: flex; justify-content: space-between; align-items: center; }
button.link { background: none; color: var(--accent); min-height: 32px; padding: 4px 0; font-size: 14px; }
.chips button.saved .remove { margin-left: 6px; color: var(--danger); font-weight: 700; }
.save-form { display: flex; gap: 8px; margin-top: 8px; }
.save-form input { flex: 1; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.quick a { font-size: 14px; padding: 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-decoration: none; }

.level { display: inline-block; font-weight: 700; border-radius: 999px; padding: 2px 10px; font-size: 14px; }
.level-여유 { background: #e3f6ea; color: #0b7a3e; }
.level-보통 { background: #fff4d6; color: #8a6100; }
.level-약간붐빔 { background: #ffe6d1; color: #b44d00; }
.level-붐빔 { background: #ffe0e0; color: #c62828; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .level-여유 { background: #173a26; color: #6fdc9b; }
  :root:not([data-theme="light"]) .level-보통 { background: #3a3116; color: #f2cc5b; }
  :root:not([data-theme="light"]) .level-약간붐빔 { background: #3d2715; color: #ffab66; }
  :root:not([data-theme="light"]) .level-붐빔 { background: #3d1c1c; color: #ff8a8a; }
}
.fav-list { display: grid; gap: 8px; margin: 8px 0 16px; }
.fav-list button {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); text-align: left;
}
.density-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.density-head h2 { font-size: 20px; margin: 0; }
.density-big { font-size: 26px; font-weight: 700; margin: 10px 0 2px; }
.star { background: none; color: var(--muted); font-size: 24px; min-height: 40px; padding: 4px 8px; }
.star[aria-pressed="true"] { color: #f5a623; }
.forecast { display: grid; gap: 6px; margin-top: 8px; }
.fc-row { display: grid; grid-template-columns: 44px 1fr 90px; gap: 8px; align-items: center; font-size: 14px; }
.fc-bar { height: 14px; border-radius: 7px; background: var(--line); overflow: hidden; }
.fc-bar span { display: block; height: 100%; border-radius: 7px; }
.fc-bar .level-여유 { background: #2fb36b; }
.fc-bar .level-보통 { background: #e8b400; }
.fc-bar .level-약간붐빔 { background: #f07b1d; }
.fc-bar .level-붐빔 { background: #e53935; }
.fc-row .fc-num { color: var(--muted); text-align: right; }
.fc-row.best { font-weight: 700; }
.hint { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: 15px; }

.date-input { font: inherit; width: 100%; padding: 10px 14px; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.room { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.room:first-of-type { border-top: 0; }
.room .cap { color: var(--muted); white-space: nowrap; }
.forest-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.forest-head h2 { font-size: 18px; margin: 0; }
