:root {
  --bg: #f6f1e9;
  --paper: #fffdf9;
  --ink: #2a2420;
  --muted: #857a70;
  --line: #e8dfd3;
  --accent: #d6452b;      /* 朱色 */
  --accent-soft: #fbe6e1;
  --teal: #2f6b6f;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .07);
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: .02em; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.error { color: var(--accent); min-height: 1em; margin: 0; font-size: 13px; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 8px 16px; cursor: pointer; transition: transform .1s, background .15s;
  white-space: nowrap;
}
.btn:hover { background: #fff; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #c33a22; }
.btn:disabled { opacity: .6; cursor: wait; }
.icon-btn, .chip-btn {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px; cursor: pointer;
  height: 38px; padding: 0 14px; font-size: 14px;
}
.icon-btn { width: 38px; padding: 0; font-size: 18px; }
.chip-btn { white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.top-actions > * { flex-shrink: 0; }
.version-sub { display: none; }

/* ---------- 登录 ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 30% 20%, #fff6ec, var(--bg) 60%); }
.login-card { background: var(--paper); padding: 36px 32px; border-radius: 24px; box-shadow: var(--shadow);
  width: min(360px, 100%); display: grid; gap: 12px; text-align: center; }
.login-emoji { font-size: 48px; }
.login-card p { margin: 0; color: var(--muted); }
.login-card input { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; text-align: center; font-size: 16px; }

/* ---------- 顶部 ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 40px) 8px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 34px; width: 52px; height: 52px; display: grid; place-items: center;
  background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); }
.brand h1 { font-size: 22px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.version { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .03em;
  padding: 4px 10px; border: 1px dashed var(--line); border-radius: 999px; white-space: nowrap; }

.tabs { display: flex; gap: 4px; padding: 8px clamp(16px, 4vw, 40px) 0; }
.tab { border: 0; background: transparent; padding: 10px 16px; border-radius: 12px 12px 0 0; cursor: pointer;
  color: var(--muted); font-weight: 600; }
.tab.active { background: var(--paper); color: var(--ink); box-shadow: 0 -1px 0 var(--line) inset; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--paper);
  padding: 14px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 500; }
.toolbar input[type=search], .toolbar select {
  height: 36px; border-radius: 999px; border: 1px solid var(--line); background: #fff; padding: 0 14px; }
.toolbar input[type=search] { flex: 1 1 200px; max-width: 320px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; height: 32px; padding: 0 12px; cursor: pointer;
  font-size: 13px; display: inline-flex; align-items: center; white-space: nowrap; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }

main { padding: 20px clamp(16px, 4vw, 40px) 60px; }

/* ---------- 卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card { background: var(--paper); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  cursor: pointer; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(60,40,20,.06), 0 14px 32px rgba(60,40,20,.12); }
.cover { position: relative; aspect-ratio: 4 / 3; background: #eee; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 56px; }
.day-badge { position: absolute; top: 10px; left: 10px; background: rgba(255,255,255,.92); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 700; color: var(--teal); }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.card-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; min-width: 0; }
.card-title h3 { font-size: 17px; line-height: 1.35; min-width: 0; overflow-wrap: anywhere; }
.fire { font-size: 12px; white-space: nowrap; letter-spacing: -2px; flex-shrink: 0; line-height: 24px; }
.fire .off { filter: grayscale(1); opacity: .25; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; }
.tag { display: inline-flex; align-items: center; max-width: 100%; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; line-height: 1; background: #f1ece5; color: #5f554c;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-type { background: #fbe6e1; color: #b23a22; }
.tag-area { background: #e6f0ee; color: var(--teal); }
.reason { margin: 0; font-size: 14px; line-height: 1.55; color: #4a423b;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 4px; min-width: 0; }
.by { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.vote { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer;
  font-size: 13px; display: inline-flex; gap: 6px; align-items: center; transition: all .15s; flex-shrink: 0; }
.vote:hover { border-color: var(--accent); }
.vote.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-emoji { font-size: 56px; margin-bottom: 8px; }

/* ---------- 地图 ---------- */
#map { height: calc(100vh - 230px); min-height: 420px; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 1; }
.map-hint { margin-top: 12px; background: var(--paper); border-radius: 12px; padding: 12px 16px; color: var(--muted); font-size: 14px; }
.pin { width: 38px; height: 38px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  display: grid; place-items: center; box-shadow: 0 3px 8px rgba(0,0,0,.25); border: 2px solid #fff; }
.pin span { transform: rotate(45deg); font-size: 18px; }
.leaflet-popup-content { margin: 12px 14px; font-family: inherit; }
.pop h4 { margin: 0 0 4px; font-size: 15px; }
.pop p { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.pop button { border: 0; background: var(--accent); color: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; }

/* ---------- 行程 ---------- */
.plan-tip { margin-bottom: 12px; }
.plan { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 12px; }
.col { background: #efe8de; border-radius: var(--radius); padding: 12px; min-height: 220px; transition: background .15s; }
.col.over { background: var(--accent-soft); }
.col h3 { font-size: 15px; display: flex; justify-content: space-between; padding: 4px 4px 10px; }
.col h3 small { color: var(--muted); font-weight: 400; }
.mini { background: var(--paper); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); display: flex; gap: 10px; align-items: center; }
.mini.dragging { opacity: .4; }
.mini-emoji { font-size: 20px; }
.mini b { display: block; font-size: 14px; }
.mini small { color: var(--muted); font-size: 12px; }

/* ---------- 弹窗 ---------- */
.modal { border: 0; border-radius: 22px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  background: var(--paper); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.small { width: min(380px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(30, 20, 10, .45); backdrop-filter: blur(2px); }
.modal-close { position: absolute; top: 12px; right: 12px; z-index: 2; border: 0; width: 34px; height: 34px;
  border-radius: 50%; background: rgba(255,255,255,.9); cursor: pointer; font-size: 15px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }

.detail-cover { aspect-ratio: 16 / 9; background: #eee; }
.detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-main { padding: 20px 24px 24px; display: grid; gap: 14px; }
.detail-main h2 { font-size: 22px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-actions a { text-decoration: none; }
.voters { display: flex; gap: 6px; flex-wrap: wrap; }
.avatar { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 10px; font-size: 13px; }

.form { padding: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form h2 { grid-column: 1 / -1; font-size: 20px; }
.form .full { grid-column: 1 / -1; }
.form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.label-text { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form input:not([type=file]), .form select, .form textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; color: var(--ink); width: 100%; }
.form textarea { resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.fire-picker { display: flex; gap: 4px; }
.fire-picker button { border: 0; background: none; font-size: 26px; cursor: pointer; padding: 0 2px; }
.fire-picker button.off { filter: grayscale(1); opacity: .25; }
.geo-row { display: flex; gap: 8px; }
.geo-results { display: grid; gap: 6px; margin-top: 8px; }
.geo-results button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.geo-results button small { display: block; color: var(--muted); font-size: 12px; }
.geo-picked { margin-top: 8px; background: #e9f3f1; color: var(--teal); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.upload input { display: none; }
.cover-preview { display: grid; place-items: center; height: 120px; border: 2px dashed var(--line); border-radius: 12px;
  cursor: pointer; color: var(--muted); background-size: cover; background-position: center; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 2000; box-shadow: var(--shadow); }

@media (max-width: 640px) {
  .brand h1 { font-size: 18px; }
  .top-actions { width: 100%; }
  #add-btn { margin-left: auto; }
  .version { display: none; }
  .version-sub { display: inline; }
  .chip-btn { padding: 0 10px; }
  .form { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 80px 1fr; }
  #map { height: calc(100vh - 290px); }
  .cover { aspect-ratio: 16 / 9; }
  .grid { gap: 14px; }
}
