/* Layout: 상단 요약 → 날짜 탭 → 2열(왼쪽 시간표, 오른쪽 고정 지도). 좁은 화면에서는 지도가 시간표 위로 올라온다. */
:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --fg: #1a2340;
  --muted: #5b6684;
  --line: #d9dfea;
  --lantern: #d4452a;
  --lantern-soft: #fbe6e0;
  --glow: #2b6cb0;
  --glow-soft: #e1ecf8;
  --on-fg: #f2f5f9;
  --font-body: "Noto Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1527;
    --surface: #172038;
    --fg: #e8ecf6;
    --muted: #9aa5c2;
    --line: #2a3555;
    --lantern: #ff7a5c;
    --lantern-soft: #3a2226;
    --glow: #7db4f0;
    --glow-soft: #1b2c4a;
    --on-fg: #0e1527;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1527;
  --surface: #172038;
  --fg: #e8ecf6;
  --muted: #9aa5c2;
  --line: #2a3555;
  --lantern: #ff7a5c;
  --lantern-soft: #3a2226;
  --glow: #7db4f0;
  --glow-soft: #1b2c4a;
  --on-fg: #0e1527;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 56px;
  word-break: keep-all;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--bg);
}

.wrap {
  max-width: 1680px;
  margin: 0 auto;
}

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

h1,
h2,
h3 {
  text-wrap: balance;
  margin: 0;
  line-height: 1.25;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
svg [tabindex]:focus-visible {
  outline: 2px solid var(--glow);
  outline-offset: 2px;
}

/* header */
header {
  padding: 28px 0 16px;
  display: grid;
  gap: 12px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--lantern);
  text-transform: uppercase;
}

h1 {
  font-size: clamp(32px, 8vw, 48px);
  font-weight: 900;
  letter-spacing: -.02em;
}

.toprow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.toprow .dates {
  color: var(--muted);
}

.toprow .dates strong {
  color: var(--fg);
}

#dday {
  font-family: var(--font-mono);
  background: var(--lantern);
  color: var(--surface);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
}

.spacer {
  flex: 1;
}

#saveState {
  font-size: 12px;
  color: var(--muted);
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.4;
}

.btn.primary {
  background: var(--fg);
  color: var(--on-fg);
  border-color: var(--fg);
  font-weight: 700;
}

.btn.danger {
  color: var(--lantern);
}

.btn.small {
  padding: 3px 9px;
  font-size: 13px;
}

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.facts div {
  background: var(--surface);
  padding: 10px 14px;
  min-width: 0;
}

.facts dt {
  font-size: 12px;
  color: var(--muted);
}

