:root {
  --bg: #12151c;
  --panel: #1c2028;
  --ink: #ece7dc;
  --muted: #8b91a0;
  --line: #2e3340;
  --accent: #b8924a;
  --danger: #d07a6a;
  --ok: #7ea37a;
  --mat: #161920;
  --print: #0d0f14;
  --shadow: 0 28px 60px rgba(6, 8, 14, 0.48);
  --shadow-soft: 0 12px 32px rgba(6, 8, 14, 0.42);
  --image-ring: oklch(1 0 0 / 0.1);
  --radius-control: 12px;
  --radius-card: 22px;
  --radius-module: 26px;
  --hit: 44px;
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --duration: 180ms;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 8% -8%, #1c2433 0%, transparent 58%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.55 "Source Sans 3", "PingFang SC", "Noto Sans SC", sans-serif;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  hanging-punctuation: first last;
  scroll-padding-top: 12px;
}

p {
  text-wrap: pretty;
}

.skip {
  position: absolute;
  left: 12px;
  top: 8px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--accent);
  color: #16130c;
  text-decoration: none;
  transform: translateY(-140%);
}

.skip:focus,
.skip:focus-visible {
  transform: none;
}

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

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

@media (forced-colors: active) {
  :focus-visible {
    outline: 2px solid Highlight;
  }
}

a,
button,
label,
input,
select,
textarea {
  touch-action: manipulation;
}

.health {
  padding: 10px 18px;
  text-align: center;
  font-size: 14px;
}

.health.warn {
  background: #3a1f18;
  color: #ffd4c8;
}

.health.ok {
  background: #1c2a18;
  color: #d8efcc;
}

.layout {
  display: grid;
  grid-template-columns: max-content minmax(280px, 1fr);
  grid-template-areas: "stage panel";
  gap: 16px 36px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px max(22px, env(safe-area-inset-right)) 40px max(22px, env(safe-area-inset-left));
  align-items: start;
}

.stage {
  --frame-side: 68vh;
  grid-area: stage;
  display: flex;
  flex-direction: column;
}

.portrait {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--print);
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 0 11px var(--panel),
    var(--shadow);
  width: max-content;
  max-width: min(46vw, var(--frame-side));
  line-height: 0;
}

.portrait:not(:has(img:not([hidden]))):not(:has(video:not([hidden]))) {
  width: min(46vw, var(--frame-side));
  min-height: var(--frame-side);
}

.portrait.waiting .badge {
  color: var(--ink);
  border-color: rgba(184, 146, 74, 0.55);
  animation: badgeBreathe 1.8s ease-in-out infinite;
}

@keyframes badgeBreathe {
  0%,
  100% {
    border-color: rgba(184, 146, 74, 0.28);
    box-shadow: 0 0 0 1px rgba(184, 146, 74, 0.08), 0 0 6px rgba(184, 146, 74, 0.12);
  }
  50% {
    border-color: rgba(184, 146, 74, 0.95);
    box-shadow: 0 0 0 1px rgba(184, 146, 74, 0.32), 0 0 14px rgba(184, 146, 74, 0.55);
  }
}

.portrait img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(46vw, var(--frame-side));
  max-height: var(--frame-side);
  object-fit: contain;
  box-shadow: inset 0 0 0 1px var(--image-ring);
}

.portrait video {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  background: var(--print);
  transition: opacity 0.7s ease;
}

.portrait video#enter {
  z-index: 2;
}

.portrait video#clip {
  z-index: 3;
}

.portrait video#live {
  z-index: 6;
  pointer-events: none;
  object-fit: cover;
  object-position: top center;
  background: var(--print);
}

.portrait video.fade-out {
  opacity: 0;
}

.portrait.veiled img {
  filter: blur(36px);
  transform: scale(1.16);
}

.portrait.veiled video:not(#enter) {
  opacity: 0;
}

.enter-veil {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(13, 15, 20, 0.22);
}

.enter-veil p {
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(13, 15, 20, 0.62);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
}

