:root {
  color-scheme: light;
  --ink: #18201f;
  --muted: #64716d;
  --line: #dfe8e2;
  --paper: #fbfaf5;
  --surface: #ffffff;
  --mint: #7fc7a4;
  --mint-dark: #2e7c5a;
  --sun: #f6c85f;
  --coral: #ee806f;
  --blue: #7eb6d9;
  --plum: #9c7ec6;
  --shadow: 0 18px 50px rgba(33, 46, 42, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --mobile-nav-height: 72px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

@supports (min-height: 100dvh) {
  body,
  .app-shell,
  .sidebar,
  .auth-shell {
    min-height: 100dvh;
  }
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: #f4f2e9;
  padding: 28px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--sun);
  box-shadow: 5px 5px 0 var(--ink);
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 0 12px;
  text-align: left;
}

.nav-item span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.nav-item:hover,
.nav-item.is-active {
  border-color: #cdd9d1;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(54, 70, 64, 0.08);
}

.sidebar-note {
  margin-top: auto;
  border-left: 4px solid var(--coral);
  padding-left: 12px;
}

.sidebar-note span {
  font-weight: 800;
}

.sidebar-note p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.icp-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 6px 0;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  z-index: 10;
}

.icp-footer a {
  color: var(--muted);
  text-decoration: none;
}

.icp-footer a:hover {
  text-decoration: underline;
}

.main {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 52px) 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.topbar h1 {
  margin: 5px 0 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 0 14px;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.primary-button {
  background: var(--ink);
  color: white;
}

.secondary-button {
  background: var(--sun);
  color: var(--ink);
}

.ghost-button {
  background: var(--surface);
  color: var(--ink);
}

.danger-button {
  background: #fff3f1;
  color: #9e372a;
}

.icon-button {
  display: grid;
  width: 40px;
  place-items: center;
  background: var(--surface);
  padding: 0;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 4px 4px 0 rgba(24, 32, 31, 0.18);
}

.view {
  display: grid;
  gap: 24px;
}

.band {
  border-block: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
  margin-inline: calc(clamp(18px, 4vw, 52px) * -1);
  padding: 24px clamp(18px, 4vw, 52px);
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 22px;
  align-items: start;
}

.today-page {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1.08fr);
  gap: 18px;
  align-items: start;
}

.panel,
.product-card,
.metric,
.post-card,
.admin-row,
.calendar-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel {
  padding: 20px;
  box-shadow: 0 14px 36px rgba(33, 46, 42, 0.08);
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
}

.panel-header p,
.muted {
  color: var(--muted);
}

.panel-header p {
  margin: 6px 0 0;
  line-height: 1.5;
}

.record-form {
  display: grid;
  gap: 18px;
}

.today-record-panel,
.today-shelf-panel {
  border-radius: 18px;
}

.today-compact-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.today-compact-head h2,
.today-section-head h2 {
  margin: 0;
}

.today-compact-head p:not(.eyebrow),
.today-section-head span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.today-mood-orb {
  display: grid;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  color: var(--mood-color);
  box-shadow: 5px 5px 0 rgba(24, 32, 31, 0.12);
  font-size: 28px;
  font-weight: 900;
}

.today-record-panel .record-form {
  gap: 14px;
}

.today-record-panel .field {
  gap: 7px;
}

.everyday-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.everyday-choice {
  justify-content: center;
  padding-inline: 8px;
}

.everyday-choice strong {
  font-size: 13px;
}

.today-record-panel .emotion-grid:not(.everyday-grid) .choice,
.today-record-panel .tag-grid .choice {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 13px;
}

.microcopy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.support-note {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(46, 124, 90, 0.24);
  border-radius: 14px;
  background: #f7fbf7;
  padding: 12px;
}

.support-note strong {
  font-size: 14px;
}

.support-note span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.safety-note,
.safety-next-card {
  border-color: rgba(158, 55, 42, 0.28);
  background: #fff5f2;
}

.safety-next-card {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(158, 55, 42, 0.28);
  border-radius: 16px;
  padding: 14px;
}

.safety-next-card strong {
  color: #8f3329;
  font-size: 15px;
}

.safety-next-card p {
  margin: 0;
  color: #6d4a43;
  font-size: 13px;
  line-height: 1.55;
}

.today-form-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
}

.today-form-actions .primary-button,
.today-form-actions .ghost-button {
  min-height: 46px;
}

