/* 한 줄 개념: 휴대폰 한 손으로 위에서 아래로 — 이름 → 시간 → 출발역 → 결과 */
:root {
  --bg: #f3f5f4;
  --card: #ffffff;
  --ink: #18201d;
  --muted: #5f6b66;
  --line: #dde3e0;
  --accent: #0e6e5c;        /* 확정·가능(○) */
  --accent-soft: #d6ece6;
  --maybe: #c98510;         /* 애매(△) */
  --maybe-soft: #f7e7c6;
  --no: #b9c2be;
  --danger: #b4412f;
  --font: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101513;
    --card: #19211e;
    --ink: #e7ece9;
    --muted: #97a39e;
    --line: #2a3531;
    --accent: #3cbf9f;
    --accent-soft: #173a31;
    --maybe: #e3a63a;
    --maybe-soft: #3a2e15;
    --no: #44504b;
    --danger: #e67a66;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top, .wrap {
  max-width: 560px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top { display: flex; align-items: center; justify-content: space-between; padding-block: 18px 6px; }
.brand { font-weight: 700; font-size: 19px; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.mode-badge { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--maybe-soft); color: var(--maybe); font-weight: 600; }
.wrap { padding-block: 8px 64px; display: flex; flex-direction: column; gap: 16px; }
.loading { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

h1 { font-size: 24px; line-height: 1.3; margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
.sub { color: var(--muted); font-size: 14px; }
.label { font-size: 12px; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
}
.step-head { display: flex; align-items: baseline; gap: 10px; }
.step-no { font-size: 12px; font-weight: 700; color: var(--accent); }

input[type="text"], input[type="search"], .select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 16px;
}
input[type="text"]:focus, input[type="search"]:focus { border-color: var(--accent); outline: none; }
.select { width: auto; padding: 10px 12px; font-size: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card);
  padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 14px;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); padding: 14px; font-size: 16px; width: 100%; }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 선택 칩 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card);
  padding: 8px 14px; border-radius: 99px; font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* 달력 */
