/* Busan trip: "metro line map". Each category is a line with its own colour; everything else stays quiet. */
:root {
  --ink: #10303F;
  --paper: #F3F6F6;
  --surface: #FFFFFF;
  --rule: #D8E1E3;
  --muted: #5C6F76;
  --signal: #F06A00;
  --tint: #EAF1F3;
  --danger: #B23A3A;
  --good: #2F7D4F;

  --c-lunch: #F06A00;
  --c-dinner: #B8860B;
  --c-afternoon: #5FA83A;
  --c-sightseeing: #217DCB;
  --c-cafe: #8B5E3C;
  --c-shopping: #D6457A;
  --c-nightlife: #7B4FA0;
  --c-activity: #00968F;

  --radius: 10px;
  --shadow: 0 20px 60px rgba(16, 48, 63, .25);
  --head-h: 56px;
  --font: "Pretendard Variable", Pretendard, system-ui, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-mark: "Black Han Sans", "Pretendard Variable", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 15px/1.5 var(--font);
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }

.wordmark { font-family: var(--font-mark); font-weight: 400; font-size: 26px; line-height: 1; letter-spacing: 0; color: var(--ink); }
.error { color: var(--danger); min-height: 1.5em; font-size: 13px; }
.status { min-height: 1.4em; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.status.good { color: var(--good); }
.status.bad { color: var(--danger); }

/* ---------- form controls ---------- */
input, select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 8px; background: #fff;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
select { padding-right: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border: 1px solid var(--rule); border-radius: var(--radius);
  background: #fff; color: var(--ink); white-space: nowrap;
}
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }

.textbtn {
  background: none; border: 0; padding: 6px 0; color: var(--ink); font-size: 13px; line-height: 1.4;
  text-decoration: none; cursor: pointer;
}
.textbtn:hover, .row-actions a:hover { text-decoration: underline; }
.textbtn.quiet { color: var(--muted); }
.textbtn.danger { color: var(--danger); }
.iconbtn {
  width: 40px; height: 40px; border: 0; border-radius: 8px; background: none; font-size: 28px; line-height: 1; color: var(--muted);
}