.portrait img[hidden],
.portrait video[hidden],
.placeholder[hidden],
.enter-veil[hidden],
.poke-hits[hidden] {
  display: none !important;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.placeholder p {
  margin: 0 0 8px;
}

.subs {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 22px;
  z-index: 4;
  text-align: center;
  font-size: 18px;
  line-height: 1.4;
  text-shadow: 0 2px 10px #000;
  background: rgba(13, 15, 20, 0.5);
  border-radius: var(--radius-control);
  padding: 10px 14px;
}

.badge {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 8;
  padding: 6px 12px;
  border-radius: 999px;
  background: none;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.hint,
.lede,
.muted,
.status-line {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

.panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 0;
  min-height: 100%;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-module);
  padding: 22px;
  box-shadow: var(--shadow-soft);
}

.hint {
  grid-area: hint;
}

.panel-identity,
.composer {
  flex: 0 0 auto;
}

.panel-identity {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

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

.identity-name h1 {
  margin: 0;
}

.gender-mark {
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
  font-weight: 500;
}

.identity-persona {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

h1 {
  margin: 0 0 6px;
  font-family: Fraunces, "Songti SC", Palatino, serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.1;
  text-wrap: balance;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.upload,
.composer {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: stretch;
}

.composer {
  align-items: flex-end;
}

.upload input[type="text"] {
  min-width: 0;
}

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

.upload input[type="text"],
.composer textarea,
button,
.file {
  border: 1px solid var(--line);
  background: var(--mat);
  color: var(--ink);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  min-height: var(--hit);
}

.file {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex: 0 0 auto;
}

.file input {
  display: none;
}

button {
  background: var(--accent);
  color: #16130c;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform var(--duration) var(--ease-out),
    filter var(--duration) ease,
    opacity var(--duration) ease,
    background-color var(--duration) ease,
    border-color var(--duration) ease,
    color var(--duration) ease;
}

@media (hover: hover) {
  button:hover:not(:disabled) {
    filter: brightness(1.06);
  }
}

button:active:not(:disabled) {
  transform: scale(0.96);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.create-open,
button.create-close,
button.voice-preview {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

@media (hover: hover) {
  button.create-open:hover:not(:disabled),
  button.create-close:hover:not(:disabled) {
    filter: none;
    background: #181c24;
    color: var(--ink);
  }
}

button.create-close {
  background: var(--mat);
  color: var(--ink);
}

.upload input[type="text"] {
  flex: 1;
}

.composer {
  margin-top: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  align-items: flex-end;
}

.composer button {
  min-width: 4.5rem;
}

.composer .mic {
  flex: 0 0 auto;
  min-width: var(--hit);
  width: var(--hit);
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
}

.composer .mic.is-listening {
  color: var(--accent);
  border-color: var(--accent);
  animation: badgeBreathe 1.8s ease-in-out infinite;
}

.composer .poke {
  flex: 0 0 auto;
  min-width: var(--hit);
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
}

.composer .poke[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

@media (hover: hover) {
  .composer .poke:hover:not(:disabled) {
    filter: none;
    color: var(--accent);
  }
}

.poke-hits {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.portrait.is-aiming .poke-hits {
  pointer-events: auto;
}

.poke-hit {
  flex: 1;
  min-height: var(--hit);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.poke-hit:active {
  background: color-mix(in oklab, white 12%, transparent);
}

@media (hover: hover) {
  .composer .mic:hover:not(:disabled) {
    filter: none;
    color: var(--accent);
  }
}

.composer textarea {
  flex: 1;
  resize: none;
  min-width: 0;
  min-height: var(--hit);
  line-height: 1.4;
}

.composer .input-mode {
  flex: 0 0 auto;
  min-width: var(--hit);
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
}

.composer.is-voice textarea,
.composer.is-voice #send {
  display: none;
}

.composer.is-voice.is-listening textarea {
  display: block;
}

.composer.is-voice .mic {
  flex: 1;
  width: auto;
  min-width: 0;
  background: var(--accent);
  color: #16130c;
  font-weight: 600;
}

.composer.is-voice.is-listening .mic {
  flex: 0 0 auto;
  min-width: var(--hit);
}

.composer.is-text .mic {
  display: none;
}

@media (hover: hover) {
  .composer .input-mode:hover:not(:disabled) {
    filter: none;
    color: var(--accent);
  }
}

.log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.log:empty::before {
  content: "从一句你好开始，认识彼此。";
  margin: auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-wrap: pretty;
}

.bubble {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 18px 18px 18px 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.bubble.user {
  align-self: flex-end;
  border-radius: 18px 18px 6px 18px;
  background: #2a3140;
}

.bubble.assistant {
  align-self: flex-start;
  background: #181c24;
}

.bubble.assistant.replayable {
  cursor: pointer;
}

@media (hover: hover) {
  .bubble.assistant.replayable:hover {
    background: #222834;
  }
}

.bubble.assistant.replayable:focus-visible {
  outline: 2px solid #d7b48a;
  outline-offset: 2px;
}

.bubble.pending {
  opacity: 0.5;
  animation: pendingPulse 1.2s ease-in-out infinite;
}

.bubble.error {
  align-self: stretch;
  background: #3a1f18;
  color: #ffd4c8;
}

.status-line {
  min-height: 18px;
  margin-top: 8px;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "stage"
      "panel";
    padding: 16px max(16px, env(safe-area-inset-right)) 20px max(16px, env(safe-area-inset-left));
  }

  .stage {
    --frame-side: 52vh;
    align-items: center;
    width: 100%;
    min-width: 0;
    container-type: inline-size;
  }

  .portrait {
    max-width: 100%;
  }

  .portrait:not(:has(img:not([hidden]))):not(:has(video:not([hidden]))) {
    width: min(100%, var(--frame-side));
    min-height: min(100cqw, var(--frame-side));
  }

  .portrait img {
    max-width: min(
      100cqw,
      calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))
    );
    max-height: var(--frame-side);
  }

  .panel {
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 18px;
  }

  .log {
    position: relative;
    z-index: 0;
  }

  .composer {
    position: sticky;
    bottom: 0;
    z-index: 6;
    transform: translateZ(0);
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--panel);
    box-shadow: 0 -28px 28px 12px var(--panel);
  }

  .composer::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 16px;
    background: var(--panel);
    pointer-events: none;
  }
}

.topnav {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 56px;
  padding: max(10px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 10px max(22px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}

.topnav a,
.brand {
  color: var(--muted);
  text-decoration: none;
  margin-left: 14px;
  transition: color var(--duration) ease;
}

.topnav .brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin-left: 0;
  color: var(--ink);
  font-family: Fraunces, "Songti SC", Palatino, serif;
  font-weight: 500;
  font-size: 20px;
}

.topnav nav {
  margin-left: auto;
}

.topnav a:first-child {
  margin-left: 0;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 0;
  min-height: var(--hit);
  padding-inline: 2px;
  font-size: 14px;
}

.back::before {
  content: "‹";
  font-size: 22px;
  line-height: 1;
  transform: translateY(-1px);
}

@media (hover: hover) {
  .topnav a:hover,
  .brand:hover {
    color: var(--ink);
  }
}

.topnav a[aria-current="page"] {
  color: var(--ink);
}

.studio {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px max(22px, env(safe-area-inset-right)) 64px max(22px, env(safe-area-inset-left));
}

.studio-head {
  margin: 0 0 24px;
  max-width: 28em;
}

.studio-title {
  margin: 0;
  font-size: 28px;
}

.studio-lead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 20px;
  align-items: stretch;
}

.cards {
  display: contents;
}

/* 角色库：独立一池，与用户角色同一套卡片和列宽（PC-042） */
.library {
  margin-top: 40px;
}

.library[hidden] {
  display: none;
}

.library-title {
  margin: 0 0 14px;
  font-family: Fraunces, "Songti SC", Palatino, serif;
  font-weight: 500;
  font-size: 18px;
  color: var(--muted);
}

.library .cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 20px;
  align-items: stretch;
}

.create-card {
  display: flex;
  aspect-ratio: 1 / 1;
  min-height: 0;
  background: transparent;
  border: 1px dashed rgba(184, 146, 74, 0.38);
  border-radius: var(--radius-card);
  padding: 0;
  overflow: hidden;
}

.create-open {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  flex: 1;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 24px;
  border: 0;
  border-radius: var(--radius-card);
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}

.create-open:focus-visible {
  color: var(--ink);
  background: #181c24;
}

@media (hover: hover) {
  .create-open:hover {
    color: var(--ink);
    background: #181c24;
  }

  .create-card:hover {
    border-color: var(--accent);
  }
}

.create-open-plus {
  font-size: 40px;
  line-height: 1;
  color: var(--muted);
}

.create-open strong {
  color: inherit;
  font-family: Fraunces, "Songti SC", Palatino, serif;
  font-size: 20px;
  font-weight: 500;
}

.studio.roster-full .create-card {
  display: none;
}

.create-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: none;
  overflow: visible;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-module);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}

.create-dialog::backdrop {
  background: rgba(6, 8, 14, 0.62);
}

.create-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.create-dialog-head h1 {
  margin: 0;
  font-size: 26px;
}

.create-close {
  width: var(--hit);
  height: var(--hit);
  min-height: var(--hit);
  margin: 0;
  padding: 0;
  border-radius: 999px;
  background: var(--mat);
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  font-weight: 400;
}

.create-dialog .create-form {
  margin-top: 0;
}

.create-dialog.has-preview:not(.is-ready) #create-status {
  color: var(--danger);
  overflow-wrap: anywhere;
}

