/* 家长端 /sov: the whole page, written to docs/06-design-spec.md with the variables in tokens.css only.
   Phone first (375 wide); on a wide screen it stays a phone-width column. No !important.
   Sections: base, shell and header, welcome, messages, choice cards, composer, @ picker, typeahead,
   孩子信息 prompt, sheets, orders, 孩子信息 form, toast, sign-in pages, touch areas, motion. */

/* —— base —— */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ds-paper);
  color: var(--ds-ink);
  font: var(--ds-text-14) / 1.5 var(--ds-font);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
}
button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button:disabled {
  cursor: default;
}
:focus-visible {
  outline: 2px solid var(--ds-focus);
  outline-offset: 2px;
}
.ui-icon {
  flex: none;
  width: 20px;
  height: 20px;
}
.brand-mark {
  display: block;
  width: 76%;
  height: 76%;
  object-fit: contain;
}

/* —— shell and header —— */
.parent-shell {
  position: fixed;
  top: var(--app-top, 0px);
  left: 0;
  right: 0;
  height: var(--app-height, 100dvh);
  display: flex;
  justify-content: center;
}
.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  min-height: 0;
}
.chat-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
  padding: max(var(--ds-space-3), env(safe-area-inset-top)) var(--ds-space-4) var(--ds-space-3);
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
}
/* No divider: the frosted bar eases out over the messages. */
.chat-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: var(--ds-space-3);
  background: linear-gradient(rgba(251, 250, 247, 0.9), rgba(251, 250, 247, 0));
  pointer-events: none;
}
.identity {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  min-width: 0;
}
.brand-logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--ds-radius-button);
  background: var(--ds-card);
  box-shadow: 0 0 0 1px var(--ds-line);
}
.identity h2 {
  margin: 0;
  font-size: var(--ds-text-16);
  font-weight: 600;
  line-height: 1.25;
}
.identity .status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--ds-text-12);
  line-height: 1.35;
  color: var(--ds-ink-3);
}
.identity .status .dot {
  width: 6px;
  height: 6px;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-wait);
}
.identity .status.wait {
  color: var(--ds-wait);
}
.orders-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 36px;
  padding: 0 var(--ds-space-3);
  border-radius: var(--ds-radius-button);
  font-size: var(--ds-text-13);
  color: var(--ds-ink);
}
.orders-trigger .ui-icon {
  width: 16px;
  height: 16px;
  color: var(--ds-ink-2);
}
.reception-banner {
  margin: var(--ds-space-2) var(--ds-space-4) 0;
  padding: var(--ds-space-2) var(--ds-space-3);
  border-radius: var(--ds-radius-control);
  background: var(--ds-wait-bg);
  color: var(--ds-wait);
  font-size: var(--ds-text-12);
  line-height: 1.5;
}
.local-flag {
  padding: var(--ds-space-1) 0 0;
  text-align: center;
  font-size: var(--ds-text-11);
  color: var(--ds-ink-3);
}

/* —— welcome —— */
.welcome {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--ds-space-6) var(--ds-space-5);
  text-align: center;
}
.welcome-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--ds-radius-sheet);
  background: var(--ds-card);
  box-shadow: 0 0 0 1px var(--ds-line);
}
.welcome h1 {
  margin: var(--ds-space-4) 0 var(--ds-space-1);
  font-size: var(--ds-text-20);
  font-weight: 600;
  line-height: 1.25;
}
.welcome p {
  margin: 0;
  font-size: var(--ds-text-14);
  color: var(--ds-ink-2);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--ds-space-2);
  margin-top: var(--ds-space-5);
  max-width: 340px;
}
.chips button {
  height: 36px;
  padding: 0 var(--ds-space-4);
  border-radius: var(--ds-radius-pill);
  font-size: var(--ds-text-13);
  color: var(--ds-ink);
}

