:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-muted: #f7f9f8;
  --surface-strong: #edf2f0;
  --text: #18221f;
  --text-muted: #68736f;
  --text-faint: #89928f;
  --border: #dce3e0;
  --border-strong: #c7d2ce;
  --accent: #176b5c;
  --accent-hover: #12594d;
  --accent-soft: #e4f1ed;
  --blue: #386fa8;
  --blue-soft: #e8f0f8;
  --amber: #9a651d;
  --amber-soft: #fbf1df;
  --coral: #b74943;
  --coral-soft: #f9e9e7;
  --violet: #6b5b95;
  --violet-soft: #eeeaf6;
  --shadow: 0 12px 36px rgba(26, 42, 36, 0.12);
  --topbar-height: 56px;
  --mobile-nav-height: 60px;
  --toast-action-clearance: 74px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(56, 111, 168, 0.24);
  outline-offset: 1px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
  font-weight: 700;
}

h3 {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 700;
}

.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-small {
  width: 14px;
  height: 14px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  margin-left: 11px;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 650;
  line-height: 1.2;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-strong);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.button-danger {
  border-color: var(--coral);
  background: var(--coral);
  color: #fff;
}

.button-danger:hover:not(:disabled) {
  border-color: #973b36;
  background: #973b36;
}

.button-block {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--border);
  background: var(--surface-strong);
  color: var(--text);
}

.icon-button-accent {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.icon-button-accent:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: #fff;
}

.danger-hover:hover:not(:disabled) {
  border-color: #efcbc8;
  background: var(--coral-soft);
  color: var(--coral);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #9baba5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(56, 111, 168, 0.12);
  outline: 0;
}

.field textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.6;
}

.form-error {
  min-height: 21px;
  color: var(--coral);
  font-size: 13px;
}

.eyebrow {
  margin-bottom: 2px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-view {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 28px 18px;
  background: var(--bg);
}

.auth-box {
  width: min(100%, 400px);
}

.auth-brand {
  justify-content: center;
  margin-bottom: 24px;
}

.auth-brand .brand-mark {
  width: 44px;
  height: 44px;
  font-size: 23px;
}

.auth-brand .brand-copy strong {
  font-size: 18px;
}

.auth-panel {
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin: 22px 0 20px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 6px;
  background: var(--surface-strong);
}

.auth-tab {
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 650;
}

.auth-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(23, 42, 35, 0.1);
}

#auth-form {
  display: grid;
  gap: 15px;
}

.consent-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: flex-start;
  gap: 9px;
  color: var(--text-muted);
  cursor: pointer;
}

.consent-option input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.consent-option > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.consent-option strong {
  color: var(--text);
  font-size: 13px;
}

.consent-option small {
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.5;
}

.auth-meta {
  margin-top: 16px;
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}

.workspace {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--surface);
}

.topbar {
  display: flex;
  width: 100%;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.compact-brand .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 12px;
}

.compact-brand .brand-copy {
  margin-left: 9px;
}

.topbar-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
}

.access-status-button {
  display: inline-flex;
  min-width: 86px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.access-status-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-strong);
  color: var(--text);
}

.access-status-button[data-state="active"] {
  border-color: #b7d3ca;
  background: var(--accent-soft);
  color: var(--accent);
}

.access-status-button[data-state="expired"] {
  border-color: #e4c99e;
  background: var(--amber-soft);
  color: var(--amber);
}

.access-status-button[data-state="inactive"] {
  border-color: #e4c6c3;
  background: var(--coral-soft);
  color: var(--coral);
}