.create-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  position: relative;
}

.photo-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.photo-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 220px;
  border: 1px dashed rgba(184, 146, 74, 0.38);
  border-radius: var(--radius-card);
  background: var(--mat);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  padding: 32px;
  transition: border-color var(--duration) ease, background-color var(--duration) ease;
}

.photo-pick:hover,
.photo-pick:focus-within {
  border-color: var(--accent);
  background: #181c24;
}

.photo-pick strong {
  color: var(--ink);
  font-family: Fraunces, "Songti SC", Palatino, serif;
  font-size: 22px;
  font-weight: 500;
}

.photo-pick span {
  font-size: 14px;
}

.create-form.has-photo .photo-pick {
  display: none;
}

.photo-preview {
  display: none;
  margin: 0;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--print);
  border: 1px solid var(--line);
}

.create-form.has-photo .photo-preview {
  display: block;
  width: 100%;
  animation: fadeUp 0.28s ease both;
}

.photo-preview img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: var(--print);
  box-shadow: inset 0 0 0 1px var(--image-ring);
}

.photo-preview #photo-change {
  position: absolute;
  right: 12px;
  bottom: 12px;
}

.create-fields {
  display: none;
  gap: 12px;
}

.create-dialog:not(.is-ready) .create-fields,
.create-fields[hidden] {
  display: none !important;
}

