:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --text: #1f1d1a;
  --muted: #74706a;
  --line: #e7e3db;
  --accent: #e8590c;
  --accent-ink: #ffffff;
  --accent-soft: #fff0e5;
  --danger: #d33a2c;
  --naver: #03c75a;
  --kakao: #fee500;
  --google: #1a73e8;
  --catch: #ff4b2b;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(31, 24, 14, 0.14);
  --tabbar-h: 0px;
  /* One height for every input and button that can sit side by side in a row.
     A row that needs smaller controls sets these again on its container. */
  --control-h: 40px;
  --control-sm: 32px;
  color-scheme: light;
}

/* Light by default; the header button switches to dark and remembers the choice. */
:root[data-theme='dark'] {
  --bg: #141517;
  --surface: #1c1d20;
  --surface-2: #26282c;
  --text: #f2f0ec;
  --muted: #a19d96;
  --line: #313338;
  --accent: #ff7a33;
  --accent-ink: #1a0d04;
  --accent-soft: #3a2416;
  --danger: #ff6b5e;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.boot { display: grid; place-items: center; height: 100dvh; color: var(--muted); }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 14px; border-radius: 10px; flex: none;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { height: var(--control-sm); padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--control-h); height: var(--control-h); flex: none;
  border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-size: 18px;
}
.icon-btn:hover { background: var(--surface-2); }
.text-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
input[type='text'], input[type='search'], input[type='password'], textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 0 14px; outline: none;
}
input[type='text'], input[type='search'], input[type='password'], select { height: var(--control-h); }
textarea { padding: 10px 14px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 96px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- login ---------- */
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); display: grid; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login-logo { width: 72px; height: 72px; }
.form-error { color: var(--danger); font-size: 13px; margin: 0; }
/* Signing in opens over the site (anyone can look without it). */
dialog.is-login { width: min(380px, calc(100% - 24px)); }
dialog.is-login .login-card { width: 100%; border: 0; box-shadow: none; }
.login-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; }

/* ---------- shell ---------- */
/* One column no wider than the screen: a long row of chips scrolls sideways instead of
   stretching the whole page (which made phones zoom the page out). */
