:root {
  --paper: #f4efe8;
  --paper-deep: #ebe2d7;
  --ink: #27221e;
  --muted: #81776e;
  --line: rgba(54, 43, 34, 0.12);
  --white: #fffdf9;
  --charcoal: #272824;
  --accent: #d9633e;
  --shadow: 0 24px 70px rgba(57, 44, 34, 0.14);
  --radius: 24px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(430px, 1fr) 310px;
  width: 100%;
  height: 100dvh;
  background:
    radial-gradient(circle at 18% 12%, rgba(255,255,255,.8), transparent 24%),
    var(--paper);
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 28px 18px 20px;
  border-right: 1px solid var(--line);
  background: rgba(245, 240, 233, 0.72);
  backdrop-filter: blur(20px);
  z-index: 5;
}

.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 10px 30px; }
.brand-mark { position: relative; width: 38px; height: 38px; }
.brand-mark span { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--ink); background: var(--paper); }
.brand-mark span:nth-child(1) { left: 0; top: 9px; }
.brand-mark span:nth-child(2) { left: 8px; top: 0; }
.brand-mark span:nth-child(3) { right: 0; top: 9px; }
.brand-mark span:nth-child(4) { left: 7px; bottom: 0; }
.brand-mark span:nth-child(5) { right: 7px; bottom: 0; }
.brand-name { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 22px; letter-spacing: -0.03em; }
.brand-caption { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; margin-top: 2px; }

.nav-stack { display: grid; gap: 5px; }
.nav-item {
  width: 100%; height: 44px; border: 0; background: transparent; border-radius: 13px;
  display: grid; grid-template-columns: 25px 1fr auto; align-items: center; gap: 8px;
  padding: 0 12px; cursor: pointer; text-align: left; color: #5d554e; transition: .18s ease;
}
.nav-item:hover { background: rgba(255,255,255,.65); color: var(--ink); }
.nav-item.is-active { background: var(--charcoal); color: #fff; box-shadow: 0 7px 20px rgba(39,40,36,.18); }
.nav-icon { font-family: Georgia, serif; font-size: 21px; line-height: 1; text-align: center; }
.nav-pill { min-width: 20px; padding: 2px 6px; border-radius: 99px; background: var(--accent); color: #fff; text-align: center; font-size: 11px; }

.people-label, .section-title { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .14em; font-weight: 700; }
.people-label { padding: 30px 12px 12px; }
.people-list { display: grid; gap: 3px; }
.person-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 13px; }
.person-row:hover { background: rgba(255,255,255,.5); }
.avatar { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--avatar-soft); color: var(--avatar); font-family: Georgia, serif; font-weight: 700; border: 1px solid color-mix(in srgb, var(--avatar) 25%, transparent); }
.avatar::after { content: ""; position: absolute; width: 7px; height: 7px; right: -1px; bottom: 1px; border: 2px solid var(--paper); border-radius: 50%; background: #87a56d; }
.person-name { font-size: 13px; font-weight: 650; }
.person-status { font-size: 10px; color: var(--muted); margin-top: 2px; }
.person-mood { font-size: 11px; color: var(--muted); }

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding: 18px 8px 0; }
.mode-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; margin-bottom: 12px; }
.mode-dot { width: 7px; height: 7px; border-radius: 50%; background: #d4a04e; box-shadow: 0 0 0 4px rgba(212,160,78,.13); }
.mode-dot.online { background: #6d9b62; box-shadow: 0 0 0 4px rgba(109,155,98,.13); }
.quiet-button { width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.38); border-radius: 11px; padding: 9px; font-size: 11px; cursor: pointer; }

.chat-column { display: grid; grid-template-rows: 82px minmax(0,1fr) auto; min-width: 0; background: rgba(255,253,249,.52); }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 26px; border-bottom: 1px solid var(--line); background: rgba(255,253,249,.56); backdrop-filter: blur(18px); z-index: 3; }
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .16em; font-size: 9px; font-weight: 750; }
.chat-header h1, .sheet-panel h2 { margin: 3px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 24px; line-height: 1; letter-spacing: -.025em; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.typing-header { min-height: 18px; color: var(--muted); font-size: 11px; font-style: italic; }
.icon-button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.6); display: grid; place-items: center; cursor: pointer; font-family: Georgia, serif; }
.mobile-only { display: none; }

