/* =========================================================
   一句开玩 2.0 · 治愈系简笔画 / 手账贴纸视觉
   ========================================================= */

:root {
  --paper: #fff9f2;
  --paper-2: #fffdf9;
  --ink: #302a27;
  --ink-soft: #5f5751;
  --muted: #8d847d;
  --purple: #7657ef;
  --purple-deep: #5a3fd6;
  --coral: #ff8a7a;
  --mint: #b9e8c8;
  --butter: #ffe7a8;
  --lavender: #ddd3ff;
  --sky: #bee3f8;
  --blush: #f7b6c2;
  --outline: 2.5px solid var(--ink);
  --shadow: 5px 6px 0 var(--ink);
  --shadow-sm: 3px 4px 0 var(--ink);
  --display: "STHupo", "YouYuan", "幼圆", "Microsoft YaHei", sans-serif;
  --round: "YouYuan", "幼圆", "Microsoft YaHei", sans-serif;
  --font: "Microsoft YaHei", "PingFang SC", "HarmonyOS Sans SC", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

html {
  background: var(--paper);
}

body.studio-body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
}

.paper-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background-image: radial-gradient(rgba(48, 42, 39, 0.1) 1.2px, transparent 1.2px);
  background-size: 28px 28px;
  mask-image: linear-gradient(#000, rgba(0, 0, 0, 0.35) 70%, transparent);
  -webkit-mask-image: linear-gradient(#000, rgba(0, 0, 0, 0.35) 70%, transparent);
}

.paper-dot {
  position: absolute;
  border: var(--outline);
  border-radius: 50%;
}

.pd-1 {
  width: 130px;
  height: 130px;
  top: 15%;
  left: -42px;
  background: var(--butter);
}

.pd-2 {
  width: 74px;
  height: 74px;
  right: 5%;
  top: 45%;
  background: var(--mint);
}

.pd-3 {
  width: 58px;
  height: 58px;
  left: 11%;
  bottom: 8%;
  background: var(--blush);
}

.paper-scribble {
  position: absolute;
  opacity: 0.34;
}

.ps-1 {
  width: 140px;
  top: 73%;
  right: 7%;
  transform: rotate(-7deg);
}

.ps-2 {
  width: 90px;
  top: 11%;
  right: 12%;
  transform: rotate(13deg);
}

.studio-top {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 28px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.studio-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.brand-doodle {
  width: 45px;
  height: 45px;
  display: block;
  transform: rotate(-4deg);
}

.brand-doodle svg {
  width: 100%;
  height: 100%;
}

.studio-brand > span:nth-child(2) {
  display: grid;
  gap: 1px;
}

.studio-brand b {
  font-family: var(--display);
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.02em;
}

.studio-brand small {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.brand-spark {
  position: absolute;
  right: -17px;
  top: -4px;
  color: var(--coral);
  font-style: normal;
  font-size: 18px;
  transform: rotate(12deg);
}

.studio-top-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.engine-chip,
.outline-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 13px;
  border: var(--outline);
  border-radius: 999px;
  background: var(--paper-2);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  font-weight: 700;
}

.engine-chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  border: 1.5px solid var(--ink);
}

.engine-chip.is-on i {
  background: var(--mint);
}

.engine-chip.is-off i {
  background: var(--coral);
}

.engine-chip {
  cursor: pointer;
}

.outline-chip {
  background: var(--butter);
  transition: transform 0.16s, box-shadow 0.16s;
}

.outline-chip:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 5px 0 var(--ink);
}

.outline-chip:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.outline-chip svg {
  width: 17px;
  height: 17px;
}

.studio-screen {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 28px calc(34px + env(safe-area-inset-bottom, 0px));
}

.home-screen {
  animation: studioIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes studioIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(360px, 0.94fr);
  align-items: center;
  gap: 24px;
  min-height: 480px;
  padding: 22px 0 8px;
}

.hero-copy {
  padding-left: 18px;
}