.cal-nav { display: flex; align-items: center; justify-content: space-between; }
.cal-nav strong { font-size: 15px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; column-gap: 0; text-align: center; user-select: none; -webkit-user-select: none; }
.cal .dow { font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.cal .dow.sun, .cal .day.sun { color: var(--danger); }
.cal .dow.sat, .cal .day.sat { color: #3a6fb5; }
.cal .day {
  height: 52px; max-width: 100%; min-width: 0;
  border: 0; background: transparent; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 15px; font-variant-numeric: tabular-nums; line-height: 1.1;
  touch-action: none; -webkit-touch-callout: none;
}
.cal .day .ds { font-size: 10px; font-weight: 600; min-height: 11px; }
.cal .day:disabled { opacity: .28; cursor: default; }
.cal .day.out { opacity: .22; }

/* 모임장: 기간 (숙소 예약처럼 띠로 표시) */
.cal .day.in { background: var(--accent-soft); border-radius: 0; color: var(--ink); }
.cal .day.in.start { border-radius: 10px 0 0 10px; }
.cal .day.in.end { border-radius: 0 10px 10px 0; }
.cal .day.in.start.end { border-radius: 10px; }
.cal .day.in.start .dn, .cal .day.in.end .dn {
  background: var(--accent); color: #fff; font-weight: 700;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
}
.cal .day.in.off { color: var(--muted); text-decoration: line-through; }

/* 멤버: 되는 날 칠하기 */
.cal .day.cand { background: var(--bg); border: 1px solid var(--line); margin: 0 2px; width: calc(100% - 4px); }
.cal .day.cand.busy { background: repeating-linear-gradient(135deg, var(--bg) 0 6px, var(--line) 6px 7px); }
.cal .day.cand.busy .ds { color: var(--danger); }
.cal .day.v { margin: 0 2px; width: calc(100% - 4px); color: #fff; font-weight: 700; background: var(--accent); }
.cal .day .ds { white-space: pre-line; }
.cal .day.v .ds { font-size: 10.5px; letter-spacing: -0.02em; }
.cal .day.v.two { gap: 0; }
.cal .day.v.two .dn { font-size: 13px; }
.cal .day.v.two .ds { font-size: 9.5px; line-height: 1.15; }
/* 고른 날 목록 (늦게 오는 날만 시간 바꾸기) */
.day-list { display: flex; flex-direction: column; gap: 6px; }
.day-list:empty { display: none; }
.day-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.day-row.all { background: var(--bg); border-radius: 10px; border-top: 0; padding: 8px 10px; }
.day-row .dl { font-weight: 700; font-size: 14px; min-width: 64px; font-variant-numeric: tabular-nums; }
.day-row .pl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.select.small { padding: 6px 8px; font-size: 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }

/* 결과: 시작 시간 두 안 + 확정 */
.opts { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.opt.chosen { background: var(--accent-soft); }
.opt-t { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.place.chosen { background: var(--accent-soft); border-radius: 10px; padding: 12px; }
.card.final { background: var(--accent); border-color: var(--accent); color: #fff; }
.card.final .label, .card.final .note { color: #fff; opacity: .85; }
.card.final .btn { color: #fff; border-color: rgba(255,255,255,.5); }
.final-line { font-weight: 700; color: var(--accent); }
.brush-row { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; }
.brush-p { font-size: 13px; font-weight: 700; color: var(--muted); }
.cal .day.vB { background: var(--accent); }
.cal .day.vL { background: linear-gradient(180deg, var(--accent) 0 50%, var(--accent-soft) 50%); color: var(--ink); }
.cal .day.vL .dn { color: #fff; }
.cal .day.vD { background: linear-gradient(180deg, var(--accent-soft) 0 50%, var(--accent) 50%); color: #fff; }
.cal .day.vD .dn { color: var(--ink); }

/* 가능 시간 표 */
.grid-wrap { overflow-x: auto; margin: 0 -4px; }
table.avail { border-collapse: separate; border-spacing: 4px; width: 100%; }
table.avail th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; white-space: nowrap; }
table.avail th.date { text-align: left; font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; padding-right: 4px; }
table.avail th.date .wd { color: var(--muted); font-weight: 400; }
.cell {
  width: 100%; min-width: 54px; height: 44px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg);
  font-size: 18px; font-weight: 700;
}
.cell[data-v="2"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.cell[data-v="1"] { background: var(--maybe-soft); border-color: var(--maybe); color: var(--maybe); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend b { display: inline-block; width: 18px; height: 18px; border-radius: 5px; vertical-align: -4px; margin-right: 4px; text-align: center; font-size: 12px; line-height: 18px; }
.legend .o { background: var(--accent); color: #fff; }
.legend .m { background: var(--maybe-soft); color: var(--maybe); }
.legend .x { background: var(--bg); border: 1px solid var(--line); }

/* 역 검색 */
.station-pick { display: flex; flex-direction: column; gap: 8px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.picked { display: flex; align-items: center; gap: 10px; }

/* 역 이름표 (지하철 표지판 느낌) */
.sign {
  display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid var(--accent); border-radius: 99px;
  padding: 3px 12px 3px 4px; font-weight: 700; background: var(--card);
  white-space: nowrap;
}
.sign::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--accent); box-sizing: border-box;
}
.sign.big { font-size: 20px; padding: 5px 16px 5px 6px; }
.sign.big::before { width: 20px; height: 20px; border-width: 4px; }

/* 탭 */
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.tabs button { border: 0; background: transparent; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); }

/* 공유 상자 */
.share { background: var(--accent-soft); border: 0; }
.share .url { font-size: 13px; word-break: break-all; color: var(--muted); user-select: all; }

/* 결과 */
.best { display: flex; flex-direction: column; gap: 10px; }
.slot-rank { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.slot-rank:first-child { border-top: 0; padding-top: 0; }
.slot-rank .rk { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.slot-rank.top .rk { color: var(--accent); }
.slot-rank .when { font-weight: 700; font-size: 16px; }
.slot-rank .who { font-size: 13px; color: var(--muted); }
.slot-rank .cnt { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.slot-rank .cnt strong { font-size: 20px; color: var(--ink); }
.bar { height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; display: flex; margin-top: 4px; }
.bar i { display: block; height: 100%; }
.bar .o { background: var(--accent); }
.bar .m { background: var(--maybe); }

.heat td { text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; border-radius: 8px; height: 36px; min-width: 50px; }

.place { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.place:first-of-type { border-top: 0; padding-top: 0; }
.place .meta { font-size: 13px; color: var(--muted); }
.dist-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.dist-list div { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.dist-list span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); }
details summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 600; }

.mapbox { background: var(--bg); border-radius: 10px; }
.mapbox svg { display: block; width: 100%; height: auto; }
.mapbox .pt { fill: var(--ink); }
.mapbox .pt-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.mapbox .rec { fill: var(--accent); }
.mapbox .rec-label { fill: var(--accent); font-size: 13px; font-weight: 700; font-family: var(--font); }
.mapbox .ray { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; }

.people { display: flex; flex-direction: column; }
.person { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; }
.person .nm { font-weight: 600; }
.person .me { font-size: 11px; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }

.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.note { font-size: 12px; color: var(--muted); }
.err { color: var(--danger); font-size: 14px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 99px; font-size: 14px; font-weight: 600;
  max-width: calc(100% - 32px);
}
[hidden] { display: none !important; }

/* ── v2 추가 ── */
.stack-xs { display: flex; flex-direction: column; gap: 2px; text-align: left; min-width: 0; }
.row.tight { gap: 6px; flex-wrap: nowrap; }
.row.between { justify-content: space-between; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.wide { width: 100%; padding: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.chip:disabled { opacity: .4; cursor: default; }
.cal .day.today { box-shadow: inset 0 0 0 1px var(--line); }
.sun { color: var(--danger); }
.sat { color: #3a6fb5; }
summary { list-style-position: inside; }
details.card > summary { font-weight: 600; color: var(--ink); font-size: 15px; }

/* 날짜별 시간 고르기 (네이버 예약처럼 시간 버튼) */
.day-block { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.day-block:first-child { border-top: 0; padding-top: 0; }
.day-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.day-head strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.day-head .note { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hours { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; user-select: none; }
.hour {
  border: 1px solid var(--line); background: var(--bg); border-radius: 9px;
  height: 46px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.hour small { font-size: 10px; font-weight: 600; color: var(--danger); margin-top: 2px; }
.hour.busy { background: repeating-linear-gradient(135deg, var(--bg) 0 6px, var(--line) 6px 7px); }
.hour[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.hour[aria-pressed="true"] small { color: #fff; opacity: .85; }
.gcal { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 10px; background: var(--accent-soft); }
.gcal .btn { align-self: flex-start; }

/* 출발지 */
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin-top: 6px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.choice-list { display: flex; flex-direction: column; gap: 6px; }
.choice {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px; text-align: left;
}
.choice:hover { border-color: var(--accent); }

/* 결과 */
.who.dim { opacity: .75; }
.heat-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.heat-row { display: flex; flex-direction: column; gap: 4px; }
.heat-day { font-size: 13px; font-weight: 600; }
.heat-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(26px, 1fr); gap: 2px; overflow-x: auto; }
.heat-cell { border-radius: 5px; height: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; line-height: 1.1; }
.heat-cell .hh { font-size: 10px; opacity: .8; }
.heat-cell .nn { font-size: 13px; font-weight: 700; }
.map { width: 100%; height: 260px; border-radius: 10px; overflow: hidden; background: var(--bg); }
.map-label {
  background: #fff; color: #18201d; border: 1px solid #c9d2ce; border-radius: 8px;
  padding: 3px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; font-family: var(--font);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.map-label.rec { border-color: #0e6e5c; color: #0e6e5c; }
.credit { font-size: 11px; color: var(--muted); opacity: .8; }
.after-block { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.sign.after { border-color: var(--maybe); border-style: dashed; }
.sign.after::before { border-color: var(--maybe); }
.map-label.after { border-color: #c98510; color: #8a5a06; border-style: dashed; }
.map-label.rec.top { background: #0e6e5c; color: #fff; font-size: 14px; }
.person.link { color: inherit; text-decoration: none; }

/* ── v3 추가 ── */
.calendar { display: flex; flex-direction: column; gap: 10px; }
.range-note { font-size: 15px; }
.chip.small { padding: 6px 11px; font-size: 13px; }
.chip.ghost { border-style: dashed; }
.chip.sun { color: var(--danger); }
.chip.sat { color: #3a6fb5; }
.chip[aria-pressed="true"].sun, .chip[aria-pressed="true"].sat { color: #fff; }
.chip.tag { display: inline-flex; align-items: center; gap: 4px; padding-right: 6px; background: var(--accent-soft); border-color: transparent; }
.chip.tag .x { border: 0; background: transparent; font-size: 16px; line-height: 1; padding: 0 4px; color: var(--muted); }
.chip .done { color: var(--accent); font-weight: 700; }
.chip[aria-pressed="true"] .done { color: #fff; }
.time-block { display: flex; flex-direction: column; gap: 8px; }
.brush { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.chip.brush-L[aria-pressed="true"] { background: linear-gradient(180deg, var(--accent) 0 50%, #2f8f7b 50%); }
.table-wrap { overflow-x: auto; margin-top: 10px; }
.day-table { border-collapse: separate; border-spacing: 3px; width: 100%; font-variant-numeric: tabular-nums; }
.day-table th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; }
.day-table th[scope="row"] { text-align: left; color: var(--ink); font-size: 13px; white-space: nowrap; }
.day-table td { text-align: center; border-radius: 6px; height: 30px; font-size: 13px; font-weight: 600; min-width: 48px; }

@media (prefers-reduced-motion: no-preference) {
  .cell, .chip, .cal .day { transition: background-color .12s, color .12s; }
}
