:root {
  color-scheme: light;
  --ink: #28231f;
  --muted: #81766d;
  --paper: rgba(255, 252, 247, .86);
  --line: rgba(75, 57, 43, .13);
  --rose: #a85f68;
  --rose-dark: #80444e;
  --jade: #577b70;
  --shadow: 0 24px 70px rgba(66, 48, 37, .13);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  min-height: 100%;
  background: #eaf0ec;
}
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 18% -8%, rgba(224,190,190,.58), transparent 38%),
    radial-gradient(circle at 92% 105%, rgba(184,210,201,.48), transparent 34%),
    linear-gradient(145deg, #eee9e2, #faf7f1 55%, #eaf0ec);
  overflow-x: hidden;
}
.ambient { position: fixed; border-radius: 50%; filter: blur(8px); opacity: .22; pointer-events: none; }
.ambient-one { width: 460px; height: 460px; right: -180px; top: -180px; background: radial-gradient(circle, #d8a9ae, transparent 68%); }
.ambient-two { width: 360px; height: 360px; left: -140px; bottom: -130px; background: radial-gradient(circle, #9ebfb3, transparent 68%); }
.login-gate { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(239,233,224,.78); backdrop-filter: blur(18px); }
.login-card { width: min(460px, 100%); padding: 34px; border: 1px solid rgba(255,255,255,.8); border-radius: 28px; background: rgba(255,252,247,.94); box-shadow: var(--shadow); text-align: center; }
.login-card .brand-mark { margin: 0 auto 16px; }
.login-card h1 { margin: 9px 0 13px; font-size: 25px; }
.login-card p { color: var(--muted); line-height: 1.7; font-size: 13px; }
.login-form { display: grid; gap: 9px; margin: 23px 0 12px; text-align: left; }
.login-form label { color: var(--muted); font-size: 12px; }
.login-form input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; outline: none; color: var(--ink); background: white; font: inherit; }
.login-form input:focus { border-color: rgba(168,95,104,.55); box-shadow: 0 0 0 4px rgba(168,95,104,.08); }
.login-primary { min-height: 48px; margin-top: 4px; }
.login-card > .ghost { width: 100%; }
.audio-entry-card > .send { width: 100%; }
.login-error { min-height: 20px; margin: 10px 0 0 !important; color: #a1545c !important; }
.shell { position: relative; width: min(1420px, 100%); min-height: 100vh; margin: 0 auto; padding: 20px clamp(22px, 4vw, 62px) 30px; }
.profile-notice { position: fixed; z-index: 15; top: 14px; left: 50%; max-width: min(92vw, 560px); padding: 11px 16px; transform: translateX(-50%); border: 1px solid rgba(87,123,112,.24); border-radius: 14px; color: var(--ink); background: rgba(244,250,247,.96); box-shadow: 0 12px 35px rgba(60,45,35,.14); cursor: pointer; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid rgba(128,68,78,.18); border-radius: 15px; overflow: hidden; background: rgba(255,255,255,.55); box-shadow: 0 8px 30px rgba(128,68,78,.1); }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .08em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.mobile-menu { position: relative; display: none; }
.mobile-menu-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0 0 5px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255,255,255,.56);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mobile-menu-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  width: 148px;
  overflow: hidden;
  border: 1px solid rgba(75,57,43,.13);
  border-radius: 14px;
  background: rgba(255,252,247,.98);
  box-shadow: 0 18px 46px rgba(58,42,34,.18);
  backdrop-filter: blur(18px);
}
.mobile-menu-panel button {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.mobile-menu-panel button + button { border-top: 1px solid var(--line); }
.mobile-menu-panel button:active { background: rgba(168,95,104,.08); }
.profile-label { max-width: 130px; overflow: hidden; color: var(--jade); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: #bc8c64; box-shadow: 0 0 0 4px rgba(188,140,100,.12); }
.status.online i { background: #5f9177; box-shadow: 0 0 0 4px rgba(95,145,119,.13); }
button { font: inherit; }
.ghost, .icon-button { border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.48); cursor: pointer; transition: .18s ease; }
.ghost { padding: 9px 13px; border-radius: 12px; }
.ghost:hover, .icon-button:hover { transform: translateY(-1px); background: rgba(255,255,255,.86); }
.ghost.danger { color: #98535b; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; height: calc(100vh - 112px); min-height: 620px; }
.workspace.lab-open { grid-template-columns: minmax(480px, 1fr) minmax(390px, .72fr); }
.conversation-card { position: relative; isolation: isolate; min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; overflow: hidden; border: 0; border-radius: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
.lab-panel { border: 1px solid rgba(255,255,255,.68); background: rgba(255,252,247,.76); backdrop-filter: blur(24px); box-shadow: 0 20px 60px rgba(66,48,37,.10); }
.mobile-stage { display: none; }
.scene-head { display: flex; align-items: end; justify-content: space-between; padding: 22px 6px 15px; border-bottom: 1px solid rgba(75,57,43,.07); }
.eyebrow { color: var(--rose); font-size: 10px; text-transform: uppercase; letter-spacing: .22em; }
h1, h2 { margin: 5px 0 0; font-family: "Songti SC", "Noto Serif SC", serif; font-weight: 600; }
h1 { font-size: clamp(21px, 2.1vw, 29px); }
h2 { font-size: 21px; }
.cue-chip { padding: 7px 10px; border-radius: 999px; background: #eee8de; color: #796d64; font: 11px ui-monospace, monospace; }
.dialogue { overflow: auto; padding: 30px clamp(6px, 3vw, 42px); scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: rgba(128,68,78,.16) transparent; }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; }
.message { display: flex; margin: 0 0 25px; animation: enter .28s ease both; }
.message.user { justify-content: flex-end; }
.bubble { position: relative; max-width: min(78%, 760px); padding: 13px 17px; border-radius: 18px; line-height: 1.78; white-space: pre-wrap; }
.assistant .bubble { padding: 9px 2px 11px; border: 0; border-radius: 0; color: #302a26; background: transparent; font: 500 17px/1.86 "Songti SC", "Noto Serif SC", serif; text-shadow: 0 1px 15px rgba(255,255,255,.72); }
.user .bubble { color: #fff; background: linear-gradient(135deg, rgba(169,95,105,.91), rgba(141,76,87,.91)); border-top-right-radius: 6px; box-shadow: 0 8px 24px rgba(142,77,87,.12); }
.speaker { display: block; margin-bottom: 5px; color: var(--rose); font-size: 11px; letter-spacing: .1em; }
.user .speaker { color: rgba(255,255,255,.72); text-align: right; }
.message:not(.complete) .bubble::after { content: ""; display: inline-block; width: 5px; height: 14px; margin-left: 4px; vertical-align: -2px; background: var(--rose); animation: blink .8s infinite; }
.composer { display: flex; gap: 11px; margin: 0 2px 13px; padding: 9px; border: 1px solid rgba(75,57,43,.10); border-radius: 20px; background: rgba(255,252,247,.52); box-shadow: 0 8px 28px rgba(60,45,35,.045); backdrop-filter: blur(15px); }
.input-mode-toggle { display: none; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: rgba(255,255,255,.72); cursor: pointer; }
.talk {
  align-self: stretch;
  min-width: 112px;
  border: 1px solid rgba(87,123,112,.28);
  border-radius: 15px;
  background: rgba(255,255,255,.68);
  color: var(--jade);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  touch-action: none;
  /* Mobile browsers otherwise interpret push-to-talk as text selection or a
     long-press callout.  Scope this to the control so dialogue stays copyable. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
.talk * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}
.talk:not(:disabled):hover { transform: translateY(-1px); }
.talk.recording { background: var(--rose); color: white; border-color: var(--rose); }
.talk:disabled { cursor: not-allowed; opacity: .42; }
.interaction-dock { position: relative; min-width: 0; }
.asr-caption { margin: 0 2px 10px; padding: 10px 13px; border-radius: 12px; background: rgba(87,123,112,.07); color: var(--ink); font-size: .92rem; pointer-events: none; user-select: none; -webkit-user-select: none; }
.asr-caption span { color: var(--jade); margin-right: 10px; font-size: .78rem; }
.asr-caption strong { font-weight: 500; }
.asr-caption small { display: block; margin-top: 7px; color: var(--muted); font-size: .7rem; }
.input-level { display: block; overflow: hidden; width: 100%; height: 3px; margin-top: 7px; border-radius: 4px; background: rgba(87,123,112,.13); }
.input-level b { display: block; width: 0; height: 100%; background: var(--jade); transition: width .06s linear; }
textarea { flex: 1; min-height: 52px; max-height: 150px; resize: none; border: 0; outline: 0; padding: 10px 9px; color: var(--ink); background: transparent; font: inherit; line-height: 1.5; }
.send { align-self: stretch; min-width: 92px; border: 0; border-radius: 14px; color: white; background: linear-gradient(145deg, var(--rose), var(--rose-dark)); cursor: pointer; }
.send b { margin-left: 7px; font-size: 16px; }
.send:disabled { opacity: .45; cursor: wait; }
.footer-line { display: flex; justify-content: space-between; gap: 12px; padding: 0 5px 10px; color: var(--muted); font-size: 11px; opacity: .76; }
.lab-panel { display: none; overflow-y: auto; border-radius: 25px; padding: 23px; }
.lab-open .lab-panel { display: block; }
.lab-head { display: flex; justify-content: space-between; align-items: start; }
.icon-button { width: 34px; height: 34px; border-radius: 50%; font-size: 21px; }
.lab-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.lab-section h3 { margin: 0 0 13px; font-size: 13px; letter-spacing: .05em; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.facts div { min-width: 0; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.6); }
.facts dt { color: var(--muted); font-size: 10px; }
.facts dd { overflow-wrap: anywhere; margin: 5px 0 0; font: 11px/1.45 ui-monospace, monospace; }
.field-cards { display: grid; gap: 7px; margin-bottom: 10px; }
.field-card { padding: 9px 11px; border-radius: 11px; background: rgba(87,123,112,.08); }
.field-card strong { display: block; color: var(--jade); font: 11px ui-monospace, monospace; }
.field-card span { color: var(--muted); font-size: 11px; line-height: 1.45; }
details { margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.55); }
summary { padding: 10px 12px; cursor: pointer; font-size: 12px; }
pre { overflow: auto; max-height: 420px; margin: 0; padding: 12px; border-top: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font: 10.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.prompt-meta { padding: 0 12px 10px; color: var(--muted); font-size: 10px; }
.warnings { margin: 0; padding-left: 20px; color: #a1545c; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 980px) {
  .workspace.lab-open { grid-template-columns: 1fr; height: auto; }
  .workspace.lab-open .conversation-card { min-height: 72vh; }
  .lab-panel { max-height: none; }
}
@media (max-width: 620px) {
  html { width: 100%; height: 100%; min-height: 0; background-color: #eaf0ec; }
  body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background-color: #eaf0ec;
    overscroll-behavior: none;
  }
  .shell {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: max(7px, env(safe-area-inset-top)) 9px max(7px, env(safe-area-inset-bottom));
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .topbar { height: 58px; padding: 0 3px 8px; align-items: center; flex: 0 0 58px; }
  .brand { gap: 10px; }
  .brand .brand-mark { width: 40px; height: 40px; border-radius: 14px; }
  .brand strong { font-size: 15px; }
  .brand small, .status { display: none; }
  .profile-label { display: block; max-width: 86px; font-size: 13px; }
  #switchProfile { display: none; }
  #modeButton { display: none; }
  #resetButton { display: none; }
  .mobile-menu { display: block; }
  .mobile-menu-button { width: 42px; height: 42px; border-radius: 14px; font-size: 21px; }
  .mobile-menu-panel { width: 158px; }
  .mobile-menu-panel button { padding: 15px 17px; font-size: 14px; }
  .ghost { padding: 8px 9px; font-size: 12px; }
  .workspace { height: auto; min-height: 0; flex: 1 1 auto; }
  .conversation-card {
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }
  .scene-head, .dialogue { display: none; }
  .mobile-stage {
    display: flex;
    min-width: 0;
    min-height: 0;
    padding: clamp(18px, 4.5vh, 40px) 20px 14px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  .mobile-stage-copy { width: min(100%, 460px); }
  .mobile-stage-speaker {
    display: block;
    margin-bottom: 16px;
    color: var(--rose);
    font: 12px/1.2 "PingFang SC", sans-serif;
    letter-spacing: .24em;
  }
  .mobile-stage-text {
    margin: 0;
    color: #332b27;
    font: 550 clamp(24px, 6.55vw, 27px)/1.62 "Songti SC", "Noto Serif SC", serif;
    text-wrap: pretty;
    text-shadow: 0 1px 12px rgba(255,255,255,.94), 0 0 28px rgba(255,252,247,.88);
    transition: opacity .18s ease, transform .28s ease, font-size .2s ease;
  }
  .mobile-stage-text.medium { font-size: clamp(24px, 6.55vw, 27px); line-height: 1.62; }
  .mobile-stage-text.long { font-size: clamp(19px, 5vw, 21px); line-height: 1.54; }
  .mobile-stage-addition {
    position: relative;
    white-space: pre-wrap;
    animation: stage-text-addition .48s cubic-bezier(.22,.7,.28,1) both;
  }
  .mobile-stage-text.turn-enter { animation: stage-turn-enter .42s ease both; }
  .mobile-stage-status {
    display: inline-flex;
    min-height: 25px;
    margin-top: 24px;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: .04em;
  }
  .mobile-stage-status i { width: 7px; height: 7px; border-radius: 50%; background: #8ca298; box-shadow: 0 0 0 6px rgba(87,123,112,.08); }
  .mobile-stage.thinking .mobile-stage-text { opacity: .62; }
  .mobile-stage.thinking .mobile-stage-status i { animation: stage-breathe 1.25s ease-in-out infinite; }
  .mobile-stage.speaking .mobile-stage-status i { background: var(--rose); animation: stage-breathe .85s ease-in-out infinite; }
  .mobile-stage.listening .mobile-stage-status i { background: var(--jade); animation: stage-breathe .62s ease-in-out infinite; }
  .composer {
    min-height: 72px;
    margin: 0 5px 8px;
    padding: 8px;
    border-color: rgba(75,57,43,.09);
    border-radius: 22px;
    background: rgba(255,252,247,.48);
    box-shadow: 0 8px 28px rgba(60,45,35,.045);
    backdrop-filter: blur(13px);
  }
  .asr-caption {
    position: absolute;
    z-index: 5;
    right: 5px;
    bottom: calc(100% - 3px);
    left: 5px;
    min-width: 0;
    min-height: 46px;
    max-height: 64px;
    margin: 0;
    padding: 9px 12px 8px;
    overflow: hidden;
    border: 0;
    border-radius: 18px 18px 9px 9px;
    background: rgba(250,248,243,.88);
    box-shadow: 0 -10px 28px rgba(60,45,35,.055);
    backdrop-filter: blur(16px);
  }
  .asr-caption span { display: block; margin: 0 0 2px; font-size: 11px; }
  .asr-caption strong { display: block; overflow: hidden; font-size: 15px; line-height: 1.38; text-overflow: ellipsis; white-space: nowrap; }
  .asr-caption.live-recognition {
    min-height: 62px;
    max-height: 90px;
    padding: 10px 13px 9px;
  }
  .asr-caption.live-recognition strong {
    display: -webkit-box;
    overflow: hidden;
    font-size: 19px;
    line-height: 1.42;
    text-overflow: clip;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .asr-caption small { display: none; }
  .asr-caption .input-level { margin-top: 5px; }
  .input-mode-toggle { display: block; flex: 0 0 64px; min-height: 60px; padding: 7px; font-size: 13px; }
  .composer.voice-mode textarea, .composer.voice-mode .send { display: none; }
  .composer.voice-mode .talk { flex: 1; min-height: 68px; font-size: 18px; }
  .composer.text-mode .talk { display: none; }
  textarea { min-height: 58px; font-size: 16px; }
  .send { min-width: 72px; }
  .send span { display: none; }
  .footer-line { display: none; }
}
@media (max-width: 620px) and (display-mode: standalone) {
  /*
   * Keep application content at the normal standalone viewport height.  The
   * root background paints the system safe areas; only the existing .shell
   * padding protects controls from the Home Indicator.  Do not enlarge the
   * layout here, otherwise the voice controls move while the iOS compositor's
   * unpainted strip remains unchanged.
   */
  html, body {
    width: 100%;
    height: 100%;
    min-height: 0;
    background-color: #eaf0ec;
  }
  .shell {
    height: 100%;
    min-height: 0;
  }
}
@keyframes stage-turn-enter { from { opacity: 0; transform: translateY(7px); } }
@keyframes stage-text-addition {
  from { top: .2em; opacity: 0; filter: blur(.7px); }
  to { top: 0; opacity: 1; filter: blur(0); }
}
@keyframes stage-breathe { 50% { opacity: .38; transform: scale(.72); } }