.doodle-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--mint);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 11.5px;
  font-weight: 700;
  transform: rotate(-1deg);
  color: var(--ink);
  font-family: var(--font);
  cursor: pointer;
}

.doodle-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--coral);
  border: 1.5px solid var(--ink);
}

.hero-copy h1 {
  margin: 22px 0 18px;
  font-family: var(--display);
  font-size: clamp(55px, 7.2vw, 92px);
  line-height: 1.04;
  letter-spacing: -0.04em;
  font-weight: 900;
}

.title-mark {
  position: relative;
  display: inline-block;
  z-index: 0;
  color: var(--purple);
  padding: 0 8px 4px;
}

.title-mark::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 0;
  right: -8px;
  bottom: 0;
  height: 36%;
  background: var(--butter);
  border: 2px solid var(--ink);
  border-radius: 46% 54% 44% 56% / 58% 42% 58% 42%;
  transform: rotate(-2deg);
}

.title-mark span {
  color: var(--coral);
}

.hero-copy > p {
  margin: 0;
  max-width: 510px;
  font-size: 16px;
  line-height: 1.8;
  color: var(--ink-soft);
}

.hero-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 24px;
}

.hero-notes span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.hero-notes b {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--purple-deep);
}

.hero-doodle {
  position: relative;
  min-height: 460px;
}

.hero-art {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 5px 0 rgba(48, 42, 39, 0.08));
  animation: artFloat 6s ease-in-out infinite;
}

@keyframes artFloat {
  0%, 100% { transform: translateY(0) rotate(-0.6deg); }
  50% { transform: translateY(-9px) rotate(0.8deg); }
}

.doodle-tape,
.hero-note {
  position: absolute;
  z-index: 2;
  font-family: var(--round);
  border: 2.5px solid var(--ink);
  box-shadow: 3px 4px 0 var(--ink);
}

.doodle-tape {
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 800;
}

.tape-a {
  top: 14px;
  left: 8px;
  background: var(--lavender);
  transform: rotate(-6deg);
}

.tape-b {
  right: 2px;
  bottom: 36px;
  background: var(--coral);
  transform: rotate(5deg);
  color: #fff;
}

.hero-note {
  padding: 5px 9px;
  border-width: 2px;
  border-radius: 8px;
  background: var(--paper-2);
  font-size: 10px;
  color: var(--ink-soft);
  box-shadow: 2px 3px 0 var(--ink);
}

.n1 {
  left: 8%;
  top: 68%;
  transform: rotate(-5deg);
}

.n2 {
  right: 4%;
  top: 28%;
  transform: rotate(4deg);
}

.prompt-zone {
  position: relative;
  z-index: 3;
  max-width: 940px;
  margin: -14px auto 0;
}

.prompt-card {
  border: var(--outline);
  border-radius: 28px;
  background: var(--paper-2);
  padding: 21px 22px 18px;
  box-shadow: 8px 9px 0 var(--ink);
}

.prompt-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.prompt-head h2 {
  margin: 0;
  font-family: var(--round);
  font-size: 16px;
  letter-spacing: 0.01em;
}

.prompt-head h2 span {
  display: inline-block;
  color: var(--coral);
  margin-right: 4px;
  transform: rotate(10deg);
}

.char-count {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.char-count b {
  color: var(--ink);
}

#promptInput {
  display: block;
  width: 100%;
  min-height: 100px;
  max-height: 190px;
  padding: 13px 0 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 17px/1.7 var(--font);
  resize: none;
  outline: 0;
}

#promptInput::placeholder {
  color: #afa59d;
}

.genre-bar {
  display: flex;
  align-items: center;
  margin: 0 0 10px;
}

.genre-select {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1.7px dashed rgba(48, 42, 39, 0.34);
  border-radius: 12px;
  background: transparent;
  color: var(--ink-soft);
  font: 11px/1.3 var(--font);
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.genre-select:hover {
  background: var(--butter);
  border-style: solid;
}

.genre-mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: var(--paper-2);
  font-size: 10px;
  font-weight: 900;
  color: var(--purple-deep);
}

