:root {
  --ink: #211f2a;
  --paper: #f2eee8;
  --white: #fcfaf6;
  --mulberry: #7b5360;
  --pine: #344b4a;
  --brass: #c2a56b;
  --line: #d8d0c5;
  --muted: #6f6a70;
  --shadow: 0 24px 70px rgba(33, 31, 42, 0.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font-family: "DM Sans", sans-serif; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
.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; }

.agent-header { height: 78px; padding: 0 max(24px, 5vw); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; font: 800 22px "Manrope", sans-serif; letter-spacing: -1px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50% 50% 48% 20%; background: linear-gradient(145deg, #8a6370, #68414d); color: white; transform: rotate(-8deg); }
.back-link { font-size: 13px; font-weight: 700; }
.kicker { color: var(--mulberry); font-size: 10px; letter-spacing: 0.16em; font-weight: 800; }

.password-gate { min-height: calc(100vh - 78px); display: grid; place-items: center; padding: 55px 20px; position: relative; overflow: hidden; }
.password-gate:before, .password-gate:after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.password-gate:before { width: 520px; height: 520px; right: -130px; top: -180px; background: #d9caa9; opacity: 0.7; }
.password-gate:after { width: 390px; height: 390px; left: -140px; bottom: -160px; border: 1px dashed #93737d; }
.gate-card { width: min(570px, 100%); background: rgba(252, 250, 246, 0.88); border: 1px solid var(--line); border-radius: 25px; box-shadow: var(--shadow); padding: 50px; position: relative; z-index: 2; backdrop-filter: blur(14px); }
.agent-orb { float: right; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--pine); color: var(--brass); font-size: 21px; }
.gate-card h1, .agent-sidebar h1 { margin: 14px 0 22px; font: 700 clamp(47px, 6vw, 70px)/1.03 "Manrope", sans-serif; letter-spacing: -0.065em; }
.gate-card h1 em, .agent-sidebar h1 em { color: var(--mulberry); font-family: Georgia, serif; font-weight: 400; }
.gate-card > p { color: var(--muted); line-height: 1.7; max-width: 450px; }
.gate-card form { margin-top: 30px; }
.gate-card label { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.password-row { display: flex; padding: 7px; background: white; border: 1px solid var(--line); border-radius: 13px; }
.password-row:focus-within { border-color: var(--mulberry); box-shadow: 0 0 0 3px rgba(123, 83, 96, 0.1); }
.password-row input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 10px 12px; }
.password-row button, .send-button { border: 0; background: var(--mulberry); color: white; border-radius: 9px; padding: 12px 18px; font-weight: 700; cursor: pointer; }
.form-error { color: #a43c3c; min-height: 20px; margin: 8px 0 0; font-size: 12px; }
.gate-card > small { display: block; color: var(--muted); margin-top: 22px; font-size: 11px; }

.agent-app { width: min(1280px, 92vw); min-height: calc(100vh - 130px); margin: 25px auto 52px; display: grid; grid-template-columns: 340px 1fr; background: var(--white); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.agent-sidebar { background: var(--pine); color: white; padding: 48px 36px; display: flex; flex-direction: column; }
.agent-sidebar .kicker { color: var(--brass); }
.agent-sidebar h1 { font-size: 46px; margin-top: 18px; }
.agent-sidebar h1 em { color: #d9c9a8; }
.agent-sidebar > p { color: #cbd6d3; line-height: 1.7; font-size: 14px; }
.agent-status { display: flex; gap: 9px; align-items: center; margin: 25px 0 auto; color: #dce5e3; font-size: 11px; }
.agent-status i { width: 8px; height: 8px; background: #89c6a6; border-radius: 50%; box-shadow: 0 0 0 5px rgba(137, 198, 166, 0.12); }
.secondary-button { width: 100%; margin-top: 10px; padding: 13px; border: 1px solid rgba(255,255,255,0.25); border-radius: 10px; color: white; background: transparent; text-align: left; cursor: pointer; }
.secondary-button:hover { background: rgba(255,255,255,0.08); }

.chat-panel { min-width: 0; display: grid; grid-template-rows: auto 1fr auto auto; height: calc(100vh - 130px); min-height: 650px; }
.chat-toolbar { min-height: 72px; padding: 15px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.chat-toolbar strong, .chat-toolbar small { display: block; }
.chat-toolbar small { color: var(--muted); margin-top: 3px; font-size: 10px; }
.chat-toolbar button { border: 1px solid var(--line); background: transparent; border-radius: 20px; padding: 8px 12px; color: var(--muted); font-size: 11px; cursor: pointer; }
.chat-toolbar button[aria-pressed="true"] { background: #e5ded4; color: var(--ink); border-color: var(--brass); }
.messages { padding: 30px clamp(20px, 5vw, 65px); overflow-y: auto; scroll-behavior: smooth; }
.message { display: flex; align-items: flex-start; gap: 12px; max-width: 78%; margin-bottom: 20px; }
.message-avatar { flex: 0 0 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: var(--pine); color: white; font-size: 11px; font-weight: 800; }
.message div { padding: 14px 17px; border-radius: 5px 16px 16px; background: #eee8df; }
.message small { display: block; color: var(--mulberry); font-size: 8px; letter-spacing: 0.1em; font-weight: 800; }
.message p { margin: 6px 0 0; line-height: 1.65; font-size: 14px; white-space: pre-wrap; }
.user-message { margin-left: auto; flex-direction: row-reverse; }
.user-message .message-avatar { background: var(--mulberry); }
.user-message div { border-radius: 16px 5px 16px 16px; background: var(--pine); color: white; }
.user-message small { color: #c9d8d5; }
.typing-dots { display: inline-flex; gap: 4px; padding: 7px 0; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: typing 1s infinite alternate; }
.typing-dots i:nth-child(2) { animation-delay: 0.2s; }.typing-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { to { opacity: 0.25; transform: translateY(-3px); } }
.suggested-prompts { margin: 30px 0 0 43px; max-width: 600px; }
.suggested-prompts p { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.suggested-prompts button { display: block; width: 100%; margin: 8px 0; padding: 12px 15px; border: 1px solid var(--line); border-radius: 10px; background: transparent; text-align: left; color: var(--ink); cursor: pointer; }
.suggested-prompts button:hover { border-color: var(--mulberry); background: #f4efe9; }
.chat-composer { margin: 0 clamp(20px, 5vw, 65px); padding: 8px; display: flex; align-items: end; gap: 8px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.chat-composer:focus-within { border-color: var(--mulberry); box-shadow: 0 0 0 3px rgba(123, 83, 96, 0.08); }
.chat-composer textarea { flex: 1; max-height: 130px; resize: none; border: 0; outline: 0; background: transparent; padding: 11px 5px; line-height: 1.45; }
.mic-button { flex: 0 0 42px; height: 42px; border: 0; border-radius: 50%; background: #e9e3da; color: var(--ink); cursor: pointer; font-size: 18px; }
.mic-button.listening { color: white; background: var(--mulberry); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(123,83,96,0.12); } }
.send-button { flex: 0 0 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 18px; }
.send-button:disabled, .mic-button:disabled { opacity: 0.45; cursor: not-allowed; }
.agent-disclaimer { margin: 11px 30px 16px; color: var(--muted); text-align: center; font-size: 9px; }

@media (max-width: 800px) {
  .agent-app { width: 100%; margin: 0; border: 0; border-radius: 0; grid-template-columns: 1fr; }
  .agent-sidebar { display: none; }
  .chat-panel { height: calc(100vh - 78px); min-height: 520px; }
  .messages { padding: 24px 18px; }
  .message { max-width: 90%; }
  .chat-composer { margin-inline: 14px; }
}

@media (max-width: 540px) {
  .agent-header { height: 66px; }
  .back-link { font-size: 11px; }
  .gate-card { padding: 35px 23px; }
  .gate-card h1 { font-size: 45px; }
  .password-row { display: block; }
  .password-row button { width: 100%; }
  .chat-panel { height: calc(100vh - 66px); }
  .chat-toolbar { padding-inline: 16px; }
  .chat-toolbar button { font-size: 0; }
  .chat-toolbar button:before { content: "◉"; font-size: 14px; }
  .suggested-prompts { margin-left: 0; }
}

/* Animated agent workspace */
.agent-app { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.avatar-panel { min-width: 0; padding: 38px clamp(24px, 3vw, 48px) 28px; background: linear-gradient(155deg, #2e4645 0%, #3c5653 55%, #263d3c 100%); color: white; display: grid; grid-template-rows: auto 1fr auto; position: relative; overflow: hidden; }
.avatar-panel:before { content: ""; position: absolute; width: 390px; height: 390px; border: 1px dashed rgba(214, 192, 148, .3); border-radius: 50%; top: 42%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.avatar-heading { position: relative; z-index: 2; }
.avatar-heading .kicker { color: var(--brass); }
.avatar-heading h1 { margin: 8px 0 5px; font: 700 clamp(30px, 3vw, 42px)/1.05 "Manrope", sans-serif; letter-spacing: -.055em; }
.avatar-heading h1 em { font-family: Georgia, serif; font-weight: 400; color: #dbc89e; }
.avatar-heading p { margin: 0; max-width: 470px; color: #cbd8d5; font-size: 13px; line-height: 1.55; }
.avatar-stage { min-height: 390px; display: grid; place-items: center; position: relative; z-index: 1; }
.avatar-halo { position: absolute; width: min(36vw, 440px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(218,199,159,.34), rgba(218,199,159,.06) 57%, transparent 70%); animation: halo-breathe 4s ease-in-out infinite; }
.avatar-frame { width: min(36vw, 440px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; position: relative; background: #f8f5ef; box-shadow: 0 28px 75px rgba(12,28,28,.38), 0 0 0 9px rgba(255,255,255,.07); transform: translateZ(0); }
.avatar-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.16); user-select: none; pointer-events: none; }
.avatar-expression { opacity: 0; }
.avatar-mouth { clip-path: inset(56% 36% 25% 36%); }
.avatar-eyes, .avatar-wink { clip-path: inset(43% 30% 37% 30%); }
.avatar-stage.mouth-open .avatar-mouth, .avatar-stage.blinking .avatar-eyes, .avatar-stage.winking .avatar-wink { opacity: 1; }
.avatar-stage.speaking .avatar-frame { animation: avatar-speaking 1.8s ease-in-out infinite; }
.speaking-indicator { position: absolute; bottom: 4px; display: flex; align-items: center; gap: 4px; padding: 8px 13px; border-radius: 20px; background: rgba(24,39,38,.78); color: #e4ecea; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; opacity: 0; transform: translateY(7px); transition: .25s; backdrop-filter: blur(7px); }
.speaking-indicator i { width: 3px; height: 8px; border-radius: 3px; background: var(--brass); animation: voice-bar .55s ease-in-out infinite alternate; }
.speaking-indicator i:nth-child(2) { animation-delay: .15s; height: 13px; }.speaking-indicator i:nth-child(3) { animation-delay: .3s; }
.speaking-indicator span { margin-left: 5px; }
.avatar-stage.speaking .speaking-indicator { opacity: 1; transform: translateY(0); }
.avatar-controls { position: relative; z-index: 2; }
.avatar-controls .agent-status { margin: 0 0 14px; }
.avatar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.avatar-actions .secondary-button { margin: 0; text-align: center; font-size: 11px; }
@keyframes avatar-speaking { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(.4deg); } }
@keyframes halo-breathe { 0%,100% { transform: scale(.96); opacity: .65; } 50% { transform: scale(1.04); opacity: 1; } }
@keyframes voice-bar { to { height: 3px; opacity: .55; } }

@media (max-width: 1000px) {
  .agent-app { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .avatar-frame, .avatar-halo { width: min(39vw, 390px); }
  .avatar-heading p { font-size: 12px; }
  .avatar-actions { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .agent-app { grid-template-columns: 1fr; }
  .avatar-panel { min-height: 560px; grid-template-rows: auto 1fr auto; }
  .avatar-frame, .avatar-halo { width: min(72vw, 390px); }
  .avatar-actions { grid-template-columns: 1fr 1fr; }
  .chat-panel { min-height: 680px; }
}

@media (max-width: 540px) {
  .avatar-panel { min-height: 510px; padding: 28px 20px 20px; }
  .avatar-stage { min-height: 330px; }
  .avatar-frame, .avatar-halo { width: min(82vw, 340px); }
  .avatar-heading p { display: none; }
  .avatar-actions .secondary-button { padding: 10px 7px; font-size: 10px; }
}