/* —— messages —— */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: var(--ds-space-3) var(--ds-space-4) var(--ds-space-4);
}
.date-sep,
.system {
  margin: var(--ds-space-3) auto;
  max-width: 300px;
  text-align: center;
  font-size: var(--ds-text-12);
  line-height: 1.5;
  color: var(--ds-ink-3);
}
.date-sep {
  font-size: var(--ds-text-11);
}
.system.typing {
  margin-top: var(--ds-space-1);
}
.history-link {
  display: block;
  margin: var(--ds-space-1) auto var(--ds-space-2);
  font-size: var(--ds-text-12);
  color: var(--ds-link);
}
.msg {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-2);
  margin: var(--ds-space-3) 0;
}
.msg.mine {
  flex-direction: row-reverse;
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-fill);
  color: var(--ds-ink-2);
  font-size: var(--ds-text-13);
  font-weight: 500;
}
.avatar.robot {
  background: var(--ds-card);
  box-shadow: 0 0 0 1px var(--ds-line);
}
.avatar.robot .brand-mark {
  width: 72%;
  height: 72%;
}
.bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: min(78%, 520px);
}
.msg.mine .bubble-wrap {
  align-items: flex-end;
}
.msg-name {
  margin: 0 0 var(--ds-space-1) var(--ds-space-1);
  font-size: var(--ds-text-12);
  line-height: 1.35;
  color: var(--ds-ink-3);
}
.bubble {
  max-width: 100%;
  padding: var(--ds-space-2) var(--ds-space-3);
  border-radius: var(--ds-radius-card);
  background: var(--ds-bubble);
  box-shadow: 0 0 0 1px var(--ds-line);
  font-size: var(--ds-text-14);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.mine .bubble {
  background: var(--ds-bubble-mine);
  box-shadow: none;
}
.msg.sending .bubble {
  opacity: 0.6;
}
.msg-meta {
  margin: var(--ds-space-1) var(--ds-space-1) 0;
  font-size: var(--ds-text-11);
  color: var(--ds-ink-4);
  font-variant-numeric: tabular-nums;
}
.message-reference {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: var(--ds-space-1) var(--ds-space-2);
  border-radius: var(--ds-radius-control);
  background: rgba(31, 45, 74, 0.06);
  font-size: var(--ds-text-12);
  color: var(--ds-ink-2);
  white-space: normal;
}
.message-reference .ui-icon {
  width: 14px;
  height: 14px;
}
.rich {
  white-space: normal;
}
.rich p,
.rich ul,
.rich ol {
  margin: 0 0 var(--ds-space-2);
}
.rich > :last-child {
  margin-bottom: 0;
}
.rich ul,
.rich ol {
  padding-left: 1.4em;
}
.rich img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: var(--ds-space-2) 0;
  border-radius: var(--ds-radius-control);
}
.rich a {
  color: var(--ds-link);
}

/* —— choice cards: the bubble is the card; navy buttons in a wrapping row, 转人工 as text —— */
.bubble.card {
  padding: var(--ds-space-3);
}
.card-choices {
  margin-top: var(--ds-space-3);
  white-space: normal;
}
.card-label {
  margin-bottom: var(--ds-space-2);
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
}
.card-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ds-space-2);
}
.card-option {
  min-height: 32px;
  padding: 6px var(--ds-space-3);
  border-radius: var(--ds-radius-button);
  color: #fff;
  font-size: var(--ds-text-13);
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
}
.card-human {
  min-height: 32px;
  padding: 6px var(--ds-space-1);
  color: var(--ds-link);
  font-size: var(--ds-text-13);
}
.card-option:disabled,
.card-human:disabled {
  opacity: 0.5;
}

/* —— composer —— */
.compose {
  position: relative;
  margin: 0 var(--ds-space-3) max(var(--ds-space-3), env(safe-area-inset-bottom));
  padding: var(--ds-space-2) var(--ds-space-2) var(--ds-space-2) var(--ds-space-3);
  border-radius: var(--ds-radius-sheet);
  background: var(--ds-card);
  box-shadow:
    0 0 0 1px var(--ds-line),
    0 4px 16px rgba(17, 24, 39, 0.05);
}
.compose textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  padding: var(--ds-space-1) 0;
  border: 0;
  outline: none;
  resize: none;
  background: none;
  font-size: var(--ds-text-16);
  line-height: 1.5;
}
.compose textarea::placeholder {
  color: var(--ds-ink-4);
}
.compose-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-3);
}
.compose-tools {
  display: flex;
  align-items: center;
}
#pick-order {
  height: 32px;
  padding: 0 var(--ds-space-2);
  border-radius: var(--ds-radius-control);
  font-size: var(--ds-text-13);
  color: var(--ds-ink-2);
}
.compose-hint {
  display: none;
}
.send {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--ds-radius-pill);
  color: #fff;
}
.send .ui-icon {
  width: 18px;
  height: 18px;
}
.selected-reference {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--ds-space-1);
  padding: var(--ds-space-1) var(--ds-space-1) var(--ds-space-1) var(--ds-space-2);
  border-radius: var(--ds-radius-control);
  background: var(--ds-fill);
  font-size: var(--ds-text-12);
  color: var(--ds-ink-2);
}
.selected-reference > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.selected-reference .ui-icon {
  width: 14px;
  height: 14px;
}
#remove-order {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--ds-radius-control);
  color: var(--ds-ink-3);
}