.shell { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; height: 100dvh; }
.topbar {
  --control-h: 36px;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* The icon is drawn on a 36-cell grid: at 36px each cell is one pixel, so it stays crisp. */
.brand img { width: 36px; height: 36px; flex: none; }
.brand h1 { margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .search { flex: 1; max-width: 420px; margin-left: 12px; }
.topbar .search input { background: var(--surface-2); border-color: transparent; }
.topbar .spacer { flex: 1; }
.me-btn {
  height: var(--control-h); padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; flex: none;
}
.theme-btn { border: 1px solid var(--line); border-radius: 999px; font-size: 16px; }

.filters { background: var(--surface); border-bottom: 1px solid var(--line); }
.filter-row { display: flex; gap: 6px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row.sub { padding-top: 0; }
.filter-row.sub .chip { height: 28px; font-size: 12px; background: var(--surface-2); border-color: transparent; }
.filter-row.sub .chip.on { background: var(--accent); color: var(--accent-ink); }
.chip {
  flex: none; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip b { font-weight: 500; color: var(--muted); margin-left: 3px; }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.on b { color: inherit; opacity: 0.7; }

.body { position: relative; display: grid; grid-template-columns: 400px 1fr; min-height: 0; }
.list-pane {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--line);
}
.list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.list-head select { width: auto; height: var(--control-sm); padding: 0 8px; font-size: 13px; }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; scrollbar-width: thin; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 14px; }

/* Photo on the left spanning the whole row: its top meets the name, its bottom the platform buttons. */
.item {
  display: grid; grid-template-columns: 80px minmax(0, 1fr); column-gap: 12px; row-gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.item.is-selected { background: var(--accent-soft); }
.item-pic-btn { grid-row: 1 / span 2; display: flex; padding: 0; border: 0; background: none; cursor: pointer; }
.item-pic {
  position: relative; overflow: hidden; flex: 1; display: grid; place-items: center;
  border-radius: 12px; background: var(--surface-2); font-size: 30px;
}
.item-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.item-main { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.item-emoji, .detail-emoji {
  position: relative; overflow: hidden;
  flex: none; display: grid; place-items: center; width: 52px; height: 52px;
  border-radius: 12px; background: var(--surface-2); font-size: 22px;
}
.detail-cover { width: 100%; height: 180px; object-fit: cover; border-radius: 14px; background: var(--surface-2); }
.item-body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.item-title { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta, .item-foot { font-size: 13px; color: var(--muted); }
.item-quote { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-foot { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.tag-warn { color: var(--danger); }
.item-tags { color: var(--accent); font-weight: 600; }

/* tags */
.tag-list, .tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tag.on, .tag-list .tag { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tagedit { display: grid; gap: 8px; }
.tagedit .tag-new { font-size: 13px; }
.tag-details summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.tag-details[open] summary { margin-bottom: 8px; }

.cat-link { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); font-weight: 700; cursor: pointer; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field-label small { font-weight: 400; margin-left: 4px; }

/* category picker */
.catpick { position: relative; }
.catpick-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; height: var(--control-h); padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left;
}
.catpick-btn[aria-expanded='true'] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.catpick-emoji { font-size: 18px; }
.catpick-label { font-weight: 700; }
.catpick-group { font-size: 12px; color: var(--muted); }
.catpick-caret { margin-left: auto; color: var(--muted); }
.catpick-panel {
  margin-top: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  box-shadow: var(--shadow); padding: 10px; display: grid; gap: 8px;
}
.catpick-list { max-height: 300px; overflow-y: auto; display: grid; gap: 10px; }
.catpick-sec-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.catpick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.catpick-chip {
  height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.catpick-chip:hover { background: var(--surface-2); }
.catpick-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.catpick-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 9px; background: none; cursor: pointer; text-align: left; font-size: 14px;
}
.catpick-row small { color: var(--muted); font-size: 12px; }
.catpick-row.active, .catpick-row:hover { background: var(--surface-2); }
.catpick-list:has(.catpick-row) { gap: 2px; }
/* The four platform buttons always stay on one line; when the row is too narrow for their
   names they shrink to just the coloured letters. */
.item-links { display: flex; flex-wrap: nowrap; gap: 4px; min-width: 0; container-type: inline-size; }
.item-links .plink { flex: none; height: 26px; gap: 4px; padding: 0 8px 0 4px; }
.item-links .plink-mark { width: 17px; height: 17px; }
/* The four buttons with names need about 256px. */
@container (max-width: 258px) {
  .item-links .plink { padding: 0 4px; }
  .item-links .plink-label { display: none; }
}

/* platform links */
.plink {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px 0 5px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  text-decoration: none; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.plink:hover { background: var(--surface-2); }
.plink-mark {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 5px;
  font-size: 11px; font-weight: 800; color: #fff;
}
.plink-naver .plink-mark { background: var(--naver); }
.plink-kakao .plink-mark { background: var(--kakao); color: #3a1d1d; }
.plink-google .plink-mark { background: var(--google); }
.plink-catchtable .plink-mark { background: var(--catch); }
.plinks-lg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plinks-lg .plink { height: 42px; justify-content: flex-start; padding: 0 12px; font-size: 14px; border-radius: 12px; }
.plinks-lg .plink-mark { width: 22px; height: 22px; font-size: 12px; }
.plinks-lg .plink small { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 12px; }

/* ---------- map ---------- */
/* isolation keeps the map library's own z-indexes from rising above the detail sheet */
.map-pane { position: relative; min-height: 0; background: var(--surface-2); isolation: isolate; }
#map { position: absolute; inset: 0; }
.map-note {
  position: absolute; left: 12px; bottom: 12px; z-index: 400; max-width: calc(100% - 80px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 10px; font-size: 12px; color: var(--muted); box-shadow: var(--shadow);
}
.locate-btn {
  position: absolute; right: 12px; bottom: 12px; z-index: 400; width: 42px; height: 42px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  box-shadow: var(--shadow); font-size: 18px;
}
.pin-anchor { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); }
.pin {
  position: relative; display: flex; align-items: center; gap: 5px; margin-bottom: 8px;
  padding: 3px; border: 0; border-radius: 999px; background: #fff; color: #222;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28); cursor: pointer; white-space: nowrap;
  font: 700 12px/1 'Pretendard Variable', Pretendard, system-ui, sans-serif;
}
.pin::after {
  content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.pin-emoji { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff0e5; font-size: 14px; }
.pin-label { display: none; max-width: 140px; overflow: hidden; text-overflow: ellipsis; padding-right: 6px; }
.labels-on .pin-label, .pin:hover .pin-label, .pin.is-selected .pin-label { display: inline; }
/* 추천 grades (relative): 1 is the group's favourites. Colours are fixed because the map stays light. */
.pin.tier-3 { background: #ffe9d8; }
.pin.tier-3::after { border-top-color: #ffe9d8; }
.pin.tier-2 { background: #ffc99f; }
.pin.tier-2::after { border-top-color: #ffc99f; }
.pin.tier-1 { background: #ff7a2e; color: #fff; box-shadow: 0 0 0 3px rgba(255, 122, 46, 0.3), 0 2px 8px rgba(0, 0, 0, 0.28); }
.pin.tier-1::after { border-top-color: #ff7a2e; }
.pin.tier-1 .pin-label { display: inline; }
.pin.tier-1 .pin-emoji, .pin.tier-2 .pin-emoji { background: #fff; }
.pin.is-selected { background: var(--accent); color: #fff; z-index: 2; }
.pin.is-selected::after { border-top-color: var(--accent); }
.pin.is-selected .pin-emoji { background: #fff; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26, 115, 232, 0.25); transform: translate(-50%, -50%); }

/* ---------- detail ---------- */
.detail {
  position: absolute; top: 0; bottom: 0; left: 0; width: 400px; z-index: 20;
  background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto;
}
.detail[hidden] { display: none; }
.detail-inner { padding: 12px 16px 32px; display: grid; gap: 16px; }
.detail-top { --control-h: var(--control-sm); display: flex; align-items: center; justify-content: space-between; }
.detail-top .actions { display: flex; gap: 6px; }
.detail-title { display: flex; gap: 12px; align-items: center; }
.detail-emoji { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; }
.detail-title h2 { margin: 0; font-size: 21px; line-height: 1.25; }
.detail-title p { margin: 2px 0 0; }
.like-row { display: flex; align-items: center; gap: 10px; }
.like-btn {
  height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 700;
}
.like-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.facts { display: grid; grid-template-columns: 44px 1fr; gap: 8px 10px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts .text-btn { margin-left: 6px; font-size: 13px; }
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 13px;
}
.notice.is-warn { background: #fff4e5; color: #8a4b00; }
:root[data-theme='dark'] .notice.is-warn { background: #3a2a14; color: #ffcf8a; }
.edit-form { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.edit-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.edit-form .row { display: flex; gap: 8px; justify-content: flex-end; }
.comments h3 { margin: 0 0 8px; font-size: 15px; }
.comments h3 span { color: var(--muted); font-weight: 500; }
.comment-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 10px; }
.comment { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.comment-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.comment-head b { font-weight: 700; }
.comment-head .text-btn { margin-left: auto; font-size: 12px; color: var(--muted); }
.comment-form { display: flex; gap: 8px; }

/* ---------- add dialog ---------- */
dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 32px); padding: 0;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 8, 5, 0.45); }
.add { display: grid; gap: 14px; padding: 16px 18px 18px; }
.add header { display: flex; align-items: center; justify-content: space-between; }
.add h2 { margin: 0; font-size: 18px; }
.add .field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.add .row { display: flex; align-items: center; gap: 10px; }
.add .hint { font-size: 12px; color: var(--muted); }
.add-result { display: grid; gap: 10px; }
.found-from { font-size: 13px; color: var(--muted); }
.warn { padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.dup { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.cands { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.add-input { display: flex; gap: 8px; }
/* One line is enough: a long link or a pasted share message scrolls instead of filling the dialog.
   The border sits on a wrapper with its own side padding, so scrolled text never touches the edge. */
.add-text-box {
  flex: 1; min-width: 0; display: flex; align-items: center; height: var(--control-h); padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.add-text-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.add-text-box textarea {
  height: 22px; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent;
  resize: none; overflow: hidden; white-space: pre; line-height: 22px;
}
/* The wrapper shows the focus; the textarea itself must not draw a second ring inside it. */
.add-text-box textarea:focus, .add-text-box textarea:focus-visible { box-shadow: none; outline: none; }
.add-meta { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 10px; align-items: end; }
.cand { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.cand-eye {
  height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.cand-eye:hover { color: var(--accent); border-color: var(--accent); }
.cand:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.cand-pick { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.cand input { margin-top: 4px; accent-color: var(--accent); }
.cand-body { display: grid; gap: 1px; min-width: 0; }
.cand-name { font-weight: 700; }
.cand-sub { font-size: 13px; color: var(--muted); }
.cand.is-registered .cand-pick { flex-direction: column; gap: 2px; cursor: default; opacity: 0.65; }
.cand-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-left: 26px; font-size: 12px; color: var(--muted); }
.cand.is-registered .cand-preview { padding-left: 0; }
.found-from .text-btn { margin-left: 4px; font-size: 13px; }
.cand-preview button.plink { cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; color: var(--text); }
.inline-frame { width: 100%; height: 340px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.naver-card-label { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: -4px; }
.naver-card-label .text-btn { font-size: 12px; }
/* Naver's place panel, shifted up so its favourite/close row sits outside the box.
   It stays live, so members can select the name to copy and scroll down to the address. */
/* Naver lays its panel out for the frame's height (a short frame gets a compact header that
   jumps straight to 출발/도착), so the frame keeps a normal height and the card clips it.
   The favourite/close row sits above the box; scrolling inside shows the rest. */
.naver-card { position: relative; height: min(420px, 50dvh); overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.naver-card iframe { position: absolute; top: -46px; left: 0; width: 100%; height: calc(100% + 46px); border: 0; }
/* Once the link is read its box gives way; once there are results the Naver card does too. */
.add.resolved .add-input, .add.has-cands .naver-card, .add.has-cands .naver-card-hint { display: none; }
.cand-links { display: flex; gap: 14px; }
.cand-links .text-btn { font-size: 13px; }
.naver-card-hint { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-top: -4px; }
.naver-card-hint .text-btn { font-size: 12px; flex: none; }
/* Naver's search list for a typed name, its own search box included. */
.naver-list { height: min(460px, 55dvh); overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.naver-list iframe { width: 100%; height: 100%; border: 0; }
.naver-pick-hint { margin: -4px 0 0; font-size: 12px; color: var(--muted); }
.naver-pick-row { display: flex; gap: 8px; }
.naver-pick-row input { flex: 1; min-width: 0; }
.naver-pick-row #naver-link-paste { padding: 0 10px; }

/* in-page preview of a platform's own page */
.preview-dialog { width: min(480px, calc(100% - 24px)); height: min(860px, calc(100dvh - 32px)); }
.pv { display: flex; flex-direction: column; height: 100%; }
.pv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 12px 8px 16px; }
.pv-title { display: grid; gap: 2px; min-width: 0; }
.pv-title strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-title span { font-size: 13px; color: var(--muted); }
.pv-tabs { display: flex; gap: 4px; padding: 0 12px 8px; border-bottom: 1px solid var(--line); }
.pv-tab { flex: 1; height: 34px; border: 0; border-radius: 9px; background: none; font-weight: 700; color: var(--muted); cursor: pointer; }
.pv-tab.on { background: var(--surface-2); color: var(--text); }
.pv-frame-box { position: relative; flex: 1; display: flex; min-height: 0; }
.pv-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.pv-loading {
  position: absolute; inset: 0; display: grid; place-items: center; background: var(--surface);
  color: var(--muted); font-size: 14px;
}
.pv-foot .text-btn.is-strong { font-size: 14px; }
.pv-foot-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.pv-foot-left .text-btn { flex: none; }
/* Box and button share one height. */
.pv-link { --control-h: var(--control-sm); display: flex; gap: 6px; flex: 1; min-width: 0; max-width: 380px; }
.pv-link input { flex: 1; min-width: 0; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.pv-link .btn { flex: none; }
.photo-tools { display: flex; gap: 8px; padding: 4px 16px 12px; border-bottom: 1px solid var(--line); }
.photo-grid {
  flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px; padding: 12px 16px; align-content: start;
}
.photo-cell { aspect-ratio: 1; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell:hover { outline: 3px solid var(--accent); outline-offset: -3px; }
.pv-loc { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 12px 16px; overflow-y: auto; }
.pv-map { flex: 1; min-height: 260px; border-radius: 12px; overflow: hidden; background: var(--surface-2); isolation: isolate; }
.pv-hint { margin: 0; padding: 8px 16px; font-size: 12px; color: var(--muted); background: var(--surface-2); }
.plink-map .plink-mark { background: var(--accent-soft); font-size: 11px; }
.research #research-paste { padding: 0 10px; }
.pv-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.pv-foot .text-btn { text-decoration: none; font-size: 13px; }
.research { display: flex; gap: 8px; }
.add footer { display: grid; gap: 10px; }
.quick-add { border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; color: var(--muted); }
.quick-add summary { cursor: pointer; font-weight: 600; }
.quick-add p { margin: 8px 0; }
.quick-add .bookmarklet { cursor: grab; text-decoration: none; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--tabbar-h)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 1000; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.tabbar { display: none; }

/* ---------- phones ---------- */
@media (max-width: 899px) {
  .item { grid-template-columns: 64px minmax(0, 1fr); }
  :root { --tabbar-h: 56px; }
  .shell { grid-template-rows: auto auto 1fr auto; }
  .topbar { flex-wrap: wrap; padding: 10px 16px 8px; gap: 8px; }
  .topbar .search { order: 5; flex-basis: 100%; max-width: none; margin: 0; }
  .topbar .spacer, .hide-sm { display: none; }
  .brand { flex: 1; }
  .brand h1 { font-size: 16px; }
  .me-btn { max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
  .body { grid-template-columns: 1fr; }
  .shell[data-view='map'] .list-pane { display: none; }
  .shell[data-view='list'] .map-pane { display: none; }
  .list-pane { border-right: 0; }
  .tabbar {
    display: grid; grid-template-columns: 1fr 1fr; height: var(--tabbar-h);
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button { border: 0; background: none; font-weight: 700; color: var(--muted); cursor: pointer; }
  .tabbar button.on { color: var(--accent); }
  .detail {
    position: fixed; top: auto; left: 0; right: 0; bottom: var(--tabbar-h); width: auto; max-height: 58dvh;
    border-right: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.18);
  }
  .detail-inner::before {
    content: ''; justify-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin-bottom: -6px;
  }
  dialog { margin: auto auto 0; width: 100%; max-width: none; border-radius: 20px 20px 0 0; max-height: 92dvh; }
  .preview-dialog { height: 92dvh; }
  .detail-cover { height: 140px; }
  .quick-add { display: none; }
  .add-meta { grid-template-columns: 1fr; }
}
