:root {
  --ink: #1a2942;
  --lake: #3a6da9;
  --mist: #7a9bc5;
  --cream: #fbf7f1;
  --champagne: #d4b87a;
  --text: #2a2f3a;
  --text-soft: #5b6478;
  --card: rgba(255, 255, 255, 0.72);
  --shadow: 0 8px 32px rgba(26, 41, 66, 0.08);
  --shadow-lg: 0 16px 48px rgba(26, 41, 66, 0.12);
  --line: rgba(26, 41, 66, 0.1);
  --danger: #c97b6b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Noto Serif TC", "PingFang TC", "Songti TC", serif;
  color: var(--text);
  line-height: 1.7;
  background:
    radial-gradient(ellipse at top left, #e8eef7 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, #f0e8d8 0%, transparent 50%),
    linear-gradient(180deg, #fbf7f1 0%, #f0eadd 100%);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.container { max-width: 960px; margin: 0 auto; padding: 24px; }

h1, h2, h3 { font-weight: 500; color: var(--ink); letter-spacing: 0.02em; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 24px;
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card .mark { font-size: 13px; letter-spacing: 0.4em; color: var(--mist); margin-bottom: 18px; }
.login-card h1 { font-size: 26px; margin-bottom: 28px; }
.login-card input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  background: rgba(255,255,255,0.8);
  outline: none;
  margin-bottom: 16px;
}
.login-card input:focus { border-color: var(--lake); background: white; }
.login-card button {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ink), var(--lake));
  color: white;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: transform 0.2s;
}
.login-card button:hover { transform: translateY(-1px); }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(16px);
  background: rgba(251,247,241,0.8);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.topbar .container { padding-top: 0; padding-bottom: 0; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.topbar h1 { font-size: 17px; }
.logout-btn { background: none; border: none; color: var(--text-soft); font-size: 13px; cursor: pointer; text-decoration: underline; }

.view { display: none; padding: 28px 0; }
.view.active { display: block; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.6); border-radius: 20px;
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-dark {
  background: linear-gradient(135deg, rgba(26,41,66,0.95), rgba(58,109,169,0.88));
  color: white; border-radius: 20px; padding: 24px; box-shadow: var(--shadow-lg);
}

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; align-items: stretch; }
.summary-stat { display: flex; flex-direction: column; justify-content: center; min-height: 108px; margin-bottom: 0; box-sizing: border-box; }
.summary-stat .label { font-size: 12px; letter-spacing: 0.15em; opacity: 0.75; margin-bottom: 8px; }
.summary-stat .value { font-size: 28px; font-weight: 500; }
@media (max-width: 640px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-grid .summary-stat:first-child { grid-column: 1 / -1; }
}

/* ---------- Charts (純 SVG，不用套件) ---------- */
.chart-wrap h3 { margin-bottom: 18px; }
.chart-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.chart-heading h3 { margin-bottom: 0; }
.chart-year-switcher { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; white-space: nowrap; }
.chart-year-switcher button {
  border: 1px solid var(--line); background: rgba(255,255,255,0.72); color: var(--lake);
  border-radius: 10px; min-width: 32px; height: 32px; padding: 0 9px; font-family: inherit; cursor: pointer;
}
.chart-year-switcher button:disabled { opacity: 0.3; cursor: default; }
.spend-filter-bar { display: flex; gap: 7px; margin: 15px 0 2px; overflow-x: auto; scrollbar-width: none; }
.spend-filter-bar::-webkit-scrollbar { display: none; }
.spend-filter-bar button {
  flex: 0 0 auto; border: 1px solid var(--line); background: rgba(255,255,255,0.6); color: var(--text-soft);
  border-radius: 999px; padding: 6px 12px; font-family: inherit; font-size: 12px; cursor: pointer;
}
.spend-filter-bar button.active { background: var(--ink); border-color: var(--ink); color: white; }
.chart-wrap svg { width: 100%; height: auto; min-height: 240px; display: block; }
.chart-empty { text-align: center; color: var(--text-soft); padding: 30px 0; font-size: 14px; }
.chart-axis-label { font-size: 15px; fill: var(--text-soft); font-weight: 500; }
.chart-value-label { font-size: 16px; fill: var(--ink); font-weight: 600; }
.chart-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; margin-bottom: 2px; color: var(--text-soft); font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.single-chart-point {
  min-height: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(58,109,169,0.1), rgba(255,255,255,0.35));
  border: 1px solid rgba(58,109,169,0.12);
}
.single-chart-value { color: var(--lake); font-size: 42px; line-height: 1.2; font-weight: 600; }
.single-chart-label { color: var(--ink); font-size: 18px; margin-top: 12px; }
.single-chart-date { color: var(--text-soft); font-size: 15px; margin-top: 6px; }
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px; }
  .chart-wrap svg { min-height: 270px; }
  .chart-axis-label { font-size: 18px; }
  .chart-value-label { font-size: 19px; }
  .single-chart-point { min-height: 250px; }
  .single-chart-value { font-size: 46px; }
}

