:root {
  color-scheme: light;
  font-family: 'DM Sans', 'Noto Sans SC', 'Microsoft YaHei UI', 'Microsoft YaHei', sans-serif;
  color: #25332f;
  background: #f4f7f4;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #25332f;
  --muted: #7e8b86;
  --line: #e7ece8;
  --teal: #3d8176;
  --teal-dark: #29594f;
  --coral: #e98776;
  --surface: #fff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f7f4; }
button, textarea { font: inherit; }
button { color: inherit; }
.app-shell { max-width: 1600px; min-height: 100vh; margin: 0 auto; padding: 0 48px 40px; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: var(--teal-dark); color: white; font-family: Georgia, serif; font-size: 21px; font-style: italic; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 15px; font-weight: 700; }
.brand-copy small { color: #95a09b; font-size: 9px; letter-spacing: 1.4px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.mode-label { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: #63736d; }
.mode-dot, .presence-dot { width: 8px; height: 8px; border-radius: 50%; background: #81b88e; box-shadow: 0 0 0 3px #81b88e22; }
.icon-button { border: 1px solid var(--line); background: white; border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; transition: border-color .18s, transform .18s; }
.icon-button:hover { border-color: #adc9c0; transform: rotate(20deg); }
.icon-button svg, .text-button svg, .stage-action svg, .send-button svg, .local-note svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-button svg { width: 18px; height: 18px; }
.logout-button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 1px; border: 0; background: transparent; color: #718078; font-size: 11px; cursor: pointer; }
.logout-button:hover { color: var(--teal-dark); }
.logout-button.hidden { display: none; }
.logout-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.workspace { display: grid; grid-template-columns: minmax(460px, 1.18fr) minmax(360px, .82fr); gap: 56px; max-width: 1290px; margin: 42px auto 0; }
.companion-column, .interaction-column { min-width: 0; }
.section-heading { min-height: 66px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 19px; }
.eyebrow { margin: 0 0 7px; color: #99a49f; font-size: 9px; font-weight: 700; letter-spacing: 1.5px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; color: var(--ink); font-size: 25px; font-weight: 600; line-height: 1.25; }
h2 { margin-bottom: 0; font-size: 18px; font-weight: 600; line-height: 1.35; }
.text-button { border: 0; padding: 9px 0; display: inline-flex; align-items: center; gap: 7px; background: transparent; color: var(--teal); font-size: 12px; cursor: pointer; }
.text-button:hover { color: var(--teal-dark); }
.text-button svg { width: 16px; height: 16px; }
.stage { position: relative; min-height: 570px; overflow: hidden; border-radius: 8px; background: #dcebe5; box-shadow: 0 12px 35px #243f3510; isolation: isolate; }
.stage::after { position: absolute; z-index: -1; inset: auto 0 0; height: 47%; content: ''; background: linear-gradient(180deg, transparent, #fffdf5d9 48%, #fffdf5f4); pointer-events: none; }
.portrait { position: absolute; z-index: -2; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; }
.stage-topline { position: absolute; top: 18px; left: 18px; right: 18px; display: flex; justify-content: space-between; align-items: center; }
.presence-pill, .version-label { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid #ffffffa3; border-radius: 20px; background: #ffffffc9; color: #52635d; backdrop-filter: blur(8px); font-size: 10px; }
.presence-dot { width: 7px; height: 7px; }
.presence-pill.offline .presence-dot { background: #d7a36b; box-shadow: 0 0 0 3px #d7a36b25; }
.version-label { color: #6e7b75; }
.stage-caption { position: absolute; left: 28px; right: 28px; bottom: 109px; display: flex; align-items: flex-end; justify-content: space-between; }
.stage-caption .eyebrow { color: #80938b; }
.stage-caption h2 { margin-bottom: 5px; font-size: 25px; }
.behavior-line { display: flex; align-items: center; gap: 7px; margin-bottom: 0; color: #64756e; font-size: 12px; }
.behavior-spark { width: 6px; height: 6px; border-radius: 50%; background: var(--coral); }
.emotion-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; color: #d38b63; background: #fff8ed; font-size: 16px; }
.stage-actions { position: absolute; bottom: 19px; left: 19px; right: 19px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.stage-action { min-width: 0; min-height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px solid #e8eeea; border-radius: 7px; background: #ffffffed; box-shadow: 0 3px 12px #33443b0b; color: #52635d; font-size: 11px; cursor: pointer; transition: background .18s, transform .18s, border-color .18s; }
.stage-action:hover { transform: translateY(-2px); border-color: #b7d3c9; background: white; }
.action-icon { display: grid; place-items: center; width: 22px; height: 22px; color: var(--teal); }
.stage-action svg { width: 20px; height: 20px; }
.stage-footnote { display: flex; justify-content: space-between; padding: 12px 3px; color: #9aa59f; font-size: 10px; }
.interaction-column { display: flex; flex-direction: column; gap: 16px; padding-top: 85px; }
.chat-panel, .memory-panel, .activity-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.chat-panel { display: flex; flex-direction: column; min-height: 375px; padding: 21px 21px 14px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-heading .eyebrow { margin-bottom: 4px; }
.panel-heading h2 { font-size: 17px; }
.chat-indicator { margin-top: 2px; padding: 5px 9px; border-radius: 20px; background: #edf5ef; color: #638b6a; font-size: 10px; }
.messages { display: flex; flex: 1; flex-direction: column; gap: 16px; overflow-y: auto; min-height: 210px; max-height: 300px; padding: 25px 2px 16px; }
.message-row { display: flex; align-items: flex-start; gap: 10px; }
.message-avatar { flex: 0 0 28px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; background: var(--teal); font-size: 12px; }
.user-row { justify-content: flex-end; }
.user-row .message-content { order: -1; align-items: flex-end; }
.user-row .message-content p { border-radius: 12px 3px 12px 12px; background: #edf5f1; }
.user-row .message-avatar { background: #d89b84; }
.message-content { max-width: calc(100% - 38px); display: flex; flex-direction: column; align-items: flex-start; }
.message-author { margin: 0 0 5px 1px; color: #9aa49f; font-size: 10px; }
.message-content p { max-width: 100%; margin-bottom: 4px; padding: 10px 12px; border-radius: 3px 12px 12px; background: #f5f7f5; color: #485750; font-size: 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-content time { padding: 0 2px; color: #adb6b1; font-size: 9px; }
.typing-message { color: #7b8983; font-size: 11px; font-style: italic; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 9px; border: 1px solid #e7ece8; border-radius: 8px; background: #fbfcfb; transition: border-color .18s; }
.composer:focus-within { border-color: #a8c8bd; }
.composer textarea { flex: 1; min-width: 0; resize: none; max-height: 90px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; line-height: 1.6; }
.composer textarea::placeholder { color: #adb7b2; }
.send-button { flex: 0 0 33px; display: grid; place-items: center; width: 33px; height: 33px; border: 0; border-radius: 7px; background: var(--teal-dark); color: white; cursor: pointer; transition: background .15s, transform .15s; }
.send-button:hover { background: #397466; transform: translateY(-1px); }
.send-button:disabled { background: #9aaca5; cursor: wait; transform: none; }
.send-button svg { width: 17px; height: 17px; }
.composer-meta { display: flex; justify-content: space-between; padding: 7px 2px 0; color: #a2aca7; font-size: 9px; }
.activity-panel { padding: 18px 20px 14px; }
.compact-heading { align-items: center; }
.state-chip { padding: 6px 10px; border-radius: 5px; background: #f2f6f3; color: #738078; font-size: 10px; }
.state-grid { display: grid; grid-template-columns: repeat(4, 1fr); padding: 17px 0 13px; }
.state-cell { display: grid; gap: 7px; padding-left: 12px; border-left: 1px solid var(--line); }
.state-cell:first-child { padding-left: 0; border-left: 0; }
.state-cell span { color: #a0aaa5; font-size: 10px; }
.state-cell strong { overflow: hidden; color: #53625b; font-size: 11px; font-weight: 600; text-overflow: ellipsis; }
.activity-footer { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid #f0f3f1; color: #8c9992; font-size: 10px; }
.event-dot { flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: #e5a78a; }
.refresh-link { margin-left: auto; padding: 2px 0 2px 6px; border: 0; color: var(--teal); background: transparent; font-size: 10px; cursor: pointer; }
.memory-panel { padding: 18px 20px 14px; }
.clear-memory-button { padding: 5px 2px; border: 0; color: #9a716a; background: transparent; font-size: 10px; cursor: pointer; }
.clear-memory-button:hover { color: #a84f43; }
.memory-form { display: flex; flex-direction: column; gap: 9px; margin-top: 15px; }
.memory-form textarea { width: 100%; min-height: 54px; resize: vertical; padding: 10px 11px; border: 1px solid #e7ece8; border-radius: 6px; outline: none; color: var(--ink); background: #fbfcfb; font-size: 11px; line-height: 1.6; }
.memory-form textarea:focus { border-color: #a8c8bd; }
.memory-form textarea::placeholder { color: #adb7b2; }
.memory-form-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.consent-control { display: inline-flex; align-items: center; gap: 7px; color: #77847e; font-size: 10px; cursor: pointer; }
.consent-control input { width: 14px; height: 14px; margin: 0; accent-color: var(--teal); }
.add-memory-button { padding: 7px 10px; border: 1px solid #dce8e2; border-radius: 5px; background: #f5f8f6; color: var(--teal-dark); font-size: 10px; cursor: pointer; }
.add-memory-button:hover { background: #edf5f1; }
.memory-list { display: grid; gap: 7px; margin-top: 12px; }
.memory-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 9px 10px; border: 1px solid #eef2ef; border-radius: 6px; background: #fcfdfc; }
.memory-content { min-width: 0; color: #56655e; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; }
.memory-item-controls { display: flex; align-items: center; gap: 9px; }
.memory-consent { display: inline-flex; align-items: center; gap: 5px; color: #88958f; font-size: 9px; white-space: nowrap; cursor: pointer; }
.memory-consent input { width: 13px; height: 13px; margin: 0; accent-color: var(--teal); }
.delete-memory-button { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid #edf1ee; border-radius: 5px; background: #fff; color: #a17a72; cursor: pointer; }
.delete-memory-button:hover { border-color: #ebc4bc; color: #a84f43; }
.delete-memory-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.empty-memory { margin: 0; padding: 11px 0 2px; color: #a5afa9; font-size: 10px; }
.memory-note { margin: 10px 0 0; color: #a0aaa5; font-size: 9px; line-height: 1.5; }
.local-note { display: flex; align-items: center; gap: 7px; margin: 0; padding: 0 2px; color: #a1aca6; font-size: 10px; line-height: 1.5; }
.local-note svg { width: 14px; height: 14px; flex: 0 0 auto; }
.toast { position: fixed; z-index: 5; left: 50%; bottom: 24px; max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 7px; background: #243a33; color: #fff; font-size: 12px; box-shadow: 0 8px 24px #14251e2e; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #9e5146; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); border: 0; }
.auth-gate { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 22px; overflow-y: auto; background: #f4f7f4; }
.auth-gate.hidden { display: none; }
.auth-panel { width: min(100%, 390px); padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: 0 16px 46px #25332f0d; }
.auth-mark { margin-bottom: 18px; }
.auth-panel .eyebrow { margin-bottom: 6px; }
.auth-panel h1 { font-size: 22px; }
.auth-subtitle { margin: 8px 0 22px; color: #829089; font-size: 12px; }
.auth-form { display: grid; gap: 8px; }
.auth-form label { margin-top: 5px; color: #697770; font-size: 11px; }
.auth-form input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid #e4eae6; border-radius: 6px; outline: 0; color: var(--ink); background: #fcfdfc; font-size: 13px; }
.auth-form input:focus { border-color: #9fc4b6; box-shadow: 0 0 0 3px #5b9f851c; }
.password-confirm-row { display: grid; gap: 8px; }
.password-confirm-row.hidden { display: none; }
.auth-error { min-height: 16px; margin: 2px 0 0; color: #ac564b; font-size: 10px; line-height: 1.5; }
.auth-submit { height: 42px; margin-top: 2px; border: 0; border-radius: 6px; background: var(--teal-dark); color: white; font-size: 12px; font-weight: 600; cursor: pointer; }
.auth-submit:hover { background: #397466; }
.auth-submit:disabled { opacity: .6; cursor: wait; }
.auth-footnote { margin: 15px 0 0; color: #9aa59f; font-size: 10px; line-height: 1.6; }

@media (min-width: 1400px) { .workspace { gap: 72px; } .stage { min-height: 610px; } .interaction-column { padding-top: 90px; } }
@media (max-width: 1000px) { .app-shell { padding: 0 26px 32px; } .workspace { grid-template-columns: minmax(340px, 1fr) minmax(320px, .9fr); gap: 28px; margin-top: 32px; } .stage { min-height: 530px; } .interaction-column { padding-top: 85px; } }
@media (max-width: 760px) { .app-shell { padding: 0 16px 28px; } .topbar { height: 68px; } .mode-label { font-size: 10px; } .workspace { display: flex; flex-direction: column; gap: 20px; margin-top: 25px; } .section-heading { min-height: 58px; margin-bottom: 13px; } h1 { font-size: 22px; } .stage { min-height: 490px; } .portrait { object-position: 50% 34%; } .stage-caption { left: 20px; right: 20px; bottom: 105px; } .stage-actions { left: 12px; right: 12px; bottom: 12px; gap: 6px; } .stage-action { min-height: 64px; font-size: 10px; } .interaction-column { padding-top: 0; } .chat-panel { min-height: 340px; padding: 17px 16px 12px; } .messages { min-height: 185px; max-height: 290px; padding-top: 20px; } .activity-panel { padding: 16px; } .stage-footnote { font-size: 9px; } }
@media (max-width: 390px) { .app-shell { padding-right: 12px; padding-left: 12px; } .stage { min-height: 445px; } .stage-caption h2 { font-size: 22px; } .state-grid { grid-template-columns: repeat(2, 1fr); gap: 13px 0; } .state-cell:nth-child(3) { padding-left: 0; border-left: 0; } .state-cell:nth-child(3), .state-cell:nth-child(4) { padding-top: 1px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
