:root {
  color-scheme: light dark;
  --bg: #f4f4ef;
  --surface: #ffffff;
  --surface-soft: #e7efed;
  --text: #172221;
  --muted: #61706e;
  --line: #ccd8d5;
  --accent: #0b4f52;
  --accent-strong: #083d3f;
  --accent-soft: #d5e8e4;
  --warm: #b94a2e;
  --shadow: 0 14px 38px rgba(9, 51, 51, 0.12);
  --radius: 18px;
  --nav-height: 78px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.auth-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: linear-gradient(155deg, #0b4f52 0 42%, #143e40 42% 58%, #f4f4ef 58%); }
.auth-card { width: min(100%, 430px); padding: 30px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: #f5f7f4; font-weight: 900; font-size: 27px; }
.eyebrow, .topbar-kicker { margin: 20px 0 7px; color: var(--warm); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; }
.auth-card h1 { margin: 0; max-width: 10ch; font-size: clamp(32px, 9vw, 46px); line-height: 1.08; letter-spacing: -0.045em; }
.auth-copy { margin: 18px 0 25px; color: var(--muted); line-height: 1.65; }
.auth-form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 14px; font-weight: 750; }
.field input { width: 100%; padding: 13px 14px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; outline: none; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field small { color: var(--muted); }
.form-error { margin: 0; color: #a22e21; font-weight: 700; }
.invite-notice { padding: 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }

.button { min-height: 44px; padding: 11px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 800; transition: transform 140ms ease, background 140ms ease; }
.button:active { transform: scale(0.98); }
.button.primary { border-color: var(--accent); background: var(--accent); color: #f5f7f4; }
.button.secondary { color: var(--accent); border-color: var(--accent); }
.button.danger { color: #9d2f23; border-color: #d8aaa3; }
.button.wide { width: 100%; }
.button:disabled { opacity: 0.55; cursor: not-allowed; }

.app-shell { width: min(100%, 1100px); min-height: 100dvh; margin: 0 auto; padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); background: var(--bg); }
.topbar { height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; position: sticky; top: 0; z-index: 500; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(15px); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -0.04em; }
.topbar-kicker { margin: 0 0 2px; font-size: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.sync-state { color: var(--muted); font-size: 12px; }
.avatar-button { width: 42px; height: 42px; border: 0; border-radius: 13px; background: var(--accent); color: #f5f7f4; font-weight: 900; }
.view { padding: 18px 16px 30px; outline: none; }
.bottom-nav { position: fixed; left: 50%; bottom: 0; z-index: 600; transform: translateX(-50%); width: min(100%, 1100px); min-height: var(--nav-height); padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(18px); }
.nav-button { display: grid; place-items: center; align-content: center; gap: 4px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.nav-button.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-symbol { font-size: 10px; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }

.hero-panel { padding: 22px; border-radius: var(--radius); background: var(--accent); color: #f5f7f4; box-shadow: var(--shadow); }
.hero-panel .date { margin: 0 0 6px; color: #b9d8d4; font-size: 13px; font-weight: 800; }
.hero-panel h2 { margin: 0; font-size: clamp(27px, 7vw, 40px); line-height: 1.1; letter-spacing: -0.045em; }
.hero-panel p { margin: 12px 0 0; max-width: 55ch; color: #dceae7; line-height: 1.55; }
.day-strip { margin: 16px -16px 18px; padding: 0 16px 4px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.day-strip::-webkit-scrollbar { display: none; }
.day-chip { min-width: 72px; padding: 10px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); text-align: center; }
.day-chip strong { display: block; color: var(--text); font-size: 16px; }
.day-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }

.section-heading { margin: 24px 0 12px; display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.section-heading h2, .section-heading h3 { margin: 0; letter-spacing: -0.035em; }
.section-heading p { margin: 5px 0 0; color: var(--muted); }
.presentation-control { margin: 14px 0; padding: 14px; display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.presentation-control p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.presentation-control select { min-height: 46px; width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-weight: 750; }
.timeline { position: relative; display: grid; gap: 2px; }
.timeline::before { content: ""; position: absolute; left: 24px; top: 22px; bottom: 22px; width: 2px; background: var(--line); }
.timeline-item { position: relative; display: grid; grid-template-columns: 50px 1fr; gap: 10px; padding: 10px 0; }
.timeline-time { position: relative; z-index: 1; width: 50px; min-height: 36px; display: grid; place-items: center; align-self: start; padding: 4px; border-radius: 10px; background: var(--surface-soft); color: var(--accent-strong); font-size: 11px; font-weight: 850; text-align: center; }
.timeline-content { padding: 14px 15px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.timeline-content h3 { margin: 0 0 5px; font-size: 17px; }
.timeline-content p { margin: 0; color: var(--muted); line-height: 1.5; }
.meta-row { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 7px; }
.tag { padding: 5px 8px; border-radius: 8px; background: var(--surface-soft); color: var(--accent-strong); font-size: 11px; font-weight: 800; }
.place-link { padding: 0; border: 0; background: none; color: var(--accent); font-weight: 850; text-decoration: underline; text-underline-offset: 3px; }

.map-toolbar { display: grid; gap: 11px; margin-bottom: 12px; }
.map-shell { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
#trip-map { height: min(62dvh, 610px); min-height: 390px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 12px 14px; color: var(--muted); font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-line { width: 22px; height: 4px; border-radius: 3px; background: var(--accent); }
.legend-line.walk { background: repeating-linear-gradient(90deg, var(--warm) 0 5px, transparent 5px 9px); }
.legend-line.ferry { background: #2f74a6; }
.legend-line.car { background: #735c9e; }
.map-empty { min-height: 390px; display: grid; place-items: center; padding: 30px; color: var(--muted); text-align: center; }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.map-popup h3 { margin: 0 0 5px; }
.map-popup button { margin-top: 7px; }

.day-section { margin-bottom: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.day-section summary { list-style: none; padding: 17px; cursor: pointer; }
.day-section summary::-webkit-details-marker { display: none; }
.day-summary-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.day-summary-line strong { font-size: 18px; letter-spacing: -0.025em; }
.day-summary-line span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.day-section summary p { margin: 7px 0 0; color: var(--muted); line-height: 1.45; }
.day-section[open] summary { background: var(--accent-soft); }
.day-events { padding: 5px 17px 15px; }
.day-event { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.day-event:last-child { border-bottom: 0; }
.day-event time { color: var(--accent); font-weight: 850; font-size: 12px; }
.day-event h4 { margin: 0 0 4px; }
.day-event p { margin: 0; color: var(--muted); line-height: 1.45; }

.progress-panel { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; padding: 18px; border-radius: var(--radius); background: var(--accent); color: #f5f7f4; }
.progress-number { font-size: 34px; font-weight: 900; letter-spacing: -0.05em; }
.progress-panel p { margin: 2px 0 0; color: #d4e8e5; }
.check-group { margin-top: 21px; }
.check-group h3 { margin: 0 0 9px; color: var(--muted); font-size: 13px; }
.check-list { display: grid; gap: 8px; }
.check-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; min-height: 58px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.check-row input { width: 21px; height: 21px; accent-color: var(--accent); }
.check-row label { line-height: 1.4; font-weight: 680; }
.check-scope { color: var(--muted); font-size: 11px; }
.check-row.done label { color: var(--muted); text-decoration: line-through; }

.sheet-dialog { width: min(calc(100% - 24px), 520px); max-height: 88dvh; padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow); overflow: auto; }
.sheet-dialog::backdrop { background: rgba(3, 22, 22, 0.58); backdrop-filter: blur(3px); }
.dialog-close { position: sticky; top: 10px; z-index: 2; float: right; margin: 10px 10px 0 0; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 800; }
.place-photo { width: 100%; aspect-ratio: 16 / 10; display: block; object-fit: cover; background: var(--surface-soft); }
.place-copy, .account-content { padding: 20px; }
.place-copy h2, .account-content h2 { margin: 0 0 4px; font-size: 28px; letter-spacing: -0.04em; }
.place-copy .local-name { color: var(--muted); }
.place-copy .description { margin: 17px 0; line-height: 1.6; }
.place-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-credit { margin-top: 12px; color: var(--muted); font-size: 11px; }
.account-meta { margin: 16px 0; padding: 14px; border-radius: 13px; background: var(--surface-soft); }
.account-actions { display: grid; gap: 9px; }
.invite-result { margin-top: 14px; padding: 13px; border-radius: 12px; background: var(--accent-soft); word-break: break-all; }
.invite-result strong { display: block; margin-bottom: 5px; }

.toast-region { position: fixed; top: 82px; left: 50%; z-index: 1000; transform: translateX(-50%); width: min(calc(100% - 28px), 430px); display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 12px 14px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-weight: 700; }
.loading-block { min-height: 55dvh; display: grid; place-items: center; color: var(--muted); }
.offline-banner { margin-bottom: 12px; padding: 12px 14px; border-radius: 12px; background: #f3dfd8; color: #6f2b20; font-weight: 750; }
.empty-state { padding: 30px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }

@media (min-width: 760px) {
  .view { padding: 25px 28px 40px; }
  .today-layout { display: grid; grid-template-columns: minmax(300px, 0.8fr) minmax(420px, 1.2fr); gap: 24px; align-items: start; }
  .today-layout .hero-column { position: sticky; top: 96px; }
  .day-strip { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .itinerary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .day-section { margin: 0; }
  .bottom-nav { left: auto; right: 18px; bottom: 18px; transform: none; width: auto; min-height: 62px; grid-template-columns: repeat(4, 112px); padding: 6px; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
  .app-shell { padding-bottom: 40px; }
  .nav-button { grid-template-columns: auto auto; gap: 8px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111817;
    --surface: #192322;
    --surface-soft: #203330;
    --text: #e8efed;
    --muted: #9aaba8;
    --line: #334542;
    --accent: #64aaa4;
    --accent-strong: #b9e0dc;
    --accent-soft: #203c39;
    --warm: #e77b58;
    --shadow: 0 16px 42px rgba(0, 0, 0, 0.3);
  }
  .auth-screen { background: linear-gradient(155deg, #123f41 0 42%, #183638 42% 58%, #111817 58%); }
  .button.primary, .avatar-button, .hero-panel, .progress-panel { color: #0b2221; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
