/* =========================================================
   共声 RESONA — a character chat prototype
   Design language: ink, warm paper, cinnabar, quiet signals
   ========================================================= */

:root {
  --bg: #0b0e0c;
  --bg-2: #101410;
  --panel: #141914;
  --panel-2: #191f19;
  --panel-3: #20271f;
  --ink: #f2eadc;
  --ink-2: #d6cec0;
  --ink-3: #b6afa2;
  --muted: #929387;
  --faint: #707369;
  --line: rgba(238, 228, 211, 0.085);
  --line-2: rgba(238, 228, 211, 0.15);
  --line-3: rgba(238, 228, 211, 0.24);
  --accent: #d97757;
  --accent-strong: #ea8d69;
  --accent-soft: rgba(217, 119, 87, 0.12);
  --accent-line: rgba(217, 119, 87, 0.36);
  --sage: #9fb7a6;
  --danger: #df7868;
  --danger-soft: rgba(223, 120, 104, 0.11);
  --bubble: rgba(233, 222, 202, 0.62);
  --bubble-ink: #211b14;
  --ambient: #445a4c;
  --chat-pad: clamp(20px, 4vw, 46px);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", "Times New Roman", serif;
  --sans: "Aptos", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Consolas", monospace;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.48), 0 2px 10px rgba(0, 0, 0, 0.24);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

*::selection {
  color: #1e1711;
  background: rgba(230, 173, 126, 0.85);
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  content: "";
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--accent);
}

h1,
h2,
h3,
h4,
p,
blockquote {
  margin: 0;
}

svg {
  display: block;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

[data-icon] > svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

::placeholder {
  color: var(--faint);
  opacity: 1;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(238, 228, 211, 0.16) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(238, 228, 211, 0.13);
  border: 2px solid transparent;
  border-radius: 99px;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(238, 228, 211, 0.24);
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* =========================
   App frame
   ========================= */

.app {
  display: grid;
  grid-template-columns: 308px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(23, 29, 23, 0.98) 0%, rgba(14, 18, 14, 0.99) 64%, #0d110d 100%);
  border-right: 1px solid var(--line);
}

.sidebar::after {
  position: absolute;
  top: 0;
  right: -1px;
  width: 1px;
  height: 100%;
  pointer-events: none;
  content: "";
  background: linear-gradient(180deg, rgba(217, 119, 87, 0.2), transparent 27%, transparent 75%, rgba(159, 183, 166, 0.08));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 25px 21px 21px;
}

.brand-mark {
  display: grid;
  width: 41px;
  height: 41px;
  color: var(--accent-strong);
  place-items: center;
  border: 1px solid rgba(217, 119, 87, 0.24);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, rgba(217, 119, 87, 0.15), transparent 65%);
}

.brand-mark svg {
  width: 33px;
  height: 33px;
}

.brand-type {
  min-width: 0;
}

.brand-name {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.12em;
}

.brand-dot {
  color: var(--accent);
  letter-spacing: 0;
}

.brand-en {
  margin-top: 6px;
  color: var(--faint);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.42em;
}

.icon-btn.sidebar-close {
  display: none;
  margin-left: auto;
}

.library-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 3px;
}

.new-character {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  height: 50px;
  padding: 0 13px;
  color: var(--ink-2);
  text-align: left;
  background: linear-gradient(120deg, rgba(217, 119, 87, 0.08), rgba(255, 255, 255, 0.018));
  border: 1px dashed var(--line-3);
  border-radius: 13px;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.new-character:hover {
  color: var(--ink);
  background: linear-gradient(120deg, rgba(217, 119, 87, 0.14), rgba(255, 255, 255, 0.025));
  border-color: rgba(217, 119, 87, 0.5);
}

.new-character-icon {
  display: grid;
  width: 25px;
  height: 25px;
  color: var(--accent-strong);
  border: 1px solid rgba(217, 119, 87, 0.3);
  border-radius: 50%;
  place-items: center;
}

.new-character-icon svg {
  width: 14px;
  height: 14px;
}

.new-character > span:nth-child(2) {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.new-character-kicker {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.16em;
}

.library-actions > .icon-btn {
  width: 50px;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.018);
}

.library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 21px 9px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.library-count {
  display: inline-grid;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 99px;
}

.character-list {
  flex: 1;
  min-height: 0;
  padding: 2px 10px 18px;
  overflow: auto;
}

.character-item {
  position: relative;
  display: flex;
  gap: 11px;
  align-items: center;
  width: 100%;
  padding: 10px 11px;
  margin-bottom: 2px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 14px;
  transition: background 170ms ease, border-color 170ms ease, transform 170ms ease;
}

.character-item:hover {
  background: rgba(255, 255, 255, 0.032);
}

.character-item.is-active {
  background: linear-gradient(110deg, rgba(238, 228, 211, 0.065), rgba(238, 228, 211, 0.025));
  border-color: var(--line);
}

.character-item.is-active::before {
  position: absolute;
  top: 50%;
  left: 0;
  width: 2px;
  height: 22px;
  content: "";
  background: var(--accent);
  border-radius: 99px;
  transform: translateY(-50%);
  box-shadow: 0 0 12px rgba(217, 119, 87, 0.55);
}

.char-copy {
  min-width: 0;
  flex: 1;
}

.char-name {
  display: flex;
  gap: 7px;
  align-items: baseline;
  min-width: 0;
}

.char-name strong {
  overflow: hidden;
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-item.is-active .char-name strong {
  color: var(--ink);
}

.char-name em {
  overflow: hidden;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7.5px;
  font-style: normal;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.char-tagline {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--faint);
  font-size: 10.8px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.char-active-dot {
  flex: none;
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(217, 119, 87, 0.7);
}

.char-list-empty {
  padding: 24px 12px;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.8;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.sidebar-quote {
  flex: none;
  padding: 16px 21px 18px;
  margin: 0 8px;
  border-top: 1px solid var(--line);
}

.quote-index {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.15em;
}

.sidebar-quote p {
  margin-top: 8px;
  color: rgba(214, 206, 192, 0.42);
  font-family: var(--serif);
  font-size: 11.5px;
  line-height: 1.9;
  letter-spacing: 0.06em;
}

.sidebar-tail {
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.16));
}

.privacy-line {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 0 7px 10px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.privacy-dot {
  width: 4px;
  height: 4px;
  background: var(--sage);
  border-radius: 50%;
  box-shadow: 0 0 7px rgba(159, 183, 166, 0.45);
}

.install-home {
  display: flex;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 8px;
  text-align: left;
  background: linear-gradient(115deg, rgba(217, 119, 87, 0.085), rgba(255, 255, 255, 0.018));
  border: 1px solid rgba(217, 119, 87, 0.15);
  border-radius: 12px;
  transition: border-color 170ms ease, background 170ms ease;
}

.install-home:hover {
  background: linear-gradient(115deg, rgba(217, 119, 87, 0.13), rgba(255, 255, 255, 0.025));
  border-color: rgba(217, 119, 87, 0.3);
}

.install-home-icon {
  display: grid;
  flex: none;
  width: 30px;
  height: 30px;
  color: var(--accent-strong);
  background: rgba(217, 119, 87, 0.1);
  border-radius: 8px;
  place-items: center;
}

.install-home-icon svg {
  width: 15px;
  height: 15px;
}

.install-home-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.install-home-copy strong {
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
}

.install-home-copy small {
  margin-top: 2px;
  overflow: hidden;
  color: var(--faint);
  font-size: 8.8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.install-home-arrow {
  flex: none;
  color: var(--faint);
}

.install-home-arrow svg {
  width: 12px;
  height: 12px;
}

.settings-entry {
  display: flex;
  gap: 11px;
  align-items: center;
  width: 100%;
  padding: 10px;
  text-align: left;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: background 170ms ease, border-color 170ms ease;
}

.settings-entry:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line-2);
}

.settings-entry > .settings-icon {
  display: grid;
  width: 31px;
  height: 31px;
  color: var(--ink-3);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 9px;
  place-items: center;
}

.settings-entry > .settings-icon svg {
  width: 16px;
  height: 16px;
}

.settings-label {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.settings-label strong {
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
}

.settings-label small {
  margin-top: 2px;
  overflow: hidden;
  color: var(--faint);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-entry > [data-icon] {
  color: var(--faint);
}

.settings-entry > [data-icon] svg {
  width: 13px;
  height: 13px;
}

/* =========================
   Portraits
   ========================= */

.portrait {
  --pa: #202c25;
  --pb: #4a5f50;
  --pc: #d9c7a7;
  position: relative;
  display: grid;
  flex: none;
  overflow: hidden;
  color: var(--pc);
  background: linear-gradient(145deg, var(--pa) 0%, var(--pb) 115%);
  border-radius: 35%;
  isolation: isolate;
  place-items: center;
}

.portrait::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.15), transparent 42%),
    linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.18));
}