.create-dialog.is-ready .create-fields,
.create-form.photo-ok .create-fields:not([hidden]) {
  display: grid;
  animation: fadeUp 0.28s ease both;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.voice-pick {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

button.voice-preview {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--mat);
  color: var(--ink);
  white-space: nowrap;
}

@media (hover: hover) {
  button.voice-preview:hover:not(:disabled) {
    filter: none;
    background: #181c24;
  }
}

.create-form textarea,
.create-form select,
.create-form input[type="text"] {
  border: 1px solid var(--line);
  background: var(--mat);
  color: var(--ink);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  width: 100%;
  min-height: var(--hit);
}

.role-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: visible;
  transition: border-color var(--duration) ease, box-shadow var(--duration) ease;
}

.role-card:hover,
.role-card:focus-within {
  border-color: var(--accent);
}

.role-link {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.role-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
  object-position: top;
  display: block;
  vertical-align: middle;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.role-card.is-creating {
  pointer-events: none;
}

/* 入场未就绪：图和文案不可点，右上 ⋯ 删除仍要能用 */
.role-card.is-waiting .role-link {
  pointer-events: none;
}

.role-pending {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.role-card.is-creating img {
  height: 100%;
  filter: blur(18px);
  transform: scale(1.08);
}

.role-pending-label {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  transform: translate(-50%, -50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: none;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.role-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-family: Fraunces, "Songti SC", Palatino, serif;
  font-weight: 500;
  line-height: 1.15;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.role-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 只钉文案区。不能用 .role-link > div 这类结构选择器：待创建卡与待入场卡的
   .role-link 本身就是 div，会被误命中而把整张卡压成 4.75rem。 */
.role-card .role-caption {
  flex: 0 0 auto;
  min-height: 4.75rem;
  padding: 12px 16px 14px;
  box-sizing: border-box;
  overflow: hidden;
}

.card-more {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
}

.card-more summary {
  display: grid;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  list-style: none;
  border-radius: 999px;
  background: rgba(13, 15, 20, 0.38);
  color: #ece7dc;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  backdrop-filter: blur(10px);
}

.card-more summary::-webkit-details-marker {
  display: none;
}

.card-more summary::marker {
  content: "";
}

.card-more[open] summary,
.card-more summary:focus-visible {
  background: rgba(13, 15, 20, 0.62);
}

@media (hover: hover) {
  .card-more summary:hover {
    background: rgba(13, 15, 20, 0.62);
  }
}

.card-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 128px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  overscroll-behavior: contain;
}

.card-menu button {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  font-weight: 500;
  text-align: left;
}

@media (hover: hover) {
  .card-menu button:hover:not(:disabled) {
    background: rgba(208, 122, 106, 0.12);
    filter: none;
  }
}

.persona-view,
.clips-label {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0;
}

.clips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
  max-height: 72px;
  overflow: auto;
}

.clip-btn {
  background: var(--mat);
  color: var(--ink);
  font-weight: 500;
}

.usage-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px max(22px, env(safe-area-inset-right)) 48px max(22px, env(safe-area-inset-left));
}

.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}