.today-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.today-section-head > span {
  max-width: 210px;
  text-align: right;
}

.need-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.need-card {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf7;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 800;
}

.need-card.is-selected {
  border-color: var(--ink);
  background: var(--sun);
  box-shadow: 3px 3px 0 rgba(24, 32, 31, 0.14);
}

.today-action-list {
  display: grid;
  gap: 10px;
}

.today-action-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffefa;
  padding: 10px;
}

.today-action-card.is-completed {
  border-color: rgba(46, 124, 90, 0.42);
  background: #f7fbf7;
}

.today-action-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.today-action-icon {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--art-a), var(--art-b));
  font-size: 24px;
  font-weight: 900;
}

.today-action-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.today-action-copy strong,
.today-action-copy small,
.today-action-copy em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-action-copy strong {
  font-size: 16px;
}

.today-action-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.today-action-copy em {
  color: #40504b;
  font-size: 13px;
  font-style: normal;
}

.today-action-tools {
  display: flex;
  gap: 6px;
}

.today-action-tools .ghost-button {
  min-height: 36px;
  padding-inline: 10px;
  font-size: 12px;
}

.today-action-tools .icon-button {
  width: 36px;
  min-height: 36px;
}

.today-mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.today-mini-stats span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.recent-panel .timeline {
  max-height: 360px;
  overflow: auto;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.field-title {
  font-size: 13px;
  font-weight: 800;
}

.emotion-grid,
.tag-grid,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
  color: var(--ink);
  padding: 0 12px;
}

.choice.is-selected {
  border-color: var(--ink);
  background: var(--mint);
  box-shadow: 3px 3px 0 rgba(24, 32, 31, 0.18);
  font-weight: 800;
}

/* ─── 强度选择器 ────────────────────────────────────────────────────── */
.intensity-picker {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.intensity-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8faf7;
  padding: 10px 4px 8px;
  cursor: pointer;
  transition: border-color 150ms, background 150ms, box-shadow 150ms;
  min-width: 0;
}

.intensity-btn:hover {
  border-color: #8abfaa;
  background: #f0f7f3;
}

.intensity-btn.is-selected {
  border-color: var(--ink);
  background: var(--mint);
  box-shadow: 3px 3px 0 rgba(24, 32, 31, 0.18);
}

.ripple-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  color: var(--ink);
}
.ring-1 { width: 10px; height: 10px; opacity: 0.7; }
.ring-2 { width: 20px; height: 20px; opacity: 0.45; }
.ring-3 { width: 30px; height: 30px; opacity: 0.28; }
.ring-4 { width: 38px; height: 38px; opacity: 0.18; }
.ring-5 { width: 46px; height: 46px; opacity: 0.1; }

.ring-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  color: var(--ink);
  opacity: 0.6;
}

.intensity-btn.is-selected .ring-dot { opacity: 1; }

.intensity-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.intensity-btn.is-selected .intensity-label { color: var(--ink); }

.intensity-num {
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
  opacity: 0.4;
}
.intensity-btn.is-selected .intensity-num { opacity: 1; }

.range-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--mint-dark);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #cfdad2;
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
  padding: 12px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 96px;
  padding: 14px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.product-card {
  display: grid;
  min-height: 330px;
  grid-template-rows: 92px auto;
  overflow: hidden;
}

.product-card.is-completed {
  border-color: rgba(46, 124, 90, 0.42);
}

.product-art {
  position: relative;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, var(--art-a), var(--art-b)),
    #eef6ef;
}

.product-art::before {
  content: "";
  position: absolute;
  width: 76px;
  height: 54px;
  border: 2px solid rgba(24, 32, 31, 0.84);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  transform: rotate(-6deg);
}

.product-art span {
  position: relative;
  z-index: 1;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fffefa;
  font-size: 28px;
}

.product-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.product-card h3 {
  margin: 0;
  font-size: 18px;
}

.product-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.product-step {
  display: grid;
  gap: 5px;
  border: 1px solid #dde7df;
  border-radius: 8px;
  background: #fbfdf9;
  padding: 10px;
}

.product-step span {
  color: var(--mint-dark);
  font-size: 12px;
  font-weight: 800;
}

.product-step strong {
  font-size: 13px;
  line-height: 1.45;
}