.save-state {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.save-state.is-busy .icon {
  animation: spin 800ms linear infinite;
}

.save-state.is-error {
  color: var(--coral);
}

.account-button {
  display: flex;
  max-width: 190px;
  height: 40px;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  padding: 3px 7px 3px 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
}

.account-button:hover {
  border-color: var(--border);
  background: var(--surface-muted);
}

.account-name {
  overflow: hidden;
  max-width: 110px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 50%;
  background: #e8eee9;
  color: #40524b;
  font-weight: 750;
}

.avatar-small {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
  font-size: 12px;
}

.avatar-tone-0 { background: #e4f1ed; color: #176b5c; }
.avatar-tone-1 { background: #e8f0f8; color: #386fa8; }
.avatar-tone-2 { background: #fbf1df; color: #8a5b1b; }
.avatar-tone-3 { background: #f9e9e7; color: #a4433e; }
.avatar-tone-4 { background: #eeeaf6; color: #66568e; }
.avatar-tone-5 { background: #e9efec; color: #4d6259; }

.workspace-grid {
  display: grid;
  width: 100%;
  height: calc(100dvh - var(--topbar-height));
  grid-template-columns: minmax(238px, 280px) minmax(390px, 1fr) minmax(330px, 390px);
  overflow: hidden;
}

.pane {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.relationship-pane,
.conversation-pane {
  border-right: 1px solid var(--border);
}

.relationship-pane,
.advice-pane {
  display: flex;
  flex-direction: column;
}

.relationship-pane {
  background: var(--surface-muted);
}

.pane-header {
  display: flex;
  min-height: 68px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.list-header {
  border-bottom: 0;
}

.search-box {
  display: flex;
  height: 38px;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  margin: 2px 12px 10px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-faint);
}

.search-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(56, 111, 168, 0.1);
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.relationship-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.relationship-item {
  display: grid;
  width: 100%;
  min-height: 66px;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.relationship-item:hover {
  background: var(--surface-strong);
}

.relationship-item.is-active {
  border-color: #c8ddd5;
  background: var(--accent-soft);
}

.relationship-main {
  min-width: 0;
}

.relationship-title-line,
.relationship-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.relationship-title-line strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relationship-meta {
  margin-top: 5px;
  color: var(--text-faint);
  font-size: 11px;
}

.stage-badge {
  display: inline-flex;
  max-width: 88px;
  align-items: center;
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text-muted);
  font-size: 14px;
}

.empty-icon {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: #a9b5b1;
  stroke-width: 1.5;
}

.centered-empty {
  width: 100%;
  height: 100%;
}

.conversation-pane {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.conversation-content {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.conversation-header {
  display: flex;
  min-height: 68px;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.conversation-title {
  min-width: 0;
  flex: 1;
}

.conversation-title h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-control select {
  max-width: 110px;
  height: 24px;
  margin-top: 2px;
  padding: 0 20px 0 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
}

.conversation-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mobile-back {
  display: none;
}

.message-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px clamp(16px, 4vw, 48px) 28px;
  background: #f8faf9;
}

.message-row {
  display: flex;
  width: 100%;
  margin: 10px 0;
  flex-direction: column;
  align-items: flex-start;
}

.message-row.sender-user {
  align-items: flex-end;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 4px 4px;
  color: var(--text-faint);
  font-size: 11px;
}

.message-bubble-wrap {
  position: relative;
  display: flex;
  max-width: min(78%, 620px);
  align-items: center;
  gap: 5px;
}

.message-bubble {
  min-width: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.sender-user .message-bubble {
  border-color: #c6ddd5;
  background: var(--accent-soft);
}

.message-row.is-targeted .message-bubble {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(56, 111, 168, 0.11);
}

.target-button {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  opacity: 0;
}

.message-row:hover .target-button,
.message-row.is-targeted .target-button,
.target-button:focus-visible {
  opacity: 1;
}

.target-button:hover,
.message-row.is-targeted .target-button {
  border-color: #c6d7e8;
  background: var(--blue-soft);
  color: var(--blue);
}

.conversation-footer {
  display: flex;
  min-height: 64px;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.selected-target {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.selected-target span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.advice-pane {
  background: var(--surface);
}

.advice-header {
  min-height: 68px;
}

.advice-view-tabs {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.advice-view-tab {
  position: relative;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
}

.advice-view-tab::after {
  position: absolute;
  right: 22%;
  bottom: -1px;
  left: 22%;
  height: 2px;
  background: transparent;
  content: "";
}

.advice-view-tab.is-active {
  color: var(--text);
  font-weight: 700;
}

.advice-view-tab.is-active::after {
  background: var(--accent);
}

.advice-view-tab:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.advice-view {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.access-gate-banner {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 12px 14px 0;
  padding: 10px;
  border: 1px solid #e4c99e;
  border-radius: 7px;
  background: var(--amber-soft);
  color: #754e19;
}

.access-gate-banner > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.access-gate-banner strong {
  font-size: 12px;
}

.access-gate-banner small {
  color: #866631;
  font-size: 11px;
  line-height: 1.45;
}

.access-gate-icon,
.access-summary-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: rgba(154, 101, 29, 0.11);
  color: var(--amber);
}

.access-gate-banner .button {
  min-height: 34px;
  padding: 6px 10px;
  border-color: #d5b77f;
  background: #fffaf0;
  color: #754e19;
  font-size: 12px;
}

.advice-controls {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.advice-compose-scroll {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
}

.advice-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-strong);
}

.advice-mode-button {
  display: flex;
  min-width: 0;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
}

.advice-mode-button.is-active {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(35, 47, 43, 0.12);
  color: var(--text);
  font-weight: 700;
}

.advice-compose-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.advice-compose-field > span small {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 500;
}

.advice-compose-field textarea {
  min-height: 48px;
  max-height: 120px;
  padding: 8px 9px;
  resize: vertical;
}

#quick-target-text {
  min-height: 62px;
  padding-right: 48px;
}

.quick-target-shell {
  position: relative;
  display: block;
  min-width: 0;
}

.quick-target-shell textarea {
  display: block;
  width: 100%;
}

.screenshot-upload-button {
  position: absolute;
  right: 5px;
  bottom: 5px;
  border-color: var(--border);
  background: var(--surface);
}

.quick-screenshot-actions {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.first-screenshot-button {
  width: 100%;
  justify-content: center;
}

.screenshot-privacy-note {
  display: flex;
  min-width: 0;
  gap: 6px;
  align-items: flex-start;
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
}

.screenshot-privacy-note .icon {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--green);
}

.consent-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.7;
}

.screenshot-ocr-status {
  min-height: 18px;
  padding: 0 2px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.screenshot-ocr-status.is-warning {
  color: #8b5b16;
}

.screenshot-ocr-status.is-error {
  color: var(--coral);
}

.advice-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 0.8fr);
  gap: 10px;
}

.compact-field {
  gap: 3px;
}

.compact-field > span {
  font-size: 11px;
}

.compact-field select {
  min-height: 34px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.advice-controls .button {
  align-self: end;
  min-height: 34px;
}

.advice-compose-toggle {
  display: none;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.advice-controls.is-collapsed .advice-compose-scroll,
.advice-controls.is-collapsed .advice-action-row {
  display: none;
}

.advice-controls.is-collapsed .advice-compose-toggle {
  display: flex;
}

.advice-empty {
  min-height: 0;
  flex: 1;
}

.advice-loading {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--text-muted);
}

.advice-cancel-button {
  min-height: 32px;
  margin-top: 5px;
  padding: 5px 10px;
}

.history-toolbar {
  display: flex;
  min-height: 50px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}

.history-toolbar > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
}

.history-toolbar span {
  color: var(--text-faint);
  font-size: 11px;
}

.relationship-analytics {
  display: grid;
  flex: 0 0 auto;
  gap: 9px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.analytics-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.analytics-metric {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 7px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.analytics-metric span {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-metric strong {
  color: var(--text);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.quality-trend {
  display: flex;
  height: 30px;
  align-items: end;
  gap: 3px;
  overflow: hidden;
}

.quality-trend-bar {
  min-width: 3px;
  max-width: 10px;
  flex: 1;
  border-radius: 2px 2px 0 0;
  background: var(--blue);
  opacity: 0.72;
}

.history-loading {
  display: flex;
  min-height: 0;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--text-muted);
  font-size: 12px;
}

.history-loading .spinner {
  width: 20px;
  height: 20px;
  margin: 0;
  border-width: 2px;
}

.history-loading.is-refreshing {
  min-height: 34px;
  flex: 0 0 auto;
  padding: 6px 14px;
  justify-content: flex-start;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.history-loading.is-refreshing .spinner {
  width: 16px;
  height: 16px;
}

.advice-history-list {
  display: grid;
  min-height: 0;
  flex: 1;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 12px 14px 20px;
}

.history-item {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.history-item-header time {
  color: var(--text-faint);
  font-size: 10px;
}

.history-score {
  display: inline-grid;
  min-width: 32px;
  height: 22px;
  place-items: center;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.history-target {
  margin: 0;
  padding: 5px 0 5px 9px;
  border-left: 2px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.history-reply {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 6px;
  margin-top: 9px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.history-reply .icon {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--blue);
}

.history-reply span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.history-tag {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 10px;
}

.history-summary {
  margin: 9px 0 0;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.55;
}

.history-details {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.history-details summary {
  cursor: pointer;
  color: var(--blue);
  font-size: 11px;
}

.history-detail-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 10px;
}

.history-detail-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.history-issues {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 10px;
}

.advice-loading strong {
  color: var(--text);
}

.spinner {
  display: block;
  width: 26px;
  height: 26px;
  margin-bottom: 4px;
  border: 3px solid #d5e5df;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.advice-result {
  min-height: 0;
  flex: 1;
  overflow-anchor: none;
  overflow-y: auto;
  padding: 14px;
}

.decision-banner {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
}

.decision-banner.decision-reply {
  border-color: #c5ded5;
  background: var(--accent-soft);
}

.decision-banner.decision-wait {
  border-color: #ead5b2;
  background: var(--amber-soft);
}

.decision-banner.decision-stop {
  border-color: #ecc7c4;
  background: var(--coral-soft);
}

.decision-banner.decision-context {
  border-color: #cbd9e7;
  background: var(--blue-soft);
}

.decision-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text-muted);
}

.decision-copy {
  min-width: 0;
}

.decision-copy strong {
  display: block;
  margin-bottom: 3px;
}

.decision-copy p {
  color: var(--text-muted);
  font-size: 12px;
}

.confidence-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  margin: 14px 2px 0;
  color: var(--text-muted);
  font-size: 11px;
}

.confidence-track {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-strong);
}

.confidence-progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  appearance: none;
  background: var(--surface-strong);
}

.confidence-progress::-webkit-progress-bar {
  border-radius: 3px;
  background: var(--surface-strong);
}

.confidence-progress::-webkit-progress-value {
  border-radius: 3px;
  background: var(--blue);
}

.confidence-progress::-moz-progress-bar {
  border-radius: 3px;
  background: var(--blue);
}

.confidence-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--blue);
}

.coaching-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.score-badge {
  display: inline-grid;
  min-width: 38px;
  height: 26px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.coaching-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.coaching-meta-item {
  min-width: 0;
  padding: 8px 9px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.coaching-meta dt {
  margin-bottom: 2px;
  color: var(--text-faint);
  font-size: 10px;
}

.coaching-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.score-compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
}

.score-metric {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.score-metric span {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-metric strong,
.score-delta {
  font-variant-numeric: tabular-nums;
}

.score-delta {
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

.score-delta.is-negative {
  color: var(--coral);
}

.score-dimensions {
  display: grid;
  gap: 9px;
  margin-top: 13px;
}

.score-dimension-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.score-dimension-line strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.score-dimension progress {
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 3px;
  appearance: none;
  background: var(--surface-strong);
}

.score-dimension progress::-webkit-progress-bar {
  border-radius: 3px;
  background: var(--surface-strong);
}

.score-dimension progress::-webkit-progress-value {
  border-radius: 3px;
  background: var(--blue);
}

.score-dimension progress::-moz-progress-bar {
  border-radius: 3px;
  background: var(--blue);
}

.score-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 13px;
}

.score-check {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 11px;
}

.score-check .icon {
  flex: 0 0 auto;
}

.score-check.is-passed .icon {
  color: var(--accent);
}

.score-check.is-failed .icon {
  color: var(--coral);
}

.score-issues {
  margin: 10px 0 0;
  padding: 9px 10px 9px 27px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
  color: var(--text-muted);
  font-size: 11px;
}

.score-issues li + li {
  margin-top: 4px;
}

.suggestion-section,
.analysis-section,
.feedback-section,
.reward-feedback {
  margin-top: 18px;
}

.reward-feedback {
  border: 1px solid #d8d0e9;
  border-radius: 7px;
  background: #faf8fd;
}

.reward-feedback-content {
  display: grid;
  gap: 8px;
  padding: 11px;
}

.reward-feedback-heading,
.reward-feedback-saved {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--violet);
  font-size: 12px;
  font-weight: 750;
}

.reward-feedback-copy {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.55;
}

.reward-feedback-form {
  display: grid;
  gap: 8px;
}

.reward-feedback-form textarea {
  width: 100%;
  min-height: 88px;
  padding: 9px 10px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.55;
}

.reward-feedback-form textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(107, 91, 149, 0.12);
  outline: 0;
}

.reward-feedback-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reward-feedback-footer .button {
  min-height: 34px;
  padding: 6px 9px;
  border-color: #c9bddf;
  color: var(--violet);
  font-size: 11px;
}

.reward-feedback-counter {
  color: var(--text-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.reward-feedback-counter.is-ready {
  color: var(--accent);
  font-weight: 700;
}

.reward-feedback-saved {
  padding: 10px 11px;
  background: #f4f0fa;
}

.reward-feedback.is-compact {
  margin-top: 9px;
}

.reward-feedback-details summary {
  padding: 9px 11px;
  color: var(--violet);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.reward-feedback-details[open] summary {
  border-bottom: 1px solid #e1daed;
}

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

.section-heading h3 {
  display: flex;
  align-items: center;
  gap: 7px;
}

.suggestion-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
}

.suggestion-text {
  min-width: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.copy-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text-muted);
}

.copy-button:hover {
  border-color: #b6cfdf;
  background: var(--blue-soft);
  color: var(--blue);
}

.alternatives {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.suggestion-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 8px;
}

.voice-rewrite-button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.voice-rewrite-button:hover {
  background: var(--accent-soft);
}

.suggestion-actions .alternative-toggle {
  margin-top: 0;
}

.alternative-toggle {
  display: inline-flex;
  min-height: 32px;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  padding: 5px 8px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.alternative-toggle:hover {
  background: var(--blue-soft);
}

.alternative-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 7px;
  padding: 8px 9px 8px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  line-height: 1.5;
}

.alternative-row .copy-button {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
}

.analysis-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.analysis-list li {
  position: relative;
  padding-left: 14px;
  color: var(--text-muted);
  line-height: 1.55;
}

.analysis-list li::before {
  position: absolute;
  top: 8px;
  left: 1px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blue);
  content: "";
}

.risk-list li::before {
  background: var(--amber);
}

.clarifying-question {
  padding: 10px 11px;
  border-left: 3px solid var(--blue);
  background: var(--blue-soft);
  color: #315979;
}

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

.feedback-button {
  min-height: 36px;
  padding: 6px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
}

.feedback-button:hover,
.feedback-button.is-active {
  border-color: #b7d3ca;
  background: var(--accent-soft);
  color: var(--accent);
}

.outcome-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
}

.feedback-saved {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.outcome-followup {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.outcome-followup-prompt {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 11px;
}

.outcome-followup-toggle {
  min-height: 32px;
  flex: 0 0 auto;
  padding: 5px 8px;
}

.outcome-form .field select {
  min-height: 36px;
}

.rating-options {
  display: flex;
  align-items: center;
  gap: 5px;
}

.rating-options > span {
  margin-right: auto;
  color: var(--text-muted);
  font-size: 12px;
}

.history-outcome-editor {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.history-outcome-toggle {
  display: inline-flex;
  min-height: 28px;
  gap: 5px;
  align-items: center;
  padding: 3px 6px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
}

.history-outcome-form {
  display: grid;
  gap: 8px;
  margin-top: 7px;
}

.rating-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
}

.rating-button.is-active {
  border-color: var(--violet);
  background: var(--violet-soft);
  color: var(--violet);
}

.consultation-view {
  position: relative;
  overflow: hidden;
  background: var(--surface);
}

.consultation-context-header {
  display: flex;
  min-height: 56px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}

.consultation-context-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.consultation-context-copy span {
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.consultation-context-copy small {
  color: var(--text-muted);
  font-size: 11px;
}

.relationship-timeline {
  flex: 0 0 auto;
  max-height: 164px;
  padding: 9px 14px 10px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.relationship-timeline > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.relationship-timeline > header strong {
  font-size: 12px;
}

.relationship-timeline > header span {
  color: var(--text-faint);
  font-size: 11px;
}

.relationship-event-list {
  display: grid;
  max-height: 116px;
  gap: 5px;
  overflow-y: auto;
}

.relationship-event-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  min-height: 38px;
  padding: 5px 2px;
  border-bottom: 1px solid var(--border);
}

.relationship-event-item:last-child {
  border-bottom: 0;
}

.relationship-event-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--blue);
}

.relationship-event-item[data-status="planned"] .relationship-event-dot {
  background: var(--amber);
}

.relationship-event-item[data-status="cancelled"] .relationship-event-dot {
  background: var(--text-faint);
}

.relationship-event-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.relationship-event-main strong {
  overflow: hidden;
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relationship-event-main small {
  color: var(--text-muted);
  font-size: 10px;
}

.relationship-event-actions {
  display: flex;
  gap: 2px;
}

.relationship-event-actions .icon-button {
  width: 26px;
  height: 26px;
}

.relationship-event-actions .icon {
  width: 14px;
  height: 14px;
}

.timeline-empty {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
}

.consultation-message-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 16px 14px 22px;
  overflow-y: auto;
}

.consultation-turn {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.consultation-turn-user {
  align-items: flex-end;
}

.consultation-user-bubble {
  max-width: 88%;
  padding: 9px 11px;
  border-radius: 7px 7px 2px 7px;
  background: var(--accent-soft);
  color: #164f45;
  overflow-wrap: anywhere;
}

.consultation-assistant {
  gap: 10px;
  padding-left: 11px;
  border-left: 3px solid var(--accent);
}

.consultation-answer {
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.consultation-assessment span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
}

.consultation-assessment small {
  color: var(--text-faint);
  font-size: 10px;
}

.consultation-assessment strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.consultation-section {
  display: grid;
  gap: 5px;
}

.consultation-section > strong {
  font-size: 11px;
}

.consultation-section ul,
.consultation-next-steps {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.consultation-section li,
.consultation-next-step {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.55;
}

.consultation-next-step {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 7px;
}

.consultation-next-step > span:first-child {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 10px;
  font-weight: 700;
}

.consultation-next-step strong {
  display: block;
  color: var(--text);
  font-size: 11px;
}

.consultation-suggested-reply {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid #d4e0ed;
  border-radius: 6px;
  background: var(--blue-soft);
  color: #2f5f8c;
  font-size: 12px;
}

.consultation-suggested-reply span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.consultation-sources {
  color: var(--text-muted);
  font-size: 10px;
}

.consultation-sources summary {
  width: fit-content;
  cursor: pointer;
}

.consultation-source-list {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}

.consultation-source-item {
  padding-left: 8px;
  border-left: 2px solid var(--border-strong);
}

.consultation-source-item strong,
.consultation-source-item span {
  display: block;
}

.consultation-source-item span {
  overflow-wrap: anywhere;
}

.consultation-empty {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 18px;
  color: var(--text-muted);
  text-align: center;
}

.consultation-empty-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.consultation-starters {
  display: grid;
  width: min(100%, 280px);
  gap: 6px;
}

.consultation-starters button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  text-align: left;
}

.consultation-loading {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.consultation-loading > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.consultation-loading strong {
  font-size: 11px;
}

.consultation-loading small {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.consultation-composer {
  display: grid;
  min-height: 66px;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: end;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.consultation-composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 112px;
  padding: 9px 10px;
  resize: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  line-height: 1.45;
}

.consultation-composer .icon-button {
  width: 38px;
  height: 38px;
}

.mobile-nav {
  display: none;
}

.dialog {
  width: min(calc(100% - 28px), 460px);
  max-height: min(86dvh, 720px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog-wide {
  width: min(calc(100% - 28px), 680px);
}

.dialog-small {
  width: min(calc(100% - 28px), 400px);
}

.dialog::backdrop {
  background: rgba(20, 29, 26, 0.48);
}

.dialog-body {
  display: grid;
  max-height: min(86dvh, 720px);
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.two-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

#memory-dialog {
  width: min(calc(100% - 28px), 760px);
}

.memory-dialog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(250px, 0.88fr);
  gap: 18px;
  min-height: 0;
}

.memory-form {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

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

.range-field {
  display: grid;
  gap: 7px;
  color: var(--text-muted);
  font-size: 11px;
}

.range-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-field output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.range-field input {
  width: 100%;
  accent-color: var(--accent);
}

.memory-evidence {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.memory-evidence legend {
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

.memory-evidence-list {
  display: grid;
  max-height: 170px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.memory-evidence-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  padding: 8px;
  cursor: pointer;
}

.memory-evidence-item + .memory-evidence-item {
  border-top: 1px solid var(--border);
}

.memory-evidence-item:hover {
  background: var(--surface-muted);
}

.memory-evidence-item input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.memory-evidence-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.memory-evidence-copy strong {
  color: var(--text-faint);
  font-size: 10px;
}

.memory-evidence-copy span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-evidence-empty {
  margin: 0;
  padding: 14px;
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}

.memory-library {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.memory-library > header {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.memory-library > header span {
  color: var(--text-faint);
  font-size: 10px;
}

.memory-list {
  display: grid;
  max-height: 480px;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
}

.memory-item {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
}

.memory-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.memory-type {
  color: var(--blue);
  font-size: 10px;
  font-weight: 700;
}

.memory-item-actions {
  display: flex;
  gap: 3px;
}

.icon-button-compact {
  width: 28px;
  height: 28px;
}

.memory-summary {
  margin: 7px 0 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.memory-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
  color: var(--text-faint);
  font-size: 10px;
}

.compact-empty {
  min-height: 190px;
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
}

.access-summary {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid #e4c99e;
  border-radius: 7px;
  background: var(--amber-soft);
}

.access-summary > span:last-child,
.access-feedback-note > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.access-summary strong,
.access-feedback-note strong {
  font-size: 12px;
}

.access-summary small,
.access-feedback-note small {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.access-summary[data-state="active"] {
  border-color: #b7d3ca;
  background: var(--accent-soft);
}

.access-summary[data-state="active"] .access-summary-icon {
  background: rgba(23, 107, 92, 0.1);
  color: var(--accent);
}

.access-summary[data-state="expired"] {
  border-color: #e4c99e;
  background: var(--amber-soft);
}

.access-summary[data-state="inactive"] {
  border-color: #e4c6c3;
  background: var(--coral-soft);
}

.access-summary[data-state="inactive"] .access-summary-icon {
  background: rgba(183, 73, 67, 0.1);
  color: var(--coral);
}

.access-code-field input {
  text-transform: uppercase;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
  letter-spacing: 0;
}

.access-feedback-note {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  color: var(--violet);
}

.access-feedback-note > .icon {
  margin: 1px auto 0;
}

.account-stats > div {
  min-width: 0;
  padding: 10px;
  text-align: center;
}

.account-stats > div + div {
  border-left: 1px solid var(--border);
}

.account-stats dt {
  color: var(--text-faint);
  font-size: 11px;
}

.account-stats dd {
  overflow: hidden;
  margin: 3px 0 0;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-actions {
  display: grid;
  border-top: 1px solid var(--border);
}

.privacy-section {
  display: grid;
  gap: 10px;
}

.privacy-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.privacy-section-header h3 {
  font-size: 15px;
}

.privacy-save-status {
  color: var(--text-faint);
  font-size: 11px;
}

.privacy-controls {
  display: grid;
  border-top: 1px solid var(--border);
}

.privacy-toggle-row {
  display: grid;
  min-height: 62px;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 14px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.privacy-toggle-row > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.privacy-toggle-row strong {
  font-size: 13px;
}

.privacy-toggle-row small {
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.45;
}

.toggle-control {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
}

.toggle-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-track {
  width: 42px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-strong);
  transition: background-color 140ms ease, border-color 140ms ease;
}

.toggle-track::after {
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(23, 42, 35, 0.24);
  content: "";
  transition: transform 140ms ease;
}

.toggle-control input:checked + .toggle-track {
  border-color: var(--accent);
  background: var(--accent);
}

.toggle-control input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.toggle-control input:focus-visible + .toggle-track {
  outline: 3px solid rgba(56, 111, 168, 0.18);
  outline-offset: 2px;
}

.toggle-control input:disabled + .toggle-track {
  cursor: wait;
  opacity: 0.55;
}

.settings-row {
  display: grid;
  min-height: 56px;
  grid-template-columns: 24px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.settings-row:hover {
  background: var(--surface-muted);
}

.settings-row > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.settings-row small {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 11px;
}

.settings-danger {
  color: var(--coral);
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 12px;
}

.danger-text {
  color: var(--coral);
}

.confirm-message {
  color: var(--text-muted);
  line-height: 1.65;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: calc(18px + var(--toast-action-clearance));
  display: grid;
  width: min(calc(100% - 36px), 360px);
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid #bed7ce;
  border-radius: 7px;
  background: #f1faf7;
  color: #235f50;
  box-shadow: 0 8px 24px rgba(28, 48, 40, 0.16);
}

.toast.is-error {
  border-color: #e9c1bd;
  background: #fff4f3;
  color: #8c3934;
}

.clipboard-helper {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: 230px minmax(350px, 1fr) 330px;
  }

  .advice-controls .button {
    min-height: 36px;
  }
}

@media (max-width: 820px) {
  :root {
    --topbar-height: 52px;
  }

  .workspace-grid {
    display: block;
    height: calc(100dvh - var(--topbar-height) - var(--mobile-nav-height) - env(safe-area-inset-bottom));
  }

  .pane {
    display: none;
    width: 100%;
    height: 100%;
    border-right: 0;
  }

  .workspace-grid[data-active-pane="relationships"] [data-pane="relationships"],
  .workspace-grid[data-active-pane="conversation"] [data-pane="conversation"],
  .workspace-grid[data-active-pane="advice"] [data-pane="advice"] {
    display: flex;
  }

  .relationship-pane,
  .advice-pane,
  .conversation-pane {
    flex-direction: column;
  }

  .mobile-nav {
    display: grid;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    grid-template-columns: repeat(4, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    background: var(--surface);
  }

  .mobile-nav-item {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
  }

  .mobile-nav-item.is-active {
    color: var(--accent);
    font-weight: 700;
  }

  .mobile-back {
    display: inline-grid;
  }

  .relationship-pane {
    background: var(--surface-muted);
  }

  .conversation-header,
  .pane-header {
    min-height: 62px;
  }

  .message-list {
    padding: 18px 12px 24px;
  }

  .message-bubble-wrap {
    max-width: 88%;
  }

  .target-button {
    opacity: 1;
  }

  .advice-action-row {
    grid-template-columns: minmax(0, 1fr) minmax(116px, 0.8fr);
  }

  .toast-region {
    right: 12px;
    bottom: calc(
      var(--mobile-nav-height) + var(--toast-action-clearance) + 12px
      + env(safe-area-inset-bottom)
    );
    width: calc(100% - 24px);
  }

  .access-gate-banner {
    margin-right: 12px;
    margin-left: 12px;
  }
}

@media (max-width: 520px) {
  .relationship-timeline {
    max-height: 142px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .relationship-event-list {
    max-height: 94px;
  }

  .consultation-message-list {
    padding: 14px 12px 18px;
  }

  .consultation-assessment {
    grid-template-columns: 1fr 1fr;
  }

  .consultation-composer {
    padding-bottom: calc(9px + env(safe-area-inset-bottom));
  }
  .compact-brand .brand-copy strong {
    font-size: 14px;
  }

  .save-state span,
  .account-name,
  .account-button > .icon {
    display: none;
  }

  .save-state {
    margin-right: 0;
  }

  .access-status-button {
    min-width: 34px;
    width: 34px;
    padding: 0;
  }

  .access-status-button span {
    display: none;
  }

  .account-button {
    width: 36px;
    padding: 2px;
  }

  .conversation-actions .button span {
    display: none;
  }

  .conversation-actions .button {
    width: 36px;
    padding: 0;
  }

  .conversation-footer {
    min-height: 62px;
    gap: 8px;
    padding: 9px 10px;
  }

  .conversation-footer .button {
    padding-right: 11px;
    padding-left: 11px;
  }

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

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

  .access-gate-banner {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .access-gate-banner .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .reward-feedback-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-panel {
    padding: 22px 18px;
  }

  .dialog-body {
    padding: 17px;
  }

  .two-fields {
    grid-template-columns: 1fr;
  }

  .memory-dialog-grid {
    grid-template-columns: 1fr;
  }

  .memory-library {
    padding-top: 14px;
    padding-left: 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .memory-sliders {
    grid-template-columns: 1fr;
  }

  .account-stats {
    grid-template-columns: 1fr;
  }

  .account-stats > div + div {
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

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