/* —— @ picker: who or what the message is about —— */
.reference-picker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + var(--ds-space-2));
  max-height: min(60dvh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--ds-space-2);
  border-radius: var(--ds-radius-card);
  background: var(--ds-card);
  box-shadow:
    0 0 0 1px var(--ds-line),
    0 12px 32px rgba(17, 24, 39, 0.12);
  transform-origin: 0 100%;
}
.picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ds-space-1) var(--ds-space-1) var(--ds-space-2) var(--ds-space-2);
  font-size: var(--ds-text-13);
  font-weight: 600;
}
#close-picker {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--ds-radius-control);
  color: var(--ds-ink-3);
}
.reference-group + .reference-group {
  margin-top: var(--ds-space-1);
  padding-top: var(--ds-space-1);
  border-top: 1px solid var(--ds-line);
}
.reference-option {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  width: 100%;
  min-height: 44px;
  padding: 6px var(--ds-space-2);
  border-radius: var(--ds-radius-control);
  text-align: left;
}
.reference-option.item-option {
  padding-left: var(--ds-space-6);
}
.reference-option > span:nth-child(2) {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.reference-option b {
  font-size: var(--ds-text-13);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reference-option small {
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
}
.reference-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--ds-radius-control);
  background: var(--ds-fill);
  color: var(--ds-ink-2);
}
.reference-icon .ui-icon {
  width: 16px;
  height: 16px;
}
.select-label {
  flex: none;
  font-size: var(--ds-text-12);
  color: var(--ds-link);
}

/* —— typeahead: questions 小伊 knows, above the box —— */
.suggest-list {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + var(--ds-space-2));
  padding: var(--ds-space-1);
  border-radius: var(--ds-radius-card);
  background: var(--ds-card);
  box-shadow:
    0 0 0 1px var(--ds-line),
    0 12px 32px rgba(17, 24, 39, 0.12);
}
.suggest-list button {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--ds-space-3);
  border-radius: var(--ds-radius-control);
  text-align: left;
  font-size: var(--ds-text-14);
}
.suggest-list .ui-icon {
  width: 16px;
  height: 16px;
  color: var(--ds-ink-4);
}
.suggest-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* —— 孩子信息 prompt above the composer —— */
.child-prompt {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  margin: 0 var(--ds-space-3) var(--ds-space-2);
  padding: var(--ds-space-2);
  border-radius: var(--ds-radius-card);
  background: var(--ds-card);
  box-shadow: 0 0 0 1px var(--ds-line);
}
.child-prompt-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--ds-radius-control);
  background: var(--ds-fill);
  color: var(--ds-ink-2);
}
.child-prompt-icon .ui-icon {
  width: 16px;
  height: 16px;
}
.child-prompt-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.35;
}
.child-prompt-main b {
  max-width: 100%;
  font-size: var(--ds-text-14);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.child-prompt-main small {
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
}
/* The row itself opens the form; 去填写 is its text cue, not a second primary button. */
.child-prompt-go {
  flex: none;
  padding: 0 var(--ds-space-1);
  font-size: var(--ds-text-13);
  color: var(--ds-link);
}
.child-prompt-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--ds-radius-control);
  color: var(--ds-ink-4);
}
.child-prompt-close .ui-icon {
  width: 14px;
  height: 14px;
}