.portrait::after {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.portrait-art {
  position: absolute;
  inset: 0;
  z-index: 0;
  color: var(--pc);
  opacity: 0.38;
  transform: scale(1.05);
}

.portrait-art svg {
  width: 100%;
  height: 100%;
}

.portrait-letter {
  position: relative;
  z-index: 2;
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.34);
}

.portrait > img {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait.has-image .portrait-letter {
  display: none;
}

.portrait.has-image .portrait-art {
  opacity: 0.12;
}

.p-xs {
  width: 27px;
  height: 27px;
  font-size: 11px;
}

.p-sm {
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.p-md {
  width: 44px;
  height: 44px;
  font-size: 17px;
}

.p-lg {
  width: 68px;
  height: 68px;
  font-size: 25px;
}

.p-xl {
  width: 94px;
  height: 94px;
  font-size: 33px;
}

.p-hero {
  width: 116px;
  height: 116px;
  font-size: 40px;
}

/* =========================
   Main / header
   ========================= */

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(70% 55% at 88% 0%, rgba(255, 255, 255, 0.025), transparent 70%),
    var(--bg);
}

.main::before {
  position: absolute;
  top: -34%;
  right: -12%;
  z-index: 0;
  width: 72vw;
  height: 76vh;
  pointer-events: none;
  content: "";
  background: radial-gradient(ellipse at center, var(--ambient) 0%, transparent 63%);
  opacity: 0.19;
  filter: blur(20px);
  transition: background 600ms ease;
}

.main.has-chat-bg {
  background-color: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(8, 11, 9, 0.16), rgba(8, 11, 9, 0.34)),
    radial-gradient(ellipse at center, transparent 42%, rgba(8, 11, 9, 0.28) 100%),
    var(--chat-bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.main.has-chat-bg::before {
  display: none;
}

.main.has-chat-bg .chat-header {
  background: linear-gradient(180deg, rgba(7, 10, 8, 0.3), rgba(7, 10, 8, 0.12));
  border-bottom-color: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(22px) saturate(120%);
}

.main.has-chat-bg .chat-header .header-name-line h2,
.main.has-chat-bg .chat-header .header-sub,
.main.has-chat-bg .chat-header .header-roman {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 16px rgba(0, 0, 0, 0.45);
}

.chat-header {
  position: relative;
  z-index: 14;
  display: flex;
  gap: 13px;
  align-items: center;
  min-height: 76px;
  padding: 12px clamp(18px, 3.2vw, 38px);
  background: rgba(11, 14, 12, 0.66);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(120%);
}

.chat-header .header-mobile {
  display: none;
}

.header-portrait {
  flex: none;
}

.header-copy {
  min-width: 0;
  flex: 1;
}

.header-name-line {
  display: flex;
  gap: 9px;
  align-items: baseline;
  min-width: 0;
}

.header-name-line h2 {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.07em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-roman {
  overflow: hidden;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.13em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-sub {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-sub .live-dot {
  flex: none;
  width: 5px;
  height: 5px;
  background: var(--sage);
  border-radius: 50%;
  box-shadow: 0 0 7px rgba(159, 183, 166, 0.5);
}

.header-sub .sub-sep {
  color: var(--faint);
}

.header-sub .voice-name {
  color: var(--faint);
}

.header-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-left: auto;
}

.icon-btn {
  display: inline-grid;
  width: 37px;
  height: 37px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  place-items: center;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.icon-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.voice-toggle.is-on {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: rgba(217, 119, 87, 0.2);
}

.voice-toggle.is-on:hover {
  color: var(--accent-strong);
  border-color: rgba(217, 119, 87, 0.4);
}

.more-wrap {
  position: relative;
}

.more-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 40;
  width: 203px;
  padding: 6px;
  background: #1a201a;
  border: 1px solid var(--line-2);
  border-radius: 13px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.48);
  animation: menu-in 140ms var(--ease);
}

.menu-item {
  display: flex;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  color: var(--ink-3);
  font-size: 11.5px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.menu-item:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.menu-item [data-icon] svg {
  width: 14px;
  height: 14px;
}

.menu-item.danger {
  color: #d99386;
}

.menu-item.danger:hover {
  color: #f0a596;
  background: rgba(223, 120, 104, 0.08);
}

.menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--line);
}

.header-voice-live {
  display: none;
  gap: 2px;
  align-items: center;
  height: 16px;
  margin-left: 2px;
}

.header-voice-live.is-live {
  display: flex;
}

.header-voice-live i {
  width: 2px;
  height: 6px;
  background: var(--accent);
  border-radius: 99px;
  animation: eq 900ms ease-in-out infinite;
}

.header-voice-live i:nth-child(2) {
  height: 12px;
  animation-delay: 120ms;
}

.header-voice-live i:nth-child(3) {
  height: 8px;
  animation-delay: 240ms;
}

/* =========================
   Chat
   ========================= */

.chat-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.chat-stage.has-chat-bg .scene-text,
.chat-stage.has-chat-bg .scene-kicker,
.chat-stage.has-chat-bg .scene-meta,
.chat-stage.has-chat-bg .message-name,
.chat-stage.has-chat-bg .message-time,
.chat-stage.has-chat-bg .date-divider span,
.chat-stage.has-chat-bg .msg-action,
.chat-stage.has-chat-bg .typing-line,
.chat-stage.has-chat-bg .model-hint {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 14px rgba(0, 0, 0, 0.55);
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-content {
  width: 100%;
  max-width: calc(880px + var(--chat-pad) * 2);
  min-height: 100%;
  padding: 27px var(--chat-pad) 8px;
  margin: 0 auto;
}

.scene-intro {
  position: relative;
  padding: 21px 4px 28px;
  text-align: center;
}

.scene-kicker {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.scene-kicker::before,
.scene-kicker::after {
  width: 25px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--line-3));
}

.scene-kicker::after {
  background: linear-gradient(90deg, var(--line-3), transparent);
}

.scene-text {
  max-width: 590px;
  margin: 13px auto 0;
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.95;
  letter-spacing: 0.025em;
}

.scene-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.scene-meta .dot {
  width: 3px;
  height: 3px;
  background: var(--faint);
  border-radius: 50%;
  opacity: 0.7;
}

.date-divider {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 11px 0 29px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.date-divider::before,
.date-divider::after {
  height: 1px;
  content: "";
  background: var(--line);
}

.date-divider::before {
  width: 30px;
}

.date-divider::after {
  flex: 1;
}

.message {
  position: relative;
  display: flex;
  gap: 13px;
  max-width: 100%;
  margin-bottom: 14px;
}

.message-avatar {
  flex: none;
  padding-top: 1px;
}

.message-body {
  min-width: 0;
  max-width: min(700px, calc(100% - 48px));
}

.message-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.07em;
}

.message-author {
  color: var(--ink-3);
  font-family: var(--serif);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.message-time {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.03em;
}

.demo-tag {
  padding: 1px 5px;
  color: rgba(234, 141, 105, 0.8);
  font-size: 7px;
  line-height: 1.4;
  letter-spacing: 0.08em;
  background: rgba(217, 119, 87, 0.07);
  border: 1px solid rgba(217, 119, 87, 0.13);
  border-radius: 99px;
}

.demo-tag.proactive-tag {
  color: rgba(159, 183, 166, 0.85);
  background: rgba(159, 183, 166, 0.07);
  border-color: rgba(159, 183, 166, 0.16);
}

.message-text {
  position: relative;
  width: fit-content;
  max-width: 100%;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.3;
  letter-spacing: 0.012em;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-character .message-text {
  padding: 7px 11px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 12px rgba(0, 0, 0, 0.3);
  background: rgba(17, 23, 19, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px 16px 16px 16px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px) saturate(118%);
  -webkit-backdrop-filter: blur(10px) saturate(118%);
}

.message-character .message-text::before {
  position: absolute;
  top: 12px;
  left: -5px;
  content: "";
  border: 5px solid transparent;
  border-right-color: rgba(17, 23, 19, 0.42);
  border-left: 0;
}

.message-avatar-user {
  display: grid;
  width: 32px;
  height: 32px;
  color: rgba(238, 232, 219, 0.78);
  font-size: 10px;
  background: linear-gradient(145deg, rgba(217, 119, 87, 0.22), rgba(255, 255, 255, 0.035));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  place-items: center;
}

.message-avatar-user span {
  transform: translateY(-0.5px);
}

.message-text .stage-line {
  display: block;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.message-text .stage-line + span,
.message-text .dialogue-line {
  display: block;
}

.message-text strong {
  color: var(--ink);
  font-weight: 600;
}

.message-text code {
  padding: 1px 4px;
  color: #e2b99b;
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.message-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  height: 16px;
  margin-top: 2px;
  opacity: 0.42;
  transform: translateY(0);
  transition: opacity 160ms ease;
}

.message:hover .message-actions,
.message:focus-within .message-actions,
.message.is-speaking .message-actions {
  opacity: 1;
}

.msg-action {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 2px 0;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.04em;
  background: transparent;
  border: 0;
}

.msg-action:hover {
  color: var(--ink-3);
}

.msg-action [data-icon] svg {
  width: 12px;
  height: 12px;
}

.msg-action.is-active {
  color: var(--accent-strong);
}

.wave-icon {
  display: inline-flex;
  gap: 1.5px;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
}

.wave-icon i {
  display: block;
  width: 1.5px;
  height: 4px;
  background: currentColor;
  border-radius: 99px;
}

.wave-icon i:nth-child(2) {
  height: 9px;
}

.wave-icon i:nth-child(3) {
  height: 6px;
}

.is-speaking .wave-icon i {
  animation: wave 760ms ease-in-out infinite;
}

.is-speaking .wave-icon i:nth-child(2) {
  animation-delay: 110ms;
}

.is-speaking .wave-icon i:nth-child(3) {
  animation-delay: 220ms;
}

.message-user {
  justify-content: flex-end;
  margin-top: 9px;
  margin-bottom: 13px;
}

.message-user .message-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: min(620px, calc(100% - 48px));
}

.message-user .message-text {
  padding: 7px 11px;
  color: var(--bubble-ink);
  font-size: 14.5px;
  line-height: 1.3;
  background: var(--bubble);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px 16px 5px 16px;
  box-shadow: 0 7px 28px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px) saturate(112%);
  -webkit-backdrop-filter: blur(10px) saturate(112%);
}

.message-user .message-text::before {
  position: absolute;
  right: -5px;
  bottom: 12px;
  content: "";
  border: 5px solid transparent;
  border-right: 0;
  border-left-color: var(--bubble);
}

.message-user .message-text .stage-line {
  color: rgba(33, 27, 20, 0.62);
}

.message-user .message-meta {
  margin-top: 6px;
  margin-bottom: 0;
  color: var(--faint);
}

.message-user .message-time {
  color: rgba(238, 228, 211, 0.28);
}

.message-actions .copy-action.is-copied {
  color: var(--sage);
}

.message-text.is-streaming::after {
  display: inline-block;
  width: 5px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -0.12em;
  content: "";
  background: var(--accent);
  border-radius: 1px;
  animation: blink 900ms steps(1) infinite;
}

.message-error .message-body {
  width: 100%;
}

.error-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 15px;
  background: var(--danger-soft);
  border: 1px solid rgba(223, 120, 104, 0.18);
  border-radius: 14px;
}

.error-card > [data-icon] {
  color: var(--danger);
  padding-top: 1px;
}

.error-card > [data-icon] svg {
  width: 16px;
  height: 16px;
}

.error-copy {
  flex: 1;
  min-width: 0;
}

.error-copy strong {
  display: block;
  margin-bottom: 4px;
  color: #e3a094;
  font-size: 11.5px;
  font-weight: 500;
}

.error-copy p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.error-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.error-actions button {
  padding: 4px 9px;
  color: var(--ink-2);
  font-size: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-2);
  border-radius: 6px;
}

.error-actions button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.typing-message {
  align-items: center;
}

.typing-line {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 26px;
  color: var(--faint);
  font-size: 10.5px;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.typing-dots i {
  width: 3px;
  height: 3px;
  background: var(--ink-3);
  border-radius: 50%;
  animation: typing 1.15s ease-in-out infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 160ms;
}

.typing-dots i:nth-child(3) {
  animation-delay: 320ms;
}

.stop-inline {
  padding: 2px 6px;
  margin-left: 2px;
  color: var(--faint);
  font-size: 9px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 99px;
}

.stop-inline:hover {
  color: var(--ink-3);
  border-color: var(--line-2);
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 55vh;
  text-align: center;
}

.chat-empty h2 {
  margin-top: 22px;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.chat-empty p {
  max-width: 380px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
}

.chat-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 22px;
}

.model-hint {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  margin: 0 0 23px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.6;
  text-align: left;
  background: linear-gradient(90deg, rgba(217, 119, 87, 0.07), rgba(255, 255, 255, 0.014));
  border: 1px solid rgba(217, 119, 87, 0.16);
  border-radius: 9px;
  transition: border-color 160ms ease, background 160ms ease;
}

.model-hint:hover {
  color: var(--muted);
  background: linear-gradient(90deg, rgba(217, 119, 87, 0.09), rgba(255, 255, 255, 0.02));
  border-color: rgba(217, 119, 87, 0.24);
}

.model-hint strong {
  color: var(--accent-strong);
  font-weight: 500;
}

.model-hint-icon {
  display: grid;
  flex: none;
  width: 23px;
  height: 23px;
  color: var(--accent);
  background: rgba(217, 119, 87, 0.09);
  border-radius: 6px;
  place-items: center;
}

.model-hint-icon svg {
  width: 12px;
  height: 12px;
}

.model-hint > span:nth-child(2) {
  flex: 1;
  min-width: 0;
}

.model-hint-arrow {
  flex: none;
  color: var(--faint);
}

.model-hint-arrow svg {
  width: 12px;
  height: 12px;
}

/* =========================
   Starters & composer
   ========================= */

.composer-zone {
  position: relative;
  z-index: 8;
  padding: 6px clamp(16px, 4vw, 46px) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11, 14, 12, 0) 0%, rgba(11, 14, 12, 0.82) 24%, var(--bg) 64%);
}