.total-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px;
}

.total-card b {
  display: block;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.total-card span {
  color: var(--muted);
  font-size: 13px;
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.usage-table th,
.usage-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}

.usage-table td {
  overflow-wrap: anywhere;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0 8px;
}

.total-card.ok {
  border-color: #3d5a32;
}

.total-card.warn {
  border-color: #6a3a2e;
}

.ops-wrap {
  max-width: 1180px;
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 18px;
  margin: 8px 0 24px;
}

.ops-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-module);
  padding: 16px 16px 8px;
  margin: 0 0 18px;
}

.ops-panel h2,
.ops-panel h3 {
  margin: 0 0 10px;
  font-family: Fraunces, serif;
  font-weight: 600;
}

.ops-table {
  font-size: 13px;
}

.ops-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ops-video-list,
.ops-chat {
  display: grid;
  gap: 12px;
}

.ops-video-card,
.ops-chat {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.ops-video-card video,
.ops-chat video {
  width: 100%;
  max-height: 240px;
  background: var(--print);
  border-radius: var(--radius-control);
}

.ops-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}

.ops-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}

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

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pendingPulse {
  0%,
  100% {
    opacity: 0.42;
  }
  50% {
    opacity: 0.85;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portrait.waiting .badge,
  .composer .mic.is-listening,
  .bubble.pending,
  .create-form.has-photo .photo-preview,
  .create-form.has-photo .create-fields {
    animation: none;
  }

  .photo-pick,
  button,
  .role-card,
  .topnav a,
  .gate-google {
    transition: none;
  }

  button:active:not(:disabled),
  .gate-google:active {
    transform: none;
  }
}

/* ---------- 账户：顶栏头像与退出（AC-001） ---------- */
.account {
  position: relative;
  margin-left: auto;
  z-index: 5;
}

.account summary {
  display: grid;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}

.account summary::-webkit-details-marker {
  display: none;
}

.account summary::marker {
  content: "";
}

.account summary img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.account[open] summary,
.account summary:focus-visible {
  border-color: var(--accent);
}

@media (hover: hover) {
  .account summary:hover {
    border-color: var(--accent);
  }
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  overscroll-behavior: contain;
}

.account-email {
  margin: 0 0 8px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.account-menu form {
  margin: 0;
}

.account-menu button {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  text-align: left;
}

@media (hover: hover) {
  .account-menu button:hover:not(:disabled) {
    filter: none;
    background: #181c24;
  }
}

/* ---------- 登录 / 候补落地页 ---------- */
.gate-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.gate-body .topnav {
  border-bottom: 0;
}

.gate {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 32px max(22px, env(safe-area-inset-right)) 72px max(22px, env(safe-area-inset-left));
}

.gate-card {
  width: min(440px, 100%);
  padding: 40px 32px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-module);
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-title {
  margin: 0 0 10px;
  font-family: Fraunces, "Songti SC", Palatino, serif;
  font-weight: 500;
  font-size: clamp(30px, 5vw, 36px);
  line-height: 1.1;
}

.gate-lead {
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 16px;
  max-width: 28em;
}

.gate-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--hit);
  padding: 10px 16px;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--print);
  font-weight: 600;
  text-decoration: none;
  transition:
    filter var(--duration) ease,
    transform var(--duration) var(--ease-out);
}