.message-list { overflow-y: auto; overscroll-behavior: contain; padding: 34px max(28px, 7vw) 24px; scroll-behavior: smooth; }
.loading-stage { min-height: 100%; display: grid; place-content: center; justify-items: center; color: var(--muted); font-size: 12px; }
.loading-orbit { position: relative; width: 62px; height: 62px; animation: orbit 9s linear infinite; }
.loading-orbit i { position: absolute; width: 19px; height: 19px; border-radius: 50%; background: var(--ink); }
.loading-orbit i:nth-child(1) { left: 0; top: 22px; background: #ff7a59; }
.loading-orbit i:nth-child(2) { left: 14px; top: 0; background: #8a6de9; }
.loading-orbit i:nth-child(3) { right: 0; top: 19px; background: #20a987; }
.loading-orbit i:nth-child(4) { left: 10px; bottom: 0; background: #d24f77; }
.loading-orbit i:nth-child(5) { right: 8px; bottom: 2px; background: #3d77d8; }
@keyframes orbit { to { transform: rotate(360deg); } }

.welcome-card { max-width: 560px; margin: 7vh auto 40px; text-align: center; }
.welcome-orbit { position: relative; width: 176px; height: 92px; margin: 0 auto 24px; }
.welcome-avatar { position: absolute; width: 54px; height: 54px; border: 5px solid var(--white); box-shadow: 0 8px 20px rgba(55,43,34,.12); }
.welcome-avatar:nth-child(1) { left: 0; top: 28px; }
.welcome-avatar:nth-child(2) { left: 31px; top: 4px; }
.welcome-avatar:nth-child(3) { left: 62px; top: 29px; z-index: 2; }
.welcome-avatar:nth-child(4) { right: 30px; top: 3px; }
.welcome-avatar:nth-child(5) { right: 0; top: 28px; }
.welcome-card h2 { font-family: Georgia, serif; font-size: clamp(30px, 5vw, 48px); letter-spacing: -.045em; margin: 0 0 14px; }
.welcome-card > p { color: var(--muted); font-size: 14px; line-height: 1.65; max-width: 470px; margin: 0 auto; }
.welcome-prompts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 25px; }
.welcome-prompts button { border: 1px solid var(--line); background: rgba(255,255,255,.7); border-radius: 99px; padding: 9px 14px; cursor: pointer; font-size: 12px; }

.day-divider { display: flex; align-items: center; gap: 12px; margin: 25px 0; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .13em; }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.message-row { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; margin: 15px 0; align-items: start; }
.message-row.is-owner { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.message-row .avatar { width: 38px; height: 38px; }
.message-body { max-width: min(630px, 84%); }
.message-meta { display: flex; align-items: baseline; gap: 8px; margin: 0 0 5px 3px; }
.message-author { font-size: 12px; font-weight: 750; }
.message-time { color: var(--muted); font-size: 9px; }
.message-bubble { position: relative; background: var(--white); border: 1px solid rgba(54,43,34,.09); border-radius: 8px 20px 20px 20px; padding: 11px 14px; box-shadow: 0 5px 20px rgba(67,51,40,.045); font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.is-owner .message-body { display: grid; justify-items: end; }
.is-owner .message-meta { justify-content: flex-end; margin-right: 3px; }
.is-owner .message-bubble { color: #fff; background: var(--charcoal); border-color: var(--charcoal); border-radius: 20px 8px 20px 20px; }
.reply-quote { display: block; border-left: 2px solid var(--avatar, var(--accent)); padding: 2px 0 2px 8px; margin: 0 0 7px; color: var(--muted); font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-owner .reply-quote { color: rgba(255,255,255,.6); }
.message-actions { display: flex; gap: 5px; margin-top: 5px; opacity: 0; transition: opacity .15s; }
.message-row:hover .message-actions, .message-row:focus-within .message-actions { opacity: 1; }
.message-actions button, .reaction-chip { border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.75); padding: 3px 7px; font-size: 10px; cursor: pointer; }
.message-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -5px; margin-left: 8px; position: relative; z-index: 1; }
.sticker-message { width: 150px; min-height: 126px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; border-radius:28px 12px 28px 28px; background:color-mix(in srgb, var(--sticker) 16%, var(--white)); border:1px solid color-mix(in srgb, var(--sticker) 30%, transparent); transform:rotate(-1.5deg); box-shadow:0 8px 25px rgba(52,42,34,.08); }.sticker-message span{font-size:48px;line-height:1}.sticker-message b{font-family:Georgia,serif;font-size:13px;color:var(--sticker);text-align:center;padding:0 8px}.is-owner .sticker-message{border-radius:12px 28px 28px 28px;transform:rotate(1.5deg)}
.typing-bubble { display: inline-flex; gap: 4px; padding: 13px 15px; background: var(--white); border-radius: 8px 18px 18px 18px; border: 1px solid var(--line); }
.typing-bubble i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: typing 1s infinite alternate; }
.typing-bubble i:nth-child(2) { animation-delay: .2s; }.typing-bubble i:nth-child(3) { animation-delay: .4s; }
@keyframes typing { to { opacity: .25; transform: translateY(-2px); } }

.composer-wrap { padding: 12px max(22px, 6vw) 18px; background: linear-gradient(transparent, rgba(244,239,232,.95) 25%); }
.composer { display: grid; grid-template-columns: 36px minmax(0,1fr) 42px; align-items: end; gap: 8px; max-width: 820px; margin: 0 auto; padding: 7px; background: var(--white); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 14px 45px rgba(52,42,34,.12); }
.composer:focus-within { border-color: rgba(39,34,30,.3); box-shadow: 0 16px 50px rgba(52,42,34,.16); }
.composer textarea { resize: none; max-height: 150px; min-height: 38px; border: 0; outline: 0; background: transparent; padding: 9px 4px 7px; color: var(--ink); line-height: 1.4; }
.composer textarea::placeholder { color: #aaa097; }
.composer-tool { width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.send-button { width: 42px; height: 42px; border: 0; border-radius: 16px; background: var(--accent); color: #fff; cursor: pointer; font-size: 22px; box-shadow: 0 6px 16px rgba(217,99,62,.28); transition: .15s; }
.send-button:hover { transform: translateY(-1px); }
.send-button:disabled { opacity: .35; box-shadow: none; cursor: default; }
.composer-hint { max-width: 820px; margin: 7px auto 0; padding-left: 14px; color: var(--muted); font-size: 9px; }
.reply-preview { max-width: 820px; margin: 0 auto 6px; background: rgba(255,255,255,.68); border-left: 3px solid var(--accent); border-radius: 9px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; }
.reply-preview span { font-size: 10px; color: var(--accent); font-weight: 700; }.reply-preview p { margin: 2px 0 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-preview button { border: 0; background: transparent; cursor: pointer; font-size: 20px; color: var(--muted); }

.context-panel { display: flex; flex-direction: column; gap: 22px; padding: 30px 24px; border-left: 1px solid var(--line); overflow-y: auto; }
.context-top h2 { margin: 7px 0 10px; font-family: Georgia, serif; font-size: 25px; line-height: 1.1; letter-spacing: -.03em; }
.context-top p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.pulse-card { background: var(--charcoal); color: #fff; padding: 18px; border-radius: 20px; box-shadow: 0 16px 35px rgba(39,40,36,.14); }
.pulse-header { display: flex; justify-content: space-between; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.pulse-header span:last-child { color: #cfbea8; }
.pulse-track { height: 4px; border-radius: 99px; background: rgba(255,255,255,.12); margin: 14px 0 10px; overflow: hidden; }
.pulse-track i { display: block; height: 100%; width: 32%; border-radius: inherit; background: linear-gradient(90deg,#ff7a59,#d5a563); transition: width .3s; }
.pulse-caption { color: #c9c2bb; font-size: 10px; line-height: 1.5; }
.today-block { display: grid; gap: 11px; }
.life-cards { display: grid; gap: 7px; }
.life-card { display: grid; grid-template-columns: 28px 1fr; gap: 9px; padding: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.45); border-radius: 14px; }
.life-card .avatar { width: 28px; height: 28px; font-size: 11px; }.life-card b { font-size: 10px; }.life-card p { margin: 2px 0 0; color: var(--muted); font-size: 9px; line-height: 1.35; }
.transparency-note { margin-top: auto; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; border-top: 1px solid var(--line); padding-top: 16px; }
.transparency-note span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--paper-deep); font-size: 9px; font-weight: 800; }
.transparency-note p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }

.side-sheet { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: flex-end; }
.sheet-backdrop { position: absolute; inset: 0; border: 0; background: rgba(39,34,30,.3); backdrop-filter: blur(3px); }
.sheet-panel { position: relative; width: min(560px, 94vw); height: 100%; background: var(--paper); box-shadow: var(--shadow); display: grid; grid-template-rows: 84px 1fr; animation: slide-in .22s ease-out; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.sheet-panel > header { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.sheet-content { overflow-y: auto; padding: 24px; }
.sheet-section { margin-bottom: 28px; }.sheet-section h3 { font-family: Georgia, serif; font-size: 21px; margin: 0 0 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }.stat-card strong { display: block; font-family: Georgia, serif; font-size: 24px; }.stat-card span { color: var(--muted); font-size: 10px; }
.relationship-list, .memory-list, .diagnostic-list { display: grid; gap: 8px; }
.relationship-card, .memory-card, .diagnostic-card { background: rgba(255,255,255,.62); border: 1px solid var(--line); border-radius: 15px; padding: 13px; }
.relationship-card header { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; }.meter-row { display: grid; grid-template-columns: 82px 1fr 30px; align-items: center; gap: 8px; margin-top: 8px; font-size: 9px; color: var(--muted); }.meter { height: 4px; background: var(--paper-deep); border-radius: 99px; overflow: hidden; }.meter i { display:block; height:100%; background: var(--accent); border-radius:inherit; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }.setting-row b { display:block; font-size:12px; }.setting-row small { display:block; color:var(--muted); margin-top:3px; max-width:320px; line-height:1.4; }.switch { position:relative; width:42px; height:24px; flex:0 0 auto; }.switch input { opacity:0; position:absolute; }.switch span { position:absolute; inset:0; border-radius:99px; background:#cfc5ba; cursor:pointer; transition:.2s; }.switch span::after { content:""; position:absolute; width:18px; height:18px; left:3px; top:3px; border-radius:50%; background:#fff; transition:.2s; box-shadow:0 2px 6px rgba(0,0,0,.18); }.switch input:checked + span { background:var(--accent); }.switch input:checked + span::after { transform:translateX(18px); }
.danger-zone { border:1px solid rgba(174,61,49,.2); background:rgba(255,237,232,.65); border-radius:16px; padding:16px; }.danger-button { border:0; background:#a83f33; color:#fff; border-radius:10px; padding:9px 13px; cursor:pointer; }
.export-button{display:inline-block;margin-right:8px;border:1px solid var(--line);background:var(--white);color:var(--ink);text-decoration:none;border-radius:10px;padding:9px 13px;font-size:12px}
.sticker-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.sticker-grid button{min-height:160px;border:1px solid color-mix(in srgb,var(--sticker) 25%,transparent);border-radius:22px;background:color-mix(in srgb,var(--sticker) 12%,var(--white));display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;cursor:pointer;transition:.16s}.sticker-grid button:hover{transform:translateY(-2px);box-shadow:0 12px 28px rgba(52,42,34,.1)}.sticker-grid span{font-size:58px}.sticker-grid b{font-family:Georgia,serif;color:var(--sticker)}

.auth-screen { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: var(--paper); }
.auth-screen::before { content:""; position:absolute; inset:0; background: radial-gradient(circle at 18% 20%, rgba(138,109,233,.12), transparent 27%), radial-gradient(circle at 84% 76%, rgba(217,99,62,.14), transparent 29%); pointer-events:none; }
.auth-card { position: relative; width: min(880px, 100%); min-height: 520px; display: grid; grid-template-columns: 1fr 1fr; background: var(--white); border: 1px solid var(--line); border-radius: 30px; overflow: hidden; box-shadow: var(--shadow); }
.auth-art { display:grid; place-items:center; background:var(--charcoal); overflow:hidden; }
.auth-ring { position:relative; width:230px; height:230px; border:1px solid rgba(255,255,255,.12); border-radius:50%; }
.auth-ring::before, .auth-ring::after { content:""; position:absolute; inset:26px; border:1px solid rgba(255,255,255,.08); border-radius:50%; }.auth-ring::after { inset:78px; background:var(--paper); border:0; }
.auth-ring b { position:absolute; display:grid; place-items:center; width:54px; height:54px; border-radius:50%; background:#fff; color:var(--ink); font-family:Georgia,serif; z-index:2; box-shadow:0 8px 20px rgba(0,0,0,.25); }.auth-ring b:nth-child(1){left:-8px;top:90px;color:#ff7a59}.auth-ring b:nth-child(2){left:42px;top:-9px;color:#8a6de9}.auth-ring b:nth-child(3){right:15px;top:18px;color:#20a987}.auth-ring b:nth-child(4){right:-10px;bottom:46px;color:#d24f77}.auth-ring b:nth-child(5){left:59px;bottom:-18px;color:#3d77d8}
.auth-copy { padding: 60px 52px; align-self:center; }.auth-copy h1 { font-family:Georgia,serif; font-size:52px; letter-spacing:-.055em; margin:5px 0 12px; }.auth-copy > p { color:var(--muted); line-height:1.6; font-size:13px; }
.auth-form { display:grid; gap:14px; margin-top:27px; }.auth-form label { display:grid; gap:6px; font-size:10px; text-transform:uppercase; letter-spacing:.1em; color:var(--muted); font-weight:700; }.auth-form input { width:100%; border:1px solid var(--line); background:var(--paper); border-radius:12px; padding:12px 13px; outline:0; color:var(--ink); text-transform:none; letter-spacing:0; font-weight:500; }.auth-form input:focus { border-color:rgba(39,34,30,.35); }.auth-form button { border:0; background:var(--accent); color:#fff; border-radius:13px; padding:13px; cursor:pointer; font-weight:750; box-shadow:0 8px 20px rgba(217,99,62,.23); }.form-error { color:#a83f33!important; min-height:18px; margin:0!important; font-size:11px!important; }.privacy-copy { font-size:9px!important; margin-top:20px; }
.toast-region { position:fixed; right:20px; bottom:20px; display:grid; gap:8px; z-index:100; }.toast { max-width:330px; background:var(--charcoal); color:#fff; padding:11px 14px; border-radius:12px; box-shadow:var(--shadow); font-size:11px; animation:toast-in .2s ease-out; }@keyframes toast-in{from{transform:translateY(8px);opacity:0}}

@media (max-width: 1100px) { .app-shell { grid-template-columns: 220px minmax(430px,1fr); }.context-panel { display:none; } }
@media (max-width: 760px) {
  .app-shell { display:block; }.sidebar { position:fixed; inset:0 auto 0 0; width:250px; transform:translateX(-102%); transition:.22s; box-shadow:var(--shadow); }.app-shell.menu-open .sidebar { transform:translateX(0); }.mobile-only { display:grid; }.chat-column { height:100dvh; grid-template-rows:72px minmax(0,1fr) auto; }.chat-header { padding:14px 16px; }.chat-header h1 { font-size:20px; }.message-list { padding:20px 14px 18px; }.message-body { max-width:89%; }.composer-wrap { padding:8px 10px max(10px, env(safe-area-inset-bottom)); }.composer-hint { display:none; }.typing-header { display:none; }.auth-card { grid-template-columns:1fr; min-height:0; }.auth-art { min-height:180px; }.auth-ring { transform:scale(.58); }.auth-copy { padding:34px 28px; }.auth-copy h1 { font-size:42px; }.welcome-card { margin-top:3vh; }.message-actions { opacity:1; }
}

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