.genre-label {
  flex: none;
  font-weight: 800;
  color: var(--ink);
}

.genre-select b {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--muted);
}

.genre-caret {
  flex: none;
  color: var(--muted);
  font-size: 13px;
}

.genre-select.has-value {
  border-style: solid;
  border-color: var(--ink);
  background: rgba(185, 232, 200, 0.45);
}

.genre-select.has-value b {
  color: var(--ink);
  font-weight: 800;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 1px 0 15px;
}

.quick-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 1.7px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.15s, transform 0.15s;
}

.quick-chip:hover {
  background: var(--butter);
  transform: rotate(-1deg);
}

.genre-sheet {
  max-width: 620px;
}

.genre-sheet-body {
  padding: 16px 18px 22px;
  overflow-y: auto;
}

#genreSearch {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: 13px/1.4 var(--font);
  outline: none;
}

#genreSearch:focus {
  box-shadow: 3px 3px 0 var(--purple);
}

.genre-all {
  width: 100%;
  min-height: 38px;
  margin: 10px 0 14px;
  border: 1.7px dashed rgba(48, 42, 39, 0.35);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: 11px/1.3 var(--font);
  font-weight: 700;
}

.genre-all.is-active {
  border-style: solid;
  border-color: var(--ink);
  background: var(--mint);
  color: var(--ink);
}

.genre-group {
  margin-bottom: 14px;
}

.genre-group h3 {
  margin: 0 0 7px;
  font: 9px/1.4 var(--mono);
  letter-spacing: 0.12em;
  color: var(--muted);
}

.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.genre-chip {
  min-height: 32px;
  padding: 0 10px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font: 10.5px/1.3 var(--font);
  font-weight: 700;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.genre-chip:hover {
  transform: rotate(-1deg);
  background: var(--butter);
}

.genre-chip.is-active {
  background: var(--purple);
  color: #fff;
}

.genre-custom {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}

.genre-custom .genre-chip {
  background: var(--blush);
}

.genre-note {
  margin: 4px 0 0;
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
}

.prompt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.doodle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: var(--outline);
  border-radius: 999px;
  font-family: var(--round);
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s, box-shadow 0.14s, background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.doodle-btn:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 4px 5px 0 var(--ink);
}

.doodle-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.doodle-btn:disabled {
  opacity: 0.44;
  cursor: not-allowed;
  box-shadow: 2px 2px 0 var(--ink);
}

.doodle-btn svg {
  width: 19px;
  height: 19px;
}

.doodle-btn.primary {
  background: var(--purple);
  color: #fff;
  min-width: 194px;
}

.doodle-btn.primary:hover {
  background: #8469f3;
}

.doodle-btn.ghost {
  background: var(--paper-2);
  color: var(--ink);
}

.doodle-btn.large {
  min-height: 56px;
  padding: 0 24px;
  font-size: 16px;
}

.prompt-footnote {
  margin: 17px auto 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--muted);
}

.prompt-footnote span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--mint);
  border: 1.5px solid var(--ink);
}

.example-section,
.recent-home {
  max-width: 1040px;
  margin: 62px auto 0;
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 0 4px;
}

.section-kicker {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--purple-deep);
}

.section-title h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: -0.015em;
}

.section-note {
  font-size: 10.5px;
  color: var(--muted);
}

.idea-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}

.idea-card {
  position: relative;
  min-height: 170px;
  padding: 16px;
  text-align: left;
  border: var(--outline);
  border-radius: 22px;
  background: var(--paper-2);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s, box-shadow 0.18s;
  overflow: hidden;
}

.idea-card::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -28px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--idea-color, var(--butter));
  border: 2px solid var(--ink);
  opacity: 0.75;
}