.gate-google[hidden],
.gate-dev[hidden],
.account[hidden] {
  display: none;
}

@media (hover: hover) {
  .gate-google:hover {
    filter: brightness(1.06);
  }
}

.gate-google:active {
  transform: scale(0.96);
}

.gate-google-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    conic-gradient(#4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0);
  -webkit-mask: radial-gradient(circle at center, transparent 42%, #000 44%);
  mask: radial-gradient(circle at center, transparent 42%, #000 44%);
}

.gate-dev {
  display: flex;
  gap: 8px;
  margin: 14px 0 0;
}

.gate-dev input {
  flex: 1;
  min-width: 0;
  min-height: var(--hit);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--mat);
  color: var(--ink);
  font-size: 16px;
}

.gate-dev button {
  margin: 0;
}

.gate-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.gate-fine {
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
}

.gate-fine a {
  color: var(--ink);
  text-underline-offset: 3px;
}

#invite-redeem {
  width: 100%;
  min-height: var(--hit);
}

#invite-home {
  display: inline-flex;
  min-height: var(--hit);
  align-items: center;
  color: var(--muted);
}

.gate-logout {
  margin: 22px 0 0;
}

.gate-logout button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

@media (hover: hover) {
  .gate-logout button:hover:not(:disabled) {
    filter: none;
    color: var(--ink);
    border-color: var(--accent);
  }
}

/* 账号入口：共享头像隐藏状态、个人中心链接。 */
.account summary img[hidden], .account summary span[hidden] { display: none; }
.topnav .account-menu .account-link { display: block; margin: 0; padding: 8px 10px; min-height: var(--hit); color: var(--ink); font-size: 14px; border-radius: 10px; text-decoration: none; }
@media (hover: hover) {
  .topnav .account-menu .account-link:hover { background: #181c24; }
}

/* Creation: keep the entire form visible without an inner scrolling panel. */
.create-dialog .create-form { gap: 12px; }
.create-dialog.is-ready .create-form { grid-template-columns: minmax(140px, .8fr) minmax(0, 1.2fr); align-items: start; }
.create-dialog.is-ready .photo-preview img { height: 340px; max-height: 52dvh; }
.create-dialog .create-fields { min-width: 0; gap: 10px; }
.speech-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 76px; gap: 8px; align-items: end; }
.speech-row .field, .speech-row select { min-width: 0; }
.speech-row button { width: 100%; padding-inline: 8px; }
.persona-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#persona-dice { min-height: 36px; padding: 4px 10px; margin: 0; background: var(--mat); color: var(--ink); border: 1px solid var(--line); font-size: 13px; }
#persona-dice span { font-size: 22px; vertical-align: middle; }
.create-dialog #persona { resize: none; min-height: 72px; height: 72px; }
.persona-preset { font-size: 12px; min-height: 18px; }
.create-dialog #create-status { margin: 10px 0 0; font-size: 12px; }
@media (max-width: 600px) {
  .create-dialog { padding: 16px; width: calc(100vw - 24px); }
  .create-dialog-head { margin-bottom: 8px; }
  .create-dialog-head h1 { font-size: 22px; }
  .create-dialog.is-ready .create-form { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .create-dialog.is-ready .photo-preview img { height: clamp(64px, calc(100dvh - 490px), 160px); }
  .create-dialog .create-fields { gap: 6px; }
  .create-dialog .field { gap: 4px; }
  .create-dialog .photo-preview #photo-change { right: 8px; bottom: 8px; padding: 6px 10px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  .create-dialog { padding: 12px 16px; }
  .create-dialog-head { margin-bottom: 4px; }
  .create-dialog .create-fields { gap: 4px; }
  .create-dialog .field { gap: 2px; }
  .create-dialog.is-ready .photo-preview img { height: 260px; }
  .create-dialog #create-status { margin-top: 4px; }
}
