:root {
  --bg: #fff;
  --bg-blur: rgba(255, 255, 255, .78);
  --raised: #fff;
  --card: #f5f5f7;
  --fill: rgba(118, 118, 128, .1);
  --fill-strong: rgba(118, 118, 128, .18);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --line: rgba(0, 0, 0, .08);
  --accent: #d9412b;
  --accent-soft: rgba(217, 65, 43, .1);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 12px 40px rgba(0, 0, 0, .14);
  --ease: cubic-bezier(.32, .72, 0, 1);
  color-scheme: light dark;
}
/* 다크: 우상단 토글로 고른 값(data-theme)이 우선, 없으면 기기 설정 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000;
    --bg-blur: rgba(0, 0, 0, .7);
    --raised: #1c1c1e;
    --card: #1c1c1e;
    --fill: rgba(118, 118, 128, .22);
    --fill-strong: rgba(118, 118, 128, .34);
    --text: #f5f5f7;
    --text-2: #98989d;
    --text-3: #636366;
    --line: rgba(255, 255, 255, .1);
    --accent: #ff6a55;
    --accent-soft: rgba(255, 106, 85, .16);
    --shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 12px 40px rgba(0, 0, 0, .6);
    --thumb: #636366;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000;
  --bg-blur: rgba(0, 0, 0, .7);
  --raised: #1c1c1e;
  --card: #1c1c1e;
  --fill: rgba(118, 118, 128, .22);
  --fill-strong: rgba(118, 118, 128, .34);
  --text: #f5f5f7;
  --text-2: #98989d;
  --text-3: #636366;
  --line: rgba(255, 255, 255, .1);
  --accent: #ff6a55;
  --accent-soft: rgba(255, 106, 85, .16);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 12px 40px rgba(0, 0, 0, .6);
  --thumb: #636366;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.47 "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
body.locked { overflow: hidden; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { border: 0; background: none; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.hero, .searchrow, .bar-inner, .filters, main, footer { max-width: 720px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }

/* Large title */
.theme { position: absolute; top: max(18px, env(safe-area-inset-top)); right: 20px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: var(--text-2); transition: transform .2s var(--ease), background .2s; }
@media (hover: hover) { .theme:hover { background: var(--fill-strong); } }
.theme svg { grid-area: 1 / 1; width: 19px; height: 19px; transition: opacity .25s, transform .45s var(--ease); }
.theme .sun { opacity: 0; transform: rotate(-90deg) scale(.5); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .sun { opacity: 1; transform: none; }
  :root:not([data-theme="light"]) .theme .moon { opacity: 0; transform: rotate(90deg) scale(.5); }
}
:root[data-theme="dark"] .theme .sun { opacity: 1; transform: none; }
:root[data-theme="dark"] .theme .moon { opacity: 0; transform: rotate(90deg) scale(.5); }
.hero { position: relative; padding-top: max(56px, env(safe-area-inset-top)); padding-bottom: 12px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .02em; }
h1 { font-size: clamp(34px, 7vw, 48px); font-weight: 700; line-height: 1.1; letter-spacing: -.035em; margin-top: 6px; }
.lede { color: var(--text-2); margin-top: 10px; }