.product-action-panel {
  border-color: rgba(46, 124, 90, 0.3);
  background: #f7fbf7;
}

.chip-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid #d7e1da;
  border-radius: 999px;
  background: #f6f9f6;
  color: #40504b;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.card-actions button:not(.icon-button) {
  flex: 1;
}

.card-actions .icon-button {
  flex: 0 0 40px;
}

.empty {
  border: 1px dashed #becdc4;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  padding: 28px;
  text-align: center;
}

.calendar-shell {
  display: grid;
  gap: 16px;
}

.calendar-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.calendar-summary-card {
  display: grid;
  gap: 4px;
  border: 1px solid #dfe8e2;
  border-radius: 14px;
  background:
    radial-gradient(circle at 18% 20%, rgba(127, 199, 164, 0.22), transparent 28%),
    #fffefa;
  padding: 12px;
}

.calendar-summary-card span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 900;
}

.calendar-summary-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
  line-height: 1.15;
}

.calendar-summary-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-head {
  display: grid;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  background: rgba(127, 199, 164, 0.1);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  position: relative;
  display: grid;
  align-content: space-between;
  gap: 8px;
  min-height: 96px;
  overflow: hidden;
  border-color: #e3ebe5;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(251, 250, 245, 0.82));
  padding: 10px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.calendar-day.has-record {
  border-color: var(--mood-color);
  background:
    radial-gradient(circle at 78% 18%, var(--mood-bg), transparent 36%),
    linear-gradient(180deg, #ffffff, #fffefa);
  box-shadow: 0 10px 22px rgba(33, 46, 42, 0.07);
}

.calendar-day.is-today {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.calendar-day-top,
.calendar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.calendar-day.is-muted {
  opacity: 0.35;
}

.calendar-day strong {
  display: block;
  margin: 0;
  font-size: 14px;
  line-height: 1;
}

.check-icon,
.empty-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.check-icon {
  background: var(--mood-color);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(33, 46, 42, 0.16);
}

.empty-icon {
  color: #aab8b0;
  background: #f2f5f1;
}

.calendar-mood {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.mood-face {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--mood-color);
  border-radius: 12px;
  background: var(--mood-bg);
  font-size: 20px;
  font-weight: 900;
}

.mood-name {
  overflow: hidden;
  color: #31413c;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.intensity-dots {
  display: flex;
  gap: 3px;
}

.intensity-dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #dbe4de;
}

.intensity-dots span.is-on {
  background: var(--mood-color);
}

.record-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.extra-moods {
  display: inline-flex;
  flex-direction: row-reverse;
}

.extra-moods span {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid #ffffff;
  border-radius: 999px;
  background: #f7faf7;
  font-size: 11px;
  margin-left: -5px;
}

.calendar-empty-mark {
  align-self: end;
  color: #a1aea8;
  font-size: 12px;
  font-weight: 800;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #dfe8e2;
  border-radius: 999px;
  background: #fffefa;
  padding: 5px 9px;
}

.calendar-legend i {
  display: inline-grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 999px;
  font-style: normal;
}

.legend-check {
  background: var(--mint-dark);
  color: white;
}

.legend-empty {
  background: #f2f5f1;
  color: #aab8b0;
}

.legend-dot {
  background: var(--sun);
}

.mood-dot {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  background: #eef7f2;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 4px solid var(--mint);
  padding: 8px 0 8px 12px;
}

.timeline-item p {
  margin: 5px 0 0;
  color: var(--muted);
}

.community-layout {
  display: grid;
  grid-template-columns: minmax(310px, 0.8fr) minmax(0, 1.2fr);
  gap: 20px;
}

.post-list {
  display: grid;
  gap: 12px;
}

.post-card {
  padding: 16px;
}

.post-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.post-card p {
  margin: 0;
  line-height: 1.6;
}

.support-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.admin-table {
  display: grid;
  gap: 10px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.7fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.dialog {
  width: min(680px, calc(100vw - 28px));
  border: 1px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.dialog::backdrop {
  background: rgba(24, 32, 31, 0.38);
}

.dialog-content {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.dialog-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.dialog-title h2 {
  margin: 0;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 32px));
  transform: translateY(18px);
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
  }

  .nav-item span {
    display: none;
  }

  .sidebar-note {
    display: none;
  }

  .grid-two,
  .today-page,
  .community-layout,
  .companion-chat-layout {
    grid-template-columns: 1fr;
  }

  .companion-sidebar {
    display: none;
  }

  .shelf-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    overscroll-behavior-x: none;
  }

  body {
    min-height: 100dvh;
    padding-bottom: calc(var(--mobile-nav-height) + var(--safe-bottom));
  }

  .app-shell {
    display: block;
    min-height: 100dvh;
    overflow-x: clip;
  }

  .sidebar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    min-height: 0;
    border-top: 1px solid rgba(24, 32, 31, 0.1);
    border-bottom: 0;
    background: rgba(255, 254, 250, 0.92);
    backdrop-filter: blur(18px);
    padding: 6px max(8px, var(--safe-right)) calc(6px + var(--safe-bottom)) max(8px, var(--safe-left));
  }

  .brand,
  .sidebar-note {
    display: none;
  }

  .nav-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
  }

  .nav-item {
    display: grid;
    min-height: 56px;
    justify-items: center;
    gap: 3px;
    border: 0;
    border-radius: 12px;
    padding: 6px 2px;
    font-size: 11px;
    font-weight: 700;
  }

  .nav-item span {
    display: grid;
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
    font-size: 17px;
  }

  .nav-item:hover,
  .nav-item.is-active {
    background: rgba(127, 199, 164, 0.18);
    box-shadow: none;
  }

  .main {
    min-width: 0;
    padding: 14px max(12px, var(--safe-right)) 20px max(12px, var(--safe-left));
  }

  .band {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 12;
    align-items: center;
    flex-direction: row;
    margin: -14px -12px 12px;
    border-bottom: 1px solid rgba(24, 32, 31, 0.08);
    background: rgba(251, 250, 245, 0.94);
    backdrop-filter: blur(18px);
    padding: calc(10px + var(--safe-top)) max(12px, var(--safe-right)) 10px max(12px, var(--safe-left));
  }

  .topbar .eyebrow {
    display: none;
  }

  .topbar h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.15;
  }

  .top-actions {
    width: auto;
    margin-left: auto;
    gap: 6px;
  }

  .top-actions .primary-button {
    flex: initial;
  }

  .top-actions .ghost-button,
  .top-actions .primary-button {
    min-height: 34px;
    padding: 0 11px;
    font-size: 13px;
    white-space: nowrap;
  }

  .top-actions .icon-button {
    width: 34px;
    min-height: 34px;
  }

  body[data-view="ai"] .top-actions {
    display: none;
  }

  .shelf-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .product-card,
  .metric,
  .post-card,
  .calendar-day,
  .empty {
    border-radius: 12px;
  }

  .panel {
    padding: 16px;
  }

  .view {
    gap: 16px;
  }

  .today-page {
    gap: 12px;
  }

  .today-record-panel,
  .today-shelf-panel {
    border-radius: 16px;
  }

  .today-compact-head {
    gap: 12px;
    margin-bottom: 14px;
  }

  .today-mood-orb {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    font-size: 24px;
  }

  .today-compact-head h2,
  .today-section-head h2 {
    font-size: 20px;
  }

  .today-compact-head p:not(.eyebrow),
  .today-section-head span {
    font-size: 12px;
  }

  .today-record-panel .record-form {
    gap: 12px;
  }

  .everyday-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .today-record-panel .emotion-grid:not(.everyday-grid) .choice,
  .today-record-panel .tag-grid .choice {
    flex: 0 0 auto;
    min-height: 38px;
    white-space: nowrap;
  }

  .today-form-actions {
    grid-template-columns: 1fr;
  }

  .today-section-head {
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .today-section-head > span {
    max-width: 45vw;
    text-align: right;
  }

  .need-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .need-card {
    min-height: 40px;
  }

  .today-action-card {
    grid-template-columns: 1fr;
  }

  .today-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    font-size: 22px;
  }

  .today-action-copy em {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .today-action-tools {
    justify-content: flex-end;
  }

  .today-mini-stats {
    justify-content: center;
  }

  .recent-panel .timeline {
    max-height: none;
  }

  .emotion-grid,
  .tag-grid,
  .filter-row {
    gap: 7px;
  }

  .choice,
  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button,
  .icon-button {
    min-height: 44px;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  textarea {
    min-height: 108px;
  }

  .range-line {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .range-line strong {
    justify-self: end;
  }

  input[type="range"] {
    min-height: 34px;
  }

  .product-card {
    min-height: auto;
    grid-template-rows: 76px auto;
  }

  .product-body {
    gap: 9px;
    padding: 12px;
  }

  .product-card h3 {
    font-size: 17px;
  }

  .product-card p,
  .product-step strong {
    font-size: 13px;
  }

  .card-actions {
    gap: 6px;
  }

  .card-actions .primary-button,
  .card-actions .ghost-button {
    min-height: 38px;
    padding-inline: 10px;
    font-size: 13px;
  }

  .calendar-grid {
    gap: 5px;
  }

  .calendar-day {
    min-height: 88px;
    gap: 6px;
    padding: 7px;
  }

  .calendar-summary {
    gap: 8px;
  }

  .calendar-summary-card {
    border-radius: 12px;
    padding: 10px 8px;
  }

  .calendar-summary-card span {
    width: 28px;
    height: 28px;
    border-radius: 9px;
  }

  .calendar-summary-card strong {
    font-size: 16px;
  }

  .calendar-summary-card small,
  .calendar-legend,
  .record-count,
  .calendar-empty-mark {
    font-size: 10px;
  }

  .calendar-head {
    min-height: 24px;
    font-size: 11px;
  }

  .calendar-day strong {
    font-size: 12px;
  }

  .check-icon,
  .empty-icon {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }

  .calendar-mood {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }

  .mood-face {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    font-size: 17px;
  }

  .mood-name {
    max-width: 100%;
    font-size: 11px;
  }

  .intensity-dots {
    gap: 2px;
  }

  .intensity-dots span {
    width: 5px;
    height: 5px;
  }

  .extra-moods {
    display: none;
  }

  .calendar-legend span {
    padding: 4px 7px;
  }

  .admin-row {
    grid-template-columns: 1fr;
  }

  .dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }

  .dialog-content {
    max-height: calc(100dvh - var(--safe-top));
    overflow-y: auto;
    padding: 18px max(16px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(16px, var(--safe-left));
  }

  .dialog-title {
    position: sticky;
    top: 0;
    z-index: 1;
    align-items: center;
    background: var(--surface);
    padding-bottom: 10px;
  }

  .toast {
    right: max(12px, var(--safe-right));
    bottom: calc(var(--mobile-nav-height) + var(--safe-bottom) + 12px);
    left: max(12px, var(--safe-left));
    max-width: none;
    text-align: center;
  }
}

/* ─── AI Chat ──────────────────────────────────────────────────────────────── */

.ai-chat-panel {
  display: flex;
  flex-direction: column;
}

.companion-chat-layout {
  display: block;
  min-height: calc(100vh - 170px);
}

.companion-sidebar {
  display: grid;
  gap: 16px;
  align-content: start;
}

.companion-hero-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.ai-chat-panel-large {
  min-height: calc(100vh - 190px);
  padding: 0;
  overflow: hidden;
}

.ai-chat-panel-large .chat-messages {
  max-height: none;
  min-height: 300px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.companion-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background:
    linear-gradient(135deg, rgba(127, 199, 164, 0.16), rgba(246, 200, 95, 0.12)),
    #fffefa;
  padding: 20px 24px;
  margin-bottom: 0;
}

.companion-hero h2 {
  margin: 2px 0 6px;
  font-size: 22px;
  line-height: 1.2;
}

.companion-hero p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.companion-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.companion-session {
  display: grid;
  gap: 0;
  padding: 0 24px 24px;
}

.companion-start-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px 24px;
  margin-bottom: 0;
  background: #fbfaf6;
}

.companion-start-card {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.companion-start-card:hover {
  border-color: var(--ink);
  box-shadow: 4px 4px 0 rgba(24, 32, 31, 0.12);
}

.companion-start-card span {
  display: block;
  color: var(--mint-dark);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.companion-start-card strong {
  display: block;
  font-size: 18px;
  margin-bottom: 6px;
}

.companion-start-card small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.companion-prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 12px 0;
}

.companion-session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 8px;
}

.companion-session-header strong {
  display: block;
}

.companion-session-header span {
  color: var(--muted);
  font-size: 13px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 260px;
  max-height: 380px;
  padding: 12px 0 18px;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
  flex: 1;
}

.chat-welcome-icon {
  font-size: 28px;
  color: var(--mint);
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.65;
  font-size: 14px;
}

.chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
}

