/* 同窗蹭饭地图 · mobile-first redesign */
:root {
  --ink: #17153a; --sub: #4f4c74; --muted: #66638a; --line: #ebe9f5; --chip: #f1f0f8; --bg: #f4f3fb;
  --accent: #4b3bea; --fresh: #0a7a42; --fresh-bg: #dcf5e7; --danger: #c0303a;
  --float: rgba(255, 255, 255, .88); --shadow: 0 8px 24px rgba(23, 21, 58, .14);
  --r-sheet: 24px; --r-ctl: 12px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, 'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; overscroll-behavior: none; }
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted, .s { color: var(--sub); }
.small { font-size: 13px; }

/* Buttons and fields shared by the sheet and dialogs */
.primary { min-height: 52px; padding: 0 20px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 700; font-size: 17px; }
.secondary { min-height: 52px; padding: 0 20px; border-radius: 14px; background: var(--chip); font-weight: 600; font-size: 17px; }
.primary:active, .secondary:active, .mem:active, .chips button:active { transform: scale(.98); transition: transform 100ms ease-out; }
.text-button, .quiet-link { min-height: 44px; padding: 0 4px; color: var(--accent); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.text-button.danger, .danger-button { color: var(--danger); }
label { display: block; font-size: 14px; font-weight: 600; color: var(--sub); margin-top: 14px; }
input:not([type=checkbox]), textarea { display: block; width: 100%; min-height: 48px; margin-top: 6px; padding: 10px 14px; border: 1px solid #dddbea; border-radius: var(--r-ctl); background: #fff; font-size: 16px; font-weight: 400; color: var(--ink); }
input:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -1px; }
label.checkbox { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.form-error { color: var(--danger); font-size: 14px; margin-top: 10px; }
form .primary { width: 100%; margin-top: 18px; }

/* Gate */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 18px calc(24px + var(--safe-bottom)); }
.gate-card { width: 100%; max-width: 420px; background: #fff; border-radius: 24px; padding: 28px 22px; box-shadow: var(--shadow); }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); }
.gate-card h1 { font-size: 26px; letter-spacing: -.02em; margin: 6px 0 8px; }
.gate-card .text-button { width: 100%; justify-content: center; margin-top: 8px; }
#entry-hint:empty { display: none; }

/* App shell: the map fills the screen; controls float above it */
#app { position: fixed; inset: 0; overflow: hidden; overflow: clip; }  /* clip: nothing (focus, scrollIntoView) may scroll the shell */
.map { position: absolute; inset: 0 0 var(--map-bottom, 0); z-index: 0; background: #e9eef5; }
#app[data-detent=full] .map { pointer-events: none; }
.map-status { position: absolute; z-index: 25; left: 16px; right: 16px; top: calc(120px + var(--safe-top)); background: #fff; border-radius: var(--r-ctl); padding: 12px 14px; box-shadow: var(--shadow); font-size: 14px; }
.top { position: absolute; top: calc(10px + var(--safe-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; z-index: 20; }
.seg { display: flex; background: var(--float); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: var(--r-ctl); padding: 3px; box-shadow: var(--shadow); }
.seg button { white-space: nowrap; min-height: 44px; display: flex; align-items: center; padding: 0 10px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--sub); }
.seg button.on { background: var(--ink); color: #fff; }
.seg em { font-style: normal; margin-left: 4px; color: var(--muted); }
.seg .on em { color: #c9c6e6; }
.mebtn { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 4px; border-radius: 22px; background: var(--float); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; }
.mebtn i { width: 36px; height: 36px; border-radius: 50%; background: #ffd84d; display: grid; place-items: center; font-style: normal; font-weight: 700; }
.mebtn .dot { width: 8px; height: 8px; border-radius: 50%; background: #e5484d; }
.fchip { position: absolute; left: 12px; top: calc(64px + var(--safe-top)); z-index: 20; min-height: 44px; padding: 0 14px; border-radius: 22px; background: var(--float); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; }
.fchip u { text-decoration: none; color: var(--accent); margin-left: 6px; }

/* Count dots on the map (ClassMap markers) */
.pt { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.pt .d { border-radius: 50%; display: grid; place-items: center; font-weight: 700; border: 2px solid #fff; box-shadow: 0 3px 8px rgba(23, 21, 58, .25); transition: transform 220ms cubic-bezier(.22, 1, .36, 1), box-shadow 220ms; }
.pt .nm { margin-top: 2px; font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--ink); text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 3px #fff; }
.pt.cl .d { box-shadow: 4px -4px 0 -1px #fff, 4px -4px 0 1px rgba(23, 21, 58, .15), 0 3px 8px rgba(23, 21, 58, .25); }
.pt.sel .d { transform: scale(1.5); box-shadow: 0 8px 18px rgba(23, 21, 58, .4); }
.pt.sel .nm { margin-top: 14px; font-size: 14px; }

/* Bottom sheet */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; height: calc(100% - 8px - var(--safe-top)); z-index: 30; display: flex; flex-direction: column;
  background: #fff; border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: 0 -8px 24px rgba(23, 21, 58, .12); touch-action: none; will-change: transform; }
.grab { flex: none; width: 100%; height: 44px; margin-bottom: -18px; display: grid; place-items: center; cursor: grab; touch-action: none; }
/* The header drags the sheet even when the list scrolls: no browser pan may claim the finger. */
#sheet-head { touch-action: none; }
.grab::before { content: ''; width: 36px; height: 5px; border-radius: 3px; background: #cfcde3; }
#sheet-body { flex: 1; min-height: 0; overflow: hidden; padding: 0 18px calc(24px + var(--safe-bottom)); }
.sheet[data-detent=full] #sheet-body { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#sheet-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
#sheet-summary { font-size: 14px; margin-top: 2px; }
.x { width: 44px; height: 44px; flex: none; display: grid; place-items: center; }
.x i { width: 32px; height: 32px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; font-style: normal; font-size: 20px; color: var(--sub); }

/* Confirmation presets */
.filter-label { margin-top: 12px; font-size: 13px; color: var(--muted); }
.chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chips button { min-height: 44px; border-radius: 22px; padding: 0 16px; font-size: 14px; font-weight: 600; background: var(--chip); }
.chips button.on { background: var(--ink); color: #fff; }
.legend { display: flex; align-items: center; gap: 6px; margin: 12px 0 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #dcdaee; }

/* Month/day popovers (replace native pickers) */
.picker { position: relative; z-index: 1; margin-top: 8px; background: #fff; border-radius: 16px; box-shadow: 0 10px 30px rgba(23, 21, 58, .2); padding: 10px; }
.picker .years { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.picker .years button { flex: none; min-height: 40px; min-width: 64px; border-radius: 20px; background: var(--chip); font-weight: 600; }
.picker .months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 6px; }
.picker .months button, .picker .days button { min-height: 44px; border-radius: 10px; background: var(--chip); font-weight: 600; }
.picker .days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 12px; color: var(--muted); }
.picker .on { background: var(--ink) !important; color: #fff; }
.picker-head button { min-height: 44px; font-weight: 700; }

/* Search (home sheet) */
.search { display: block; margin: 10px 0 0; }
.search input { margin-top: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Lists */
.sec { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 16px 0 2px; font-size: 14px; font-weight: 600; color: var(--sub); }
.sec small { font-weight: 400; font-size: 13px; color: var(--muted); }
.mem { width: 100%; display: flex; gap: 12px; align-items: center; min-height: 68px; padding: 10px 0; border-bottom: 1px solid var(--line); text-align: left; }
.mem .av { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 17px; flex: none; }
.mem .tx { flex: 1; min-width: 0; }
.mem b { font-size: 16px; font-weight: 600; }
.mem .s { display: block; font-size: 14px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mem .bio { display: block; font-size: 14px; margin-top: 2px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me { font-size: 12px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.fit-all { position: absolute; right: 12px; top: calc(64px + var(--safe-top)); z-index: 20; min-height: 44px; padding: 0 14px; border-radius: 22px; background: var(--float); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; }
.tag { font-size: 12px; font-weight: 600; border-radius: 6px; padding: 1px 6px; margin-left: 6px; background: var(--fresh-bg); color: var(--fresh); white-space: nowrap; }
.mem.old .av { filter: grayscale(1); opacity: .6; }
.mem.old b { color: var(--sub); }
.mem.old .tag { background: #f0eff6; color: var(--muted); }
.chev { color: #a9a7c4; flex: none; }
.more { width: 100%; min-height: 48px; border-radius: var(--r-ctl); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 14px; background: var(--chip); font-size: 15px; font-weight: 600; margin-top: 12px; text-align: left; }
.more span { color: var(--muted); font-weight: 400; font-size: 13px; }
.empty { padding: 20px 0 8px; color: var(--sub); }
.empty .secondary { margin-top: 12px; width: 100%; }
.account { display: flex; flex-wrap: wrap; gap: 0 16px; margin-top: 4px; }

/* Update-my-location flow */
.block { display: block; width: 100%; margin-top: 10px; }
.who { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 14px; color: var(--sub); }
.who b { color: var(--ink); font-weight: 600; }
.who .text-button { margin-left: auto; }
.card { border-radius: 16px; background: #f7f6fc; padding: 16px; margin: 10px 0 6px; }
.card .big { font-size: 20px; font-weight: 700; margin: 4px 0 2px; }
.note { font-size: 13px; color: var(--muted); text-align: center; margin-top: 10px; }
.tog { display: flex; background: var(--chip); border-radius: var(--r-ctl); padding: 3px; margin-top: 12px; }
.tog button { flex: 1; min-height: 44px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--sub); }
.tog button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(23, 21, 58, .15); }
.hint { font-size: 14px; color: var(--sub); margin-top: 8px; }
.sugg button { width: 100%; min-height: 52px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 600; text-align: left; }
.sugg button span { font-weight: 400; color: var(--muted); font-size: 14px; }
.opt { position: relative; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; min-height: 52px; border-bottom: 1px solid var(--line); font-size: 15px; margin-top: 6px; }
.opt .picker { flex-basis: 100%; }
.field-error { color: var(--danger); font-size: 14px; margin-top: 6px; }
.field-error:empty { display: none; }
.savebar { position: sticky; bottom: var(--kb, 0px); padding: 10px 0 4px; background: linear-gradient(transparent, #fff 30%); }

/* Member detail inside the sheet */
#member-detail h2 { font-size: 22px; font-weight: 700; }
.mini-map { height: 220px; border-radius: 16px; overflow: hidden; margin-top: 12px; background: #e9eef5; }
.map-inline-status { padding: 12px; color: var(--muted); font-size: 14px; }
.footprint-list { margin-top: 12px; }
.footprint { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.footprint .step { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.footprint h3 { font-size: 15px; font-weight: 600; }
.stay-date, .member-note { font-size: 13px; color: var(--sub); }
.record-actions, .actions { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.profile-summary { margin-top: 6px; color: var(--sub); }

/* Dialogs (auth, admin, editing) */
/* Upstream dialogs build plain <button>s; give every one a real 44px target. */
:where(dialog) button:not([class]) { min-height: 44px; padding: 0 14px; border-radius: var(--r-ctl); background: var(--chip); font-weight: 600; }
.danger-button { min-height: 44px; padding: 0 14px; border-radius: var(--r-ctl); background: #fdecee; font-weight: 600; }
.point-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; color: var(--sub); font-size: 14px; }
dialog { width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px); border: 0; border-radius: 20px; padding: 0 18px 20px; box-shadow: 0 20px 60px rgba(23, 21, 58, .3); color: var(--ink); }
dialog::backdrop { background: rgba(23, 21, 58, .4); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 14px 0 6px; background: #fff; }
.modal-head h2 { font-size: 20px; font-weight: 700; }
.icon-button { width: 44px; height: 44px; font-size: 24px; color: var(--sub); }
.segmented { display: flex; background: var(--chip); border-radius: var(--r-ctl); padding: 3px; margin: 6px 0 4px; }
.segmented button { flex: 1; min-height: 40px; border-radius: 10px; font-weight: 600; color: var(--sub); }
.segmented button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(23, 21, 58, .15); }
.simple-list button, .admin-members > div { width: 100%; min-height: 52px; display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); text-align: left; }
.simple-list span, .admin-members small { color: var(--muted); font-size: 13px; display: block; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.admin-tabs button { min-height: 44px; padding: 0 14px; border-radius: 22px; background: var(--chip); font-weight: 600; }
.admin-tabs .primary { background: var(--accent); color: #fff; min-height: 44px; font-size: 15px; }
details { margin-top: 12px; }
summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.preview-box { background: var(--chip); border-radius: var(--r-ctl); padding: 12px 14px; margin-top: 12px; }
.empty-small { color: var(--muted); font-size: 14px; padding: 8px 0; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(14px + var(--safe-top)); z-index: 100; max-width: calc(100% - 24px); background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 16px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); }
#toast.error { background: var(--danger); }

/* Wide screens: the list is a right-hand panel that folds down to a small card. It sits on
   the right so AMap's logo, scale and review number (bottom-left) are never covered. */
@media (min-width: 720px) {
  .sheet { left: auto; right: 16px; width: 400px; bottom: 16px; height: calc(100% - 92px); border-radius: var(--r-sheet); }
}

@media (prefers-reduced-motion: reduce) {
  .pt .d, .primary:active, .secondary:active, .mem:active, .chips button:active { transition: none; transform: none; }
  .pt.sel .d { transform: scale(1.5); }
}
@media (prefers-reduced-transparency: reduce) {
  .seg, .mebtn, .fchip { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