.idea-card:hover {
  transform: translateY(-4px) rotate(-0.8deg);
  box-shadow: 6px 7px 0 var(--ink);
}

.idea-card:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.idea-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 2px solid var(--ink);
  border-radius: 17px;
  background: var(--idea-color, var(--butter));
  transform: rotate(-3deg);
}

.idea-icon svg {
  width: 32px;
  height: 32px;
}

.idea-card b {
  position: relative;
  z-index: 1;
  display: block;
  margin-bottom: 5px;
  font-family: var(--round);
  font-size: 14px;
}

.idea-card small {
  position: relative;
  z-index: 1;
  display: block;
  padding-right: 22px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--muted);
}

.recent-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 3px 12px;
  scrollbar-width: none;
}

.recent-strip::-webkit-scrollbar {
  display: none;
}

.recent-card {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  min-height: 64px;
  padding: 10px 13px;
  border: 2px solid var(--ink);
  border-radius: 17px;
  background: var(--paper-2);
  box-shadow: 2px 3px 0 var(--ink);
  text-align: left;
}

.recent-card > span:first-child {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: none;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--lavender);
  font-family: var(--display);
  font-size: 18px;
}

.recent-card b,
.recent-card small {
  display: block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-card b {
  font-size: 12px;
}

.recent-card small {
  margin-top: 2px;
  font-size: 9.5px;
  color: var(--muted);
}

.studio-footer {
  max-width: 1040px;
  margin: 70px auto 0;
  padding: 24px 8px 0;
  border-top: 2px dashed rgba(48, 42, 39, 0.2);
  text-align: center;
}

.studio-footer > div {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  color: var(--muted);
}

.studio-footer b {
  color: var(--ink);
}

.studio-footer i {
  margin: 0 5px;
  font-style: normal;
  color: var(--coral);
}

.studio-footer p {
  margin: 10px 0 0;
  font-size: 9.5px;
  color: #a49a92;
}

/* ---------------- 策划室 ---------------- */

.studio-room {
  animation: studioIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 1240px;
}

.room-head {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px 0 22px;
}

.room-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 32px;
  letter-spacing: -0.02em;
}

.round-doodle {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border: var(--outline);
  border-radius: 50%;
  background: var(--paper-2);
  box-shadow: var(--shadow-sm);
  font-family: var(--round);
  font-size: 19px;
  font-weight: 900;
  transition: transform 0.14s, box-shadow 0.14s;
}

.round-doodle:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 5px 0 var(--ink);
}

.round-doodle:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.round-doodle.light {
  background: var(--paper-2);
}

.room-head > div {
  flex: 1;
}

.room-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 37px;
  padding: 0 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--butter);
  box-shadow: 2px 3px 0 var(--ink);
  font-size: 11px;
}

.room-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
  border: 1.5px solid var(--ink);
  animation: statusPulse 1.3s ease-in-out infinite;
}

.room-status.is-done {
  background: var(--mint);
}

.room-status.is-done i {
  background: #64c987;
  animation: none;
}

.room-status.is-error {
  background: #ffd4cc;
}

@keyframes statusPulse {
  50% { transform: scale(0.55); }
}

.room-grid {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.conversation-card {
  position: sticky;
  top: 14px;
  border: var(--outline);
  border-radius: 24px;
  background: var(--paper-2);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.conversation-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 2px solid var(--ink);
  background: var(--lavender);
}

.mini-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--paper-2);
}

.mini-avatar svg {
  width: 100%;
  height: 100%;
}

.conversation-head > div {
  min-width: 0;
  flex: 1;
}

.conversation-head b {
  display: block;
  font-family: var(--round);
  font-size: 12.5px;
}

.conversation-head small {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 800;
}

.conversation-live i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--coral);
}

.message-list {
  min-height: 380px;
  max-height: 540px;
  overflow-y: auto;
  padding: 15px 14px 10px;
  background-image: radial-gradient(rgba(48, 42, 39, 0.07) 1px, transparent 1px);
  background-size: 18px 18px;
}

