:root {
  --sea: #EAF3F2;      /* page: sea glass */
  --paper: #FFFFFF;
  --ink: #12313D;      /* Andaman night */
  --ink-2: #4A6670;
  --line: #C9DCDA;
  --pink: #E5197E;     /* Bangkok taxi pink */
  --yellow: #F7C318;   /* tuk-tuk yellow */
  --green: #1F8A70;    /* longtail green */
  --moon: #5B5FC7;     /* Koh Phangan night */
  --r: 14px;
  --display: 'Mitr', system-ui, sans-serif;
  --body: 'Sarabun', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }
body { margin: 0; background: var(--sea); color: var(--ink); font: 400 17px/1.55 var(--body); padding-bottom: 72px; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; line-height: 1.15; margin: 0; }
a { color: var(--ink); text-decoration-color: var(--pink); text-underline-offset: 3px; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.nowrap { white-space: nowrap; }
.note { color: var(--ink-2); font-size: 15px; margin: 6px 0 18px; max-width: 70ch; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff; }
.top-row { display: flex; align-items: center; gap: 16px; justify-content: space-between; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { font-family: var(--display); font-size: 20px; color: #fff; text-decoration: none; }
.brand::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--pink); box-shadow: 14px 0 0 var(--yellow); margin-right: 24px; vertical-align: 1px; }
.me { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.me .who { border-color: rgba(255,255,255,.35); color: #fff; }
.me .who.on { background: var(--yellow); color: var(--ink); border-color: var(--yellow); }
.me-label { font-size: 13px; opacity: .75; margin-right: 2px; }
.me.pulse { animation: pulse .9s ease 2; }
@keyframes pulse { 50% { transform: scale(1.04); filter: drop-shadow(0 0 8px var(--yellow)); } }
.offline { font-size: 13px; color: var(--yellow); }

/* chips / pills */
.who { border: 1.5px solid var(--line); background: transparent; border-radius: 999px; padding: 5px 13px; font-size: 15px; line-height: 1.3; }
.who.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.who.edit { border-style: dashed; }
.seg, .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }

/* hero */
.hero { padding-top: 44px; padding-bottom: 18px; }
.hero h1 { font-size: clamp(34px, 6.4vw, 66px); font-weight: 600; letter-spacing: -0.01em; max-width: 15ch; }
.lede { font-size: 18px; max-width: 60ch; margin: 18px 0 26px; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0; border-top: 2px solid var(--ink); }
.fact { padding: 14px 16px 6px 0; display: flex; flex-direction: column; }
.fact b { font-family: var(--display); font-weight: 500; font-size: 24px; }
.fact span { color: var(--ink-2); font-size: 15px; }

.block { padding-top: 56px; }
.block h2 { font-size: clamp(26px, 4vw, 38px); }

/* options */
.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.opt { background: var(--paper); border-radius: var(--r); padding: 20px 20px 16px; display: flex; flex-direction: column; border: 2px solid transparent; }
.opt.shown { border-color: var(--ink); }
.opt-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.opt h3 { font-size: 22px; }
.tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--sea); white-space: nowrap; }
.tag.pick { background: var(--yellow); }
.opt-dates { margin: 6px 0 0; font-weight: 600; }
.opt-dates span { font-weight: 400; color: var(--ink-2); }
.opt-price { font-family: var(--display); font-size: 30px; margin: 6px 0 10px; }
.opt-price span { font-family: var(--body); font-size: 15px; color: var(--ink-2); }
.route { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; font-size: 14px; }
.route li { padding: 2px 0; }
.route li + li::before { content: '›'; margin: 0 7px; color: var(--pink); font-weight: 700; }
.pros, .cons { list-style: none; padding: 0; margin: 0 0 6px; font-size: 15px; }
.pros li::before, .cons li::before { display: inline-block; width: 18px; font-weight: 700; }
.pros li::before { content: '+'; color: var(--green); }
.cons li::before { content: '–'; color: var(--pink); }
.opt-foot { margin-top: auto; padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; text-decoration-color: var(--pink); text-underline-offset: 3px; font-size: 15px; }