.chat-bubble.is-user {
  align-self: flex-end;
  background: var(--ink);
  color: white;
  border-bottom-right-radius: 3px;
}

.chat-bubble.is-ai {
  align-self: flex-start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
}

/* 聊天日期导航栏 */
.chat-date-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.chat-date-label {
  font-size: 13px;
  color: var(--ink-muted, #888);
  min-width: 60px;
  text-align: center;
}
.chat-date-nav {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink);
  padding: 0 4px;
  line-height: 1;
  opacity: 0.6;
}
.chat-date-nav:disabled { opacity: 0.2; cursor: default; }
.chat-date-nav:not(:disabled):hover { opacity: 1; }

/* 流式打字光标 */
.stream-cursor {
  display: inline-block;
  animation: blink 0.7s step-end infinite;
  margin-left: 1px;
  opacity: 0.7;
}
@keyframes blink {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 0; }
}

/* 旁白动图 */
.action-gif-ph {
  display: inline-block;
  font-size: 1.1em;
  vertical-align: middle;
}

.action-gif-img {
  display: block;
  margin: 6px 0 2px;
  max-width: 160px;
  max-height: 120px;
  border-radius: 10px;
  object-fit: cover;
}

.chat-bubble.is-thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}

.chat-bubble.is-thinking span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: thinking-pulse 1.2s ease-in-out infinite;
}