.message-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  animation: messageIn 0.28s ease;
}

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

.message-avatar {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1.7px solid var(--ink);
  border-radius: 9px;
  background: var(--mint);
  font-family: var(--display);
  font-size: 11px;
}

.message-row.developer .message-avatar {
  background: var(--butter);
}

.message-bubble {
  max-width: calc(100% - 35px);
  padding: 10px 11px;
  border: 2px solid var(--ink);
  border-radius: 5px 15px 15px 15px;
  background: var(--paper-2);
  box-shadow: 2px 2px 0 var(--ink);
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.user .message-bubble {
  background: var(--purple);
  color: #fff;
  border-radius: 15px 5px 15px 15px;
}

.message-row.user .message-avatar {
  order: 2;
  background: var(--lavender);
  color: var(--ink);
}

.message-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.62;
}

.message-bubble p {
  margin: 0;
  font-size: 11px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 1px 1px;
}

.typing-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  animation: typing 1.1s infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 0.14s; }
.typing-dots i:nth-child(3) { animation-delay: 0.28s; }

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

.conversation-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 13px;
  border-top: 1.5px dashed rgba(48, 42, 39, 0.2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7.5px;
}

.room-main {
  min-width: 0;
  display: grid;
  gap: 15px;
}

.build-board,
.design-preview,
.ready-card,
.error-card {
  border: var(--outline);
  border-radius: 24px;
  background: var(--paper-2);
  box-shadow: var(--shadow);
}

.build-board {
  padding: 20px 21px 19px;
}

.build-board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.build-board h2 {
  margin: 2px 0 6px;
  font-family: var(--display);
  font-size: 27px;
  letter-spacing: -0.025em;
}

.build-board p {
  margin: 0;
  font-size: 11px;
  line-height: 1.65;
  color: var(--muted);
}

#progressNumber {
  flex: none;
  padding-top: 4px;
  font-family: var(--mono);
  font-size: 23px;
  letter-spacing: -0.06em;
}

.progress-track {
  height: 14px;
  margin: 17px 0 18px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 3%;
  height: 100%;
  border-right: 2px solid var(--ink);
  background: repeating-linear-gradient(
    -45deg,
    var(--purple) 0 9px,
    #8f77f4 9px 18px
  );
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stage-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-height: 58px;
  padding: 9px;
  border: 1.5px dashed rgba(48, 42, 39, 0.18);
  border-radius: 13px;
  background: var(--paper);
  opacity: 0.62;
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
}

.stage-item i {
  width: 14px;
  height: 14px;
  flex: none;
  margin-top: 1px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-2);
}

.stage-item b {
  display: block;
  font-size: 9.5px;
  line-height: 1.35;
}

.stage-item small {
  display: block;
  margin-top: 2px;
  font-size: 7.5px;
  line-height: 1.45;
  color: var(--muted);
}

.stage-item.is-active {
  opacity: 1;
  border-style: solid;
  border-color: var(--ink);
  background: var(--butter);
}

.stage-item.is-active i {
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

.stage-item.is-done {
  opacity: 1;
  border-style: solid;
  border-color: var(--ink);
  background: #edf9f1;
}

.stage-item.is-done i {
  position: relative;
  background: var(--mint);
}

.stage-item.is-done i::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0;
  width: 4px;
  height: 7px;
  border: solid var(--ink);
  border-width: 0 1.7px 1.7px 0;
  transform: rotate(42deg);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.design-preview {
  padding: 19px 21px;
}

.design-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.design-stamp {
  display: inline-flex;
  padding: 5px 9px;
  border: 1.7px solid var(--ink);
  border-radius: 7px;
  background: var(--mint);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  transform: rotate(-1.5deg);
}

.text-link {
  padding: 4px 0;
  border: 0;
  background: none;
  font-size: 10px;
  font-weight: 700;
  color: var(--purple-deep);
}

.design-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 13px;
}