/* —— sheets: 我的订单 and 孩子信息 —— */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--ds-scrim);
}
.order-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  max-height: 88dvh;
  margin: 0 auto;
  border-radius: var(--ds-radius-sheet) var(--ds-radius-sheet) 0 0;
  background: var(--ds-paper);
  box-shadow: 0 -8px 32px rgba(17, 24, 39, 0.12);
}
.drawer-handle {
  flex: none;
  width: 36px;
  height: 4px;
  margin: var(--ds-space-2) auto 0;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-ink-4);
  opacity: 0.6;
}
.order-drawer header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3) var(--ds-space-5) var(--ds-space-3);
}
.order-drawer h2 {
  margin: 0;
  font-size: var(--ds-text-20);
  font-weight: 600;
  line-height: 1.25;
}
.order-drawer header span {
  display: block;
  margin-top: var(--ds-space-1);
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
}
.order-drawer header button {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--ds-radius-pill);
  color: var(--ds-ink-2);
}
.order-drawer header button .ui-icon {
  width: 18px;
  height: 18px;
}
.drawer-orders {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 var(--ds-space-4) max(var(--ds-space-6), env(safe-area-inset-bottom));
}
.oc-empty {
  margin: var(--ds-space-6) 0;
  text-align: center;
  font-size: var(--ds-text-13);
  color: var(--ds-ink-3);
}
.orders-refresh {
  display: block;
  margin: var(--ds-space-2) auto 0;
  padding: var(--ds-space-2) var(--ds-space-3);
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
}
.oc-more {
  display: block;
  width: 100%;
  margin: 0 0 var(--ds-space-3);
  padding: var(--ds-space-3) 0;
  border: 1px dashed var(--ds-dash);
  border-radius: var(--ds-radius-button);
  font-size: var(--ds-text-12);
  color: var(--ds-link);
}

/* —— child tabs in 我的订单 —— */
.child-tabs {
  display: flex;
  gap: var(--ds-space-2);
  padding: 0 var(--ds-space-5) var(--ds-space-3);
  overflow-x: auto;
  scrollbar-width: none;
  touch-action: pan-x;
}
.child-tabs::-webkit-scrollbar {
  display: none;
}
.child-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 34px;
  padding: 0 var(--ds-space-4);
  border-radius: var(--ds-radius-pill);
  background: var(--ds-fill);
  font-size: var(--ds-text-14);
  color: var(--ds-ink-2);
}
.child-tab small {
  font-size: var(--ds-text-11);
  color: var(--ds-ink-3);
}
.child-tab[aria-selected='true'] {
  background: var(--ds-navy);
  color: #fff;
}
.child-tab[aria-selected='true'] small {
  color: rgba(255, 255, 255, 0.7);
}
.child-tab.add {
  background: none;
  box-shadow: inset 0 0 0 1px var(--ds-dash);
  color: var(--ds-link);
}
.child-tab.add[aria-selected='true'] {
  background: var(--ds-doing-bg);
  box-shadow: inset 0 0 0 1px var(--ds-link);
  color: var(--ds-link);
}
.child-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--ds-space-1) var(--ds-space-3);
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
  font-variant-numeric: tabular-nums;
}
.child-unbind {
  padding: var(--ds-space-1) 0;
  font-size: var(--ds-text-12);
  color: var(--ds-danger);
}
.child-empty {
  margin: var(--ds-space-6) 0;
  text-align: center;
  font-size: var(--ds-text-13);
  color: var(--ds-ink-3);
}
.child-bind-card h3 {
  margin: var(--ds-space-1) 0 var(--ds-space-1);
  font-size: var(--ds-text-16);
  font-weight: 600;
}
.child-bind-card > p {
  margin: 0 0 var(--ds-space-4);
  font-size: var(--ds-text-13);
  color: var(--ds-ink-3);
}