/* ---------- 套組次數統計 ---------- */
.package-chart { display: flex; flex-direction: column; gap: 18px; margin-top: 18px; }
.package-chart-row { min-width: 0; }
.package-chart-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 7px; }
.package-chart-head span { color: var(--text); font-size: 14px; overflow-wrap: anywhere; word-break: break-word; }
.package-chart-head strong { color: var(--lake); font-size: 15px; font-weight: 600; white-space: nowrap; }
.package-chart-track { height: 16px; overflow: hidden; border-radius: 999px; background: rgba(58,109,169,0.1); }
.package-chart-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ink), var(--lake)); }

/* ---------- 魔法商品數量統計 ---------- */
.magic-count-summary { margin-top: 16px; }
.magic-count-total {
  display: flex; align-items: baseline; justify-content: center; gap: 8px;
  padding: 18px; border-radius: 16px; color: white;
  background: linear-gradient(135deg, var(--ink), var(--lake));
}
.magic-count-total span { font-size: 14px; opacity: 0.82; }
.magic-count-total strong { font-size: 42px; line-height: 1; font-weight: 600; }
.magic-count-categories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.magic-count-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(255,255,255,0.58); color: var(--text-soft);
}
.magic-count-item > span { font-size: 13px; }
.magic-count-item strong { color: var(--ink); font-size: 24px; white-space: nowrap; }
.magic-count-item small { color: var(--text-soft); font-size: 12px; font-weight: 400; }

/* ---------- 互動月曆 ---------- */
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.calendar-title-group { display: flex; align-items: center; gap: 9px; }
.calendar-head .cal-title { font-size: 15px; color: var(--ink); font-weight: 500; }
.calendar-head button {
  border: 1px solid var(--line); background: rgba(255,255,255,0.6); border-radius: 10px;
  width: 30px; height: 30px; cursor: pointer; font-family: inherit; color: var(--text);
}
.calendar-head .calendar-today-btn { width: auto; padding: 0 9px; border-radius: 999px; color: var(--lake); font-size: 11px; }
.calendar-today-btn[hidden] { display: none; }
.calendar-legend { display: flex; gap: 18px; font-size: 13px; margin-bottom: 16px; flex-wrap: wrap; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; max-width: 480px; margin: 0 auto; }
.cal-dow { text-align: center; font-size: 12px; color: var(--text-soft); padding-bottom: 6px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 12px; background: rgba(255,255,255,0.5);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text); gap: 4px; position: relative; border: 1px solid transparent;
  font: inherit; padding: 0; cursor: pointer;
}
.cal-cell.empty { background: transparent; }
.cal-cell:not(.empty):hover { background: rgba(58,109,169,0.08); }
.cal-cell.today { border-color: var(--lake); }
.cal-cell.selected { background: var(--ink); border-color: var(--ink); color: white; box-shadow: 0 6px 16px rgba(26,41,66,0.18); }
.cal-cell .cal-daynum { font-size: 13px; }
.cal-cell.today .cal-daynum { font-weight: 700; color: var(--lake); }
.cal-cell.selected .cal-daynum { color: white; }
.cal-cell .icons { display: flex; gap: 3px; align-items: center; justify-content: center; min-height: 16px; }
.cal-cell .icons svg { display: block; }
.calendar-detail {
  max-width: 480px; margin: 18px auto 0; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,0.58);
  overflow-wrap: anywhere; word-break: break-word;
}
.calendar-detail[hidden] { display: none; }
.calendar-detail-date { color: var(--text-soft); font-size: 12px; margin-bottom: 8px; }
.calendar-detail-list { display: flex; flex-direction: column; gap: 6px; color: var(--ink); font-size: 15px; }
.calendar-detail-empty { color: var(--text-soft); font-size: 14px; }
@media (max-width: 480px) {
  .calendar-grid { max-width: 100%; gap: 5px; }
  .cal-cell { border-radius: 9px; gap: 2px; }
  .cal-cell .cal-daynum { font-size: 11px; }
}