.design-icon {
  width: 58px;
  height: 58px;
  flex: none;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: var(--lavender);
  font-family: var(--display);
  font-size: 28px;
  transform: rotate(-3deg);
}

.design-title-row h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 29px;
  letter-spacing: -0.03em;
}

.design-title-row p {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.design-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.design-meta span {
  padding: 4px 8px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 8.5px;
  font-weight: 700;
}

.design-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.design-columns > div {
  padding: 11px 12px;
  border: 1.5px solid rgba(48, 42, 39, 0.16);
  border-radius: 14px;
  background: var(--paper);
}

.design-columns h3 {
  margin: 0 0 7px;
  font-family: var(--round);
  font-size: 11px;
}

.design-columns ol,
.design-columns ul {
  margin: 0;
  padding-left: 17px;
}

.design-columns li {
  margin: 4px 0;
  padding-left: 2px;
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.design-rules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.design-rules > div {
  display: flex;
  gap: 8px;
  padding: 7px 9px;
  border: 1.5px dashed rgba(48, 42, 39, 0.2);
  border-radius: 10px;
}

.design-rules span {
  flex: none;
  font-size: 8px;
  font-weight: 800;
  color: var(--purple-deep);
}

.design-rules b {
  font-size: 8.5px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink-soft);
}

.error-card {
  display: flex;
  gap: 14px;
  padding: 20px;
  background: #fff0ec;
}

.error-card > span {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--coral);
  font-family: var(--display);
  font-size: 24px;
}

.error-card h2 {
  margin: 0 0 5px;
  font-family: var(--display);
  font-size: 23px;
}

.error-card p {
  margin: 0 0 12px;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--ink-soft);
  word-break: break-word;
}

.ready-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 21px;
  overflow: hidden;
  background: #edf9f1;
}

.ready-burst {
  width: 58px;
  height: 58px;
  flex: none;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: var(--butter);
  font-size: 28px;
  transform: rotate(-5deg);
}

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

.ready-copy h2 {
  margin: 0 0 5px;
  font-family: var(--display);
  font-size: 26px;
  letter-spacing: -0.02em;
}

.ready-copy p {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.ready-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.ready-actions .ghost {
  min-height: 42px;
  padding: 0 13px;
  font-size: 10.5px;
}

/* ---------------- 游戏页 ---------------- */

.game-screen {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #ebe5da;
  padding: calc(7px + env(safe-area-inset-top, 0px)) 8px calc(7px + env(safe-area-inset-bottom, 0px));
}

.game-toolbar {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 9px;
}

.game-name {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.game-name span {
  flex: none;
  padding: 3px 6px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: var(--mint);
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 800;
}

.game-name b {
  min-width: 0;
  font-family: var(--round);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-tools {
  display: flex;
  gap: 6px;
}

.tool-btn {
  min-height: 34px;
  padding: 0 10px;
  border: 1.7px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-2);
  box-shadow: 2px 2px 0 var(--ink);
  font-size: 9.5px;
  font-weight: 700;
}

.tool-btn:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.game-stage {
  position: relative;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 5px 6px 0 var(--ink);
}

#gameFrame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--paper);
}

.game-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--paper);
  font-size: 12px;
  transition: opacity 0.25s;
}

.game-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-doodle {
  font-size: 38px;
  color: var(--coral);
  animation: loadingSpin 1.7s ease-in-out infinite;
}

@keyframes loadingSpin {
  50% { transform: rotate(24deg) scale(1.15); }
}

/* ---------------- 抽屉与历史 ---------------- */

.studio-sheet-backdrop {
  z-index: 100;
  padding: 18px;
  background: rgba(48, 42, 39, 0.42);
  backdrop-filter: none;
}