.facts dd {
  margin: 2px 0 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* tabs */
nav {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: var(--bg);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

nav button {
  width: 100%;
  text-align: center;
  padding: 7px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.3;
}

nav button b {
  display: block;
  font-family: var(--font-mono);
  font-size: 14px;
}

nav button span {
  font-size: 12px;
  color: var(--muted);
}

nav button[aria-current="true"] {
  background: var(--fg);
  color: var(--on-fg);
  border-color: var(--fg);
}

nav button[aria-current="true"] span {
  color: inherit;
  opacity: .75;
}

/* board */
.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  padding-top: 24px;
  align-items: start;
}

@media (max-width: 860px) {
  .board {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .mapcard {
    order: -1;
    position: static !important;
    height: auto !important;
  }

  .mapbox {
    height: 340px !important;
  }
}

.day-head {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.day-head .when {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.day-head h2 {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.01em;
}

.day-head p {
  margin: 0;
  color: var(--muted);
}

ol.stops {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--fg);
}

.stop {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 0 12px;
  padding: 13px 8px;
  border-bottom: 1px solid var(--line);
}

.stop.sel {
  background: var(--glow-soft);
  border-radius: 6px;
}

.num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--fg);
  color: var(--on-fg);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 0;
  display: grid;
  place-items: center;
}

.num.noloc {
  background: transparent;
  color: var(--muted);
  border: 1.5px dashed var(--muted);
}

.stop.sel .num {
  background: var(--lantern);
  color: var(--surface);
  border: 0;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.tag {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tag[data-tag="식사"],
.tag[data-tag="쇼핑"] {
  background: var(--lantern-soft);
  border-color: transparent;
  color: var(--lantern);
}

.tag[data-tag="야경"],
.tag[data-tag="관광"] {
  background: var(--glow-soft);
  border-color: transparent;
  color: var(--glow);
}

.stop h3 {
  font-size: 16px;
  font-weight: 700;
  margin-top: 2px;
  cursor: pointer;
}

.stop p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.stop a.ml {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
}

.empty {
  padding: 20px 8px;
  color: var(--muted);
}

/* edit fields */
.f {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  min-width: 0;
}

textarea.f {
  resize: vertical;
}

.efields {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.row2 {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 6px;
}

.acts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.acts select {
  width: auto;
  max-width: 100%;
}

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

.addrow {
  padding: 14px 0 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.dayedit {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.dayedit .f.t {
  font-size: 18px;
  font-weight: 700;
}

/* map */
.mapcard {
  position: sticky;
  top: calc(76px + env(safe-area-inset-top, 0px));
  height: calc(100vh - 96px - env(safe-area-inset-top, 0px));
  min-height: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 0;
}

.maphead {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

.maphead strong {
  margin-right: auto;
  font-size: 14px;
}

.mapcard .cap {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

/* extras */
section.block {
  padding-top: 44px;
}

section.block>h2 {
  font-size: 21px;
  font-weight: 900;
  margin-bottom: 6px;
}

section.block>p.lead {
  margin: 0 0 14px;
  color: var(--muted);
}

.scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

tr:last-child td {
  border-bottom: 0;
}

td.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
}

.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 28px;
}

.check {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.check li {
  background: var(--surface);
}

.check label {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  align-items: start;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--lantern);
}

.check small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.check input:checked+span {
  color: var(--muted);
  text-decoration: line-through;
}

.check input:checked+span small {
  text-decoration: none;
}

.notes {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.notes li::marker {
  color: var(--lantern);
}

.confirm {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--lantern);
  border-radius: 8px;
  background: var(--lantern-soft);
}

footer {
  margin-top: 44px;
  color: var(--muted);
  font-size: 12px;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
}

.mapbox {
  min-height: 0;
  position: relative;
}

#gmap {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
}

.gmk {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--fg);
  color: var(--on-fg);
  font: 500 13px var(--font-mono);
  display: grid;
  place-items: center;
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  cursor: pointer;
}

.gmk.sel {
  background: var(--lantern);
  color: var(--surface);
  transform: scale(1.18);
}

/* 지도 위 소요 시간 표시 */
.rlabel {
  background: #fff;
  color: #1a2340;
  border: 1px solid #9aa5c2;
  border-radius: 6px;
  padding: 1px 7px;
  font: 700 12px var(--font-body);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  cursor: pointer;
  white-space: nowrap;
}

.rlabel.sel {
  background: #0b57d0;
  color: #fff;
  border-color: #0b57d0;
  font-size: 14px;
}

/* 이동 경로 */
.leg .modes {
  margin: 0 0 4px;
  color: var(--fg);
}

.leg a {
  display: inline-block;
  margin-top: 6px;
}

.leg .man {
  margin: 4px 0 0;
  color: var(--fg);
}

.embed {
  display: block;
  width: 100%;
  height: 340px;
  border: 0;
  border-radius: 8px;
  margin-top: 8px;
}

.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.leg {
  list-style: none;
  padding: 7px 8px 7px 50px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.leg:empty {
  display: none;
}

.leg summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--fg);
}

.leg ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.leg p {
  margin: 4px 0 0;
}

.chip {
  display: inline-block;
  padding: 0 7px;
  border-radius: 4px;
  font: 700 12px var(--font-body);
}

.daysum {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.daysum:empty {
  display: none;
}

.err {
  color: var(--lantern);
}

.gmsg {
  margin: 0;
  color: var(--lantern);
  font-size: 13px;
}

/* 장소 검색 */
.searchrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.res {
  display: grid;
  gap: 4px;
}

.res:empty {
  display: none;
}

.res .btn {
  text-align: left;
}