/* Sticky translucent bar */
.bar { position: sticky; top: 0; z-index: 20; background: var(--bg-blur); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid transparent; transition: border-color .3s; }
.bar.stuck { border-bottom-color: var(--line); }
.bar-inner { padding-top: 10px; padding-bottom: 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.row { display: flex; gap: 8px; }

.search { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 12px; background: var(--fill); color: var(--text-2); }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1 1 0; width: 100%; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font-size: 16px; }
.search input::placeholder { color: var(--text-2); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.near { flex: none; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 15px; font-weight: 600; white-space: nowrap; transition: transform .2s var(--ease), background .25s, color .25s; }
.near svg { width: 16px; height: 16px; }
.near[aria-pressed="true"] { background: var(--accent); color: #fff; }
.near[aria-pressed="true"] svg { fill: currentColor; }
.near.busy svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
button:active { transform: scale(.96); }
.searchrow { padding-top: 6px; }
.viewseg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 2px; border-radius: 12px; background: var(--fill); }
.viewseg button { display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 13px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--text-2); transition: background .2s, color .2s; }
.viewseg button.on { background: var(--thumb, var(--raised)); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.viewseg b { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.viewseg b:empty { display: none; }
/* 내 여행 화면에서는 검색 · 필터를 숨김 */
.tripmode .filters, .tripmode #cities, .tripmode #count, .tripmode #status, .tripmode .searchrow { display: none; }
.filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding-top: 2px; }

/* Segmented control */
.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 2px; border-radius: 10px; background: var(--fill); }
.seg button { position: relative; z-index: 1; height: 30px; font-size: 14px; font-weight: 500; border-radius: 8px; transition: color .2s; }
.seg button.on { font-weight: 600; }
.seg .thumb { position: absolute; top: 2px; bottom: 2px; left: 2px; border-radius: 8px; background: var(--thumb, var(--raised)); box-shadow: 0 1px 4px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); transition: transform .35s var(--ease), width .35s var(--ease); }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px; }
.chips::-webkit-scrollbar { display: none; }
.chips { --l: #000; --r: #000; -webkit-mask-image: linear-gradient(90deg, var(--l), #000 44px, #000 calc(100% - 44px), var(--r)); mask-image: linear-gradient(90deg, var(--l), #000 44px, #000 calc(100% - 44px), var(--r)); user-select: none; -webkit-user-select: none; }
.chips.more-l { --l: transparent; }
.chips.more-r { --r: transparent; }
.chips:empty { display: none; }
.chips button { flex: none; height: 32px; padding: 0 13px; border-radius: 16px; font-size: 14px; font-weight: 500; color: var(--text-2); background: var(--fill); transition: background .2s, color .2s, transform .2s var(--ease); }
.chips button.on { background: var(--text); color: var(--bg); }
.tags button { height: 28px; padding: 0 11px; font-size: 13px; background: none; box-shadow: inset 0 0 0 1px var(--line); }
.tags button::before { content: '#'; opacity: .45; margin-right: 1px; }
.tags button.on { background: var(--accent-soft); color: var(--accent); box-shadow: none; }

/* List */
main { padding-top: 8px; padding-bottom: 40px; min-height: 60vh; }
.status { margin: 8px 0 4px; padding: 12px 14px; border-radius: 14px; background: var(--fill); color: var(--text-2); font-size: 14px; }
.viewhead { padding: 14px 4px 0; font-size: 13px; color: var(--text-2); }

.grp { margin-top: 24px; }
.grp:first-child { margin-top: 0; }
.grp header { position: sticky; top: var(--bar-h, 108px); z-index: 5; display: grid; grid-template-columns: 1fr auto; align-items: end; margin: 0 -20px; padding: 10px 24px; background: var(--bg-blur); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
.grp header small { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.grp header h2 { font-size: 24px; font-weight: 700; line-height: 1.2; letter-spacing: -.03em; }
.grp header span { font-size: 13px; font-weight: 500; color: var(--text-3); padding-bottom: 3px; }
.card { border-radius: 20px; background: var(--card); overflow: hidden; }

.item { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; text-align: left; padding: 15px 14px 15px 18px; animation: rise .45s var(--ease) both; transition: background .15s; }
.item + .item::before { content: ''; position: absolute; top: 0; left: 18px; right: 0; height: 1px; background: var(--line); }
@media (hover: hover) { .item:hover { background: var(--fill); } }
.item:active { transform: none; background: var(--fill-strong); }
.still .item { animation: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.item .name { font-size: 18px; font-weight: 650; line-height: 1.3; letter-spacing: -.02em; }
.item .side { grid-row: 1 / span 3; grid-column: 2; align-self: center; display: flex; align-items: center; gap: 8px; }
.item .chev { width: 16px; height: 16px; stroke-width: 2.4; color: var(--text-3); transition: transform .2s var(--ease), color .2s; }
@media (hover: hover) { .item:hover .chev { color: var(--accent); transform: translateX(2px); } }
.item .dist { font-size: 14px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.item .dist small { display: block; font-size: 12px; font-weight: 500; color: var(--text-3); }
.item .tip { grid-column: 1; margin-top: 3px; font-size: 15px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .meta { grid-column: 1; margin-top: 5px; font-size: 13px; color: var(--text-3); }
.item .meta b { font-weight: 600; color: var(--accent); }
/* 추천(#추천): 별 핀 + 별 아이콘만, 나머지는 일반 장소와 같은 스타일 */
.star { display: inline-block; width: .82em; height: .82em; margin-right: .22em; vertical-align: -.04em; fill: var(--accent); stroke: none; }
.mk-label .star { fill: var(--c); }
.tags .pickchip::before { content: none; }
.sheet .tags .picktag { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.pin.pick { display: grid; place-items: center; width: 26px; height: 26px; z-index: 1; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent), 0 2px 8px rgba(0, 0, 0, .45); }
.pin.pick .star { width: 13px; height: 13px; margin: 0; fill: #fff; }

/* 내 여행 */
.triphead { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 4px 12px; }
.triphead h2 { font-size: 28px; font-weight: 700; letter-spacing: -.03em; }
.triphead span { font-size: 13px; color: var(--text-3); }
.tripbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.tripbar button, .tripedit button { height: 40px; padding: 0 16px; border-radius: 12px; font-size: 14px; font-weight: 600; background: var(--fill); transition: transform .2s var(--ease), background .2s; }
.tripbar .fill { background: var(--accent); color: #fff; }
.tripbar .on { background: var(--text); color: var(--bg); }
.sharedbox { margin-bottom: 14px; padding: 16px 18px; border-radius: 18px; background: var(--accent-soft); }
.sharedbox p { margin-bottom: 12px; font-size: 15px; color: var(--text); }
.trow { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 14px 12px 14px 16px; }
.trow + .trow::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); }
.tno { display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; background: var(--c); color: #fff; font-size: 12px; font-weight: 700; }
/* 삭제 모드: 항목 전체를 눌러 고르고, 고른 항목은 흐려져 삭제 대상임을 보여 줌 */
.editing .trow { cursor: pointer; transition: background .15s; }
@media (hover: hover) { .editing .trow:hover { background: var(--fill); } }
.editing .trow .tmain { pointer-events: none; transition: opacity .2s; }
.tcheck { display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text-3); color: transparent; transition: background .2s, box-shadow .2s, color .2s; }
.tcheck svg { width: 13px; height: 13px; stroke-width: 2.2; }
.editing .trow.sel, .editing .trow.sel:hover { background: var(--accent-soft); } /* 고른 표시는 항상 우선 */
.trow.sel .tmain { opacity: .38; }
.trow.sel .tname { text-decoration: line-through; }
.trow.sel .tcheck { background: var(--accent); box-shadow: none; color: #fff; }
.tname { display: block; max-width: 100%; text-align: left; font-size: 17px; font-weight: 650; line-height: 1.3; letter-spacing: -.02em; }
.tname:active { transform: none; opacity: .5; }
.tmain small { display: block; margin-top: 2px; font-size: 13px; color: var(--text-3); }
.stops.sub { margin: 10px 0 2px; gap: 7px; }
.stops.sub li { font-size: 14px; color: var(--text-2); }
.stops.sub li.side { margin-left: 28px; font-size: 13px; }
.stops.sub b { min-width: 19px; height: 19px; font-size: 11px; }
.tmemo { display: block; width: 100%; margin-top: 6px; padding: 9px 12px; border: 0; outline: 0; resize: none; overflow: hidden; border-radius: 10px; background: var(--fill); color: var(--text); font: inherit; font-size: 15px; line-height: 1.5; word-break: break-word; }
.tmemo:focus { box-shadow: 0 0 0 2px var(--accent); }
.tmemo-ro { margin-top: 6px; font-size: 15px; line-height: 1.55; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.tripbar button { display: inline-flex; align-items: center; gap: 6px; }
.tripbar button svg { width: 15px; height: 15px; stroke-width: 2.4; }
.tripbar.main { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.tripbar.main button { justify-content: center; height: 46px; border-radius: 14px; font-size: 15px; }
.tripbar.main button svg { width: 17px; height: 17px; stroke-width: 2; }
.tripbar.sub { flex-wrap: nowrap; justify-content: space-between; align-items: center; margin: 6px 0 2px; }
.tripbar.sub button { white-space: nowrap; }
.tripbar button svg { flex: none; }
.tripbar.main button { white-space: nowrap; }
@media (max-width: 400px) { .tripbar.sub .long { display: none; } .tripbar.main button { font-size: 14px; gap: 5px; } }
/* 가져오기: 버튼으로 보이게 (알약 모양 · 배경) */
.tripbar.sub [data-act="import"] { height: 38px; padding: 0 15px 0 12px; border-radius: 19px; background: var(--fill); color: var(--text); font-size: 14px; font-weight: 600; }
@media (hover: hover) { .tripbar.sub [data-act="import"]:hover { background: var(--fill-strong); } }
/* 삭제 모드: 켜고 끄는 스위치 */
.tripbar .tswitch { flex: none; height: 38px; padding: 0 0 0 4px; gap: 7px; background: none !important; color: var(--text-2); font-size: 14px; font-weight: 600; }
.tswitch:active { transform: none; }
.tswitch svg { width: 16px; height: 16px; stroke-width: 1.9; }
.tswitch .sw { position: relative; flex: none; width: 46px; height: 28px; margin-left: 2px; border-radius: 14px; background: var(--fill-strong); transition: background .25s; }
.tswitch .sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25); transition: transform .3s var(--ease); }
.tswitch.on { color: var(--accent); }
.tswitch.on .sw { background: var(--accent); }
.tswitch.on .sw::after { transform: translateX(18px); }
.tripbar.center { justify-content: center; margin-top: -48px; padding-bottom: 60px; }
.spin { display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; border-radius: 50%; border: 2.2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions button:disabled { opacity: .75; cursor: default; }
.savedhint { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; line-height: 1.5; color: var(--text); }
.savedhint b { font-weight: 700; }
.flabel { display: block; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field { display: block; width: 100%; height: 46px; margin-top: 6px; padding: 0 14px; border: 0; outline: 0; border-radius: 13px; background: var(--fill); color: var(--text); font: inherit; font-size: 16px; }
.field:focus { box-shadow: 0 0 0 2px var(--accent); }
select.field option { background: var(--raised); color: var(--text); }
.fcols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* 내 여행의 티켓: 참고사항을 기본으로 보여 줌 (메모는 그 아래) */
.ttip { margin: 8px 0 2px; padding: 10px 12px; border-radius: 10px; background: var(--fill); font-size: 14px; line-height: 1.5; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.tnote { margin-top: 6px; font-size: 15px; color: var(--text-2); }
.tnote b { margin-right: 8px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.tfields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tfields select, .tfields input { height: 36px; min-width: 0; padding: 0 10px; border: 0; outline: 0; border-radius: 10px; background: var(--fill); color: var(--text); font: inherit; font-size: 14px; }
/* 펼친 목록은 반투명 배경을 못 쓰므로 불투명한 색을 직접 지정 (다크모드에서 밝은 글자 + 밝은 배경이 되는 문제) */
.tfields select option { background: var(--raised); color: var(--text); }
.tfields select:focus, .tfields input:focus { box-shadow: 0 0 0 2px var(--accent); }
.tlabel { display: flex; align-items: center; gap: 6px; padding-left: 10px; border-radius: 10px; background: var(--fill); font-size: 13px; font-weight: 600; color: var(--text-2); }
.tlabel input { padding-left: 2px; background: none; }
.tlabel:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.tlabel input:focus { box-shadow: none; }
.tlabel { min-width: 0; }
.tlabel input { min-width: 0; width: 100%; }
@media (max-width: 480px) { .tfields select { flex: 1 1 100%; } .tlabel { flex: 1 1 0; gap: 4px; padding-left: 9px; } .tlabel input { padding-right: 4px; } .tlabel input::-webkit-calendar-picker-indicator { display: none; } }
.thandle { width: 36px; height: 44px; margin: -4px -4px 0 0; border-radius: 10px; display: grid; place-items: center; color: var(--text-3); cursor: grab; touch-action: none; }
.thandle svg { width: 20px; height: 20px; stroke-width: 2; }
@media (hover: hover) { .thandle:hover { background: var(--fill); color: var(--text-2); } }
.thandle:active { transform: none; cursor: grabbing; }
.tghost { opacity: .25; }
.tdrag { border-radius: 16px; background: var(--raised); box-shadow: var(--shadow); opacity: .97 !important; }
.tdrag::before { display: none; }
.dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }
.tcard { min-height: 56px; }
.newday { opacity: .55; transition: opacity .2s; }
.dragging .newday { opacity: 1; }
.newday .tcard { background: none; box-shadow: inset 0 0 0 1.5px var(--line); }
.dragging .newday .tcard { box-shadow: inset 0 0 0 1.5px var(--accent); }
.drophint { padding: 17px 16px; font-size: 14px; color: var(--text-3); text-align: center; }
.tcard .trow ~ .drophint, .tcard .drophint:not(:only-child) { display: none; }
/* 메모 항목 */
.trow.note { background: color-mix(in srgb, var(--c, var(--text-3)) 0%, transparent); }
.tno.memo { background: none; box-shadow: inset 0 0 0 1.5px var(--c); color: var(--c); }
.tno.memo svg { width: 13px; height: 13px; stroke-width: 2; }
.trow.note .tmemo { margin-top: 0; }
.trow.note .tfields { margin-top: 0; margin-bottom: 8px; }
.trow.note .tmemo-ro { margin-top: 2px; color: var(--text); }
.trow.note .tmemo-ro i { color: var(--text-3); font-style: normal; }
.addnote { position: relative; display: flex; align-items: center; gap: 6px; width: 100%; padding: 11px 16px; font-size: 13px; font-weight: 600; color: var(--text-3); order: 99; }
.addnote svg { width: 14px; height: 14px; stroke-width: 2; }
@media (hover: hover) { .addnote:hover { color: var(--text-2); background: var(--fill); } }
.addnote:active { transform: none; }
.tcard { display: flex; flex-direction: column; }
.tcard .trow ~ .addnote::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); }
.tmove { display: grid; gap: 4px; }
.tmove button { width: 32px; height: 28px; border-radius: 9px; background: var(--fill); color: var(--text-2); font-size: 10px; }
.tmove button:disabled, .tripedit button:disabled { opacity: .3; cursor: default; }
.tripedit { position: sticky; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 6; display: flex; gap: 8px; margin-top: 18px; padding: 10px; border-radius: 18px; background: var(--bg-blur); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); box-shadow: var(--shadow); }
.tripedit button { flex: 1; color: var(--accent); }
.actions .tripadd { grid-column: 1 / -1; background: var(--accent-soft); color: var(--accent); }
.actions .tripadd.on { background: var(--fill); color: var(--text-2); }

.empty { padding: 80px 0; text-align: center; color: var(--text-2); }

/* Map */
#map { height: min(68vh, 640px); margin-top: 6px; border-radius: 22px; overflow: hidden; background: var(--fill); z-index: 0; }
.mk-label { z-index: 2; display: block; text-align: center; cursor: pointer; max-width: 116px; padding: 4px 9px 5px; border-radius: 11px; border-bottom: 2.5px solid var(--c); background: var(--raised); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 4px 14px rgba(0, 0, 0, .18); font-size: 12px; font-weight: 650; line-height: 1.25; letter-spacing: -.02em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .2s; }
.mk-label small { display: block; font-size: 10px; font-weight: 700; color: var(--c); }
.mk-label.off { visibility: hidden; }
.mk-label:active, .pin:active { transform: none; }
.pin { padding: 0; cursor: pointer; width: 18px; height: 18px; border-radius: 50%; background: var(--c, var(--accent)); border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
.me { width: 18px; height: 18px; border-radius: 50%; background: #0a84ff; border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(10, 132, 255, .25), 0 2px 6px rgba(0, 0, 0, .3); }
.pin.stop.wide { width: auto; padding: 0 8px; border-radius: 13px; white-space: nowrap; }
.pin.stop { display: grid; place-items: center; width: 24px; height: 24px; color: #fff; font-size: 12px; font-weight: 700; z-index: 1; }
.legend { position: absolute; z-index: 3; left: 10px; right: 60px; top: 10px; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.legend button { pointer-events: auto; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px 0 9px; border-radius: 15px; font-size: 12px; font-weight: 600; background: var(--bg-blur); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px); box-shadow: 0 1px 6px rgba(0, 0, 0, .14); transition: opacity .2s, transform .2s var(--ease); }
.legend button.dim { opacity: .45; }
.legend .clip { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.maplibregl-map { font: inherit; }
.maplibregl-ctrl-group { border-radius: 12px !important; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, .14) !important; }

footer p + p { margin-top: 6px; }
footer { padding-top: 12px; padding-bottom: max(40px, env(safe-area-inset-bottom)); font-size: 12px; color: var(--text-3); }

/* Sheet */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .32); opacity: 0; transition: opacity .35s; }
.scrim.open { opacity: 1; }
.sheet { position: fixed; z-index: 31; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; margin: 0 auto; max-width: 560px; padding: 10px 24px max(24px, env(safe-area-inset-bottom)); background: var(--raised); border-radius: 28px 28px 0 0; box-shadow: var(--shadow); transform: translateY(105%); transition: transform .5s var(--ease); }
.sheet.open { transform: none; }
.sheet.dragging { transition: none; }
.sheet .grab { touch-action: none; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--fill-strong); margin: 0 auto 18px; }
.sheet .close { position: absolute; top: 16px; right: 16px; width: 30px; height: 30px; border-radius: 50%; background: var(--fill); color: var(--text-2); display: grid; place-items: center; }
.sheet .close svg { width: 14px; height: 14px; stroke-width: 2.4; }
.sheet .kind { font-size: 13px; font-weight: 600; color: var(--accent); }
.sheet h2 { font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -.03em; margin: 4px 36px 0 0; }
.sheet .where { margin-top: 6px; font-size: 15px; color: var(--text-2); }
.sheet .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.sheet .tags span { font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 12px; background: var(--fill); color: var(--text-2); }
.sheet h3 { margin-top: 26px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.sheet .tiptext { margin-top: 6px; font-size: 18px; line-height: 1.55; white-space: pre-line; }
.sheet .addr { margin-top: 6px; font-size: 15px; color: var(--text-2); word-break: normal; }
.stops { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.stops li { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.stops b { flex: none; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #12A5B8; color: #fff; font-size: 12px; font-weight: 700; }
.stops b.start { background: #1FA971; }
.stops b.end { background: #F2542D; }
.stops b.side { background: none; box-shadow: inset 0 0 0 1.5px var(--c); color: var(--c); }
.stops li.side { margin-left: 32px; font-size: 15px; color: var(--text-2); }
.stops li small { font-size: 13px; color: var(--text-3); }
.pin.stop.side { font-size: 11px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 28px; }
.actions a, .actions button { display: grid; place-items: center; height: 50px; border-radius: 15px; font-size: 16px; font-weight: 600; text-decoration: none; background: var(--fill); color: var(--text); transition: transform .2s var(--ease); }
.actions a:active { transform: scale(.97); }
.actions .primary { grid-column: 1 / -1; background: var(--accent); color: #fff; }

@media (min-width: 640px) {
  .sheet { bottom: auto; top: 50%; border-radius: 28px; padding-top: 28px; transform: translateY(-46%) scale(.96); opacity: 0; pointer-events: none; transition: transform .4s var(--ease), opacity .25s; }
  .sheet.open { transform: translateY(-50%); opacity: 1; pointer-events: auto; }
  .sheet .grab { display: none; }
  .item { border-radius: 0; }
  .item:hover .name { color: var(--accent); }
}

.toast { position: fixed; z-index: 40; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); padding: 10px 18px; border-radius: 20px; font-size: 14px; font-weight: 600; background: var(--text); color: var(--bg); opacity: 0; transition: opacity .3s, transform .4s var(--ease); }
.toast.open { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