.studio-sheet {
  width: 100%;
  max-width: 820px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  border: 3px solid var(--ink);
  border-radius: 25px;
  background: var(--paper-2);
  box-shadow: 8px 9px 0 var(--ink);
  overflow: hidden;
  animation: sheetPop 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.studio-sheet.compact {
  max-width: 540px;
}

@keyframes sheetPop {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 17px 19px;
  border-bottom: 2px solid var(--ink);
  background: var(--butter);
}

.sheet-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 25px;
}

.doc-scroll {
  overflow-y: auto;
  padding: 20px 22px 28px;
}

.engine-setup {
  padding: 18px 20px 22px;
  display: grid;
  gap: 12px;
  overflow-y: auto;
}

.engine-setup > p {
  margin: 0;
  font: 12px/1.75 var(--font);
  color: var(--ink-soft);
}

.engine-setup code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--butter);
  font-family: var(--mono, monospace);
  font-size: 11px;
}

.engine-field {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.engine-field input,
.engine-field select {
  display: block;
  width: 100%;
  height: 46px;
  margin-top: 6px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: 13px/1.4 var(--font);
  outline: none;
}

.engine-field input:focus,
.engine-field select:focus {
  box-shadow: 3px 3px 0 var(--purple);
}

#engineSave {
  width: 100%;
  min-width: 0;
}

.engine-note {
  margin: 0;
  text-align: center;
  font-size: 10px !important;
  color: var(--muted) !important;
}

.design-doc-text {
  margin: 0;
  font: 12px/1.82 var(--font);
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.studio-history {
  overflow-y: auto;
  padding: 17px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 66px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 15px;
  background: var(--paper);
  box-shadow: 2px 3px 0 var(--ink);
  text-align: left;
}

.history-item + .history-item {
  margin-top: 8px;
}

.history-icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1.7px solid var(--ink);
  border-radius: 12px;
  background: var(--lavender);
  font-family: var(--display);
  font-size: 18px;
}

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

.history-copy b,
.history-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-copy b {
  font-size: 11.5px;
}

.history-copy small {
  margin-top: 2px;
  font-size: 9px;
  color: var(--muted);
}

.history-open {
  flex: none;
  font-size: 10px;
  font-weight: 800;
  color: var(--purple-deep);
}

.history-empty {
  padding: 45px 20px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--muted);
}