.chat-bubble.is-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-bubble.is-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50%       { opacity: 1;    transform: scale(1.1); }
}

.chat-input-row {
  display: flex;
  gap: 10px;
  margin-top: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.chat-input-row input,
.chat-input-row textarea {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  resize: none;
  transition: border-color 160ms ease;
}

.chat-input-row textarea {
  max-height: 120px;
  overflow-y: auto;
}

.chat-input-row input:focus,
.chat-input-row textarea:focus {
  outline: none;
  border-color: var(--mint);
}

.ai-key-config {
  padding: 4px 0;
}

.local-chat-setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffefa;
}

.local-chat-setting.is-enabled {
  border-color: color-mix(in srgb, var(--mint) 52%, var(--line));
  background: color-mix(in srgb, var(--mint) 9%, #fffefa);
}

.local-chat-setting strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.local-chat-setting p,
.local-chat-setting small {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.local-chat-setting small {
  margin-top: 6px;
  color: var(--coral);
  font-weight: 700;
}

@media (max-width: 640px) {
  .local-chat-setting {
    grid-template-columns: 1fr;
  }
}

.ai-report-panel {
  animation: fade-in 0.3s ease;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.insight-card {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  padding: 12px;
}

.insight-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.insight-card strong {
  display: block;
  font-size: 14px;
  line-height: 1.55;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0);   }
}

@media (max-width: 720px) {
  body[data-view="ai"] {
    background: #fffefa;
  }

  body[data-view="ai"] .main {
    padding: 10px 0 0;
  }

  body[data-view="ai"] .topbar {
    margin: -10px 0 0;
    padding-inline: 14px;
  }

  body[data-view="ai"] .view {
    gap: 0;
  }

  body[data-view="ai"] .panel {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .companion-hero {
    padding: 18px 16px 14px;
    border-bottom: 0;
  }

  .companion-hero h2 {
    font-size: 23px;
    font-weight: 800;
    line-height: 1.18;
  }

  .companion-hero p {
    font-size: 13px;
    line-height: 1.55;
  }

  .companion-hero .eyebrow {
    font-size: 10px;
    letter-spacing: 0.08em;
  }

  .companion-status-row {
    margin-top: 10px;
  }

  .companion-start-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    overflow-x: auto;
    border-bottom: 0;
    padding: 8px 14px 12px;
    scrollbar-width: none;
  }

  .companion-start-grid::-webkit-scrollbar {
    display: none;
  }

  .companion-start-card {
    min-height: 82px;
    min-width: 0;
    padding: 10px 8px;
  }

  .companion-start-card strong {
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
  }

  .companion-start-card small {
    font-size: 11px;
    line-height: 1.35;
  }

  .companion-session {
    padding: 0 max(14px, var(--safe-right)) calc(88px + var(--safe-bottom)) max(14px, var(--safe-left));
  }

  .companion-session-header {
    align-items: center;
    flex-direction: row;
    padding: 10px 0 6px;
  }

  .companion-session-header strong {
    font-size: 15px;
    font-weight: 800;
  }

  .companion-session-header span {
    display: none;
  }

  .companion-session-header .ghost-button {
    min-height: 32px;
    padding-inline: 10px;
    font-size: 12px;
  }

  .ai-chat-panel-large,
  .companion-chat-layout {
    min-height: auto;
  }

  .ai-chat-panel-large .chat-messages {
    min-height: 38vh;
  }

  .chat-messages {
    gap: 10px;
    padding-top: 8px;
  }

  .chat-bubble {
    max-width: 88%;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
  }

  .chat-bubble.is-user {
    border-bottom-right-radius: 5px;
  }

  .chat-bubble.is-ai {
    border-bottom-left-radius: 5px;
  }

  .companion-prompt-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 0;
    scrollbar-width: none;
  }

  .companion-prompt-row::-webkit-scrollbar {
    display: none;
  }

  .companion-prompt-row .choice {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .chat-input-row {
    position: fixed;
    right: 0;
    bottom: calc(var(--mobile-nav-height) + var(--safe-bottom));
    left: 0;
    z-index: 18;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    border-top: 1px solid rgba(24, 32, 31, 0.08);
    background: rgba(255, 254, 250, 0.96);
    backdrop-filter: blur(18px);
    padding: 10px max(12px, var(--safe-right)) 10px max(12px, var(--safe-left));
  }

  .chat-input-row input,
  .chat-input-row textarea {
    min-height: 44px;
    border-radius: 22px;
    background: #f4f6f3;
    padding: 10px 16px;
    max-height: 88px;
    font-size: 16px;
  }

  .chat-input-row .primary-button {
    min-width: 64px;
    min-height: 44px;
    border-radius: 999px;
    padding: 0 16px;
  }

  .insight-grid {
    grid-template-columns: 1fr;
  }

  .companion-chat-layout,
  .ai-chat-panel-large {
    min-height: auto;
  }

  .ai-chat-panel-large .chat-messages {
    min-height: 340px;
  }
}

/* ─── 登录/注册页 ──────────────────────────────────────────────────────────── */

.auth-shell {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
}

.auth-tabs {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  min-height: 40px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms, color 160ms;
}

.auth-tab.is-active {
  background: var(--ink);
  color: white;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-id-toggle,
.auth-method-toggle {
  display: flex;
  gap: 8px;
}

.auth-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.auth-code-row input { width: 100%; }

.auth-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff3f1;
  color: #9e372a;
  font-size: 13px;
  line-height: 1.5;
}

.auth-submit {
  width: 100%;
  min-height: 46px;
  font-size: 15px;
  font-weight: 800;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-disclaimer {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.auth-user-chip {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f9f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 0 10px;
  line-height: 32px;
}

@media (max-width: 480px) {
  .topbar h1 {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-list {
    gap: 1px;
  }

  .nav-item {
    min-height: 54px;
    font-size: 10px;
  }

  .nav-item span {
    width: 22px;
    height: 22px;
    font-size: 16px;
  }

  .auth-shell {
    align-items: stretch;
    padding: calc(16px + var(--safe-top)) max(12px, var(--safe-right)) calc(16px + var(--safe-bottom)) max(12px, var(--safe-left));
  }

  .auth-card {
    align-self: center;
    padding: 28px 20px 22px;
  }
}

/* ─── Companion Popup ──────────────────────────────────────────────────────── */
.companion-popup {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.13), 0 2px 8px rgba(0, 0, 0, 0.07);
  z-index: 900;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}
.companion-popup.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.companion-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
}
.companion-popup-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.companion-popup-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  padding: 0 2px;
}
.companion-popup-close:hover { color: var(--ink); }
.companion-popup-body {
  padding: 10px 16px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
}
.companion-popup-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
}
.companion-popup-actions .primary-button {
  flex: 1;
  font-size: 13px;
  padding: 8px 12px;
}
.companion-popup-actions .ghost-button {
  font-size: 13px;
  padding: 8px 12px;
}

@media (max-width: 720px) {
  .companion-popup {
    right: max(12px, var(--safe-right));
    bottom: calc(var(--mobile-nav-height) + var(--safe-bottom) + 12px);
    left: max(12px, var(--safe-left));
    width: auto;
    max-width: none;
    border-radius: 16px;
  }

  .companion-popup-actions {
    flex-direction: column;
  }
}
