/* Portal + login pages. Uses the site's tokens from /styles.css. */
.auth { max-width: 460px; margin: 0 auto; padding: 48px var(--gutter) 80px; }
.auth h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
.auth .lead { margin-bottom: 24px; }
.auth form { display: grid; gap: 14px; }
.auth input[type="tel"], .auth input[type="text"] { font: inherit; width: 100%; min-height: 52px; padding: 12px 18px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--white); color: var(--ink); font-size: 1.15rem; letter-spacing: .02em; }
.auth input:focus { border-color: var(--terracotta); box-shadow: 0 0 0 4px rgba(217,112,74,.15); outline: none; }
.auth .btn-lg { width: 100%; }
.auth .links { display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: center; }
.auth .linkbtn { font: inherit; font-weight: 700; color: var(--terracotta-deep); background: none; border: 0; cursor: pointer; padding: 6px; text-decoration: underline; }
.auth .form-note { text-align: center; }
.auth strong { color: var(--plum); }

/* Portal */
.portal-header .wrap { min-height: 60px; }
.portal-nav { display: none; gap: 18px; margin-left: 10px; }
.portal-nav a { color: var(--ink-soft); text-decoration: none; font-weight: 700; font-size: .95rem; }
.portal-nav a:hover, .portal-nav a.active { color: var(--plum); }
@media (min-width: 760px) { .portal-nav { display: flex; } }
.minutes-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--sage-deep); background: rgba(111,176,143,.14); border-radius: 999px; padding: 6px 12px; font-size: .9rem; white-space: nowrap; }
.who { color: var(--ink-mute); font-size: .9rem; display: none; }
@media (min-width: 560px) { .who { display: inline; } }

.portal-main { padding: 20px var(--gutter) 60px; }
.portal-grid { display: grid; gap: 20px; max-width: var(--wrap); margin: 0 auto; }
@media (min-width: 900px) { .portal-grid { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; } }