/* ---------- Forms ---------- */
.form-row { margin-bottom: 16px; min-width: 0; }
.form-hint { margin: -4px 0 18px; color: var(--text-soft); font-size: 12px; }
.form-row label { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; max-width: 100%; min-width: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 14px; background: rgba(255,255,255,0.85); outline: none;
}
.form-row input[type="date"] { display: block; }
.form-row input[type="date"]::-webkit-date-and-time-value { text-align: left; min-width: 0; }
.form-row input, .form-row select { min-height: 48px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--lake); background: white; }
.form-row input.field-invalid, .form-row select.field-invalid, .form-row textarea.field-invalid {
  border-color: var(--danger); background: rgba(201,123,107,.055); box-shadow: 0 0 0 3px rgba(201,123,107,.1);
}
.field-error { margin: 6px 2px 0; color: #b75f52; font-size: 12px; line-height: 1.45; }
.form-row textarea { min-height: 130px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.filter-bar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.filter-bar .form-row { margin-bottom: 0; min-width: 130px; flex: 1; }
.filter-bar .btn { text-decoration: none; white-space: nowrap; text-align: center; }
.tag-filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }
.tag-filter-bar button {
  border: 1px solid var(--line); border-radius: 18px; padding: 7px 14px;
  background: rgba(255,255,255,0.65); color: var(--text-soft); font: inherit; font-size: 13px; cursor: pointer;
}
.tag-filter-bar button.active { background: var(--ink); border-color: var(--ink); color: white; }

#rRawPaste { min-height: 240px; }
#pBurnReading { min-height: 180px; }
.parse-hint { font-size: 12px; color: var(--text-soft); margin-top: 6px; min-height: 16px; }

.section-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.5fr);
  gap: 12px;
  margin-bottom: 14px;
  padding: 48px 14px 14px;
  align-items: start;
  background: rgba(255,255,255,0.45);
  border: 1px solid var(--line);
  border-radius: 14px;
  position: relative;
}
.section-row input { min-width: 0; min-height: 48px; }
.section-row textarea { min-width: 0; min-height: 170px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.section-row .sec-label { min-height: 110px; }
.section-row .row-remove {
  position: absolute; top: 10px; left: 10px; width: 28px; height: 28px;
  display: grid; place-items: center; padding: 0; border-radius: 50%;
  border: 1px solid rgba(201,123,107,0.45); background: rgba(201,123,107,0.11);
  color: var(--danger); font: 600 20px/1 sans-serif; cursor: pointer;
}
.section-row .row-remove:hover { color: white; background: var(--danger); }

@media (max-width: 640px) {
  .card { padding: 20px 16px; }
  .section-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 50px 12px 14px;
    margin-bottom: 18px;
  }
  .form-row input, .form-row select, .form-row textarea { font-size: 16px; }
  .login-card input { font-size: 16px; }
  .section-row input { min-height: 52px; font-size: 16px; }
  .section-row textarea { min-height: 190px; font-size: 16px; line-height: 1.7; }
  .section-row .sec-label { min-height: 120px; }
  .section-row .row-remove { width: 30px; height: 30px; }
  #rRawPaste { min-height: 280px; font-size: 16px; }
  #pBurnReading { min-height: 220px; font-size: 16px; }
}