/* The free Pagelet host adds a fixed badge in the lower-right corner.
   Reserve a dark strip for it so it never covers the composer or send button. */
html.is-pagelet-host .composer-zone {
  padding-bottom: calc(62px + env(safe-area-inset-bottom));
}

.starter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  width: 100%;
  max-width: 880px;
  padding: 0 0 11px;
  margin: 0 auto;
}

.starter-row:empty {
  display: none;
}

.starter-label {
  display: inline-flex;
  align-items: center;
  padding-right: 2px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.06em;
}

.starter-chip {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 7px 11px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.3;
  text-align: left;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 99px;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.starter-chip:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line-3);
}

.starter-chip [data-icon] {
  color: var(--faint);
  transition: transform 160ms ease, color 160ms ease;
}

.starter-chip [data-icon] svg {
  width: 11px;
  height: 11px;
}

.starter-chip:hover [data-icon] {
  color: var(--accent);
  transform: translateX(2px);
}

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  width: 100%;
  max-width: 880px;
  padding: 8px 8px 8px 15px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(31, 38, 31, 0.94), rgba(22, 28, 22, 0.97));
  border: 1px solid var(--line-2);
  border-radius: 23px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.composer:focus-within {
  border-color: rgba(217, 119, 87, 0.42);
  box-shadow:
    0 20px 55px rgba(0, 0, 0, 0.3),
    0 0 0 3px rgba(217, 119, 87, 0.055),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.composer.is-listening {
  border-color: rgba(217, 119, 87, 0.54);
  box-shadow: 0 0 0 4px rgba(217, 119, 87, 0.07);
}

.message-input {
  flex: 1;
  width: 100%;
  min-height: 42px;
  max-height: 170px;
  padding: 10px 2px 8px;
  overflow-y: auto;
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.65;
  resize: none;
  background: transparent;
  border: 0;
  outline: 0;
}

.composer-tool {
  display: grid;
  flex: none;
  width: 37px;
  height: 37px;
  margin-bottom: 2px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  place-items: center;
}

.composer-tool:hover {
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.05);
}