/* —— order receipts (五「订单卡」) —— */
.oc-paper {
  margin-bottom: var(--ds-space-3);
  /* The outline follows the torn edge, which a border under the mask cannot. */
  filter: drop-shadow(0 0 0.6px rgba(17, 24, 39, 0.25)) drop-shadow(0 2px 3px rgba(17, 24, 39, 0.05));
}
.oc {
  padding: var(--ds-space-4) var(--ds-space-4) var(--ds-space-5);
  border-radius: var(--ds-radius-card) var(--ds-radius-card) 0 0;
  background: var(--ds-card);
  -webkit-mask: radial-gradient(circle 4px at 6px 100%, #0000 98%, #000) 0 0 / 12px 100% repeat-x;
  mask: radial-gradient(circle 4px at 6px 100%, #0000 98%, #000) 0 0 / 12px 100% repeat-x;
}
.oc-head {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-2);
}
.oc-head b {
  flex: 1;
  min-width: 0;
  font-size: var(--ds-text-14);
  font-weight: 600;
  line-height: 1.25;
}
.oc-status,
.oi-chip {
  flex: none;
  border-radius: var(--ds-radius-pill);
  padding: 1px 7px;
  font-size: var(--ds-text-11);
  line-height: 16px;
  color: var(--ds-ended);
  background: var(--ds-ended-bg);
}
.oc-status.success,
.oi-chip.success {
  color: var(--ds-done);
  background: var(--ds-done-bg);
}
.oc-status.progress,
.oi-chip.progress {
  color: var(--ds-doing);
  background: var(--ds-doing-bg);
}
.oc-status.warning,
.oi-chip.warning {
  color: var(--ds-wait);
  background: var(--ds-wait-bg);
}
.oc-info {
  display: grid;
  gap: var(--ds-space-1);
  margin: var(--ds-space-3) 0 0;
  font-size: var(--ds-text-12);
}
.oc-info div {
  display: flex;
  justify-content: space-between;
  gap: var(--ds-space-3);
}
.oc-info dt {
  flex: none;
  color: var(--ds-ink-3);
}
.oc-info dd {
  margin: 0;
  min-width: 0;
  color: var(--ds-ink-2);
  text-align: right;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.oc-items,
.oc-total {
  margin-top: var(--ds-space-3);
  border-top: 1px dashed var(--ds-dash);
}
.oi-row + .oi-row {
  border-top: 1px solid var(--ds-line);
}
.oc-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: var(--ds-space-3);
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
}
.oc-total b {
  margin-left: var(--ds-space-1);
  font-size: var(--ds-text-16);
  font-weight: 600;
  color: var(--ds-ink);
  font-variant-numeric: tabular-nums;
}
.oc-quote {
  display: block;
  margin: var(--ds-space-3) auto 0;
  padding: 6px var(--ds-space-3);
  font-size: var(--ds-text-13);
  color: var(--ds-link);
}

/* 商品行 (五「商品行」): icon top-aligned, then three left/right lines. */
.oi-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: var(--ds-space-3) 0;
}
.oi-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--ds-radius-control);
  background: var(--ds-fill);
  color: var(--ds-ink-3);
}
.oi-icon svg {
  width: 18px;
  height: 18px;
}
.oi-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: var(--ds-space-1);
}
.oi-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-2);
  min-width: 0;
  line-height: 1.35;
}
.oi-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin: 0;
}
.oi-name b {
  flex: 0 1 auto;
  min-width: 0;
  font-size: var(--ds-text-13);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.oi-name em {
  flex: 0 100 auto;
  min-width: 0;
  font-style: normal;
  font-size: var(--ds-text-11);
  color: var(--ds-ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.oi-line small {
  min-width: 0;
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
  font-variant-numeric: tabular-nums;
}
.oi-facts {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.oi-amount {
  flex: none;
  font-size: var(--ds-text-13);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
/* 引用: 12px text, its tap area grown to 44px without moving the layout. */
.oi-quote {
  flex: none;
  margin: -14px -12px -14px auto;
  padding: 14px 12px;
  font-size: var(--ds-text-12);
  line-height: 16px;
  color: var(--ds-link);
}

/* —— 孩子信息 form (sheet, and 添加孩子 in 我的订单) —— */
.child-form {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-3);
}
.child-card {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-3);
  min-width: 0;
  margin: 0;
  padding: var(--ds-space-4);
  border: 0;
  border-radius: var(--ds-radius-card);
  background: var(--ds-card);
  box-shadow: 0 0 0 1px var(--ds-line);
}
.child-card.has-error {
  box-shadow: 0 0 0 1px var(--ds-error);
}
.child-card legend {
  float: left;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  font-size: var(--ds-text-12);
  font-weight: 500;
  color: var(--ds-ink-3);
}
.child-card legend + * {
  clear: both;
}
.child-remove-row {
  padding: 2px 0 2px var(--ds-space-3);
  font-size: var(--ds-text-12);
  color: var(--ds-danger);
}
.child-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.child-field span {
  font-size: var(--ds-text-13);
  color: var(--ds-ink-2);
}
.child-field input {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 var(--ds-space-3);
  border: 1px solid var(--ds-dash);
  border-radius: var(--ds-radius-control);
  outline: none;
  background: var(--ds-card);
  font-size: var(--ds-text-16);
  color: var(--ds-ink);
}
.child-field input::placeholder {
  color: var(--ds-ink-4);
}
.child-field input:focus {
  border-color: var(--ds-link);
  box-shadow: 0 0 0 3px var(--ds-doing-bg);
}
.child-card.has-error input {
  border-color: var(--ds-error);
}
.child-phone {
  font-variant-numeric: tabular-nums;
}
.child-row-error {
  margin: -4px 0 0;
  font-size: var(--ds-text-12);
  color: var(--ds-error);
}
.child-add-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  height: 48px;
  border-radius: var(--ds-radius-card);
  box-shadow: inset 0 0 0 1px var(--ds-dash);
  font-size: var(--ds-text-14);
  color: var(--ds-link);
}
.child-add-row small {
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
}
.child-notice {
  margin: 0;
  font-size: var(--ds-text-13);
  color: var(--ds-done);
}
.child-actions {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
  margin-top: var(--ds-space-1);
}
.child-submit {
  height: 48px;
  border-radius: var(--ds-radius-button);
  color: #fff;
  font-size: var(--ds-text-16);
  font-weight: 500;
}
.child-skip {
  height: 44px;
  border-radius: var(--ds-radius-button);
  font-size: var(--ds-text-14);
  color: var(--ds-ink-2);
}
.child-submit:disabled,
.child-skip:disabled {
  opacity: 0.5;
}
.child-privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-1);
  margin: 0;
  font-size: var(--ds-text-12);
  color: var(--ds-ink-3);
}
@media (min-width: 701px) {
  .child-sheet .child-form {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
  }
}