/* 諮詢題目改為上下排列，兩個欄位都橫向占滿卡片 */
#rSections .section-row { grid-template-columns: minmax(0, 1fr); }
#rSections .section-row .sec-label { min-height: 86px; }
#rSections .section-row .sec-content { min-height: 210px; }
#pCandles .section-row { grid-template-columns: minmax(0, 1fr); }
#pCandles .section-row .cand-name { min-height: 58px; }
#pCandles .section-row .cand-wish { min-height: 190px; }
@media (max-width: 640px) {
  #rSections .section-row .sec-label { min-height: 92px; }
  #rSections .section-row .sec-content { min-height: 230px; }
  #pCandles .section-row .cand-name { min-height: 58px; }
  #pCandles .section-row .cand-wish { min-height: 210px; }
}

.btn { padding: 10px 20px; border-radius: 10px; border: 0; font-family: inherit; font-size: 14px; cursor: pointer; }
.btn-primary { background: linear-gradient(135deg, var(--ink), var(--lake)); color: white; }
.btn-ghost { background: rgba(255,255,255,0.6); border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: rgba(201,123,107,0.12); color: var(--danger); border: 1px solid rgba(201,123,107,0.3); }
.btn-small { padding: 6px 12px; font-size: 12px; }

/* ---------- 紀錄卡片（各自獨立、左對齊） ---------- */
.record-list { display: flex; flex-direction: column; gap: 14px; }
.record-card {
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  text-align: left;
}
.record-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.record-title { font-size: 16px; color: var(--ink); font-weight: 500; text-align: left; overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.record-price { font-family: inherit; font-size: 17px; color: var(--lake); font-weight: 500; white-space: nowrap; }
.record-card-sub { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; gap: 10px; }
.record-meta { font-size: 12px; color: var(--text-soft); text-align: left; }
.record-delete {
  background: none; border: none; color: var(--text-soft); cursor: pointer;
  font-size: 12px; padding: 4px 8px; border-radius: 8px; transition: all 0.15s; flex-shrink: 0;
}
.record-delete:hover { background: rgba(201,123,107,0.12); color: var(--danger); }
.record-body { margin-top: 12px; font-size: 14px; color: var(--text); text-align: left; overflow-wrap: anywhere; word-break: break-word; }
.record-body .sec { margin-bottom: 6px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.record-body .sec b { color: var(--ink); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 20px; background: rgba(58,109,169,0.1); color: var(--lake); font-size: 11px; margin-left: 6px; }
.tag.candle { background: rgba(212,184,122,0.18); color: #a07a30; }
.tag.topic { background: rgba(58,109,169,0.1); color: var(--lake); white-space: nowrap; }
.tag.quantity { background: rgba(212,184,122,0.18); color: #8a6928; white-space: nowrap; }

.empty-hint { text-align: center; color: var(--text-soft); padding: 40px 0; font-size: 14px; }
.site-footer { text-align: center; color: var(--text-soft); font-size: 12px; letter-spacing: 0.08em; padding: 18px 0 30px; opacity: 0.72; }

/* ---------- App 式底部導覽 ---------- */
.bottom-tabbar {
  position: fixed; z-index: 40; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 720px); display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(251,247,241,0.94); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0; box-shadow: 0 -10px 36px rgba(26,41,66,0.12);
  backdrop-filter: blur(18px);
}
.bottom-tabbar button {
  width: 100%; min-width: 0; min-height: 56px; padding: 0; justify-self: stretch;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 0; border-radius: 17px; background: transparent; color: #647087;
  font: inherit; font-size: 11px; letter-spacing: .04em; cursor: pointer; transition: color .2s, background .2s, transform .2s;
}
.bottom-tabbar button > span:last-child { display: block; width: 100%; height: 15px; text-align: center; line-height: 15px; }
.bottom-tabbar button.active { color: var(--ink); background: linear-gradient(145deg, rgba(58,109,169,.12), rgba(212,184,122,.11)); font-weight: 600; }
.bottom-tabbar button:active { transform: scale(.98); }
.tab-icon { position: relative; display: block; width: 24px; height: 24px; color: currentColor; }
.icon-home i { position: absolute; display: block; }
.icon-home .roof-left,
.icon-home .roof-right {
  top: 2px; width: 2px; height: 12px; border-radius: 999px; background: currentColor;
  transform-origin: 50% 1px;
}
.icon-home .roof-left { left: 11px; transform: rotate(45deg); }
.icon-home .roof-right { right: 11px; transform: rotate(-45deg); }
.icon-home .home-body {
  left: 5px; top: 11px; width: 14px; height: 11px; box-sizing: border-box;
  border: 2px solid currentColor; border-top: 0; border-radius: 0 0 3px 3px;
}
.icon-tarot::before {
  content: ""; position: absolute; left: 5px; top: 2.5px; width: 14px; height: 19px;
  box-sizing: border-box; border: 2px solid currentColor; border-radius: 2px; transform: rotate(-8deg);
}
.icon-tarot::after {
  content: "✦"; position: absolute; left: 9.5px; top: 6px; font: 8px/1 sans-serif; color: var(--champagne); transform: rotate(-8deg);
}
.icon-candle::before {
  content: ""; position: absolute; left: 7px; top: 10.5px; width: 10px; height: 12px;
  border: 2px solid currentColor; border-radius: 2px 2px 3px 3px; box-sizing: border-box;
}
.icon-candle::after {
  content: ""; position: absolute; left: 9px; top: 2.5px; width: 7px; height: 9px;
  background: var(--champagne); border-radius: 70% 25% 65% 35%; transform: rotate(38deg); box-shadow: inset 0 0 0 1px rgba(160,122,48,.22);
}
.icon-magic::before {
  content: ""; position: absolute; left: 6px; top: 9px; width: 12px; height: 13px;
  border: 2px solid currentColor; border-radius: 3px 3px 4px 4px; box-sizing: border-box;
  background: linear-gradient(to top, rgba(212,184,122,.28) 0 28%, transparent 28%);
}
.icon-magic::after {
  content: ""; position: absolute; left: 8px; top: 4px; width: 8px; height: 6px;
  border: 2px solid currentColor; border-bottom: 0; border-radius: 2px 2px 0 0; box-sizing: border-box;
  box-shadow: 5px -2px 0 -1px var(--champagne);
}

/* ---------- 浮動新增與 Bottom Sheet ---------- */
.fab {
  position: fixed; z-index: 25; right: max(22px, calc((100vw - 920px) / 2));
  bottom: calc(88px + env(safe-area-inset-bottom)); width: 58px; height: 58px;
  border: 0; border-radius: 50%; background: linear-gradient(135deg, var(--ink), var(--lake));
  color: white; font: 300 30px/1 sans-serif; box-shadow: 0 12px 28px rgba(26,41,66,0.28); cursor: pointer;
}
.fab:hover { transform: translateY(-2px); }
.sheet-backdrop {
  position: fixed; z-index: 50; inset: 0; background: rgba(20,28,43,0.42);
  opacity: 0; visibility: hidden; transition: opacity .24s ease, visibility .24s ease;
}
.sheet-backdrop.open { opacity: 1; visibility: visible; }
.bottom-sheet {
  position: fixed; z-index: 51; left: 50%; bottom: 0; width: min(720px, 100%); max-height: min(88vh, 920px);
  margin: 0; overflow-y: auto; overscroll-behavior: contain; transform: translate(-50%, 105%);
  border-radius: 26px 26px 0 0; padding: 10px 26px calc(28px + env(safe-area-inset-bottom));
  background: rgba(251,247,241,0.98); transition: transform .3s cubic-bezier(.22,.8,.3,1);
}
.bottom-sheet.open { transform: translate(-50%, 0); }
.sheet-handle { width: 42px; height: 5px; margin: 2px auto 12px; border-radius: 99px; background: rgba(26,41,66,.2); }
.sheet-head { position: sticky; top: -10px; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 14px; background: rgba(251,247,241,.96); }
.sheet-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(26,41,66,.08); color: var(--ink); font-size: 24px; cursor: pointer; }
body.sheet-open { overflow: hidden; }

/* ---------- 月份分組與可展開摘要 ---------- */
.month-group + .month-group { margin-top: 26px; }
.month-heading { position: sticky; top: 58px; z-index: 3; margin: 0 4px 10px; padding: 7px 10px; color: var(--ink); font-size: 13px; letter-spacing: .08em; background: rgba(251,247,241,.9); border-radius: 10px; backdrop-filter: blur(10px); }
.record-summary { width: 100%; display: grid; grid-template-columns: 24px 58px minmax(0,1fr) auto; align-items: center; gap: 8px; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.record-chevron { color: var(--mist); font: 18px/1 sans-serif; transition: transform .2s; }
.record-card.expanded .record-chevron { transform: rotate(90deg); }
.record-date-short { font-size: 13px; color: var(--text-soft); }
.record-summary .record-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-details { display: none; padding: 14px 0 0 32px; }
.record-card.expanded .record-details { display: block; }
.record-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 10px; }

@media (max-width: 640px) {
  .container { padding: 18px 14px; }
  .view { padding-top: 18px; }
  .record-summary { grid-template-columns: 18px 48px minmax(0,1fr) auto; gap: 6px; }
  .record-details { padding-left: 24px; }
  .month-heading { top: 54px; }
}

/* 手機版由底部滑入全螢幕，可從把手或標題區下滑關閉 */
@media (max-width: 640px) {
  .bottom-sheet {
    inset: 0; left: 0; bottom: 0; width: 100vw; height: 100vh; height: 100dvh; max-height: none;
    margin: 0; padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    border: 0; border-radius: 24px 24px 0 0; transform: translateY(100%);
    transition: transform .34s cubic-bezier(.22,.8,.3,1), visibility 0s linear .34s;
    overflow-x: hidden; overflow-y: auto; overscroll-behavior: none; visibility: hidden;
  }
  .bottom-sheet.open {
    visibility: visible; transform: translateY(0);
    transition: transform .34s cubic-bezier(.22,.8,.3,1), visibility 0s;
  }
  .bottom-sheet.dragging { transition: none; }
  .bottom-sheet .sheet-handle { display: block; margin-top: 0; touch-action: none; cursor: grab; }
  .bottom-sheet .sheet-head { top: -12px; padding-top: 12px; touch-action: none; }
  body.sheet-open { overscroll-behavior: none; }
  .bottom-sheet .form-grid,
  .bottom-sheet .form-grid > .form-row { width: 100%; max-width: 100%; min-width: 0; }
  .bottom-sheet .form-row:has(input[type="date"]) {
    width: 100%; max-width: 100%; min-width: 0; overflow: hidden; contain: inline-size;
  }
  .bottom-sheet input[type="date"] {
    -webkit-appearance: none; appearance: none; display: block;
    inline-size: -webkit-fill-available; width: -webkit-fill-available;
    min-inline-size: 0 !important; min-width: 0 !important;
    max-inline-size: 100% !important; max-width: 100% !important;
    box-sizing: border-box !important; overflow: hidden;
  }
  .bottom-sheet input[type="date"]::-webkit-date-and-time-value { min-width: 0; width: 100%; text-align: left; }
}
