:root {
  color-scheme: dark;
  --ink: #f4f6f2;
  --muted: #9aa49f;
  --faint: #6d7772;
  --line: #2a3230;
  --panel: #171c1b;
  --panel-deep: #101414;
  --accent: #c8ef78;
  --accent-ink: #17200e;
  --warm: #f0b77a;
  --rose: #e9a6a7;
  --shadow: 0 18px 50px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: #0d1010;
  color: var(--ink);
  font: 15px/1.6 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.app-shell { min-height: 100vh; max-width: 1440px; margin: 0 auto; padding: 0 32px 32px; }
.topbar {
  min-height: 78px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 600; letter-spacing: .01em; }
.brand strong { color: var(--accent); font-weight: 600; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--accent); color: var(--accent); font-family: Georgia, serif; font-size: 19px; }
.topbar-actions { display: flex; align-items: center; gap: 22px; }
.service-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(200, 239, 120, .09); }
.service-status.is-thinking .status-dot { background: var(--warm); box-shadow: 0 0 0 4px rgba(240, 183, 122, .1); }
.clear-button { padding: 5px 0; border: 0; color: var(--muted); background: transparent; }
.clear-button:hover, .clear-button:focus-visible { color: var(--ink); }

.role-picker { padding: clamp(54px, 7vw, 88px) clamp(0px, 4vw, 62px) 20px; }
.picker-intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; column-gap: 36px; margin-bottom: 38px; }
.eyebrow { margin: 0 0 16px; color: var(--warm); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
h1 { margin: 0; color: var(--ink); font: 500 clamp(36px, 4.6vw, 64px)/1.04 Georgia, "Times New Roman", serif; letter-spacing: 0; }
h1 em { color: var(--accent); font-style: italic; }
.intro-copy { max-width: 430px; margin: 23px 0 0; color: var(--muted); }
.random-button, .change-role-button {
  display: inline-flex; align-items: center; gap: 9px; border: 1px solid var(--accent); color: var(--accent-ink); background: var(--accent); font-size: 13px; font-weight: 700; transition: transform .16s, box-shadow .16s, background .16s;
}
.random-button { align-self: end; padding: 12px 15px; border-radius: 4px; }
.random-button:hover, .random-button:focus-visible { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(200, 239, 120, .12); }
.button-icon { font-size: 16px; line-height: 1; }
.button-arrow { margin-left: 4px; font-size: 16px; }
.role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.role-card {
  position: relative; display: grid; grid-template-columns: 118px minmax(0, 1fr); min-height: 184px; overflow: hidden; padding: 0; text-align: left; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: var(--panel); box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset; transition: border-color .18s, transform .18s, box-shadow .18s;
}
.role-card::after { position: absolute; inset: 0; border: 1px solid transparent; border-radius: inherit; content: ""; pointer-events: none; transition: border-color .18s; }
.role-card:hover, .role-card:focus-visible { transform: translateY(-3px); border-color: #5b675b; box-shadow: var(--shadow); }
.role-card:hover::after, .role-card:focus-visible::after { border-color: color-mix(in srgb, var(--role-accent) 60%, transparent); }
.role-cover { position: relative; min-height: 184px; overflow: hidden; background: #2b312e; }
.role-cover::after { position: absolute; inset: 0; background: rgba(12, 15, 15, .14); content: ""; }
.role-cover img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; filter: saturate(.88); transition: transform .35s, filter .35s; }
.role-card:hover .role-cover img, .role-card:focus-visible .role-cover img { transform: scale(1.04); filter: saturate(1); }
.role-available { position: absolute; z-index: 1; top: 11px; left: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; color: #f7faf5; background: rgba(16, 20, 20, .62); font-size: 10px; line-height: 1; backdrop-filter: blur(8px); }
.role-available::before { width: 5px; height: 5px; border-radius: 50%; background: var(--role-accent); content: ""; }
.role-info { display: flex; flex-direction: column; min-width: 0; padding: 20px 18px 16px; }
.role-name { margin: 0; font: 500 26px/1 Georgia, "Times New Roman", serif; letter-spacing: 0; }
.role-title { margin: 7px 0 0; color: var(--role-accent); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.role-tagline { margin: 11px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.role-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 14px; }
.role-tag { padding: 3px 7px; border: 1px solid var(--line); color: var(--faint); font-size: 10px; line-height: 1.2; }

.chat-layout { display: grid; grid-template-columns: minmax(220px, .62fr) minmax(0, 1.55fr); gap: clamp(38px, 7vw, 116px); padding: 68px clamp(0px, 5vw, 74px) 0; }
.companion-sidebar { padding-top: 4px; }
.companion-summary { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 13px; align-items: center; }
.companion-avatar { width: 68px; height: 68px; overflow: hidden; border: 1px solid var(--role-accent); border-radius: 50%; background: #2b312e; }
.companion-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.companion-name { margin: 0; font: 500 25px/1 Georgia, "Times New Roman", serif; }
.companion-title { margin: 5px 0 0; color: var(--role-accent); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.change-role-button { margin-top: 23px; padding: 9px 11px; border-color: var(--line); color: var(--muted); background: transparent; font-size: 12px; }
.change-role-button:hover, .change-role-button:focus-visible { border-color: #647064; color: var(--ink); }
.sidebar-rule { height: 1px; margin: 35px 0 28px; background: var(--line); }
.starter-list { display: grid; gap: 12px; max-width: 320px; }
.starter { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; text-align: left; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: transparent; transition: border-color .15s, color .15s, transform .15s; }
.starter span:last-child { color: var(--accent); }
.starter:hover, .starter:focus-visible { transform: translateX(2px); border-color: #596250; color: var(--ink); }

.chat-panel { min-width: 0; min-height: 690px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.conversation { flex: 1; min-height: 0; overflow: auto; padding: 30px clamp(18px, 4vw, 48px); }
.message { display: flex; gap: 13px; max-width: 760px; margin-bottom: 30px; }
.user-message { margin-left: auto; flex-direction: row-reverse; }
.avatar { flex: 0 0 31px; display: grid; place-items: center; width: 31px; height: 31px; overflow: hidden; border-radius: 50%; color: var(--accent-ink); background: var(--accent); font: 600 15px Georgia, serif; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-message .avatar { color: #241b11; background: var(--warm); }
.message-body { min-width: 0; padding-top: 2px; }
.message-meta { margin-bottom: 5px; color: var(--faint); font-size: 12px; }
.message-meta time { margin-left: 8px; }
.message-body p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #dce2de; }
.user-message .message-body { text-align: right; }
.typing p::after { display: inline-block; width: 7px; height: 16px; margin-left: 3px; vertical-align: -3px; background: var(--role-accent, var(--accent)); content: ""; animation: blink .9s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.composer { display: flex; align-items: flex-end; gap: 12px; margin: 0 18px; padding: 14px 0 0; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-height: 42px; max-height: 140px; resize: none; padding: 10px 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.composer textarea::placeholder { color: var(--faint); }
.send-button { flex: 0 0 auto; min-width: 76px; padding: 9px 13px; border: 0; border-radius: 4px; color: var(--accent-ink); background: var(--accent); font-size: 13px; font-weight: 700; }
.send-button span:last-child { margin-left: 5px; }
.send-button:disabled { cursor: wait; opacity: .55; }
.composer-note { margin: 4px 18px 17px; color: var(--faint); font-size: 11px; text-align: center; }
.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; }
[hidden] { display: none !important; }

@media (max-width: 980px) {
  .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-layout { gap: 34px; }
}
@media (max-width: 760px) {
  .app-shell { padding: 0 16px 18px; }
  .topbar { min-height: 68px; }
  .topbar-actions { gap: 14px; }
  .role-picker { padding: 42px 0 12px; }
  .picker-intro { display: block; margin-bottom: 30px; }
  h1 { font-size: 42px; }
  .intro-copy { margin: 18px 0 22px; }
  .role-grid { grid-template-columns: 1fr; gap: 12px; }
  .role-card { grid-template-columns: 106px minmax(0, 1fr); min-height: 162px; }
  .role-cover { min-height: 162px; }
  .role-info { padding: 17px 15px 14px; }
  .role-name { font-size: 24px; }
  .role-tags { padding-top: 11px; }
  .chat-layout { display: flex; flex-direction: column; gap: 28px; padding: 38px 0 0; }
  .companion-sidebar { padding-top: 0; }
  .sidebar-rule { margin: 27px 0 23px; }
  .starter-list { display: flex; max-width: none; overflow-x: auto; padding-bottom: 2px; }
  .starter { flex: 0 0 auto; min-width: 175px; }
  .chat-panel { min-height: 590px; }
  .conversation { padding: 24px 16px; }
  .send-label { display: none; }
  .send-button { min-width: 45px; padding: 10px 12px; }
}