/* —— toast: below the header, never over the composer —— */
#toast {
  position: fixed;
  top: calc(var(--app-top, 0px) + max(var(--ds-space-3), env(safe-area-inset-top)) + 64px);
  left: 50%;
  z-index: 30;
  display: none;
  max-width: calc(100vw - 2 * var(--ds-space-4));
  padding: var(--ds-space-2) var(--ds-space-4);
  border-radius: var(--ds-radius-button);
  background: var(--ds-navy);
  color: #fff;
  font-size: var(--ds-text-13);
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.16);
  opacity: 0;
  transform: translate(-50%, -6px);
  transition:
    opacity var(--ds-pop) var(--ds-ease-out),
    transform var(--ds-pop) var(--ds-ease-out);
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* —— sign-in pages: WeChat only, and a failed start —— */
.wechat-only,
.boot-error {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-3);
  padding: var(--ds-space-6);
  text-align: center;
}
.wechat-only h1 {
  margin: 0;
  font-size: var(--ds-text-20);
  font-weight: 600;
  line-height: 1.25;
}
.wechat-only p,
.boot-error p {
  margin: 0;
  font-size: var(--ds-text-14);
  color: var(--ds-ink-2);
}
.wechat-qr {
  width: 200px;
  height: 200px;
  padding: var(--ds-space-3);
  border-radius: var(--ds-radius-card);
  background: var(--ds-card);
  box-shadow: 0 0 0 1px var(--ds-line);
}
.wechat-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}
.wechat-link {
  font-size: var(--ds-text-12);
}
.wechat-only button,
.boot-error button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 120px;
  height: 44px;
  padding: 0 var(--ds-space-5);
  border-radius: var(--ds-radius-button);
  color: #fff;
  font-size: var(--ds-text-16);
}
.wechat-only button .ui-icon {
  width: 18px;
  height: 18px;
}

/* —— touch: 44×44 to a finger (四), press feedback (六) —— */
:is(
    .orders-trigger,
    .card-option,
    .card-human,
    #pick-order,
    .send,
    .oc-quote,
    .oc-more,
    .orders-refresh,
    .child-tab,
    .child-prompt-go,
    .child-prompt-close,
    .child-unbind,
    .child-remove-row,
    .history-link,
    #close-picker,
    #remove-order,
    .chips button
  ) {
  position: relative;
}
:is(
    .orders-trigger,
    .card-option,
    .card-human,
    #pick-order,
    .send,
    .oc-quote,
    .oc-more,
    .orders-refresh,
    .child-tab,
    .child-prompt-go,
    .child-prompt-close,
    .child-unbind,
    .child-remove-row,
    .history-link,
    #close-picker,
    #remove-order,
    .chips button
  )::after {
  content: '';
  position: absolute;
  inset: min(0px, calc((100% - 44px) / 2)) min(0px, calc((100% - 44px) / 2));
}
.oi-quote:active,
.card-human:active,
.history-link:active,
.child-unbind:active,
.child-remove-row:active,
.orders-refresh:active {
  transform: none;
  opacity: 0.6;
}
@media (hover: hover) and (pointer: fine) {
  .suggest-list button:hover,
  .reference-option:hover {
    background: var(--ds-fill);
  }
  .card-option:hover,
  .card-human:hover,
  .oi-quote:hover,
  .oc-quote:hover,
  .history-link:hover {
    opacity: 0.75;
  }
}

