.app-body {
  min-height: 100vh;
  background: var(--bg);
  min-width: 210px;
  flex-direction: column;
  align-items: stretch;
  display: flex;
}

.chat-voice-note audio {
  display: none;
}

.chat-voice-play,
.chat-voice-speed {
  min-width: 30px;
  min-height: 29px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font: 10px var(--sans);
}

.chat-voice-note input[type="range"] {
  width: 100px;
  min-width: 35px;
  accent-color: var(--accent);
}

.chat-voice-time {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.chat-message-actions {
  position: absolute;
  top: 2px;
  right: 5px;
}

.chat-message-actions > summary {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  list-style: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  opacity: 0;
}

.chat-message-actions > summary::-webkit-details-marker {
  display: none;
}

.chat-bubble:hover .chat-message-actions > summary,
.chat-message-actions[open] > summary,
.chat-message-actions:focus-within > summary {
  opacity: 1;
}

.chat-message-menu {
  position: absolute;
  top: 25px;
  right: 0;
  z-index: 4;
  min-width: 150px;
  padding: 4px;
  display: grid;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-message-menu button {
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font: 10px var(--sans);
}

.chat-message-menu button:hover {
  background: var(--surface-2);
}

.chat-image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  max-width: 360px;
}

.chat-image-grid .chat-media-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.chat-preview-item {
  position: relative;
  flex: 0 0 auto;
}

.chat-preview-item > button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 21px;
  height: 21px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  color: var(--bg);
  cursor: pointer;
  font-size: 16px;
}

.chat-upload-state.is-failed {
  color: var(--accent);
}

.chat-upload-state button {
  padding: 3px 7px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font: 9px var(--sans);
}

.chat-bubble .chat-message-actions {
  opacity: 0;
}

.chat-bubble:hover .chat-message-actions,
.chat-message-actions[open],
.chat-message-actions:focus-within {
  opacity: 1;
}

.chat-bubble.is-emoji-only .chat-message-actions {
  top: 0;
}

.chat-form .chat-upload-preview {
  flex: 1 0 100%;
}

.chat-replying-banner {
  flex: 1 0 100%;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-left: 2px solid var(--accent);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
}

.chat-replying-banner button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}

.chat-jump-button {
  transition: transform 140ms ease;
}

.chat-jump-button:hover {
  transform: translateY(-2px);
}

.chat-attach-menu[open] summary {
  border-color: var(--accent);
}

.chat-contact-heart {
  flex: 0 0 auto;
}

.chat-message-status[aria-label="Sent"]::after {
  content: " sent";
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.chat-drop-zone.is-dragging::after {
  position: absolute;
  inset: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--muted);
  content: "Drop images to share";
  font: 500 14px var(--sans);
}

.app-header {
  background: color-mix(in srgb, var(--bg) 88%, transparent);
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--muted);
}

.app-shell {
  width: min(100% - 40px, 980px);
  min-height: calc(100vh - 175px);
  margin: 0 auto;
  padding: 54px 0 72px;
}