.composer-tool svg {
  width: 18px;
  height: 18px;
}

.composer-tool.is-listening {
  color: var(--accent-strong);
  background: var(--accent-soft);
  animation: listen-pulse 1.6s ease-in-out infinite;
}

.send-btn {
  display: grid;
  flex: none;
  width: 40px;
  height: 40px;
  margin-bottom: 1px;
  color: #21160f;
  background: var(--accent);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 5px 16px rgba(217, 119, 87, 0.22);
  place-items: center;
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.send-btn:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.send-btn:active {
  transform: translateY(0) scale(0.96);
}

.send-btn:disabled {
  color: var(--faint);
  background: rgba(238, 228, 211, 0.07);
  box-shadow: none;
  opacity: 0.72;
  transform: none;
}

.send-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.6;
}

.send-btn.is-sending svg {
  animation: send-float 800ms ease-in-out infinite;
}

.composer-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 880px;
  padding: 7px 5px 0;
  margin: 0 auto;
  color: rgba(238, 228, 211, 0.26);
  font-size: 9px;
  letter-spacing: 0.015em;
}

.composer-meta kbd {
  font-family: var(--mono);
  font-size: 8.5px;
}

.meta-sep {
  margin: 0 2px;
  opacity: 0.55;
}

.mode-mini {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  flex: none;
}

.mode-mini::before {
  width: 4px;
  height: 4px;
  content: "";
  background: var(--sage);
  border-radius: 50%;
}

.mode-mini.is-cloud::before {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(217, 119, 87, 0.5);
}