/* —— motion (七): a new message's avatar first, then its bubble opens from it; sheets rise; only what is new
   plays, carried across re-renders by a negative delay (--enter) —— */
.msg.enter > .avatar {
  animation: appear var(--ds-pop) var(--ds-ease-enter) var(--enter, 0ms) both;
}
.msg.enter > .bubble-wrap {
  transform-origin: 0 0;
  animation: appear 340ms var(--ds-ease-enter) calc(var(--enter, 0ms) + 100ms) both;
}
.msg.enter.mine > .bubble-wrap {
  transform-origin: 100% 0;
}
.system.enter {
  animation: fade var(--ds-pop) ease-out var(--enter, 0ms) both;
}
.drawer-backdrop.enter {
  animation: fade 200ms ease-out var(--enter, 0ms) both;
}
.order-drawer.enter {
  animation: rise var(--ds-sheet) var(--ds-ease-drawer) var(--enter, 0ms) both;
}
.reference-picker,
.suggest-list {
  animation: appear var(--ds-pop) var(--ds-ease-out) both;
}
@keyframes appear {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes rise {
  from {
    transform: translateY(100%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .msg.enter > .avatar,
  .msg.enter > .bubble-wrap,
  .order-drawer.enter,
  .reference-picker,
  .suggest-list {
    animation-name: fade;
    animation-duration: 200ms;
  }
  #toast {
    transform: translate(-50%, 0);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .chat-header {
    background: var(--ds-card);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}


/* —— 订单叠放 (order-stack.js): the demo on port 7323, pending in the spec —— */
/* It clips at its end, so longer cards behind never show below it nor lengthen the drawer's scroll; the 12px
   around the cards (inside the drawer's own padding) keeps their shadows. */
.oc-stack {
  position: relative;
  overflow: hidden;
  margin: -12px -12px var(--ds-space-3);
  padding: 12px 12px 0;
}
/* The last card of a pile shows its title only, like the rest, and keeps its torn bottom edge. */
.oc-slot.is-tail .oc > :not(.oc-head) {
  display: none;
}
.oc-slot {
  position: absolute;
  inset: 12px 12px auto;
  cursor: pointer;
  transition: transform var(--ds-spring-calm-ms) var(--ds-spring-calm);
}
.oc-slot .oc-paper {
  margin: 0;
}
/* In a pile each card throws a soft shadow upward onto the one beneath. */
.oc-slot:not(.is-front) .oc-paper {
  filter: drop-shadow(0 0 0.6px rgba(17, 24, 39, 0.25)) drop-shadow(0 -4px 12px rgba(17, 24, 39, 0.06));
}
.oc-slot.is-front {
  cursor: auto;
}

.oc-stack.is-still .oc-slot,
.oc-slot.is-dragging {
  transition: none;
}
/* The ✕ between the open card and the pile below puts it back. */
.oc-stack-close {
  position: absolute;
  z-index: 50;
  left: 50%;
  top: 12px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-card);
  box-shadow:
    0 0 0 1px var(--ds-line),
    0 2px 8px rgba(17, 24, 39, 0.12);
  color: var(--ds-ink-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ds-ease-out);
}
.oc-stack-close .ui-icon {
  width: 14px;
  height: 14px;
}
.oc-stack.is-open .oc-stack-close {
  opacity: 1;
  pointer-events: auto;
}
/* A bigger target than it looks. */
.oc-stack-close::after {
  content: '';
  position: absolute;
  inset: -8px;
}
@media (prefers-reduced-motion: reduce) {
  .oc-slot {
    transition: none;
  }
}