.talk-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 60vh; height: calc(100vh - 140px); max-height: 820px; }
.talk-panel h2 { font-size: 1.1rem; margin: 0; color: var(--ink-soft); font-family: var(--font-body); font-weight: 700; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-head .hint { color: var(--ink-mute); font-size: .82rem; margin: 0; }
.conversation { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 6px 2px; scroll-behavior: smooth; }
.history-status { color: var(--ink-mute); text-align: center; font-size: .92rem; margin: 6px 0; }
.history-status:empty { display: none; }
.history-more { align-self: center; }
.msg { max-width: 85%; display: grid; gap: 2px; }
.msg-user { align-self: flex-end; }
.msg-yexy { align-self: flex-start; }
.msg-meta { font-size: .75rem; color: var(--ink-mute); padding: 0 8px; }
.msg-user .msg-meta { text-align: right; }
.msg-text { padding: 10px 14px; border-radius: 16px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg-user .msg-text { background: var(--plum); color: #fff; border-bottom-right-radius: 6px; }
.msg-yexy .msg-text { background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg-pending .msg-text { color: var(--ink-mute); }

.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-top: 12px; }
.composer form { display: flex; gap: 8px; min-width: 0; }
.composer input[type="text"] { min-height: 52px; }
.composer .btn-send { min-height: 52px; border-radius: 999px; padding: 0 18px; }
.talk-wrap { display: grid; justify-items: center; gap: 4px; }
.talk-btn { width: 72px; height: 72px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; background: linear-gradient(160deg, var(--terracotta), var(--terracotta-deep)); color: #fff; box-shadow: 0 8px 22px rgba(217,112,74,.4); transition: transform .12s ease, box-shadow .2s ease; touch-action: none; user-select: none; -webkit-user-select: none; }
.talk-btn svg { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.talk-btn:active { transform: scale(.96); }
.talk-btn.open { background: linear-gradient(160deg, var(--sage), var(--sage-deep)); box-shadow: 0 0 0 8px rgba(111,176,143,.25), 0 8px 22px rgba(63,138,102,.4); animation: breathe 1.6s ease-in-out infinite; }
.talk-btn[data-state="thinking"] { background: linear-gradient(160deg, var(--apricot), var(--terracotta)); }
.talk-btn[data-state="speaking"] { background: linear-gradient(160deg, var(--glow), var(--apricot)); color: var(--plum); animation: breathe 1.2s ease-in-out infinite; }
.talk-btn[data-state="speaking"] svg { stroke: var(--plum); }
.talk-btn[data-state="connecting"] { opacity: .7; }
@keyframes breathe { 0%,100% { transform: scale(1);} 50% { transform: scale(1.06);} }
.talk-label { font-size: .8rem; font-weight: 700; color: var(--ink-soft); min-height: 1.2em; text-align: center; }
.end-voice { font: inherit; font-size: .8rem; font-weight: 700; color: var(--terracotta-deep); background: none; border: 0; cursor: pointer; text-decoration: underline; }

.side { display: grid; gap: 16px; }
.side .card h3 { margin-top: 0; font-size: 1.1rem; }
.side .big { font-family: var(--font-display); font-size: 2.4rem; color: var(--plum); line-height: 1; margin: 6px 0; }
.side .muted { color: var(--ink-mute); font-size: .9rem; }
.side form { display: grid; gap: 10px; margin-top: 8px; }
.side .row { display: flex; flex-wrap: wrap; gap: 8px; }
.side .btn-ghost { font-size: .9rem; }

.name-step { max-width: 460px; margin: 10vh auto 0; text-align: center; display: grid; gap: 14px; }
.name-step form { display: grid; gap: 12px; }
.name-step .linkbtn { font: inherit; color: var(--ink-mute); background: none; border: 0; cursor: pointer; text-decoration: underline; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--plum); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: min(92vw, 520px); box-shadow: var(--shadow); transition: opacity .2s ease, transform .2s ease; z-index: 80; }
.toast.err, .toast.ok { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--sage-deep); }
[hidden] { display: none !important; }

/* ---- Talk screen v2: the stage (character) is the interface ---- */
.portal-body .site-footer { display: none; }
.portal-main { min-height: calc(100vh - 60px); display: grid; align-content: start; }
.view { max-width: 760px; width: 100%; margin: 0 auto; }
.view-talk { max-width: none; display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: calc(100vh - 100px); padding-bottom: 12px; }
.stage { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-items: center; min-height: 0; }
.character { width: min(72vmin, 520px); height: min(72vmin, 520px); --level: 0; animation: idle-float 5s ease-in-out infinite; transition: transform .3s ease; }
.character svg { width: 100%; height: 100%; overflow: visible; }
.ch-glow { opacity: calc(0.35 + var(--level) * 0.65); transform-origin: 100px 110px; transform: scale(calc(0.9 + var(--level) * 0.35)); transition: opacity .12s linear, transform .12s linear; }
.ch-ring { transform-origin: 100px 110px; transition: stroke-width .2s ease, opacity .2s ease; }
.ch-ear { transform-origin: 70px 60px; transition: transform .3s ease; }
.ch-ear-r { transform-origin: 130px 60px; }
.character[data-state="off"] .ch-ring { opacity: .35; }
.character[data-state="connecting"] .ch-ring { animation: ring-spin 1.2s linear infinite; stroke-dasharray: 60 420; }
.character[data-state="listening"] .ch-ring { stroke-width: 7; animation: ring-breathe 1.8s ease-in-out infinite; }
.character[data-state="listening"] .ch-ear-l { transform: rotate(-8deg); }
.character[data-state="listening"] .ch-ear-r { transform: rotate(8deg); }
.character[data-state="thinking"] .ch-eyes { animation: eyes-up 1.6s ease-in-out infinite; }
.character[data-state="thinking"] .ch-ring { stroke-dasharray: 30 18; animation: ring-spin 3s linear infinite; }
.character[data-state="speaking"] { animation: idle-float 5s ease-in-out infinite, talk-sway 1.1s ease-in-out infinite; }
.character[data-state="speaking"] .ch-ring { stroke-width: calc(5px + var(--level) * 6px); }
.character.g-bounce { animation: bounce .7s cubic-bezier(.3,1.4,.5,1) 1; }
.character.g-happy { animation: happy 1s ease-in-out 1; }
@keyframes idle-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes talk-sway { 0%,100% { rotate: -1.5deg; } 50% { rotate: 1.5deg; } }
@keyframes ring-breathe { 0%,100% { opacity: .6; } 50% { opacity: 1; } }
@keyframes ring-spin { to { transform: rotate(360deg); } }
@keyframes eyes-up { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes bounce { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-26px) scale(1.04, .96); } 70% { transform: translateY(0) scale(.98, 1.02); } 100% { transform: translateY(0) scale(1); } }
@keyframes happy { 0%,100% { rotate: 0deg; } 20% { rotate: -8deg; transform: translateY(-10px); } 50% { rotate: 8deg; } 80% { rotate: -4deg; } }
.caption { min-height: 3.2em; max-width: 42em; padding: 0 var(--gutter) 8px; text-align: center; font-family: var(--font-display); font-size: clamp(1.15rem, 2.6vw, 1.6rem); line-height: 1.4; color: var(--plum); display: flex; flex-direction: column; gap: 2px; }
.caption-text.idle { color: var(--ink-mute); font-family: var(--font-body); font-size: 1rem; }
.caption-text:not(.idle):empty { display: none; }
.talk-dock { display: grid; justify-items: center; gap: 6px; padding: 8px 0 env(safe-area-inset-bottom); }
.talk-dock .talk-btn { width: 88px; height: 88px; }
.talk-dock .talk-btn svg { width: 38px; height: 38px; }
.view.card { margin-top: 20px; }
.view.card h2 { margin-top: 0; }
.view .big { font-family: var(--font-display); font-size: 2.6rem; color: var(--plum); line-height: 1; margin: 6px 0; }
.view .muted { color: var(--ink-mute); }
.view form { display: grid; gap: 10px; margin-top: 8px; max-width: 420px; }
.view .row { display: flex; flex-wrap: wrap; gap: 8px; }
.conversation { max-height: none; overflow: visible; margin-top: 12px; }
.portal-nav a.active { color: var(--terracotta-deep); }
.minutes-pill { text-decoration: none; }
body.naming .view { display: none; }
@media (max-width: 759px) {
  .portal-nav { display: flex; gap: 14px; order: 3; width: 100%; overflow-x: auto; padding-bottom: 6px; }
  .site-header.portal-header .wrap { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .character, .character[data-state="speaking"], .character.g-bounce, .character.g-happy, .ch-ring, .ch-eyes { animation: none !important; }
  .ch-glow { transition: none; }
}