/* =========================
   Dialog foundations
   ========================= */

.dialog {
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 23px;
  box-shadow: var(--shadow-lg);
}

.dialog::backdrop {
  background: rgba(4, 6, 5, 0.72);
  backdrop-filter: blur(8px) saturate(80%);
}

.dialog[open] {
  animation: dialog-in 260ms var(--ease);
}

.dialog[open]::backdrop {
  animation: fade-in 220ms ease;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.2em;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 25px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.dialog-footer {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 14px 25px calc(14px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.12);
  border-top: 1px solid var(--line);
}

.footer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.ghost-btn,
.solid-btn,
.outline-btn,
.text-btn {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 9px;
}

.ghost-btn {
  padding: 9px 14px;
  color: var(--muted);
  font-size: 11.5px;
  background: transparent;
  border: 1px solid transparent;
}

.ghost-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.solid-btn {
  padding: 10px 17px;
  color: #21160f;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: 0 4px 16px rgba(217, 119, 87, 0.16);
}

.solid-btn:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.solid-btn.small {
  padding: 8px 12px;
  font-size: 10.5px;
}

.solid-btn.danger {
  color: #fff4f0;
  background: #b85545;
  border-color: #b85545;
}

.solid-btn.danger:hover {
  background: #c96251;
  border-color: #c96251;
}

.outline-btn {
  padding: 8px 11px;
  color: var(--ink-3);
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid var(--line);
}

.outline-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line-2);
}

.outline-btn [data-icon] svg,
.text-btn [data-icon] svg {
  width: 13px;
  height: 13px;
}

.text-btn {
  padding: 5px 0;
  color: var(--accent-strong);
  font-size: 10.5px;
  background: transparent;
  border: 0;
}

.text-btn:hover {
  color: #f0a07f;
}

.text-btn.subtle {
  color: var(--faint);
}

.text-btn.subtle:hover {
  color: var(--ink-3);
}

.form-error {
  flex: 1;
  color: #e6a195;
  font-size: 10.5px;
  line-height: 1.5;
}

.form-error:empty {
  display: block;
}

/* =========================
   Character studio
   ========================= */

.studio {
  width: min(1040px, calc(100vw - 40px));
  height: min(790px, calc(100dvh - 40px));
}

.studio[open] {
  display: block;
}

.studio-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.studio-header {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 17px;
  border-bottom: 1px solid var(--line);
}

.studio-header h2 {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.studio-body {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1.16fr) minmax(300px, 0.84fr);
  min-height: 0;
}

.studio-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
}

.studio-tabs {
  display: flex;
  flex: none;
  gap: 25px;
  padding: 0 24px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.studio-tab {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 14px 0 12px;
  color: var(--faint);
  font-size: 11.5px;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid transparent;
  transition: color 170ms ease, border-color 170ms ease;
}

.studio-tab span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.04em;
}

.studio-tab:hover {
  color: var(--ink-3);
}

.studio-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.studio-tab.is-active span {
  color: var(--accent);
}

.studio-panels {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.studio-panel {
  padding: 22px 24px 30px;
}

.studio-panel[hidden] {
  display: none;
}

.avatar-editor {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 22px;
  margin-bottom: 21px;
  border-bottom: 1px solid var(--line);
}

.avatar-preview-mount {
  flex: none;
}

.background-editor {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 22px;
  margin-bottom: 21px;
  border-bottom: 1px solid var(--line);
}

.background-preview {
  position: relative;
  flex: none;
  width: 164px;
  height: 92px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 24% 22%, rgba(217, 119, 87, 0.14), transparent 55%),
    linear-gradient(145deg, #1b211a, #101410);
  background-position: center;
  background-size: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.background-preview::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, transparent 35%, rgba(8, 11, 9, 0.7));
  pointer-events: none;
}

.background-preview.has-image {
  border-color: var(--accent-line);
}

.background-preview span {
  position: absolute;
  bottom: 8px;
  left: 9px;
  z-index: 1;
  color: rgba(238, 237, 230, 0.72);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.12em;
}

@media (max-width: 620px) {
  .background-editor {
    flex-direction: column;
    gap: 10px;
  }

  .background-preview {
    width: 100%;
    height: 112px;
  }
}

.avatar-editor-copy {
  flex: 1;
  min-width: 0;
}