/* votes */
.vote { display: flex; align-items: center; gap: 8px; }
.vote-btn { border: 2px solid var(--ink); background: transparent; border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 15px; }
.vote-btn.on { background: var(--pink); border-color: var(--pink); color: #fff; }
.faces { display: inline-flex; }
.face { width: 26px; height: 26px; border-radius: 50%; background: var(--yellow); display: grid; place-items: center; font-size: 13px; font-weight: 700; border: 2px solid var(--paper); margin-left: -6px; }
.face:first-child { margin-left: 0; }
.vote-n { font-size: 13px; color: var(--ink-2); }

/* calendar: the one loud thing */
.cal-block { background: var(--ink); color: #fff; margin-top: 56px; padding: 48px 0 40px; }
.cal-block .note, .cal-block .me-label { color: #B9CFD3; }
.cal-block .who { border-color: rgba(255,255,255,.3); color: #fff; }
.cal-block .who.on { background: #fff; color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: #D9E6E8; margin-bottom: 10px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 18px; height: 14px; border-radius: 3px; display: inline-block; }
.cal-show { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 18px; }
.months { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 28px; }
.month h3 { font-size: 30px; margin-bottom: 8px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wd { font-size: 12px; text-align: center; color: #9DB6BB; padding-bottom: 2px; }
.day { position: relative; aspect-ratio: 1 / 1.05; border: 0; border-radius: 8px; background: var(--bg); color: var(--ink); padding: 4px 5px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; min-width: 0; }
.day .dn { font-family: var(--display); font-size: 16px; line-height: 1; }
.day.wknd .dn { color: var(--pink); }
.day .fp { font-size: 10.5px; color: #3D5A63; line-height: 1; white-space: nowrap; overflow: hidden; }
.marks { display: flex; gap: 3px; align-items: center; min-height: 9px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ev { background: var(--pink); }
.dot.mp { background: var(--moon); box-shadow: 0 0 0 2px #fff; }
.moon { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.moon.full { background: #fff; box-shadow: inset 0 0 0 1.5px var(--ink); }
.moon.dark { background: var(--ink); box-shadow: 0 0 0 1.5px #fff; }
.legend .moon.full { box-shadow: none; }
.day.trip { box-shadow: inset 0 -5px 0 var(--yellow); }
.day.start, .day.end { box-shadow: inset 0 -5px 0 var(--yellow), 0 0 0 2px var(--yellow); }
.day.sel { outline: 3px solid #fff; outline-offset: 1px; }
.day-detail { margin-top: 22px; background: var(--paper); color: var(--ink); border-radius: var(--r); padding: 18px 20px; }
.day-detail .note { margin: 0; }
.day-detail h3 { font-size: 24px; margin-bottom: 8px; }
.day-detail dl { margin: 0; }
.dd-row { display: grid; grid-template-columns: minmax(120px, 230px) 1fr; gap: 4px 16px; padding: 7px 0; border-top: 1px solid var(--line); }
.dd-row dt { color: var(--ink-2); font-size: 15px; }
.dd-row dd { margin: 0; }
.dd-row ul { margin: 0; padding-left: 18px; }
.dd-row li.sold { color: var(--ink-2); }
.dd-row li.party { font-weight: 600; }

.day .rain { position: absolute; top: 0; left: 0; height: 3px; background: #2F7FD8; border-radius: 8px 0 0 0; }
.wx { list-style: none; padding: 0 !important; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 14px; }
.wx li { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; }
.wx em { grid-column: 1 / -1; font-style: normal; font-size: 13px; color: var(--ink-2); }
.wx-src { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }

/* finder */
.weights { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 20px; background: var(--paper); border-radius: var(--r); padding: 16px 20px; margin-bottom: 16px; }
.wt { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-weight: 600; font-size: 15px; }
.wt input { grid-column: 1 / -1; accent-color: var(--pink); width: 100%; }
.wt em { font-style: normal; font-weight: 400; color: var(--ink-2); font-size: 14px; }
.finder { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 10px; }
.win { background: var(--paper); border-radius: var(--r); padding: 14px 18px; display: grid; grid-template-columns: 52px 1fr; gap: 14px; border: 2px solid transparent; }
.win.shown { border-color: var(--ink); }
.win-rank { display: flex; flex-direction: column; align-items: center; }
.win-rank b { font-family: var(--display); font-weight: 500; font-size: 28px; line-height: 1; }
.win-rank span { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.win-rank span::after { content: ' pts'; }
.win h3 { font-size: 19px; }
.win-kind { font-family: var(--body); font-size: 15px; color: var(--ink-2); font-weight: 400; }
.win-nums { margin: 4px 0 8px; font-size: 15px; color: var(--ink-2); }
.win-nums b { color: var(--ink); font-family: var(--display); font-weight: 500; font-size: 20px; }
.catch { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.catch li { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--sea); }
.catch li.party { background: #FDE0EE; }
.catch li.culture { background: #E3E4F7; }
.catch li.warn { background: #FFF4CC; }
.win .opt-foot { padding-top: 10px; }

/* trip map (sketchbook) */
.map-wrap { position: relative; }
#tripMap { height: 640px; border-radius: var(--r); overflow: hidden; background: #CFE8EC; touch-action: none; }
#tripMap svg { width: 100%; height: 100%; display: block; cursor: grab; }
#tripMap .st-name { font: 700 28px 'Caveat', cursive; fill: var(--ink); }
#tripMap .st.here circle { stroke: var(--pink); stroke-width: 4; }
.map-panel { position: absolute; left: 16px; bottom: 16px; top: 16px; width: min(340px, 42%); background: #FFFDF2; border: 2.5px solid var(--ink); border-radius: 14px; padding: 14px 16px; box-shadow: 5px 5px 0 var(--ink); display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.map-panel h3 { font: 700 30px/1 'Caveat', cursive; margin: 4px 0 0; }
.map-panel p { margin: 0; font-size: 15px; }
.mp-trips { display: flex; flex-wrap: wrap; gap: 5px; }
.mp-trips .who { font-size: 13px; padding: 3px 10px; }
.mp-city { font-weight: 700; color: var(--green); }
.mp-move, .mp-near { color: var(--ink-2); font-size: 14px !important; }
.mp-rain { font-size: 14px !important; color: #2F7FD8; font-weight: 600; }
.mp-ev { margin: 2px 0; padding-left: 18px; font-size: 14px; color: var(--pink); }
.mp-ctl { margin-top: auto; padding-top: 8px; }
.mp-ctl input { width: 100%; accent-color: var(--pink); }
.mp-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.map-key { font: 600 20px/1.3 'Caveat', cursive; color: var(--ink-2); margin: 10px 0 0; }
.k-stay { display: inline-block; width: 10px; height: 10px; background: var(--yellow); border: 1.5px solid var(--ink); border-radius: 2px; }
.k-do { display: inline-block; width: 10px; height: 10px; background: var(--green); border-radius: 50%; }
.k-ev { color: var(--pink); } .k-moon { color: var(--moon); }
@media (max-width: 760px) {
  #tripMap { height: 440px; }
  .map-panel { position: static; width: auto; margin-top: 12px; box-shadow: 4px 4px 0 var(--ink); }
}

/* plan */
.plan { list-style: none; padding: 0; margin: 0; }
.pl { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.pl.new-city { border-top: 2px solid var(--ink); }
.pl-when b { font-family: var(--display); font-weight: 500; }
.pl-city { font-weight: 700; color: var(--green); }
.pl-body p { margin: 2px 0 0; }
.pl-move { font-size: 14px; color: var(--ink-2); }

/* things + stays */
.things, .stays { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.thing, .stay { background: var(--paper); border-radius: var(--r); padding: 16px 18px 14px; display: flex; flex-direction: column; border-left: 5px solid var(--line); }
.thing.festival, .thing.party { border-left-color: var(--pink); }
.thing.adventure, .thing.nature { border-left-color: var(--green); }
.thing.sport { border-left-color: var(--yellow); }
.thing.culture, .thing.food { border-left-color: var(--moon); }
.stay { border-left-color: var(--yellow); }
.thing-top { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.thing h3, .stay h3 { font-size: 19px; }
.fits { font-size: 13px; background: var(--sea); padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.thing-meta { margin: 4px 0 6px; font-size: 14px; color: var(--ink-2); }
.thing p, .stay p { margin: 0 0 4px; font-size: 15px; }
.cost { font-weight: 600; font-size: 15px; }
.watch { color: var(--ink-2); }
.stay .vote { margin-top: auto; padding-top: 10px; }

/* budget */
.budget { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.budget-controls, .budget-out { background: var(--paper); border-radius: var(--r); padding: 18px 20px; }
.budget-out { position: sticky; top: 76px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }
.field select, .field input { font: inherit; color: var(--ink); padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acts { border: 0; padding: 0; margin: 4px 0 0; }
.acts legend { font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.act { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; font-size: 15px; padding: 3px 0; }
.act input { width: 18px; height: 18px; accent-color: var(--pink); }
.act em { font-style: normal; color: var(--ink-2); font-size: 14px; }
.total { font-family: var(--display); font-size: 44px; margin: 0; }
.total span { display: block; font-family: var(--body); font-size: 15px; color: var(--ink-2); }
.bar { height: 12px; border-radius: 999px; background: var(--sea); overflow: hidden; margin: 10px 0 0; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.bar.over i { background: var(--pink); }
.budget-out table { width: 100%; border-collapse: collapse; font-size: 15px; }
.budget-out td { padding: 6px 0; border-top: 1px solid var(--line); }
.budget-out td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.budget-out tr.sub td { color: var(--ink-2); }

/* checklist */
.todo { list-style: none; padding: 0; margin: 0; background: var(--paper); border-radius: var(--r); }
.todo li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--line); }
.todo li:first-child { border-top: 0; }
.todo label { display: flex; gap: 10px; align-items: center; }
.todo input { width: 20px; height: 20px; accent-color: var(--green); flex: none; }
.todo li.done span:not(.face):not(.when) { text-decoration: line-through; color: var(--ink-2); }
.when { font-size: 13px; color: var(--ink-2); white-space: nowrap; }

.foot { padding-top: 48px; padding-bottom: 32px; color: var(--ink-2); font-size: 15px; }

/* bottom dock */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--paper); border-top: 1px solid var(--line); display: flex; justify-content: center; gap: 2px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.dock { overflow-x: auto; justify-content: safe center; scrollbar-width: none; }
.dock a { text-decoration: none; padding: 8px 12px; border-radius: 10px; font-size: 15px; font-weight: 600; flex: none; }
.dock a:hover { background: var(--sea); }

dialog { border: 0; border-radius: var(--r); padding: 22px; width: min(92vw, 380px); color: var(--ink); }
dialog::backdrop { background: rgba(18, 49, 61, .5); }
dialog h3 { font-size: 22px; margin-bottom: 12px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-2); margin-bottom: 10px; }
dialog input { font: inherit; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ghost, .solid { border-radius: 999px; padding: 7px 16px; font-weight: 600; border: 2px solid var(--ink); background: transparent; }
.solid { background: var(--ink); color: #fff; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  .nowrap { white-space: normal; }
  .budget { grid-template-columns: 1fr; }
  .budget-out { position: static; }
  .pl { grid-template-columns: 1fr; gap: 2px; }
  .dd-row { grid-template-columns: 1fr; }
  .months { grid-template-columns: 1fr; }
  .day .fp { font-size: 9.5px; }
  .dock a { padding: 8px 8px; font-size: 14px; }
  .top-row { flex-wrap: nowrap; gap: 10px; min-height: 52px; }
  .brand { font-size: 17px; flex: none; }
  .brand::before { margin-right: 20px; }
  .me { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 16px; }
  .me .me-label { display: none; }
  .me .who { flex: none; font-size: 14px; padding: 4px 11px; }
  html { scroll-padding-top: 64px; }
}
.map-zoom { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.map-zoom button { width: 40px; height: 40px; border-radius: 10px; border: 2.5px solid var(--ink); background: #FFFDF2; font: 600 24px/1 'Mitr', sans-serif; box-shadow: 3px 3px 0 var(--ink); }
.map-zoom button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
#tripMap { position: relative; }
