/* 个人管家 — 深色礼宾，原生 iOS 应用壳 */
:root {
  --bg: #0B0C0E;
  --surface: #16181C;
  --surface-2: #1C1F24;
  --surface-3: #22262C;
  --gold: #C4B5A0;
  --gold-dim: rgba(196, 181, 160, 0.14);
  --gold-line: rgba(196, 181, 160, 0.35);
  --ink: #F5F4F1;
  --muted: #8B9098;
  --faint: #5C616A;
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.10);
  --danger: #C98989;
  --danger-bg: rgba(201, 137, 137, 0.12);
  --good: #C4B5A0;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 44px;
  --tabbar-h: 56px;
  --app-w: 390px;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans SC", "SF Pro Text", "Microsoft YaHei", system-ui, sans-serif;
  --display: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans SC", "SF Pro Display", system-ui, sans-serif;
  --serif: "Songti SC", "Source Serif Pro", "Noto Serif CJK SC", "Noto Serif SC", Georgia, serif;
  --mono: "SF Mono", "Menlo", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  height: 100%;
  background: var(--bg);
}
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
}
button { cursor: pointer; }
textarea { resize: none; }
img { display: block; max-width: 100%; }
a { color: var(--gold); }

.app {
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ——— Top bars ——— */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--tap);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 8px;
  background: var(--bg);
  z-index: 5;
}
.topbar .eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
}
.topbar .eyebrow strong {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  margin-left: 8px;
}
.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  margin: 0 -8px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  border-radius: 50%;
}
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.back-btn {
  width: var(--tap);
  height: var(--tap);
  margin-left: -12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 28px;
  line-height: 1;
  font-weight: 300;
}

/* ——— Scroll panes ——— */
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.scroll.chat-scroll {
  padding: 8px 20px 16px;
}
.scroll.page-scroll {
  padding: 4px 20px 28px;
}

/* ——— Sample chip ——— */
.sample-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 14px;
  color: var(--muted);
  font-size: 12px;
}
.sample-chip button {
  color: var(--gold);
  min-height: 32px;
  padding: 0 4px;
  font-size: 12px;
}

/* ——— Briefing / butler voice ——— */
.briefing {
  padding: 12px 0 28px;
}
.briefing .greet {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.25;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 22px;
  letter-spacing: 0.01em;
}
.briefing .prose,
.bubble.butler .prose {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
  color: #E6E3DC;
  margin: 0 0 16px;
  white-space: pre-wrap;
}
.briefing .prose:last-child { margin-bottom: 0; }

.brief-block {
  margin: 18px 0 0;
}
.brief-block .kicker {
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 8px;
}
.brief-block p {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
  color: #E6E3DC;
  margin: 0;
}

.start-row, .meet-row, .pending-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.start-row button, .meet-row button {
  flex-shrink: 0;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 999px;
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.meet-card, .pending-card {
  margin-top: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 2px solid var(--gold);
  width: 100%;
  text-align: left;
  min-height: var(--tap);
}
.meet-card .when, .pending-card .when {
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.04em;
  margin: 0 0 4px;
  font-family: var(--font);
}
.meet-card .title, .pending-card .title {
  font-family: var(--display);
  font-size: 15px;
  color: var(--ink);
  margin: 0;
}
.meet-card .sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ——— Chat bubbles ——— */
.turn { margin: 0 0 18px; }
.turn.user { display: flex; justify-content: flex-end; }
.bubble {
  max-width: 86%;
}
.bubble.user {
  background: var(--surface-2);
  border-radius: 18px 18px 6px 18px;
  padding: 12px 16px;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
}
.bubble.butler {
  max-width: 100%;
}
.bubble.butler .who {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.bubble.butler .who .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  display: inline-block;
}
.bubble.system {
  max-width: 100%;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
  padding: 4px 0;
}

.preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.preview-actions button {
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 999px;
  font-size: 15px;
}
.preview-actions .confirm {
  background: var(--gold);
  color: #16110C;
  font-weight: 600;
}
.preview-actions .cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line-strong);
}

.typing {
  display: flex;
  gap: 5px;
  padding: 6px 0 12px;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.35;
  animation: pulse 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

/* ——— Composer ——— */
.composer {
  flex-shrink: 0;
  padding: 8px 16px 10px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.composer form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 16px;
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.4;
  outline: none;
}
.composer textarea::placeholder { color: var(--faint); }
.composer .send {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  background: var(--gold);
  color: #16110C;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.composer .send svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.composer .send:disabled { opacity: 0.4; }

/* ——— Tab bar (in layout flow) ——— */
.tabbar {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  min-height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding: 4px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--line);
  z-index: 8;
}
.tabbar button {
  flex: 1;
  min-height: var(--tap);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.08em;
  background: none;
}
.tabbar button svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar button.is-on {
  color: var(--gold);
}
.tabbar button.is-on svg { stroke-width: 1.8; }

/* ——— Money / people / matters lists ——— */
.hero {
  padding: 8px 0 22px;
}
.hero .label {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 6px;
}
.hero .amt {
  font-family: var(--display);
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.1;
}
.hero .amt .yen {
  font-size: 0.55em;
  margin-right: 2px;
  color: var(--muted);
  font-weight: 400;
}
.hero .sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.segbar {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 18px;
  background: var(--surface);
  border-radius: 12px;
}
.segbar button {
  flex: 1;
  min-height: 36px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
}
.segbar button[aria-selected="true"] {
  background: var(--surface-3);
  color: var(--gold);
}

.fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 22px;
}
.fact {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-height: 76px;
}
.fact .k { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin: 0 0 6px; }
.fact .v { font-family: var(--display); font-size: 20px; letter-spacing: -0.02em; margin: 0; }
.fact .s { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.bar {
  height: 3px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0 0;
}
.bar span { display: block; height: 100%; background: var(--gold); border-radius: 2px; }
.bar.over span { background: var(--danger); }

.list { margin: 0; padding: 0; list-style: none; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap);
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  background: none;
  color: inherit;
}
.row .main { min-width: 0; flex: 1; }
.row .name { margin: 0; font-size: 16px; color: var(--ink); }
.row .meta { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.row .amt { font-family: var(--display); font-size: 16px; letter-spacing: -0.02em; white-space: nowrap; }
.row .amt.out { color: var(--muted); }
.row .amt.in { color: var(--gold); }
.row .chev { color: var(--faint); font-size: 18px; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 0 8px;
}
.section-title h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
}
.section-title button, .text-link {
  color: var(--gold);
  font-size: 13px;
  min-height: 32px;
}

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 20px 0;
  line-height: 1.6;
}
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.pill.low { background: var(--surface-3); color: var(--muted); }

