:root {
  --bg: #f4f7f8;
  --card: #ffffff;
  --text: #0f1f24;
  --muted: #5d6f75;
  --line: #e1e8ea;
  --brand: #0e7490;
  --brand-soft: #e0f2f6;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --ok: #18794e;
  --ok-soft: #e3f5ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 31 36 / 6%), 0 2px 8px rgb(15 31 36 / 5%);
  --tabbar-h: 62px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1416;
    --card: #152125;
    --text: #e8f0f2;
    --muted: #93a6ab;
    --line: #24343a;
    --brand: #38bdd8;
    --brand-soft: #123039;
    --danger: #ff8a7a;
    --danger-soft: #3a1714;
    --warn: #ffc65c;
    --warn-soft: #362810;
    --ok: #5fd39a;
    --ok-soft: #12301f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

a { color: var(--brand); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.topbar h1 { font-size: 18px; margin: 0; }
.status { font-size: 12px; color: var(--muted); text-align: right; }

.view { max-width: 640px; margin: 0 auto; padding: 12px 16px 24px; outline: none; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
}
.tabbar a span { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: 0.7; }
.tabbar a.active { color: var(--brand); font-weight: 600; }
.tabbar a.active span { filter: none; opacity: 1; }

h2 { font-size: 20px; margin: 18px 0 8px; }
h3 { font-size: 16px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 24px 0; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 14px;
  margin: 10px 0;
}

.hero {
  background: linear-gradient(135deg, #0e7490, #0891b2 55%, #f59e0b);
  color: #fff;
  border: 0;
}
.hero .muted { color: rgb(255 255 255 / 85%); }
.hero h2 { margin: 2px 0 6px; font-size: 22px; }
.hero .big { font-size: 34px; font-weight: 700; line-height: 1.1; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.item { display: grid; grid-template-columns: 58px 1fr; gap: 10px; }
.item .time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.item .time small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.item .title { font-weight: 600; }
.item .place { color: var(--muted); font-size: 14px; }
.item.past { opacity: 0.55; }
.item.next { outline: 2px solid var(--brand); outline-offset: -1px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  overflow-wrap: anywhere;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

.notes { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.notes li { padding: 6px 10px; border-radius: 10px; margin-top: 4px; background: var(--brand-soft); }
.notes li.warn { background: var(--warn-soft); color: var(--warn); }
.notes li.danger { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.notes li.info { background: transparent; color: var(--muted); padding: 2px 10px; }

.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-height: 40px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn:disabled { opacity: 0.5; }
.btn.block { width: 100%; justify-content: center; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  text-decoration: none;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.weather { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.weather .icon { font-size: 40px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.field { display: block; margin: 10px 0; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; }
ol.steps { padding-left: 20px; }
ol.steps li { margin: 6px 0; }
.error { color: var(--danger); }
details summary { cursor: pointer; color: var(--brand); font-size: 14px; }

/* ── 일정 편집 폼 ── */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset:disabled { opacity: 0.6; }
.req { color: var(--danger); font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); margin: -4px 0 8px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 10px; }
.grid2 > * { min-width: 0; }
.field input, .field select { min-width: 0; max-width: 100%; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1; min-width: 0; }
.field textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  resize: vertical;
}
/* iOS: 16px 미만이면 입력 시 화면이 확대됨 */
.field input, .field select, .field textarea { font-size: 16px; min-height: 44px; }
.field input[type="date"], .field input[type="time"], .field input[type="datetime-local"] { -webkit-appearance: none; appearance: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip.check { cursor: pointer; user-select: none; position: relative; overflow: hidden; }
.chip.check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.chip.check:has(input:checked) { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.check:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--brand); }
.reserve-box { border-left: 3px solid var(--warn-soft); padding-left: 10px; margin-bottom: 6px; }
.danger-btn { color: var(--danger); border-color: var(--danger-soft); margin-top: 8px; }
.notice { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-size: 14px; }
.add-btn { border-style: dashed; color: var(--brand); margin: 10px 0; }
#place-found a { font-size: 12px; }