.auth-card {
  width: min(100%, 445px);
  margin: 28px auto;
  padding: 36px 39px 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.back-link {
  display: inline-block;
  margin-bottom: 36px;
  color: var(--muted);
  font-size: 11px;
}

.auth-card h1,
.dashboard-heading h1 {
  margin: 20px 0 12px;
  font-family: var(--serif);
  font-size: 52px;
  font-weight: 500;
  letter-spacing: -2px;
  line-height: 1.08;
}

.auth-card h1 em,
.dashboard-heading h1 em {
  color: var(--accent);
  font-weight: 500;
}

.auth-intro,
.panel-intro {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.passkey-login {
  margin-top: 17px;
}

.passkey-login .app-submit {
  margin-top: 0;
}

.passkey-login .record-meta,
.passkey-register-status {
  min-height: 1em;
  margin: 6px 0 0;
}

.passkey-register-form {
  display: grid;
  gap: 10px;
}

.passkey-dialog {
  position: relative;
  width: min(100% - 32px, 430px);
  padding: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.passkey-dialog::backdrop {
  background: color-mix(in srgb, var(--ink) 48%, transparent);
}

.passkey-dialog h2 {
  margin: 0 35px 9px 0;
  font: 500 25px/1.2 var(--serif);
}

.passkey-dialog > p:not(.passkey-register-status) {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.passkey-dialog-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
}

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.passkey-register-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.passkey-register-form input {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font: 12px var(--sans);
}

.passkey-register-form input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.passkey-register-status {
  grid-column: 1 / -1;
}

.app-form {
  margin-top: 25px;
  display: grid;
  gap: 15px;
}

.app-form label,
.inline-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.app-form input,
.inline-form input {
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font: 12px var(--sans);
}

.app-form input:focus,
.inline-form input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.app-submit {
  width: 100%;
  margin-top: 3px;
}

.app-alert {
  margin: 16px 0 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.app-alert.is-success {
  border-color: var(--line);
  background: var(--bg);
  color: var(--muted);
}

.setup-details {
  margin-top: 25px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.setup-details summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.setup-details > p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

.dashboard {
  padding-top: 14px;
}

.dashboard-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.dashboard-heading h1 {
  margin-top: 13px;
  font-size: 46px;
}

.text-button {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.text-button:hover,
.back-link:hover {
  color: var(--accent);
}

.app-tabs {
  position: relative;
  margin-top: 27px;
  padding: 4px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  scrollbar-width: none;
}

.app-tabs::-webkit-scrollbar {
  display: none;
}

.app-tabs::after {
  position: sticky;
  right: 0;
  min-width: 24px;
  margin-left: -24px;
  flex: 0 0 24px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--surface) 0%, transparent), var(--surface));
  content: "";
  pointer-events: none;
}

.app-tab {
  min-height: 39px;
  padding: 0 12px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: 500 10px var(--sans);
}

.chat-unread-badge {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

.chat-unread-badge[hidden] {
  display: none;
}

.app-tab:hover,
.app-tab.is-active {
  background: var(--ink);
  color: var(--bg);
}

.dashboard-alert {
  margin-top: 15px;
}

.tab-panel {
  padding-top: 26px;
}

.tab-panel[hidden],
.auth-card[hidden],
.dashboard[hidden],
.setup-details[hidden] {
  display: none !important;
}

.welcome-card {
  position: relative;
  min-height: 220px;
  padding: 31px 35px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  background: var(--surface-2);
}

.welcome-copy {
  position: relative;
  z-index: 1;
  max-width: 750px;
}

.welcome-card h2,
.panel-heading h2 {
  margin: 12px 0 10px;
  font-family: var(--serif);
  font-size: 35px;
  font-weight: 500;
  letter-spacing: -1px;
  line-height: 1.15;
}

.welcome-card h2 em,
.panel-heading h2 em {
  color: var(--accent);
  font-weight: 500;
}

.welcome-copy > p:last-of-type {
  max-width: 475px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}

.assistant-sparkle {
  position: absolute;
  right: 24px;
  bottom: -54px;
  color: color-mix(in srgb, var(--accent) 14%, transparent);
  font-size: 150px;
  line-height: 1;
  pointer-events: none;
}

.flirty-message-button {
  min-height: 34px;
  margin-top: 16px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  color: var(--muted);
  cursor: pointer;
  font: 600 9px var(--sans);
}

.flirty-message-button:hover {
  background: var(--surface);
  color: var(--accent);
}

.flirty-message-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.insight-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.insight-card {
  min-height: 164px;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.insight-card-peach {
  background: var(--accent-soft);
}

.insight-card-green {
  background: var(--sage);
}

.insight-kicker {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.insight-card h3 {
  margin: 15px 0 8px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
}

.insight-card p,
.privacy-note,
.medical-note {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.8;
}

.privacy-note {
  margin-top: 17px;
  padding: 12px 14px;
  border-left: 2px solid var(--accent);
  background: var(--surface-2);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-heading h2 {
  margin: 10px 0 0;
  font-size: 39px;
}

.panel-mark {
  color: var(--accent);
  font-size: 38px;
}

.panel-intro {
  max-width: 650px;
  margin: 14px 0 20px;
}

.inline-form {
  padding: 16px;
  display: flex;
  align-items: end;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.inline-form label {
  flex: 1 1 0;
  min-width: 0;
}

.inline-form .button {
  min-height: 43px;
  flex: 0 0 auto;
}

.optional-label {
  color: var(--muted);
  font-weight: 400;
}

.cycle-summary,
.expense-total {
  margin-top: 14px;
  padding: 15px 17px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.cycle-summary:empty,
.expense-total:empty {
  display: none;
}

.cycle-stats {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.cycle-stat {
  padding: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.cycle-stats > .empty-state {
  grid-column: 1 / -1;
}

.cycle-stat span {
  display: block;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.cycle-stat strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
}

.cycle-calendar-card,
.cycle-subsection {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.calendar-heading {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calendar-heading h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
}

.calendar-nav {
  width: 34px;
  height: 34px;
  margin-left: 5px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

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

.calendar-weekday,
.calendar-day {
  min-width: 0;
  min-height: 39px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.calendar-weekday {
  min-height: 27px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.calendar-day {
  position: relative;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.calendar-day:hover,
.calendar-day.is-selected {
  border-color: var(--accent);
}

.calendar-day:disabled {
  cursor: default;
}

.calendar-day.is-outside {
  color: var(--muted);
}

.calendar-day.is-period {
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
}

.calendar-day.is-predicted:not(.is-period) {
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--muted);
}

.calendar-day.has-entry::after {
  position: absolute;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
}

.calendar-legend {
  margin-top: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 9px;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.calendar-legend i {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
}

.legend-period {
  background: var(--accent);
}

.legend-prediction {
  background: var(--accent-soft);
}

.legend-logged {
  background: var(--muted);
}

.cycle-day-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.cycle-day-form > label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.cycle-day-form input:not([type="checkbox"]):not([type="radio"]),
.cycle-day-form select,
.cycle-day-form textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  font: 11px var(--sans);
}

.cycle-day-form textarea {
  resize: vertical;
}

.symptom-fieldset,
.cycle-note-label {
  grid-column: 1 / -1;
}

.symptom-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.flow-fieldset {
  grid-column: auto;
}

.symptom-fieldset legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.symptom-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.symptom-chips label {
  cursor: pointer;
}

.symptom-chips input {
  position: absolute;
  opacity: 0;
}

.symptom-chips span {
  padding: 8px 11px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
}

.symptom-chips input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--muted);
}

.symptom-chips input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cycle-day-form > .button {
  grid-column: 1 / -1;
  justify-self: start;
}

.cycle-patterns {
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.8;
}

.cycle-late-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
}

.cycle-late-toggle input {
  accent-color: var(--accent);
}

.cycle-log-time-label {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
}

.cycle-log-time-label select {
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font: 10px var(--sans);
}

.list-title {
  margin: 24px 0 10px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
}

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

.record-item {
  min-height: 54px;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border: 1px solid var(--accent-soft);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.record-item strong {
  color: var(--ink);
  font-weight: 600;
}

.record-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.record-delete {
  padding: 5px 8px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: 500 9px var(--sans);
}

.record-edit {
  padding: 5px 8px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: 500 9px var(--sans);
}

.record-edit:hover {
  color: var(--accent);
  text-decoration: underline;
}

.record-delete:hover {
  color: var(--accent);
  text-decoration: underline;
}

.record-delete:disabled {
  cursor: wait;
  opacity: 0.6;
}

.empty-state {
  padding: 21px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.medical-note {
  margin-top: 16px;
  padding: 13px;
  background: var(--surface-2);
}

.chat-list {
  min-height: 240px;
  height: calc(100dvh - 390px);
  max-height: 680px;
  padding: 18px clamp(12px, 4vw, 34px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: var(--surface-2);
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.chat-bubble {
  position: relative;
  max-width: min(80%, 560px);
  margin-right: auto;
  padding: 9px 12px 7px;
  align-self: flex-start;
  border-radius: 12px 12px 12px 2px;
  border: 1px solid color-mix(in srgb, var(--accent) 10%, transparent);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  touch-action: pan-y;
}

.chat-bubble.is-mine {
  margin-right: 0;
  margin-left: auto;
  align-self: flex-end;
  border-radius: 12px 12px 2px 12px;
  border-color: transparent;
  background: var(--line);
  box-shadow: var(--shadow);
}

.app-tabs::after {
  display: none;
}

body.chat-mode .app-tabs {
  display: grid;
}

body.chat-mode .app-shell {
  height: calc(100dvh - 116px);
}

.chat-bubble.is-grouped {
  margin-top: -5px;
}

.chat-bubble.is-mine .record-meta {
  text-align: right;
}

.chat-header {
  min-height: 52px;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
}

.chat-contact,
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-contact-heart {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-size: 18px;
}

.chat-contact h2 {
  margin: 0;
  font: 500 15px var(--serif);
}

.chat-presence {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.chat-header-actions {
  gap: 6px;
}

.chat-icon-button,
.chat-jump-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 19px;
}

.chat-icon-button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.chat-settings {
  padding: 10px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.chat-settings[hidden],
.chat-typing[hidden],
.chat-recording-status[hidden],
.chat-jump-button[hidden] {
  display: none;
}

.chat-settings label {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.chat-settings select,
.chat-cleanup-button {
  min-height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  font: 10px var(--sans);
}

.chat-cleanup-button {
  cursor: pointer;
}

.chat-cleanup-button:disabled {
  opacity: .55;
  cursor: wait;
}

.chat-drop-zone {
  position: relative;
}

.chat-drop-zone.is-dragging {
  outline: 2px dashed var(--accent);
  outline-offset: -5px;
}

.chat-jump-button {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 1;
  width: auto;
  min-width: 42px;
  padding: 0 10px;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.chat-jump-button span {
  font-size: 11px;
}

.chat-typing {
  min-height: 14px;
  margin: 4px 12px 0;
  color: var(--muted);
  font-size: 10px;
}

.chat-date-divider,
.chat-new-divider {
  position: relative;
  margin: 8px auto;
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
}

.chat-new-divider {
  background: var(--line);
  color: var(--muted);
}

.chat-message-text a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-message-text.is-emoji-only {
  font-size: 38px;
  line-height: 1.2;
}

.chat-bubble.is-emoji-only {
  padding: 3px 9px;
  background: transparent;
}

.chat-bubble.is-emoji-only.is-mine {
  background: transparent;
}

.chat-message-status {
  display: inline-block;
  margin-left: 5px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: -2px;
}

.chat-message-status.is-seen {
  color: var(--accent);
}

.chat-seen-line {
  display: block;
  color: var(--accent);
  font-size: 9px;
  text-align: right;
}

.chat-reply-preview {
  margin-bottom: 5px;
  padding: 5px 8px;
  border-left: 2px solid var(--accent);
  background: color-mix(in srgb, var(--surface) 38%, transparent);
  color: var(--muted);
  font-size: 10px;
}

.chat-reaction {
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--surface);
  font-size: 11px;
}

.chat-media-image,
.chat-media-player {
  width: 100%;
  max-width: 360px;
  display: block;
  border-radius: 7px;
}

.chat-media-image {
  max-height: 340px;
  object-fit: contain;
  cursor: zoom-in;
}

.chat-media-player {
  margin-bottom: 6px;
}

.chat-message-text {
  margin-top: 5px;
  white-space: pre-wrap;
}

.chat-form {
  position: relative;
  margin-top: 0;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--surface);
}

.chat-form > textarea {
  min-width: 0;
  min-height: 38px;
  max-height: 100px;
  padding: 8px 12px;
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 19px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font: 12px/1.45 var(--sans);
}

.chat-form > textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.chat-attachment-tools {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-tool-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font: 500 12px var(--sans);
}

.chat-tool-button:hover {
  border-color: var(--accent);
  color: var(--muted);
}

.chat-attachment-name {
  max-width: 70px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-attach-menu {
  position: relative;
}

.chat-attach-menu summary {
  list-style: none;
  cursor: pointer;
}

.chat-attach-menu summary::-webkit-details-marker {
  display: none;
}

.chat-attach-options {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 3;
  min-width: 190px;
  padding: 5px;
  display: grid;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-attach-options .chat-upload-hint {
  margin: 4px 7px 6px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.chat-attach-options button {
  padding: 9px 11px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font: 11px var(--sans);
}

.chat-attach-options button:hover {
  background: var(--surface-2);
}

.chat-mic-button.is-recording {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
  touch-action: none;
}

.chat-recording-status {
  color: var(--accent);
  font-size: 10px;
  white-space: nowrap;
}

.chat-form .chat-send-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-size: 18px;
}

.chat-upload-preview {
  width: 100%;
  padding: 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.chat-upload-preview img,
.chat-upload-preview video {
  width: 68px;
  height: 68px;
  border-radius: 5px;
  object-fit: cover;
}

.chat-upload-state {
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 9px;
}

.chat-upload-state progress {
  width: 100px;
  accent-color: var(--accent);
}

.chat-lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  padding: 48px 12px 14px;
  border: 0;
  background: color-mix(in srgb, var(--ink) 96%, transparent);
}

.chat-lightbox::backdrop {
  background: color-mix(in srgb, var(--ink) 96%, transparent);
}

.chat-lightbox img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: manipulation;
}

.chat-lightbox-close,
.chat-lightbox-download {
  position: absolute;
  top: 10px;
  color: var(--bg);
}

.chat-lightbox-close {
  left: 12px;
  border: 0;
  background: none;
  font-size: 30px;
}

.chat-lightbox-download {
  right: 14px;
  padding: 8px;
  font-size: 12px;
}

.expense-form,
.schedule-form {
  flex-wrap: wrap;
}

.notification-row {
  margin: 0 0 12px;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--sage);
  color: var(--muted);
  font-size: 10px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.toast {
  position: fixed;
  z-index: 5;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 16px;
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.app-footer {
  border-top: 1px solid color-mix(in srgb, var(--accent) 8%, transparent);
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 30px, 520px);
    padding-top: 30px;
  }

  .auth-card {
    margin: 12px auto;
    padding: 29px 23px 30px;
  }

  .dashboard-heading h1 {
    font-size: 39px;
  }

  .app-tabs {
    margin-top: 16px;
    padding: 2px;
  }

  .welcome-card {
    min-height: 210px;
    padding: 23px;
  }

  .assistant-sparkle {
    right: 5px;
    bottom: -35px;
    font-size: 105px;
  }

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

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

  .cycle-calendar-card,
  .cycle-subsection {
    padding: 12px;
  }

  .calendar-day {
    min-height: 36px;
  }

  .cycle-day-form {
    grid-template-columns: 1fr;
  }

  .symptom-fieldset,
  .cycle-note-label,
  .cycle-day-form > .button {
    grid-column: auto;
  }

  .cycle-day-form > .button {
    width: 100%;
  }

  .insight-card {
    min-height: auto;
    padding: 17px;
  }

  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form .button {
    width: 100%;
  }

  .chat-form > textarea {
    width: 100%;
    min-width: 0;
  }

  .chat-attachment-tools {
    width: auto;
    flex: 0 0 auto;
  }

  .chat-list {
    height: calc(100dvh - 320px);
    min-height: 230px;
    padding: 12px 8px;
  }

  .chat-bubble {
    max-width: 80%;
    padding: 8px 10px 6px;
    font-size: 12px;
  }

  .chat-settings {
    align-items: flex-start;
    flex-direction: column;
  }
}

body.chat-mode {
  height: 100dvh;
  overflow: hidden;
}

body.chat-mode .site-header {
  height: 48px;
}

body.chat-mode .header-link,
body.chat-mode .app-footer,
body.chat-mode .dashboard-heading {
  display: none;
}

body.chat-mode .app-shell {
  height: calc(100dvh - 48px);
  min-height: 0;
  padding: 8px 0 10px;
  overflow: hidden;
}

body.chat-mode .dashboard {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: 0;
}

body.chat-mode .app-tabs {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 1px;
}

body.chat-mode .app-tab {
  min-height: 34px;
  padding: 0 10px;
}

body.chat-mode .tab-panel[data-panel="chat"] {
  min-height: 0;
  padding-top: 4px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

body.chat-mode .chat-drop-zone {
  min-height: 0;
  flex: 1 1 auto;
}

body.chat-mode .chat-list {
  height: 100%;
  min-height: 0;
  max-height: none;
  padding-top: 10px;
  padding-bottom: 10px;
}

body.chat-mode .chat-form {
  flex: 0 0 auto;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

body.chat-mode .chat-form > textarea {
  width: auto;
  flex: 1 1 0;
}

body.chat-mode .chat-form .chat-attachment-tools {
  flex: 0 0 auto;
}

body.chat-mode .chat-form .chat-send-button {
  width: 38px;
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

.app-body {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

.app-header,
.site-header.app-header {
  background: var(--surface);
}

.app-header-actions {
  gap: 14px;
}

.appearance-menu {
  position: relative;
}

.appearance-menu > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  list-style: none;
  width: auto;
  min-width: 40px;
  height: 38px;
  padding: 0 12px;
  border-radius: 20px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
}

.appearance-menu > summary::-webkit-details-marker {
  display: none;
}

.appearance-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  padding: 16px;
  display: grid;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.appearance-popover label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.appearance-popover select {
  width: 100%;
  min-height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

.app-tabs {
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.app-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.app-tab > span:first-child {
  font-size: 15px;
}

.today-card-grid {
  position: relative;
}

.today-link-card {
  width: 100%;
  min-height: 145px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.today-link-card:hover {
  transform: translateY(-4px);
}

.insight-card {
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.insight-card-peach {
  background: var(--peach);
}

.insight-card-green {
  background: var(--sage);
}

.quick-actions {
  margin: 20px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.quick-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.quick-actions button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.work-status-strip {
  margin: 0 0 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.work-status-pill {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 11px;
}

.today-card-grid.is-loading .today-link-card > * {
  visibility: hidden;
}

.today-card-grid.is-loading .today-link-card {
  min-height: 145px;
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.expense-form,
.inline-form {
  border-radius: 18px;
}

.settlement-card,
.chart-card,
.office-schedule-card,
.us-section {
  margin: 20px 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.settlement-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}

.settlement-card strong {
  flex: 1 1 240px;
  color: var(--ink);
  font-size: 17px;
}

.settlement-card > span {
  flex: 1 1 220px;
  color: var(--muted);
  font-size: 12px;
}

.chart-heading,
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chart-heading h3,
.chart-card h3,
.section-title-row h3 {
  margin: 0;
  color: var(--ink);
}

.chart-month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.expense-charts {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(250px, 0.8fr);
  gap: 16px;
}

.chart-card {
  min-width: 0;
  margin: 0;
}

.expense-chart {
  width: 100%;
  height: 230px;
  overflow: visible;
}

.donut-chart-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.expense-donut-chart {
  flex: 0 0 150px;
  width: 150px;
  height: 150px;
}

.chart-legend,
.chart-inline-legend {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
}

.chart-inline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.chart-legend span,
.chart-inline-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i,
.chart-inline-legend i {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.office-schedule-card {
  overflow: hidden;
}

.office-schedule-grid {
  min-width: 620px;
  margin-top: 16px;
  display: grid;
  gap: 6px;
  overflow-x: auto;
}

.office-grid-heading,
.office-grid-row {
  display: grid;
  grid-template-columns: minmax(90px, 1.15fr) repeat(7, minmax(62px, 1fr));
  gap: 6px;
}

.office-grid-heading > span,
.office-grid-row > * {
  min-height: 42px;
  padding: 7px 4px;
  display: grid;
  align-content: center;
  justify-items: center;
  border-radius: 10px;
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}

.office-grid-heading > span.is-today,
.office-grid-row > .is-today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.office-grid-row > strong {
  justify-items: start;
  padding-left: 9px;
  color: var(--ink);
  font-size: 10px;
}

.office-cell {
  background: var(--surface-2);
  color: var(--ink) !important;
  line-height: 1.5;
}

.office-cell.status-office,
.office-cell.status-shift {
  background: var(--accent-soft);
}

.office-cell.status-wfh {
  background: var(--sage);
}

.office-cell.status-off,
.office-cell.status-unset {
  color: var(--muted) !important;
}

.office-schedule-form {
  display: grid;
  gap: 8px;
}

.office-edit-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) repeat(3, minmax(95px, 0.6fr));
  align-items: center;
  gap: 8px;
}

.office-edit-row strong,
.office-edit-row input,
.office-edit-row select {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
}

.app-dialog {
  width: min(94vw, 680px);
  max-height: 90vh;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  animation: dialog-in 180ms ease-out;
}

.app-dialog::backdrop {
  background: color-mix(in srgb, var(--ink) 48%, transparent);
  animation: fade-in 160ms ease-out;
}

.app-dialog h2 {
  margin-bottom: 20px;
}

.dialog-close-form {
  position: absolute;
  top: 12px;
  right: 12px;
}

.dialog-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  font-size: 20px;
}

.dialog-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.us-section > .inline-form {
  margin: 14px 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.checkbox-label {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
}

.checkbox-label input {
  width: auto;
  min-height: auto;
}

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

.timeline-year {
  margin: 18px 0 0;
  color: var(--accent);
  font: 500 24px var(--serif);
}

.memory-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
}

.memory-emoji {
  font-size: 24px;
}

.memory-item p {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.shared-todo > input,
.wishlist-item > input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.shared-todo.is-done strong,
.wishlist-item.is-done strong {
  color: var(--muted);
  text-decoration: line-through;
}

.wishlist-total {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.wishlist-link {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.app-alert:not([hidden]) {
  border-radius: 12px;
  background: var(--rose);
}

.button,
.app-tab,
.text-button,
.record-item,
.cycle-stat,
.calendar-day {
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.button:active,
.quick-actions button:active,
.app-tab:active {
  transform: scale(0.97);
}

.record-item,
.cycle-stat {
  border-radius: 16px;
  box-shadow: 0 1px 5px color-mix(in srgb, var(--ink) 5%, transparent);
}

.tab-panel.is-active {
  animation: panel-in 260ms ease both;
}

.today-card-grid.is-animating > * {
  animation: card-in 360ms ease both;
}

.today-card-grid.is-animating > *:nth-child(2) { animation-delay: 35ms; }
.today-card-grid.is-animating > *:nth-child(3) { animation-delay: 70ms; }
.today-card-grid.is-animating > *:nth-child(4) { animation-delay: 105ms; }
.today-card-grid.is-animating > *:nth-child(5) { animation-delay: 140ms; }
.today-card-grid.is-animating > *:nth-child(6) { animation-delay: 175ms; }

.toast {
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

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

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes skeleton-shimmer {
  to { background-position: -220% 0; }
}

@media (max-width: 700px) {
  .app-body {
    padding-bottom: 68px;
  }

  .app-header {
    height: 66px;
    padding: 0 18px;
  }

  .app-header-actions {
    gap: 8px;
  }

  .app-header-actions .header-link {
    display: none;
  }

  .appearance-menu > summary span {
    display: none;
  }

  .appearance-menu > summary {
    width: 38px;
    padding: 0;
  }

  .app-tabs {
    position: fixed;
    right: 8px;
    bottom: 8px;
    left: 8px;
    z-index: 30;
    width: auto;
    margin: 0;
    padding: 6px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .app-tab {
    min-width: 0;
    min-height: 48px;
    padding: 4px 2px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 2px;
    border-radius: 12px;
    font-size: 9px;
  }

  .app-tab > span:first-child {
    font-size: 16px;
  }

  .app-tab > span:last-child {
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-tab .chat-unread-badge {
    position: absolute;
    transform: translate(10px, -6px);
  }

  .expense-charts {
    grid-template-columns: 1fr;
  }

  .office-schedule-card,
  .us-section,
  .chart-card,
  .settlement-card {
    padding: 16px;
    border-radius: 18px;
  }

  .office-schedule-card {
    overflow-x: auto;
  }

  .office-edit-row {
    grid-template-columns: minmax(115px, 1fr) repeat(3, minmax(74px, 0.7fr));
    gap: 5px;
  }

  .office-edit-row strong,
  .office-edit-row input,
  .office-edit-row select {
    padding: 7px 5px;
    font-size: 9px;
  }

  .app-dialog {
    padding: 24px 16px;
  }

  .today-link-card {
    min-height: 130px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.app-tabs {
  width: fit-content;
  max-width: 100%;
  margin: 20px auto 0;
  flex-wrap: nowrap;
  border-radius: 999px;
}

.app-tab {
  min-height: 44px;
  font-size: 12px;
}

.app-tab > span:first-child {
  font-size: 22px;
}

.chat-message-actions:not([open]) .chat-message-menu {
  display: none;
}

.chat-message-menu {
  position: fixed;
  top: 0;
  right: auto;
  max-width: calc(100vw - 16px);
  max-height: min(60dvh, 360px);
  overflow-y: auto;
}

.chat-message-menu button {
  min-height: 40px;
  padding: 9px 10px;
  font-size: 12px;
}

.chat-message-actions > summary {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.chat-list {
  position: relative;
  gap: 10px;
  background-color: var(--surface-2);
}

.chat-list[data-wallpaper="pattern"] {
  background-image: url("assets/chat-wallpaper.svg?v=1");
  background-repeat: repeat;
  background-size: 112px 112px;
}

.chat-list[data-wallpaper="rose"] {
  background-color: color-mix(in srgb, var(--rose) 55%, var(--surface-2));
}

.chat-list[data-wallpaper="sage"] {
  background-color: color-mix(in srgb, var(--sage) 65%, var(--surface-2));
}

.chat-list[data-wallpaper="ocean"] {
  background-color: color-mix(in srgb, #dceaf2 55%, var(--surface-2));
}

:root[data-theme="dark"] .chat-list[data-wallpaper="rose"] {
  background-color: color-mix(in srgb, #572d3b 42%, var(--surface-2));
}

:root[data-theme="dark"] .chat-list[data-wallpaper="sage"] {
  background-color: color-mix(in srgb, #304330 45%, var(--surface-2));
}

:root[data-theme="dark"] .chat-list[data-wallpaper="ocean"] {
  background-color: color-mix(in srgb, #294352 48%, var(--surface-2));
}

.chat-bubble {
  max-width: min(75%, 560px);
  margin-top: 0;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.45;
}

.chat-bubble.is-mine {
  background: var(--sent-bg);
}

.chat-bubble.is-emoji-only,
.chat-bubble.is-emoji-only.is-mine {
  background: var(--sent-bg);
}

.chat-bubble:not(.is-mine).is-emoji-only {
  background: var(--surface);
}

.chat-bubble.is-grouped {
  margin-top: -8px;
}

.chat-bubble.has-tail::before {
  position: absolute;
  bottom: 7px;
  left: -5px;
  width: 10px;
  height: 10px;
  background: var(--surface);
  content: "";
  transform: rotate(45deg);
}

.chat-bubble.is-mine.has-tail::before {
  right: -5px;
  left: auto;
  background: var(--sent-bg);
}

.chat-bubble .record-meta {
  font-size: 11px;
}

.chat-message-status {
  color: #85827e;
  font-size: 12px;
  letter-spacing: -2px;
}

.chat-message-status.is-delivered {
  color: #85827e;
}

.chat-message-status.is-seen {
  color: var(--accent);
}

.chat-date-divider {
  position: sticky;
  top: 7px;
  z-index: 2;
  flex: 0 0 auto;
  align-self: center;
  font-size: 11px;
  box-shadow: var(--shadow);
}

.chat-contact-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 18px var(--sans);
}

.chat-icon-button,
.chat-jump-button {
  width: 44px;
  height: 44px;
  font-size: 23px;
}

.chat-settings select {
  min-height: 38px;
  font-size: 12px;
}

.chat-typing {
  display: none !important;
}

.chat-form {
  width: 100%;
  margin: 0;
  padding: 8px;
  flex: 0 0 auto;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  border-top: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
}

.chat-composer {
  width: 100%;
  min-width: 0;
  padding: 3px 5px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
}

.chat-composer > textarea {
  width: auto;
  min-width: 0;
  min-height: 42px;
  max-height: 105px;
  padding: 11px 6px;
  flex: 1 1 auto;
  resize: none;
  overflow-y: hidden;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 15px/1.4 var(--sans);
}

.chat-composer > textarea:focus {
  border: 0;
  box-shadow: none;
}

.chat-composer .chat-tool-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  font-size: 23px;
}

.chat-attachment-tools {
  flex: 0 0 auto;
  gap: 1px;
}

.chat-composer > .chat-recording-status,
.chat-composer > .chat-attachment-name {
  width: 100%;
  padding: 2px 8px 4px;
  flex: 1 0 100%;
  text-align: center;
}

.chat-composer > .chat-recording-status {
  font-size: 11px;
}

.chat-form .chat-send-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  border: 0;
  background: var(--accent);
  color: var(--surface);
  font-size: 22px;
}

.chat-send-button.is-recording {
  background: var(--accent);
  color: var(--surface);
}

.chat-emoji-menu,
.chat-attach-menu {
  position: relative;
  flex: 0 0 44px;
}

.chat-emoji-menu > summary,
.chat-attach-menu > summary {
  list-style: none;
  cursor: pointer;
}

.chat-emoji-menu > summary::-webkit-details-marker,
.chat-attach-menu > summary::-webkit-details-marker {
  display: none;
}

.chat-emoji-options {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 0;
  z-index: 5;
  width: min(250px, calc(100vw - 24px));
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-emoji-options button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 23px;
}

.chat-emoji-options button:hover {
  background: var(--surface-2);
}

body.chat-mode {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

body.chat-mode .site-header {
  height: 82px;
  flex: 0 0 82px;
}

body.chat-mode .header-link,
body.chat-mode .app-footer,
body.chat-mode .dashboard-heading {
  display: none !important;
}

body.chat-mode .app-shell {
  width: 100%;
  height: calc(100dvh - 82px);
  min-height: 0;
  max-width: none;
  padding: 10px clamp(12px, 3vw, 40px);
  flex: 1 1 auto;
  overflow: hidden;
}

body.chat-mode .dashboard {
  height: 100%;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

body.chat-mode .app-tabs {
  width: fit-content;
  margin: 0 auto 8px;
  padding: 3px;
  display: flex;
  flex: 0 0 auto;
}

body.chat-mode .app-tab {
  min-height: 44px;
}

body.chat-mode .tab-panel[data-panel="chat"] {
  min-height: 0;
  padding: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

body.chat-mode .chat-header {
  min-height: 58px;
  flex: 0 0 auto;
}

body.chat-mode .chat-settings {
  flex: 0 0 auto;
}

body.chat-mode .chat-drop-zone {
  min-height: 0;
  flex: 1 1 auto;
}

body.chat-mode .chat-list {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  border-radius: 0;
  overscroll-behavior: contain;
}

body.chat-mode .chat-form {
  flex: 0 0 auto;
}

body.chat-mode .chat-form .chat-upload-preview,
body.chat-mode .chat-form .chat-replying-banner {
  flex: 1 0 100%;
}

@media (max-width: 720px) {
  .app-body {
    min-height: 100dvh;
    padding-bottom: 0;
    overflow-x: clip;
  }

  .app-header,
  .site-header.app-header {
    height: 64px;
    min-height: 64px;
    padding-right: 16px;
    padding-left: 16px;
  }

  .app-shell {
    width: 100%;
    min-width: 0;
    min-height: calc(100dvh - 64px);
    padding: 24px 18px calc(118px + env(safe-area-inset-bottom));
  }

  .dashboard,
  .tab-panel {
    width: 100%;
    min-width: 0;
  }

  .dashboard-heading {
    display: grid;
    justify-items: start;
    gap: 8px;
  }

  .dashboard-heading > div:first-child {
    width: 100%;
    min-width: 0;
  }

  .dashboard-heading h1 {
    margin: 10px 0 0;
    font-size: clamp(32px, 9vw, 38px);
    letter-spacing: -1.2px;
    line-height: 1.08;
    overflow-wrap: anywhere;
  }

  .dashboard-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 22px;
  }

  .dashboard-actions .text-button {
    min-height: 40px;
    padding: 8px 0;
    font-size: 12px;
  }

  .tab-panel {
    padding-top: 18px;
  }

  .panel-heading {
    align-items: flex-start;
    gap: 8px;
  }

  .panel-heading h2 {
    margin-top: 7px;
    font-size: clamp(30px, 8vw, 35px);
    line-height: 1.08;
    letter-spacing: -.8px;
  }

  .panel-mark {
    flex: 0 0 auto;
    font-size: 28px;
  }

  .panel-intro {
    margin: 11px 0 16px;
    font-size: 13px;
    line-height: 1.65;
  }

  .welcome-card {
    min-height: 0;
    padding: 23px 21px 24px;
    border-radius: 20px;
  }

  .welcome-copy {
    width: 100%;
    max-width: 100%;
  }

  .welcome-card h2 {
    max-width: 100%;
    margin-top: 10px;
    font-size: clamp(28px, 7.5vw, 34px);
    letter-spacing: -.7px;
    line-height: 1.13;
    overflow-wrap: anywhere;
  }

  .welcome-copy > p:last-of-type {
    max-width: 100%;
    font-size: 12px;
    line-height: 1.65;
  }

  .flirty-message-button {
    min-height: 42px;
    margin-top: 14px;
    font-size: 11px;
  }

  .assistant-sparkle {
    right: 2px;
    bottom: -39px;
    font-size: 100px;
  }

  .quick-actions {
    margin: 14px 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .quick-actions button {
    min-width: 0;
    min-height: 44px;
    padding: 6px 9px;
    font-size: 11px;
    line-height: 1.35;
  }

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

  .privacy-note {
    font-size: 11px;
    line-height: 1.7;
  }

  .app-footer {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .app-tabs {
    position: fixed;
    right: 8px;
    bottom: 0;
    left: 8px;
    z-index: 30;
    width: auto;
    max-width: none;
    height: calc(70px + env(safe-area-inset-bottom));
    margin: 0;
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .app-tab {
    min-width: 0;
    min-height: 54px;
    padding: 4px 1px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    border-radius: 13px;
    font-size: 10px;
  }

  .app-tab > span:first-child {
    font-size: 21px;
  }

  .app-tab:hover {
    background: transparent;
    color: var(--muted);
  }

  .app-tab.is-active,
  .app-tab.is-active:hover {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .app-tab:active {
    transform: none;
  }

  .office-schedule-grid {
    min-width: 0;
    overflow: hidden;
  }

  .office-grid-heading,
  .office-grid-row {
    width: 100%;
    grid-template-columns: minmax(55px, 1.3fr) repeat(7, minmax(0, 1fr));
    gap: 2px;
  }

  .office-grid-heading > span,
  .office-grid-row > * {
    min-width: 0;
    min-height: 40px;
    padding: 4px 1px;
    font-size: 8px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .office-grid-row > strong {
    font-size: 9px;
  }

  .inline-form {
    gap: 12px;
    padding: 14px;
  }

  .inline-form label,
  .cycle-day-form > label {
    font-size: 12px;
    line-height: 1.4;
  }

  .inline-form input,
  .inline-form select,
  .inline-form textarea,
  .cycle-day-form input:not([type="checkbox"]):not([type="radio"]),
  .cycle-day-form select,
  .cycle-day-form textarea {
    min-height: 46px;
    font-size: 16px;
  }

  .inline-form .button {
    min-height: 48px;
  }

  .settlement-card {
    gap: 8px;
    padding: 15px;
  }

  .settlement-card strong,
  .settlement-card > span {
    min-width: 0;
    flex-basis: 100%;
    overflow-wrap: anywhere;
  }

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

  .settlement-card > span {
    font-size: 12px;
    line-height: 1.5;
  }

  .chart-heading,
  .section-title-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .donut-chart-wrap {
    justify-content: center;
    flex-wrap: wrap;
  }

  .record-item {
    min-width: 0;
    padding: 14px;
    overflow-wrap: anywhere;
  }

  body.chat-mode .site-header {
    height: 66px;
    flex-basis: 66px;
  }

  body.chat-mode .app-shell {
    height: calc(100dvh - 66px);
    padding: 0 0 calc(70px + env(safe-area-inset-bottom));
  }

  body.chat-mode .dashboard {
    padding: 0;
  }

  body.chat-mode .app-tabs {
    width: auto;
    margin: 0;
    height: calc(70px + env(safe-area-inset-bottom));
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
    display: grid;
  }

  body.chat-mode .tab-panel[data-panel="chat"] {
    padding: 0;
  }

  body.chat-mode .chat-header {
    min-height: 60px;
    padding: 5px 12px;
  }

  body.chat-mode .chat-drop-zone {
    min-height: 0;
  }

  body.chat-mode .chat-list {
    padding: 10px 10px;
  }

  body.chat-mode .chat-form {
    padding: 5px 7px max(5px, env(safe-area-inset-bottom));
  }

  .chat-bubble {
    max-width: 85%;
  }

  .chat-composer {
    gap: 1px;
    padding: 2px;
  }

  .chat-composer > textarea {
    padding: 11px 3px;
  }

  .chat-composer .chat-tool-button,
  .chat-form .chat-send-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    flex-basis: 42px;
  }

  .chat-emoji-menu,
  .chat-attach-menu {
    flex-basis: 42px;
  }

  .chat-settings {
    gap: 8px;
  }

  .chat-settings label {
    white-space: normal;
  }
}