.fab-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}
.fab-row button {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}
.fab-row button.primary {
  background: var(--gold);
  color: #16110C;
  font-weight: 600;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  min-height: var(--tap);
}
.task-row .check {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-line);
  flex-shrink: 0;
}
.task-row.is-done .check { background: var(--gold); border-color: var(--gold); }
.task-row.is-done .name { color: var(--faint); text-decoration: line-through; }
.task-row .name { margin: 0; font-size: 16px; }
.task-row .meta { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
}
.cal-head button {
  width: var(--tap);
  height: var(--tap);
  color: var(--gold);
  font-size: 22px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin: 0 0 18px;
}
.cal-grid .dow {
  text-align: center;
  font-size: 11px;
  color: var(--faint);
  padding: 4px 0 8px;
}
.cal-grid button {
  aspect-ratio: 1;
  min-height: 40px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--ink);
  position: relative;
}
.cal-grid button.out { color: var(--faint); }
.cal-grid button.is-today { box-shadow: inset 0 0 0 1px var(--gold-line); }
.cal-grid button.is-on { background: var(--gold); color: #16110C; }
.cal-grid button.has-ev::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  transform: translateX(-50%);
}
.cal-grid button.is-on.has-ev::after { background: #16110C; }

.settings-list { margin: 8px 0 0; padding: 0; list-style: none; }
.settings-list li button, .settings-list .row {
  width: 100%;
}
.settings-group {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 0 16px;
}
.settings-group .row {
  padding: 14px 16px;
  border-bottom-color: var(--line);
}
.settings-group .row:last-child { border-bottom: 0; }

/* ——— Forms & sheets ——— */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.overlay.open { display: flex; }
.sheet-wrap {
  width: 100%;
  max-width: var(--app-w);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
}
.sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow);
}
.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 6px auto 12px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--tap);
  margin: 0 0 8px;
}
.sheet-head h2, #sheet-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.sheet .brief h4 {
  margin: 18px 0 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}
.sheet .brief ul { margin: 0; padding: 0 0 0 18px; color: #E6E3DC; }
.sheet .brief li { margin: 0 0 6px; font-family: var(--serif); font-size: 16px; line-height: 1.65; }
.sheet .brief p.hint, .sheet > .hint { margin-top: 16px; }

.field { display: block; margin: 0 0 14px; }
.field > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  outline: none;
  color: var(--ink);
}
.field textarea { min-height: 88px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold-line);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.time-24 { display: flex; align-items: center; gap: 6px; }
.time-24 select { min-height: var(--tap); padding: 8px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; }
.time-colon { color: var(--muted); }

.btn {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink);
  font-size: 15px;
}
.btn.primary { background: var(--gold); color: #16110C; font-weight: 600; }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.btn-block { width: 100%; display: block; margin-top: 8px; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}
.form-error, [data-error] {
  color: var(--danger);
  font-size: 13px;
  min-height: 0;
  margin: 0 0 10px;
}
[data-error].show { display: block; }

.dl-list { margin: 0; }
.dl-list > div { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dl-list dt { width: 76px; flex-shrink: 0; color: var(--faint); font-size: 13px; }
.dl-list dd { margin: 0; flex: 1; font-size: 15px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline .when { font-size: 12px; color: var(--gold); margin: 0 0 2px; }
.timeline .item-title { margin: 0; font-size: 15px; }
.timeline .item-sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: 320px;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  z-index: 40;
  box-shadow: var(--shadow);
}

.checkboxes { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.checkboxes label { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.checkboxes input { width: 18px; height: 18px; accent-color: var(--gold); }

.about p { color: var(--muted); font-size: 14px; line-height: 1.7; }
.wordmark {
  font-family: var(--serif);
  font-size: 22px;
  margin: 4px 0 18px;
}

.filter-row { display: flex; gap: 6px; margin: 0 0 8px; }
.filter-row button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
}
.filter-row button.is-on { color: var(--gold); background: var(--gold-dim); }

@media (min-width: 768px) {
  body { background: #050506; }
  .app {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 50%;
    right: auto;
    width: min(100%, 430px);
    max-width: 430px;
    height: auto;
    transform: translateX(-50%);
    box-shadow: 0 0 0 1px var(--line), var(--shadow);
  }
  .sheet-wrap { width: min(100%, 430px); }
}