/* ---------- header ---------- */
.topbar {
  height: var(--head-h); padding: 0 20px; background: var(--surface);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.trip-dates { font-size: 13px; color: var(--muted); white-space: nowrap; }

.view-switch { display: flex; padding: 3px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
.view-switch button {
  height: 30px; padding: 0 16px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 14px;
}
.view-switch button.active { background: var(--ink); color: #fff; }

.account { position: relative; justify-self: end; display: flex; align-items: center; gap: 12px; }
.user-name { background: none; border: 0; padding: 0; font-size: 13px; color: var(--muted); cursor: default; }
.account .textbtn { color: var(--ink); }
.account-menu { display: flex; align-items: center; gap: 12px; }
.import-text { width: 100%; font: inherit; font-size: 13px; }
.radio-row { display: flex !important; align-items: center; gap: 8px; margin-bottom: 8px !important; }
.radio-row input { width: auto; height: auto; margin: 0; }
.radio-row > span { margin: 0 !important; font-size: 15px !important; color: var(--ink) !important; }
.import-report { font-size: 14px; }
.import-report h3 { margin: 12px 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.import-report h3:first-child { margin-top: 0; }
.import-report p { margin: 0 0 4px; }
.import-report ul { margin: 0 0 8px; padding-left: 18px; }
.import-report li { margin-bottom: 2px; }
.import-report .bad { color: var(--danger); }
.import-report .good { color: var(--good); }

.line-band { display: flex; height: 4px; }
.line-band span { flex: 1; }

/* ---------- layout (desktop) ---------- */
@media (min-width: 900px) {
  body:not(.login-page) { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
  .app { flex: 1; min-height: 0; display: grid; grid-template-columns: 460px minmax(0, 1fr); }
  .panel { overflow-y: auto; background: var(--surface); border-right: 1px solid var(--rule); }
  .map-pane { position: relative; }
  #map { position: absolute; inset: 0; }
  .toolbar { padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--rule); }
  .when-toggle, .seg-float, .fab { display: none !important; }
  .pill { height: 30px; }
  .toolbar { gap: 10px; }
}

.search-row { display: flex; gap: 8px; align-items: center; }
.search-row input[type="search"] {
  flex: 1; min-width: 0; padding-left: 38px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235C6F76' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center;
}
.when-toggle.on { border-color: var(--ink); }
.count-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--signal); color: #fff;
  font-size: 12px; line-height: 18px; text-align: center; font-weight: 600;
}

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 34px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 999px; background: #fff; color: var(--ink);
  font-size: 13px; white-space: nowrap;
}
.pill.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill.dashed { border-style: dashed; color: var(--muted); }
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; }
.pill.on .dot { box-shadow: 0 0 0 1px #fff; }

.when-row { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.count-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.place-count { font-size: 13px; color: var(--muted); }
#sort { width: auto; height: 32px; border-color: transparent; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }

.list { background: var(--surface); }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }

/* ---------- place + hotel rows ---------- */
.row { position: relative; display: flex; background: var(--surface); border-bottom: 1px solid var(--rule); }
.row:first-child { border-top: 1px solid var(--rule); }
.stripe { flex: none; width: 4px; display: flex; flex-direction: column; }
.stripe span { flex: 1; }
.row-body { flex: 1; min-width: 0; padding: 14px 16px 8px 14px; }
.row-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.title-box { min-width: 0; }
.title { font-size: 17px; font-weight: 600; line-height: 1.3; cursor: pointer; overflow-wrap: anywhere; }
.name-zh { margin-top: 2px; font-size: 13px; color: var(--muted); }

.vote-pill {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 58px; height: 36px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 999px; background: #fff; color: var(--ink);
}
.vote-pill b { font-weight: 600; font-variant-numeric: tabular-nums; }
.vote-pill.on { background: var(--signal); border-color: var(--signal); color: #fff; }

.cats { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 8px; font-size: 13px; }
.cat { display: inline-flex; align-items: center; gap: 6px; }

.when { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 8px; font-size: 13px; }
.when-part { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.when-items { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.when-text { color: var(--muted); }
.everyday { background: none; border: 0; padding: 4px 0; font-size: 13px; color: var(--ink); cursor: pointer; }
.everyday:hover { text-decoration: underline; }
.daysq { display: inline-flex; gap: 4px; }
.sq {
  width: 26px; height: 26px; padding: 0; border: 1px solid var(--ink); border-radius: 4px; background: transparent; color: var(--ink);
  font-size: 13px; font-weight: 600; line-height: 1;
}
.sq.on { background: var(--ink); color: #fff; }
.mini { height: 26px; padding: 0 8px; border: 1px solid var(--rule); border-radius: 4px; background: #fff; font-size: 13px; color: var(--muted); }
.mini.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.details-box { margin-top: 8px; }
.details { max-width: 70ch; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.details.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.voters { margin-top: 6px; font-size: 13px; color: var(--muted); }
.address { margin-top: 6px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.nolocation { font-size: 13px; color: var(--muted); padding: 6px 0; }

.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; margin-top: 6px; }
.row-actions a { font-size: 13px; padding: 6px 0; color: var(--ink); text-decoration: none; line-height: 1.4; }

.comments { margin-top: 8px; padding: 10px 0 8px; border-top: 1px solid var(--rule); font-size: 14px; }
.comment { margin: 4px 0; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }

/* hotels */
.hotel-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-ctl { flex: 1 1 100%; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.inline-ctl select, .hotel-controls select { width: auto; }
.hotel-controls #add-hotel { margin-left: auto; }
.hotel-controls select { height: 36px; }
.hotel-stats { padding: 8px 12px; border-radius: 8px; background: var(--tint); color: var(--ink); font-size: 13px; }
.hotel-stats:empty { display: none; }
.hotel-price { margin-top: 8px; font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--ink); }
.hotel-sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.hotel-row.selected { background: var(--tint); border-left: 2px solid var(--ink); }
.hotel-pick {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 0; border: 0; background: none; color: var(--ink); font-size: 13px;
}
.hotel-pick.on { font-weight: 600; }
.radio { width: 14px; height: 14px; border: 2px solid var(--ink); border-radius: 50%; background: transparent; }
.hotel-pick.on .radio { background: var(--ink); box-shadow: inset 0 0 0 2px var(--tint); }
.hotel-warn { margin-top: 8px; padding: 6px 10px; border-radius: 4px; background: #FFF1E0; color: #8A4B00; font-size: 13px; }

/* ---------- map pins and popups ---------- */
.leaflet-marker-icon.pin-wrap { display: flex; align-items: center; justify-content: center; background: none; border: 0; }
.pin-dot {
  flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(16, 48, 63, .45);
}
.pin-wrap.selected .pin-dot, .pin-dot.selected { width: 20px; height: 20px; box-shadow: 0 0 0 2px var(--ink), 0 1px 4px rgba(16, 48, 63, .5); }
.hotel-marker, .leaflet-marker-icon.hotel-marker {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 2px solid #fff; background: var(--ink); font-size: 14px; line-height: 1; box-shadow: 0 1px 4px rgba(16, 48, 63, .5);
}
.gm-pin { transform: translateY(50%); }
.popup { font: 13px/1.45 var(--font); }
.popup > div { margin-top: 2px; }
.popup b { font-size: 15px; }
.leaflet-container { font-family: var(--font); }

.pin-map { height: 220px; border-radius: 8px; border: 1px solid var(--rule); }
.pin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.pin-row b { color: var(--ink); font-weight: 600; }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(16, 48, 63, .45);
}
.modal-box {
  display: flex; flex-direction: column; width: 100%; max-width: 560px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden;
  animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 20px; border-bottom: 1px solid var(--rule); }
.modal-head h2 { font-size: 17px; font-weight: 600; }
.modal-body { flex: 1; overflow-y: auto; padding: 16px 20px 4px; overscroll-behavior: contain; }
.modal-foot { flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--rule); background: var(--surface); }
.modal-foot .error { flex: 1; min-height: 0; margin-right: 8px; }
.section { margin-bottom: 20px; }
.section-label { margin-bottom: 10px; padding-bottom: 4px; border-bottom: 1px solid var(--rule); font-size: 13px; font-weight: 600; color: var(--muted); }
.modal-box label, .modal-box .field { display: block; margin-bottom: 12px; }
.modal-box label > span, .label { display: block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.new-cat { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.new-cat input { flex: 1; min-width: 120px; }
#find-address { margin: -4px 0 12px; }
.price-row { display: flex; gap: 8px; }
.price-row label { flex: 1; min-width: 0; margin-bottom: 0; }
.price-row label:first-child { flex: 2; }
#gsearch-box gmp-place-autocomplete, #hgsearch-box gmp-place-autocomplete { width: 100%; color-scheme: light; }

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login .line-band { border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.login-card { padding: 28px 24px 24px; border: 1px solid var(--rule); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface); text-align: center; }
.login-card .wordmark { font-size: 56px; }
.login-sub { margin: 8px 0 24px; font-size: 15px; color: var(--muted); }
.login-card form { text-align: left; }
.login-card label { display: block; margin-bottom: 12px; }
.login-card label > span { display: block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.login-card .error { margin: 0 0 8px; }

/* ---------- mobile ---------- */
@media (max-width: 899px) {
  .topbar { display: flex; gap: 8px; padding: 0 12px 0 16px; }
  .brand { flex: 1; }
  .wordmark { font-size: 24px; }
  .view-switch button { padding: 0 12px; }
  .account { gap: 0; }
  .user-name {
    width: 32px; height: 32px; border-radius: 50%; background: var(--tint); color: var(--ink); cursor: pointer;
    font-size: 0; display: flex; align-items: center; justify-content: center;
  }
  .user-name::before { content: attr(data-initial); font-size: 14px; font-weight: 600; }
  .account-menu {
    display: none; flex-direction: column; align-items: stretch; gap: 0; position: absolute; right: 0; top: 40px; z-index: 30;
    background: #fff; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden;
  }
  .account-menu .textbtn { padding: 10px 16px; font-size: 14px; white-space: nowrap; text-align: left; }
  .account.open .account-menu { display: flex; }

  .toolbar { display: contents; }
  .panel { background: var(--surface); padding-bottom: 104px; min-height: calc(100dvh - 60px); }
  .search-row { position: sticky; top: 0; z-index: 20; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--rule); }
  .cat-pills {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 10px 28px 4px 16px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .cat-pills::-webkit-scrollbar { display: none; }
  .when-row { display: none; flex-direction: column; gap: 6px; padding: 8px 16px 0; }
  .when-row.open { display: flex; }
  .when-row .pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .when-row .pills::-webkit-scrollbar { display: none; }
  .count-row { padding: 4px 16px 2px; }
  .hotel-controls { padding: 10px 16px 0; }
  .hotel-controls #add-hotel { display: none; }
  .hotel-stats { margin: 10px 16px 0; }
  .list { margin-top: 6px; }
  #add-place { display: none; }
  .when-toggle { height: 40px; padding: 0 12px; }

  .app { display: block; }
  .app[data-tab="list"] .map-pane { display: none; }
  .app[data-tab="map"] .panel { display: none; }
  .map-pane { height: calc(100vh - 60px); height: calc(100dvh - 60px); }
  #map { width: 100%; height: 100%; }
  .leaflet-bottom { bottom: 76px; }

  .seg-float {
    position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1200;
    display: flex; padding: 3px; border-radius: 999px; background: var(--ink);
  }
  .seg-float button { height: 38px; min-width: 76px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: #fff; font-size: 14px; }
  .seg-float button.active { background: #fff; color: var(--ink); font-weight: 600; }
  .fab {
    position: fixed; right: 16px; bottom: 16px; z-index: 1200; width: 52px; height: 52px; border: 0; border-radius: 50%;
    background: var(--ink); color: #fff; font-size: 30px; line-height: 1; box-shadow: var(--shadow);
  }

  .vote-pill { height: 40px; }
  .sq { width: 30px; height: 30px; }
  .mini { height: 32px; }
  .textbtn, .row-actions a, .hotel-pick { padding: 9px 0; }
  .row-actions { gap: 0 18px; }

  .modal { padding: 0; align-items: stretch; background: var(--surface); }
  .modal-box { max-width: none; max-height: none; height: 100vh; height: 100dvh; border-radius: 0; box-shadow: none; }
  .modal-body, .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-head { padding-right: 4px; }
  .modal-foot .btn { height: 44px; }
  .login-card .wordmark { font-size: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