.studio-body .toast {
  z-index: 120;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--ink);
  box-shadow: 4px 4px 0 rgba(48, 42, 39, 0.25);
  font-family: var(--round);
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 980px) {
  .home-hero {
    grid-template-columns: 1fr 400px;
    min-height: 430px;
  }

  .hero-copy h1 {
    font-size: clamp(52px, 8.2vw, 72px);
  }

  .idea-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .room-grid {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .stage-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ready-card {
    flex-wrap: wrap;
  }

  .ready-actions {
    width: 100%;
    padding-left: 74px;
  }
}

@media (max-width: 760px) {
  .studio-top {
    padding: calc(13px + env(safe-area-inset-top, 0px)) 16px 8px;
  }

  .engine-chip {
    display: none;
  }

  .studio-screen {
    padding-left: 16px;
    padding-right: 16px;
  }

  .home-hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-top: 26px;
  }

  .hero-copy {
    padding-left: 2px;
    text-align: center;
  }

  .hero-copy h1 {
    margin-top: 18px;
    font-size: clamp(53px, 17vw, 76px);
  }

  .hero-copy > p {
    margin: 0 auto;
    max-width: 430px;
    font-size: 14px;
  }

  .hero-notes {
    justify-content: center;
  }

  .hero-doodle {
    min-height: 0;
    width: min(100%, 430px);
    margin: -6px auto -8px;
    order: -1;
  }

  .hero-art {
    max-height: 345px;
  }

  .doodle-tape {
    font-size: 9.5px;
  }

  .hero-note {
    display: none;
  }

  .prompt-zone {
    margin-top: 8px;
  }

  .prompt-card {
    border-radius: 24px;
    padding: 17px 16px 15px;
    box-shadow: 5px 6px 0 var(--ink);
  }

  #promptInput {
    min-height: 104px;
    font-size: 15.5px;
  }

  .prompt-actions {
    align-items: stretch;
  }

  .doodle-btn {
    min-height: 46px;
    padding: 0 14px;
    font-size: 12.5px;
  }

  .doodle-btn.primary {
    flex: 1;
    min-width: 0;
  }

  .doodle-btn.ghost svg {
    display: none;
  }

  .example-section,
  .recent-home {
    margin-top: 48px;
  }

  .section-title h2 {
    font-size: 21px;
  }

  .idea-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .idea-card {
    min-height: 148px;
    padding: 12px;
  }

  .idea-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 13px;
    border-radius: 14px;
  }

  .idea-icon svg {
    width: 27px;
    height: 27px;
  }

  .idea-card b {
    font-size: 12px;
  }

  .idea-card small {
    font-size: 9px;
  }

  .studio-footer {
    margin-top: 50px;
  }

  .room-head {
    padding: 12px 0 17px;
  }

  .room-head h1 {
    font-size: 26px;
  }

  .room-status {
    min-height: 33px;
    padding: 0 10px;
    font-size: 9.5px;
  }

  .room-grid {
    grid-template-columns: 1fr;
  }

  .conversation-card {
    position: static;
    order: 2;
  }

  .message-list {
    min-height: 250px;
    max-height: 360px;
  }

  .build-board {
    padding: 17px 15px;
  }

  .build-board h2 {
    font-size: 23px;
  }

  .stage-list {
    grid-template-columns: 1fr 1fr;
  }

  .design-preview {
    padding: 16px 15px;
  }

  .design-title-row h2 {
    font-size: 25px;
  }

  .design-icon {
    width: 51px;
    height: 51px;
    font-size: 24px;
  }

  .design-columns {
    grid-template-columns: 1fr;
  }

  .design-rules {
    grid-template-columns: 1fr;
  }

  .ready-card {
    padding: 17px 15px;
  }

  .ready-copy h2 {
    font-size: 22px;
  }

  .ready-actions {
    padding-left: 0;
  }

  .ready-actions .doodle-btn {
    flex: 1;
  }

  .studio-sheet-backdrop {
    padding: 10px;
  }

  .studio-sheet {
    max-height: 92dvh;
  }

  .game-screen {
    padding-left: 5px;
    padding-right: 5px;
  }

  .game-stage {
    border-radius: 16px;
    box-shadow: 3px 4px 0 var(--ink);
  }

  .game-toolbar {
    padding-bottom: 7px;
  }

  .game-tools {
    gap: 4px;
  }

  .tool-btn {
    padding: 0 8px;
  }
}

@media (max-width: 430px) {
  .studio-brand b {
    font-size: 18px;
  }

  .outline-chip {
    min-height: 37px;
    padding: 0 10px;
    font-size: 10.5px;
  }

  .home-hero {
    padding-top: 18px;
  }

  .hero-doodle {
    width: min(100%, 365px);
  }

  .hero-copy h1 {
    font-size: clamp(48px, 16.2vw, 64px);
  }

  .doodle-badge {
    font-size: 9.5px;
  }

  .hero-notes {
    gap: 7px 11px;
  }

  .hero-notes span {
    font-size: 9.5px;
  }

  .prompt-head h2 {
    font-size: 14px;
  }

  .quick-row {
    display: none;
  }

  .idea-card {
    min-height: 141px;
  }

  .idea-card small {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .section-note {
    font-size: 9px;
  }

  .room-status b {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .room-head {
    gap: 10px;
  }

  .room-head .round-doodle {
    width: 39px;
    height: 39px;
  }

  .ready-burst {
    width: 47px;
    height: 47px;
  }

  .ready-card {
    gap: 10px;
  }

  .ready-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .game-name span {
    display: none;
  }

  .round-doodle.light {
    width: 38px;
    height: 38px;
  }
}

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