:root {
  color-scheme: dark;
  --ink: #f4efe4;
  --muted: #b6bcb7;
  --gold: #e8d3a4;
  --rule: rgba(222, 211, 185, .18);
  --serif: 'Baskervville', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { background: #0a1114; }
body {
  margin: 0; min-height: 100svh; color: var(--ink); font-family: var(--sans);
  background: radial-gradient(ellipse at 50% 24%, #173034 0%, #0d1a1d 35%, transparent 66%),
              linear-gradient(145deg, #11191c, #090f12 68%, #15181a);
}
button, input { font: inherit; }
button, a { touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 3px;
}
a { color: var(--gold); text-underline-offset: .2em; }
header {
  min-height: 66px; padding: 0 clamp(18px, 4vw, 68px); display: flex; align-items: center;
  gap: 18px; border-bottom: 1px solid var(--rule); background: #0c1417a6;
}
.brand { color: #c7cbc5; font-size: .77rem; letter-spacing: .09em; text-decoration: none; font-weight: 620; }
.brand span { display: none; }
header strong { padding-left: 18px; border-left: 1px solid var(--rule); color: var(--ink); font: 1.68rem/1 var(--serif); letter-spacing: -.055em; }
#info { margin-left: auto; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); }
#info svg { width: 21px; height: 21px; }
main { width: min(100%, 740px); margin: 0 auto; padding: 0 clamp(16px, 4vw, 34px) 18px; }
.stage { position: relative; display: grid; justify-items: center; align-content: center; height: clamp(216px, 43svh, 450px); }
.halo { position: absolute; inset: 6% 2%; pointer-events: none; background: radial-gradient(ellipse at center,#5dc1bf13,transparent 64%); }
#orb { border: 0; background: transparent; border-radius: 50%; padding: 0; width: min(36svh, 75vw, 350px); aspect-ratio: 1; position: relative; }
canvas { width: 100%; height: 100%; display: block; }
#status { color: #b9c7c2; font: 500 .69rem/1.5 var(--sans); letter-spacing: .065em; text-align: center; }
.panel { width: 100%; }
h1 { font: 400 clamp(2.25rem, 5vw, 4rem)/1.1 var(--serif); letter-spacing: -.055em; text-align: center; margin: .24em 0 .45em; }
.choices { display: flex; justify-content: center; gap: .55rem; flex-wrap: wrap; margin-bottom: 26px; }
.choices button, .message-action, dialog button {
  background: #d7c79708; border: 1px solid var(--rule); border-radius: 25px;
  padding: 10px 15px; font: 500 .81rem/1.4 var(--sans); color: var(--gold); text-decoration: none;
}
.choices button:hover, .message-action:hover, dialog button:hover { border-color: #cdb78999; background: #e1c48b12; }
form { display: flex; align-items: center; gap: 3px; padding: 7px; background: #172325; border: 1px solid #747c70; border-radius: 30px; box-shadow: 0 8px 32px #05090b55; }
form:focus-within { border-color: #c7b68f; }
input { min-width: 0; flex: 1; padding: 9px 4px 9px 14px; background: transparent; color: var(--ink); border: 0; font-size: 16px; }
input:focus-visible { outline: 0; }
input::placeholder { color: #a8b2ac; }
form button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; }
svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
#voice { color: #d6dbd3; }
#send { color: #252619; background: linear-gradient(120deg,#f2e6c7,#d8c395); }
button:disabled { opacity: .5; cursor: progress; }
footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 8px; color: var(--muted); font-size: .71rem; }
footer a { color: #ccc5b5; text-decoration: none; }
.history { display: none; }
.started { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; }
.started main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: max(6px,env(safe-area-inset-bottom)); }
.started .stage { flex: none; height: clamp(100px, 20dvh, 172px); }
.started #orb { width: min(15dvh, 130px); }
.started h1, .started .choices { display: none; }
.started .panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.started .history {
  flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 19px;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: #55645d transparent;
  padding: 12px 5px 19px; border-top: 1px solid var(--rule);
}
.started form { margin-top: .6rem; flex: none; }
.message { flex: none; min-width: 0; max-width: min(96%, 64ch); overflow-wrap: anywhere; }
.message.assistant { padding: .3rem 0 .1rem clamp(12px,2vw,20px); border-left: 1px solid #b99f6c80; }
.message.mine { align-self: flex-end; max-width: 83%; background: #233536; padding: 10px 16px; border-radius: 17px 17px 4px 17px; }
.message p { margin: 0; color: var(--ink); font-size: clamp(.98rem, 1.3vw, 1.07rem); line-height: 1.56; white-space: pre-line; }
.message p + p { margin-top: .55em; }
.message.mine p { font-size: .93rem; }
.quote-scroll {
  max-width: 100%; overflow-x: auto; margin-block: 12px 5px;
  border: 1px solid var(--rule); border-radius: 10px;
  background: #132022; scrollbar-color: #667469 #162224;
}
.quote-scroll:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.quote-table {
  width: 100%; min-width: calc(var(--quote-cols) * 5em); border-collapse: collapse;
  text-align: left; font: .87rem/1.48 var(--sans); font-variant-numeric: tabular-nums;
}
.quote-table th, .quote-table td { padding: .6em .7em; vertical-align: top; }
.quote-table thead { background: #1d2a2a; color: var(--gold); }
.quote-table thead th { font-weight: 600; font-size: .95em; }
.quote-table tbody th { font-weight: 550; }
.quote-table tbody tr + tr, .quote-table tfoot { border-top: 1px solid var(--rule); }
.quote-table tfoot { color: var(--gold); background: #1a2424; font-weight: 600; }
.message .actions { margin-top: 10px; display: flex; gap: 5px; flex-wrap: wrap; }
.message details { margin-top: 8px; font-size: .76rem; color: var(--muted); }
.message summary { cursor: pointer; width: fit-content; padding: 5px 0; color: #dac69e; }
.message summary::marker { color: #ad996d; }
.message details ul { padding: 0; margin: 4px 0; list-style: none; }
.message details a { display: inline-block; padding: 5px 0; line-height: 1.45; color: #d5dbd2; }
dialog { max-width: min(460px,92vw); max-height: 80dvh; background: #152023; color: var(--ink); border: 1px solid #6d695d; border-radius: 20px; padding: clamp(20px,4vw,34px); line-height: 1.55; }
dialog::backdrop { background: #050a0cbb; }
dialog h2 { font: 2rem/1.1 var(--serif); margin: 0; }
.wait-audio { display: flex; align-items: center; gap: .65em; margin-block: .75rem; min-height: 44px; }
.wait-audio input { flex: none; width: 18px; height: 18px; accent-color: var(--gold); }
.wait-audio input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
body[data-state=waiting] #status { max-width: 38em; text-wrap: balance; color: var(--gold); }
body[data-state=listening] #voice { background: #284942; }
body[data-state=speaking] #voice { background: #473e37; }
@media(max-width:600px) {
  header { min-height: 52px; gap: 13px; }
  header strong { padding-left: 13px; font-size: 1.45rem; }
  .started .stage { height: clamp(95px, 17dvh, 140px); }
  .started[data-state=waiting] .stage { min-height: 110px; }
  .started #orb { width: min(13dvh,105px); }
  .started .history { gap: 15px; }
}
@media(max-height:550px) {
  .stage, .started .stage { height: 100px; }
  #orb, .started #orb { width: 77px; }
}
@media(max-width:759px) {
  body[data-keyboard].started { height: var(--estetiq-visible-height); }
  body[data-keyboard] header { min-height: 40px; }
  body[data-keyboard] .stage { height: clamp(54px, 17dvh, 78px); }
  body[data-keyboard][data-state=waiting] .stage { min-height: 86px; }
  body[data-keyboard] #orb { width: 50px; }
  body[data-keyboard] .choices { margin-bottom: 8px; }
  body[data-keyboard] footer { padding-block: 4px; }
}
@media(prefers-reduced-motion:no-preference) {
  body[data-state=waiting] #sphere { animation: estetiq-breathe 5.6s ease-in-out infinite; }
  @keyframes estetiq-breathe {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.13); }
    75% { transform: scale(.90); }
  }
  .message { animation: arrive .23s ease-out; }
  @keyframes arrive { from { opacity: .25; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