.avatar-editor-title {
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.avatar-editor-copy p {
  margin-top: 5px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.65;
}

.avatar-actions {
  display: flex;
  gap: 12px;
  margin-top: 9px;
}

.motif-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.motif-swatch {
  display: grid;
  width: 23px;
  height: 23px;
  padding: 0;
  color: var(--ink-3);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 6px;
  place-items: center;
}

.motif-swatch svg {
  width: 15px;
  height: 15px;
}

.motif-swatch:hover {
  border-color: var(--line-3);
}

.motif-swatch.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.palette-row {
  display: flex;
  gap: 7px;
  margin-top: 9px;
}

.palette-swatch {
  position: relative;
  width: 18px;
  height: 18px;
  padding: 0;
  overflow: hidden;
  background: linear-gradient(135deg, var(--sw-a), var(--sw-b));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
}

.palette-swatch:hover {
  transform: scale(1.08);
}

.palette-swatch.is-active::after {
  position: absolute;
  inset: 3px;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

.field-half,
.field-quarter {
  grid-column: span 1;
}

.field-full {
  grid-column: 1 / -1;
}

.field > span:first-child,
.field > legend {
  padding: 0;
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.field em {
  color: var(--accent);
  font-style: normal;
}

.field i {
  margin-left: 4px;
  color: var(--faint);
  font-size: 8.5px;
  font-style: normal;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.65;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.field textarea {
  min-height: 65px;
  line-height: 1.75;
  resize: vertical;
}

.field select {
  padding-right: 29px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23929387' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--line-2);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(217, 119, 87, 0.55);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.07);
}

.field input[type="number"] {
  font-family: var(--mono);
}

.choice-row {
  display: flex;
  gap: 5px;
}

.choice {
  position: relative;
  flex: 1;
  min-width: 0;
}

.choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.choice span {
  display: block;
  padding: 8px 4px;
  overflow: hidden;
  color: var(--faint);
  font-size: 10px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.choice input:checked + span {
  color: var(--ink);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.choice input:focus-visible + span {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.panel-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 11px 12px;
  margin-bottom: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.panel-note > [data-icon] {
  padding-top: 1px;
  color: var(--accent);
}

.panel-note > [data-icon] svg {
  width: 14px;
  height: 14px;
}

.panel-note p {
  font-size: 10px;
  line-height: 1.7;
}

.voice-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

.voice-mode {
  position: relative;
  display: block;
}

.voice-mode input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.voice-mode-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  height: 100%;
  padding: 11px;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: border-color 160ms ease, background 160ms ease;
}

.voice-mode-body:hover {
  border-color: var(--line-2);
}

.voice-mode-icon {
  display: grid;
  width: 24px;
  height: 24px;
  margin-bottom: 3px;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 6px;
  place-items: center;
}

.voice-mode-icon svg {
  width: 13px;
  height: 13px;
}

.voice-mode-body strong {
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 500;
}

.voice-mode-body small {
  color: var(--faint);
  font-size: 8.5px;
  line-height: 1.5;
}

.voice-mode input:checked + .voice-mode-body {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.voice-mode input:checked + .voice-mode-body .voice-mode-icon {
  color: var(--accent-strong);
  background: rgba(217, 119, 87, 0.1);
}

.voice-mode input:checked + .voice-mode-body strong {
  color: var(--ink);
}

.voice-mode input:focus-visible + .voice-mode-body {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.voice-result {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  margin: 12px 0 15px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
  background: rgba(159, 183, 166, 0.045);
  border: 1px solid rgba(159, 183, 166, 0.14);
  border-radius: 9px;
}

.voice-result > [data-icon] {
  color: var(--sage);
}

.voice-result > [data-icon] svg {
  width: 15px;
  height: 15px;
}

.voice-result strong {
  color: var(--ink-3);
  font-weight: 500;
}

.voice-result small {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 9px;
}

.voice-result.is-missing {
  background: var(--accent-soft);
  border-color: rgba(217, 119, 87, 0.17);
}

.voice-result.is-missing > [data-icon],
.voice-result.is-missing strong {
  color: var(--accent-strong);
}

.range-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-field output {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
}

.field input[type="range"] {
  width: 100%;
  height: 16px;
  margin: 0;
  appearance: none;
  cursor: pointer;
  background: transparent;
  border: 0;
}

.field input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, var(--accent) var(--pct, 50%), rgba(238, 228, 211, 0.12) var(--pct, 50%));
  border-radius: 99px;
}

.field input[type="range"]::-moz-range-track {
  height: 2px;
  background: rgba(238, 228, 211, 0.12);
  border-radius: 99px;
}

.field input[type="range"]::-moz-range-progress {
  height: 2px;
  background: var(--accent);
  border-radius: 99px;
}

.field input[type="range"]::-webkit-slider-thumb {
  width: 11px;
  height: 11px;
  margin-top: -4.5px;
  appearance: none;
  background: var(--ink-2);
  border: 2px solid var(--panel);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--accent);
}

.field input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 9px;
  background: var(--ink-2);
  border: 2px solid var(--panel);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--accent);
}

.voice-test {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  margin-top: 17px;
  border-top: 1px solid var(--line);
}

.setting-kicker {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.17em;
}

.voice-test p {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 10px;
}

.voice-test-actions {
  display: flex;
  gap: 13px;
  align-items: center;
}

.hint {
  color: var(--faint);
  font-size: 9.5px;
  line-height: 1.75;
}

.voice-hint {
  margin-top: 10px;
}

/* Studio preview */

.studio-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 0;
  padding: 24px 24px 22px;
  overflow-y: auto;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 17%, rgba(255, 255, 255, 0.075), transparent 51%),
    linear-gradient(165deg, #171d17, #0f140f 72%);
}

.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 24px;
}

.preview-live {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: var(--faint);
  font-size: 8.5px;
}

.preview-live i {
  width: 4px;
  height: 4px;
  background: var(--sage);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(159, 183, 166, 0.5);
}

.preview-portrait {
  display: grid;
  padding: 7px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 38%;
  background: rgba(255, 255, 255, 0.018);
  place-items: center;
}

.preview-portrait .portrait {
  width: 108px;
  height: 108px;
  font-size: 38px;
}

.studio-preview h3 {
  max-width: 100%;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-role {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.07em;
}

.preview-tagline {
  max-width: 260px;
  margin-top: 12px;
  color: var(--ink-3);
  font-family: var(--serif);
  font-size: 12.5px;
  line-height: 1.8;
  letter-spacing: 0.02em;
}

.preview-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-top: 12px;
}

.preview-traits span {
  padding: 3px 7px;
  color: var(--faint);
  font-size: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 99px;
}

.preview-dialogue {
  width: 100%;
  padding: 12px 13px;
  margin-top: auto;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.preview-dialogue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  color: var(--faint);
  font-size: 8px;
}

.preview-dialogue-head span:first-child {
  color: var(--ink-3);
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.preview-dialogue p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1.8;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.preview-voice {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-top: 13px;
  margin-top: 10px;
  color: var(--faint);
  font-size: 8.5px;
  border-top: 1px solid var(--line);
}

.preview-voice [data-icon] {
  color: var(--sage);
}

.preview-voice [data-icon] svg {
  width: 12px;
  height: 12px;
}

.studio-footer {
  display: flex;
  flex: none;
  gap: 16px;
  align-items: center;
  padding: 13px 24px calc(13px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.14);
  border-top: 1px solid var(--line);
}

/* =========================
   Settings
   ========================= */

.settings {
  width: min(740px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
}

.settings[open] {
  display: flex;
  flex-direction: column;
}

.settings-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.settings form {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100dvh - 34px);
}

.settings-body {
  flex: 1;
  min-height: 0;
  padding: 0 25px;
  overflow-y: auto;
}

.settings-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-child {
  border-bottom: 0;
}

.section-title {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title h3 {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.section-title p {
  margin-top: 4px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.65;
}

.status-badge {
  flex: none;
  padding: 4px 8px;
  color: var(--faint);
  font-size: 8.5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 99px;
}

.status-badge.is-cloud {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: rgba(217, 119, 87, 0.22);
}

.proactive-target {
  margin: 11px 0 8px;
  color: var(--faint);
  font-size: 9.5px;
}

.proactive-mode {
  display: flex;
  gap: 5px;
  margin-bottom: 9px;
}

.proactive-mode .choice {
  flex: 1;
}

.proactive-mode .choice span {
  padding: 8px 6px;
  font-size: 10px;
}

.proactive-interval {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  margin-bottom: 9px;
}

.proactive-interval > label {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: var(--faint);
  font-size: 9px;
}

.proactive-interval select,
.proactive-interval input {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  color: var(--ink-2);
  font-size: 11px;
  color-scheme: dark;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.proactive-interval select {
  padding-right: 24px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23929387' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.proactive-interval input:focus,
.proactive-interval select:focus {
  border-color: rgba(217, 119, 87, 0.55);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.07);
}

.interval-range {
  display: flex;
  gap: 4px;
  align-items: center;
}

.interval-range span {
  flex: none;
  color: var(--faint);
  font-size: 8px;
}

.proactive-hint {
  margin: -1px 0 9px;
  font-size: 8.5px;
}

.proactive-generate {
  padding: 8px 10px;
  margin: 0 0 9px;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.proactive-generate span {
  font-size: 9px;
}

.proactive-generate strong {
  font-size: 10px;
}

@media (max-width: 620px) {
  .proactive-interval {
    flex-direction: column;
    align-items: stretch;
  }

  .proactive-interval > label {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .proactive-interval select {
    width: 118px;
  }

  .proactive-interval .interval-range {
    flex: 1;
    justify-content: flex-end;
  }

  .proactive-interval input {
    width: 105px;
    font-size: 16px;
  }
}

.proactive-target strong {
  color: var(--ink-3);
  font-weight: 500;
}

.proactive-times {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 9px;
}

.proactive-times label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--faint);
  font-size: 9px;
}

.proactive-times input {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  color: var(--ink-2);
  font-size: 11px;
  color-scheme: dark;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

.proactive-times input:focus {
  border-color: rgba(217, 119, 87, 0.55);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.07);
}

.proactive-days {
  display: flex;
  gap: 5px;
  margin-bottom: 11px;
}

.proactive-days label {
  position: relative;
  flex: 1;
  min-width: 0;
}

.proactive-days input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.proactive-days span {
  display: grid;
  height: 25px;
  color: var(--faint);
  font-size: 9px;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid var(--line);
  border-radius: 7px;
  place-items: center;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.proactive-days input:checked + span {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.proactive-days input:focus-visible + span {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.proactive-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 7px;
}

.proactive-actions .outline-btn[disabled] {
  opacity: 0.45;
}

.status-badge.is-on {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: rgba(217, 119, 87, 0.22);
}

.provider-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 13px;
}

.provider-chips button {
  padding: 6px 10px;
  color: var(--faint);
  font-size: 9.5px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 99px;
}

.provider-chips button:hover {
  color: var(--ink-3);
  border-color: var(--line-2);
}

.provider-chips button.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.settings .field-grid {
  gap: 12px;
}

.settings .field input,
.settings .field select {
  padding: 8px 10px;
}

.secret-wrap {
  position: relative;
  display: block;
}

.secret-wrap input {
  padding-right: 36px !important;
}

.secret-toggle {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  width: 27px;
  height: 27px;
  padding: 0;
  color: var(--faint);
  background: transparent;
  border: 0;
  border-radius: 6px;
  place-items: center;
  transform: translateY(-50%);
}

.secret-toggle:hover {
  color: var(--ink-3);
  background: rgba(255, 255, 255, 0.04);
}

.secret-toggle svg {
  width: 14px;
  height: 14px;
}

.check-line {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  color: var(--ink-3);
  font-size: 10.5px;
  cursor: pointer;
}

.check-line input {
  width: 14px;
  height: 14px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.check-line strong {
  display: block;
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 500;
}

.check-line small {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 9px;
}

.check-line.compact {
  align-items: center;
  height: 34px;
}

.security-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 11px;
  margin-top: 13px;
  color: var(--faint);
  background: rgba(223, 120, 104, 0.045);
  border: 1px solid rgba(223, 120, 104, 0.11);
  border-radius: 8px;
}

.security-note > [data-icon] {
  flex: none;
  color: var(--danger);
  padding-top: 1px;
}

.security-note > [data-icon] svg {
  width: 14px;
  height: 14px;
}

.security-note p {
  font-size: 9px;
  line-height: 1.7;
}

.settings-fineprint {
  margin-top: 10px;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.7;
}

.install-btn {
  margin-top: 6px;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* =========================
   Install, confirm & toast
   ========================= */

.install-dialog {
  width: min(480px, calc(100vw - 32px));
}

.install-body {
  padding: 23px 27px 21px;
}

.install-platform {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.install-steps {
  padding: 0;
  margin: 14px 0 18px;
  list-style: none;
  counter-reset: install-step;
}

.install-steps li {
  position: relative;
  padding-left: 34px;
  margin-bottom: 13px;
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 1.8;
  counter-increment: install-step;
}

.install-steps li:last-child {
  margin-bottom: 0;
}

.install-steps li::before {
  position: absolute;
  top: 1px;
  left: 0;
  display: grid;
  width: 21px;
  height: 21px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 8px;
  content: counter(install-step, decimal-leading-zero);
  background: var(--accent-soft);
  border: 1px solid rgba(217, 119, 87, 0.16);
  border-radius: 50%;
  place-items: center;
}

.install-url-wrap {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.install-url-wrap span {
  display: block;
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 8.5px;
  letter-spacing: 0.03em;
}

.install-url-wrap code {
  display: block;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.install-note {
  margin-top: 13px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.75;
}

.confirm-dialog {
  width: min(410px, calc(100vw - 32px));
}

.confirm-body {
  padding: 26px 26px 22px;
  text-align: center;
}

.confirm-mark {
  display: grid;
  width: 38px;
  height: 38px;
  margin: 0 auto 14px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid rgba(217, 119, 87, 0.16);
  border-radius: 50%;
  place-items: center;
}

.confirm-mark svg {
  width: 17px;
  height: 17px;
}

.confirm-body h2 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.confirm-body p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.8;
}

.confirm-dialog .dialog-footer {
  justify-content: flex-end;
}

.toast-host {
  position: fixed;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  width: fit-content;
  max-width: calc(100vw - 48px);
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  pointer-events: none;
  inset: calc(76px + 14px) 24px auto auto;
}

.toast-host[popover]:not(:popover-open) {
  display: none;
}

.toast-host[popover] {
  position: fixed;
  margin: 0;
}

.toast-host:empty {
  display: none;
}

.toast {
  display: flex;
  gap: 9px;
  align-items: center;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 13px;
  color: var(--ink-2);
  font-size: 10.5px;
  line-height: 1.55;
  background: #1c221c;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 13px 40px rgba(0, 0, 0, 0.38);
  animation: toast-in 240ms var(--ease);
}

.toast [data-icon] {
  color: var(--sage);
}

.toast.is-error [data-icon] {
  color: var(--danger);
}

.toast.is-out {
  animation: toast-out 180ms ease forwards;
}

/* =========================
   Responsive
   ========================= */

.scrim {
  display: none;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(326px, 86vw);
    border-right: 1px solid var(--line-2);
    box-shadow: 24px 0 70px rgba(0, 0, 0, 0.47);
    transform: translateX(-103%);
    transition: transform 260ms var(--ease);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .icon-btn.sidebar-close {
    display: inline-grid;
  }

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: block;
    padding: 0;
    background: rgba(4, 6, 5, 0.55);
    border: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 240ms ease;
    backdrop-filter: blur(2px);
  }

  .scrim.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .chat-header .header-mobile {
    display: inline-grid;
  }

  .chat-header {
    min-height: 68px;
    padding: 10px 15px;
    gap: 9px;
  }

  .header-actions {
    gap: 1px;
  }

  .header-actions .icon-btn {
    width: 34px;
    height: 34px;
  }

  .chat-content {
    padding-top: 17px;
  }

  .composer-zone {
    padding-right: 16px;
    padding-left: 16px;
  }

  .message-body {
    max-width: calc(100% - 46px);
  }

  .message-actions {
    opacity: 0.65;
  }

  .studio {
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .studio-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .studio-preview {
    display: none;
  }

  .studio-main {
    border-right: 0;
  }
}

@media (max-width: 620px) {
  .chat-header {
    min-height: 63px;
    padding: 8px 11px;
    gap: 8px;
  }

  .header-name-line h2 {
    font-size: 17px;
  }

  .header-roman {
    display: none;
  }

  .header-sub {
    margin-top: 2px;
    font-size: 9.5px;
  }

  .header-sub .voice-name,
  .header-sub .sub-sep {
    display: none;
  }

  .header-actions .edit-btn {
    display: none;
  }

  .header-portrait .portrait {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  .chat-content {
    padding: 10px 16px 4px;
  }

  .scene-intro {
    padding: 16px 2px 21px;
  }

  .scene-text {
    font-size: 15px;
    line-height: 1.85;
  }

  .scene-meta {
    font-size: 8.5px;
  }

  .date-divider {
    margin: 5px 0 22px;
  }

  .message {
    gap: 9px;
    margin-bottom: 11px;
  }

  .message .portrait.p-sm {
    width: 29px;
    height: 29px;
    font-size: 11px;
  }

  .message-meta {
    margin-bottom: 6px;
  }

  .message-text {
    font-size: 14px;
    line-height: 1.2;
  }

  .message-text .stage-line {
    font-size: 12px;
    line-height: 1.18;
  }

  .message-user {
    margin-top: 7px;
    margin-bottom: 11px;
  }

  .message-user .message-body {
    max-width: calc(100% - 38px);
  }

  .message-user .message-text {
    font-size: 14px;
  }

  .message-avatar-user {
    width: 29px;
    height: 29px;
    font-size: 9px;
  }

  .message-actions {
    height: 15px;
    opacity: 0.7;
  }

  .starter-row {
    flex-wrap: nowrap;
    gap: 6px;
    padding-bottom: 9px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .starter-row::-webkit-scrollbar {
    display: none;
  }

  .starter-label {
    display: none;
  }

  .starter-chip {
    flex: none;
    max-width: 78vw;
    padding: 6px 9px;
    overflow: hidden;
    font-size: 9.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .composer-zone {
    padding: 4px 10px calc(9px + env(safe-area-inset-bottom));
  }

  html.is-pagelet-host .composer-zone {
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
  }

  .composer {
    padding: 6px 6px 6px 12px;
    border-radius: 20px;
  }

  .message-input {
    min-height: 40px;
    padding-top: 9px;
    font-size: 16px;
  }

  .send-btn {
    width: 38px;
    height: 38px;
  }

  .composer-meta {
    padding: 6px 4px 0;
    font-size: 8px;
  }

  .composer-meta > span:first-child {
    display: none;
  }

  .composer-meta kbd,
  .meta-sep {
    display: none;
  }

  .mode-mini {
    margin-left: auto;
  }

  .dialog {
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }

  .studio,
  .settings {
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }

  .settings {
    width: 100vw;
    height: 100dvh;
    border: 0;
  }

  .settings form {
    height: 100%;
  }

  .settings-body {
    flex: 1;
    padding: 0 17px;
    overflow-y: auto;
  }

  .dialog-header {
    padding: 18px 17px 14px;
  }

  .dialog-header h2 {
    font-size: 21px;
  }

  .dialog-footer {
    padding: 11px 17px calc(11px + env(safe-area-inset-bottom));
  }

  .studio-header {
    padding: 15px 17px 13px;
  }

  .studio-header h2 {
    font-size: 22px;
  }

  .studio-tabs {
    gap: 20px;
    padding: 0 17px;
  }

  .studio-tab {
    padding: 12px 0 10px;
    font-size: 10.5px;
  }

  .studio-panel {
    padding: 18px 17px 25px;
  }

  .studio-panel .field-grid {
    gap: 12px;
  }

  .avatar-editor {
    gap: 14px;
  }

  .avatar-editor .portrait.p-lg {
    width: 59px;
    height: 59px;
    font-size: 22px;
  }

  .motif-swatch {
    width: 22px;
    height: 22px;
  }

  .field input[type="text"],
  .field input[type="password"],
  .field input[type="number"],
  .field select,
  .field textarea {
    font-size: 16px; /* prevents iOS zoom; visually scaled by density */
    padding: 8px 10px;
  }

  .studio .field input,
  .studio .field select,
  .studio .field textarea {
    font-size: 16px;
  }

  .studio-footer {
    padding: 10px 17px calc(10px + env(safe-area-inset-bottom));
  }

  .form-error {
    font-size: 9px;
  }

  .solid-btn {
    padding: 9px 14px;
  }

  .footer-actions {
    gap: 4px;
  }

  .ghost-btn {
    padding: 9px 10px;
  }

  .settings .field input,
  .settings .field select {
    font-size: 16px;
  }

  .toast-host {
    inset: calc(68px + env(safe-area-inset-top)) 12px auto 12px;
    align-items: stretch;
    width: auto;
    max-width: none;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 380px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .field-half,
  .field-quarter {
    grid-column: 1 / -1;
  }

  .choice-row {
    gap: 4px;
  }

  .voice-mode-grid {
    grid-template-columns: 1fr;
  }

  .header-actions .voice-toggle {
    display: inline-grid;
  }
}

@media (hover: none) {
  .message-actions {
    opacity: 0.64;
  }
}

@media (max-height: 760px) {
  .sidebar-quote {
    display: none;
  }
}

@media (max-width: 620px) {
  .install-steps li {
    font-size: 13px;
    line-height: 1.8;
  }

  .install-note {
    font-size: 10.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================
   Keyframes
   ========================= */

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes blink {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

@keyframes wave {
  0%, 100% { transform: scaleY(0.55); }
  50% { transform: scaleY(1.35); }
}

@keyframes eq {
  0%, 100% { transform: scaleY(0.55); }
  50% { transform: scaleY(1); }
}

@keyframes listen-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 87, 0.14); }
  50% { box-shadow: 0 0 0 5px rgba(217, 119, 87, 0.02); }
}

@keyframes send-float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(1px, -1px); }
}
