/* ปั้นเรื่อง · หน้าตาแนว iOS รุ่น Pro: พื้นมืด กระจกฝ้า มุมโค้งใหญ่ ปุ่มแคปซูล
 * สีและขนาดทั้งหมดอ้างจาก tokens.css
 */

/* ---------- พื้นฐาน ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; background: var(--color-paper); }
body {
  margin: 0; min-height: 100dvh;
  background:
    radial-gradient(52rem 34rem at 88% -8%, var(--glow-warm), transparent 70%),
    radial-gradient(46rem 32rem at -6% 104%, var(--glow-cool), transparent 70%),
    var(--color-paper);
  background-attachment: fixed;
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, fieldset, legend { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--color-accent-deep); text-underline-offset: 0.2em; }
code { font-family: var(--font-mono); font-size: 0.92em; padding: 0.1em 0.4em; border-radius: 6px; background: var(--color-fill-2); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip {
  position: absolute; left: var(--space-md); top: -4rem; z-index: var(--z-toast);
  padding: var(--space-xs) var(--space-md); border-radius: var(--radius-pill);
  background: var(--color-ink); color: var(--color-paper);
}
.skip:focus { top: var(--space-md); }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }

.icon { width: 1.25em; height: 1.25em; flex: none; display: block; }
[data-icon] { display: inline-flex; }

/* พื้นผิวกระจกฝ้า ใช้ร่วมกันหลายที่ */
.rail, .bar, .chat, .stage, .toast, .confirm__card, .thinking__card {
  background: var(--color-glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: var(--rule-hair) solid var(--color-glass-edge);
}

/* ---------- โครงหน้า ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100dvh; }

.rail {
  position: sticky; top: var(--space-sm); z-index: var(--z-rail);
  height: calc(100dvh - var(--space-lg)); margin: var(--space-sm) 0 var(--space-sm) var(--space-sm);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-xl);
  padding: var(--space-lg) var(--space-xs);
  border-radius: var(--radius-sheet); box-shadow: var(--shadow-float);
}
.rail__brand { display: grid; justify-items: center; gap: var(--space-xs); color: var(--color-ink); text-decoration: none; border-radius: var(--radius-input); }
.mark { width: 2.75rem; height: 2.75rem; display: block; }
.mark__tile { fill: var(--color-accent); }
.mark__dot { fill: var(--color-accent-ink); }
.mark__play { fill: var(--color-ink); }
.rail__name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xs); letter-spacing: var(--track-tight); white-space: nowrap; }
.rail__links { display: grid; gap: var(--space-xs); width: 100%; }
.rail__link {
  display: grid; justify-items: center; gap: 3px;
  padding: var(--space-sm) var(--space-2xs);
  border-radius: var(--radius-input);
  color: var(--color-muted); text-decoration: none; font-size: var(--text-xs); font-weight: 500; white-space: nowrap;
  transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}
.rail__link .icon { width: 1.5rem; height: 1.5rem; }
.rail__link:hover { background: var(--color-fill); color: var(--color-ink); }
.rail__link.is-current { background: var(--color-fill-2); color: var(--color-accent-deep); box-shadow: var(--shadow-card); }

.conn {
  margin-top: auto; display: grid; justify-items: center; gap: var(--space-2xs);
  padding: var(--space-xs); border-radius: var(--radius-input);
  color: var(--color-ink-2); text-decoration: none; font-size: 0.75rem; line-height: 1.35; text-align: center;
}
.conn:hover { background: var(--color-fill); }
.conn__dot { width: 0.625rem; height: 0.625rem; border-radius: var(--radius-pill); background: var(--color-sun); }
.conn[data-state="live"] .conn__dot { background: var(--color-ok); }

.main { min-width: 0; padding: var(--space-xl) clamp(var(--space-md), 4vw, var(--space-2xl)) 0; display: flex; flex-direction: column; }

/* ---------- แถบขั้นตอน ---------- */
.steps { display: flex; align-items: flex-start; max-width: 34rem; margin-bottom: var(--space-xl); }
.steps li { flex: 1 1 0; position: relative; min-width: 0; }
.steps li + li::before, .steps li + li::after {
  content: ""; position: absolute; top: 1.3125rem; right: calc(50% + 1.75rem); width: calc(100% - 3.5rem); height: 3px;
  border-radius: var(--radius-pill); background: var(--color-fill-2);
}
.steps li + li::after { background: var(--color-accent); transform: scaleX(0); transform-origin: left center; transition: transform var(--dur-long) var(--ease-out); }
.steps li.is-reached::after { transform: scaleX(1); }
.steps__item {
  position: relative; z-index: var(--z-base); width: 100%;
  display: grid; justify-items: center; gap: var(--space-xs);
  padding: 0; border: 0; background: none; cursor: pointer; border-radius: var(--radius-input);
  color: var(--color-muted); font-size: var(--text-sm); font-weight: 500; white-space: nowrap;
}
.steps__item:disabled { cursor: default; }
.steps__node {
  width: 2.75rem; height: 2.75rem; border-radius: var(--radius-pill);
  display: grid; place-items: center;
  background: var(--color-paper-2); border: var(--rule-hair) solid var(--color-rule); color: var(--color-muted);
  transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out);
}
.steps li.is-done .steps__node { background: var(--color-fill-2); color: var(--color-accent-deep); border-color: transparent; }
.steps li.is-current .steps__node { background: var(--color-accent); border-color: transparent; color: var(--color-accent-ink); transform: scale(1.1); box-shadow: var(--shadow-thumb); }
.steps li.is-current .steps__item, .steps li.is-done .steps__item { color: var(--color-ink); }
.steps li.is-current .steps__label { font-weight: 600; }
.steps__item:not(:disabled):hover .steps__node { background: var(--color-paper-3); }
.steps li.is-current .steps__item:hover .steps__node { background: var(--color-accent); }

/* ---------- หัวเรื่อง ---------- */
.head { display: grid; gap: var(--space-xs); margin-bottom: var(--space-xl); }
.title {
  font-family: var(--font-display); font-weight: 700; font-size: var(--text-display);
  line-height: var(--leading-tight); letter-spacing: var(--track-tight); overflow-wrap: anywhere; min-width: 0;
}
.title:focus { outline: none; }
.lede { color: var(--color-ink-2); max-width: 38rem; }

/* ---------- การปรากฏ ---------- */
.reveal { opacity: 0; transform: translateY(14px) scale(0.985); animation: reveal var(--dur-long) var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes reveal { to { opacity: 1; transform: none; } }
.step { flex: 1; display: flex; flex-direction: column; }
.step.is-entering > :first-child { animation: step-in var(--dur-long) var(--ease-out); }
@keyframes step-in { from { opacity: 0; transform: translateY(16px) scale(0.99); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.86); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ขั้นที่ 1 ---------- */
.idea { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 21rem); gap: var(--space-2xl); align-items: start; flex: 1; }
.idea__form { display: grid; gap: var(--space-xl); min-width: 0; padding-bottom: var(--space-2xl); }
.idea__form .head { margin-bottom: 0; }
.q { display: grid; gap: var(--space-sm); }
.q__title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); line-height: var(--leading-tight); letter-spacing: var(--track-tight); margin-bottom: var(--space-sm); display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-xs); }
.q__opt { font-family: var(--font-body); font-weight: 400; font-size: var(--text-sm); color: var(--color-muted); letter-spacing: 0; }
.hint { font-size: var(--text-sm); color: var(--color-muted); }

/* การ์ดเลือกชนิดผลงาน */
.kinds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-md); }
.kind {
  position: relative; display: grid; gap: 2px; align-content: start;
  padding: var(--space-xs); padding-bottom: var(--space-md);
  background: var(--color-surface); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2);
  cursor: pointer;
  transition: transform var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out);
}
.kind input, .style input, .shape input, .seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.kind:hover { transform: translateY(-3px); background: var(--color-paper-3); }
.kind:active { transform: scale(0.98); }
.kind:has(input:checked) { background: var(--color-paper-3); box-shadow: var(--shadow-card), 0 0 0 2px var(--color-accent); }
.kind:has(input:focus-visible), .style:has(input:focus-visible), .shape:has(input:focus-visible), .seg label:has(input:focus-visible) { outline: 2px solid var(--color-focus); outline-offset: 3px; }
.kind__name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); line-height: var(--leading-tight); letter-spacing: var(--track-tight); margin-top: var(--space-sm); padding-inline: var(--space-xs); }
.kind__hint { font-size: var(--text-sm); color: var(--color-ink-2); line-height: 1.45; padding-inline: var(--space-xs); }

.tick {
  position: absolute; top: var(--space-sm); right: var(--space-sm); z-index: var(--z-base);
  width: 1.625rem; height: 1.625rem; border-radius: var(--radius-pill);
  display: grid; place-items: center;
  background: var(--color-accent); color: var(--color-accent-ink);
  box-shadow: 0 4px 10px -2px var(--color-film);
  transform: scale(0.4); opacity: 0;
  transition: transform var(--dur-short) var(--ease-out), opacity var(--dur-micro) var(--ease-out);
  pointer-events: none;
}
.tick .icon { width: 0.95rem; height: 0.95rem; stroke-width: 2.75; }
:is(.kind, .style, .shape):has(input:checked) .tick { transform: scale(1); opacity: 1; }

.kind__art { position: relative; display: block; aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden; background: var(--color-paper-2); }
/* วิดีโอ: แถบฟิล์มเลื่อนเมื่อถูกเลือก */
.kind--video .kind__art { background: var(--color-film); display: grid; grid-template-rows: 14% 1fr 14%; }
.kind__scene { display: block; overflow: hidden; min-height: 0; }
.kind__scene .art, .kind__photo .art { width: 100%; height: 100%; display: block; }
.kind__strip { display: block; position: relative; overflow: hidden; }
.kind__strip::before {
  content: ""; position: absolute; inset: 24% -24px 24% 0; width: calc(100% + 48px);
  background: repeating-linear-gradient(90deg, var(--color-film-hole) 0 10px, transparent 10px 24px);
  border-radius: 2px;
}
.kind:has(input:checked) .kind__strip::before { animation: film 900ms linear infinite; }
.kind:has(input:checked) .kind__strip--b::before { animation-direction: reverse; }
@keyframes film { to { transform: translateX(-24px); } }
.kind__play {
  position: absolute; left: 50%; top: 50%; width: 2.75rem; height: 2.75rem; margin: -1.375rem 0 0 -1.375rem;
  display: grid; place-items: center; border-radius: var(--radius-pill);
  background: var(--color-glass-strong); color: var(--color-ink);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: var(--rule-hair) solid var(--color-glass-edge);
  transition: transform var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}
.kind__play .icon { fill: currentColor; width: 1.05rem; height: 1.05rem; margin-left: 2px; }
.kind:hover .kind__play { transform: scale(1.08); }
.kind:has(input:checked) .kind__play { transform: scale(1.08); background: var(--color-accent); color: var(--color-accent-ink); border-color: transparent; }
/* ภาพนิ่ง: รูปถ่ายซ้อนกัน คลี่ออกเมื่อถูกเลือก */
.kind--image .kind__art { background: var(--color-teal-soft); }
.kind__photo {
  position: absolute; inset: 14% 20% 14% 20%; display: block; overflow: hidden;
  border: 4px solid var(--color-photo); border-radius: 6px; background: var(--color-teal);
  box-shadow: 0 10px 20px -8px var(--color-film);
  transition: transform var(--dur-long) var(--ease-out);
}
.kind__photo--back { transform: rotate(5deg) translateX(6%); }
.kind__photo--front { transform: rotate(-3deg); }
.kind--image:hover .kind__photo--back, .kind--image:has(input:checked) .kind__photo--back { transform: rotate(11deg) translateX(16%); }
.kind--image:hover .kind__photo--front, .kind--image:has(input:checked) .kind__photo--front { transform: rotate(-6deg) translateX(-8%); }
/* เสียง: แท่งคลื่นเสียงเต้นเมื่อถูกเลือก */
.kind--audio .kind__art { background: var(--color-sun-soft); display: grid; place-items: center; }
.kind__bars { display: flex; align-items: center; gap: 5px; height: 62%; }
.kind__bars i { display: block; width: 5px; height: 100%; border-radius: var(--radius-pill); background: var(--color-ink); transform: scaleY(var(--h, 0.4)); }
.kind__bars i:nth-child(1) { --h: 0.25; } .kind__bars i:nth-child(2) { --h: 0.5; } .kind__bars i:nth-child(3) { --h: 0.8; }
.kind__bars i:nth-child(4) { --h: 0.45; } .kind__bars i:nth-child(5) { --h: 1; background: var(--color-accent); } .kind__bars i:nth-child(6) { --h: 0.6; }
.kind__bars i:nth-child(7) { --h: 0.85; } .kind__bars i:nth-child(8) { --h: 0.4; } .kind__bars i:nth-child(9) { --h: 0.22; }
.kind__bars i:nth-child(10) { --h: 0.55; } .kind__bars i:nth-child(11) { --h: 0.9; background: var(--color-accent); } .kind__bars i:nth-child(12) { --h: 0.5; } .kind__bars i:nth-child(13) { --h: 0.3; }
.kind:has(input:checked) .kind__bars i, .stage__canvas[data-kind="audio"] .kind__bars i { animation: bars 1100ms var(--ease-in-out) infinite alternate; animation-delay: calc(var(--h) * -900ms); }
@keyframes bars { from { transform: scaleY(calc(var(--h) * 0.45)); } to { transform: scaleY(var(--h)); } }
.kind__mic {
  position: absolute; left: 8%; bottom: 10%; width: 2rem; height: 2rem; display: grid; place-items: center;
  border-radius: var(--radius-pill); background: var(--color-glass-strong); border: var(--rule-hair) solid var(--color-glass-edge);
}
.kind__mic .icon { width: 1.05rem; height: 1.05rem; }

/* ช่องกรอก */
.field { display: grid; gap: var(--space-xs); }
.input {
  width: 100%; padding: var(--space-sm) var(--space-md);
  background: var(--color-fill); border: var(--rule-hair) solid var(--color-rule-2); border-radius: var(--radius-input);
  line-height: 1.6; resize: vertical;
  transition: border-color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out);
}
.input::placeholder { color: var(--color-muted); }
.input:hover { background: var(--color-fill-2); }
.input:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -1px; border-color: transparent; background: var(--color-fill-2); }
.input:disabled { opacity: 0.5; cursor: not-allowed; }
.input[aria-invalid="true"] { outline: 2px solid var(--color-danger); outline-offset: -1px; border-color: transparent; }
.input--idea { font-size: var(--text-lg); min-height: 8.5rem; border-radius: var(--radius-card); padding: var(--space-md) var(--space-lg); }
.input--mono { font-family: var(--font-mono); font-size: var(--text-sm); }
.field__error { display: flex; align-items: center; gap: var(--space-xs); color: var(--color-danger); font-size: var(--text-sm); font-weight: 500; }

.examples { display: grid; gap: var(--space-xs); margin-top: var(--space-xs); }
.examples__label { font-size: var(--text-sm); color: var(--color-ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.chip {
  padding: 0.45rem 0.95rem; border-radius: var(--radius-pill);
  background: var(--color-fill-2); border: 0; color: var(--color-ink);
  font-size: var(--text-sm); line-height: 1.5; text-align: left; cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.chip:hover { background: var(--color-accent-soft); color: var(--color-accent-deep); }
.chip:active { transform: scale(0.96); }
.chip:disabled { opacity: 0.5; cursor: not-allowed; }

/* ช่องวางไฟล์ต้นแบบ */
.drop {
  position: relative; display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border: 1.5px dashed var(--color-rule); border-radius: var(--radius-card);
  background: var(--color-fill); cursor: pointer;
  transition: background-color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out);
}
.drop:hover, .drop.is-over { background: var(--color-accent-soft); border-color: var(--color-accent); }
.drop:has(input:focus-visible) { outline: 2px solid var(--color-focus); outline-offset: 3px; }
.drop__art {
  flex: none; width: 3rem; height: 3rem; display: grid; place-items: center;
  border-radius: var(--radius-pill); background: var(--color-fill-2); color: var(--color-accent-deep);
  transition: transform var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}
.drop:hover .drop__art, .drop.is-over .drop__art { transform: translateY(-3px); background: var(--color-accent); color: var(--color-accent-ink); }
.drop__text { display: grid; gap: 2px; min-width: 0; }
.drop__text strong { font-weight: 600; }
.drop__text span { font-size: var(--text-sm); color: var(--color-ink-2); line-height: 1.5; }

.refs { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.refs:empty { display: none; }
.ref {
  position: relative; width: 6.5rem; aspect-ratio: 4 / 3; border-radius: var(--radius-input); overflow: hidden;
  background: var(--color-paper-3); box-shadow: 0 0 0 var(--rule-hair) var(--color-rule);
  animation: pop var(--dur-long) var(--ease-out);
}
.ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref__badge, .ref__remove, .result__stamp, .scene__num {
  background: var(--color-glass-strong); color: var(--color-ink);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
.ref__badge { position: absolute; left: 5px; bottom: 5px; display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: var(--radius-pill); font-size: 0.6875rem; line-height: 1.5; }
.ref__badge .icon { width: 0.75rem; height: 0.75rem; }
.ref__remove { position: absolute; top: 5px; right: 5px; width: 1.625rem; height: 1.625rem; display: grid; place-items: center; border: 0; border-radius: var(--radius-pill); cursor: pointer; transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out); }
.ref__remove .icon { width: 0.85rem; height: 0.85rem; stroke-width: 2.25; }
.ref__remove:hover { background: var(--color-danger); color: var(--color-ink); }
.ref.is-busy { display: grid; place-items: center; font-size: var(--text-xs); color: var(--color-ink-2); text-align: center; padding: var(--space-xs); line-height: 1.4; }
.ref.is-busy::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--color-accent);
  transform: scaleX(var(--p, 0.08)); transform-origin: left center; transition: transform var(--dur-short) var(--ease-out);
}
.local { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); color: var(--color-ink-2); }

/* สวิตช์แบบ iOS */
.check { display: flex; align-items: center; gap: var(--space-sm); cursor: pointer; font-size: var(--text-sm); position: relative; width: fit-content; }
.check input { position: absolute; opacity: 0; width: 3.1875rem; height: 1.9375rem; margin: 0; cursor: pointer; }
.check__box {
  position: relative; flex: none; width: 3.1875rem; height: 1.9375rem; border-radius: var(--radius-pill);
  background: var(--color-paper-3); transition: background-color var(--dur-short) var(--ease-out);
}
.check__box .icon { display: none; }
.check__box::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 1.6875rem; height: 1.6875rem; border-radius: var(--radius-pill);
  background: var(--color-ink); box-shadow: 0 3px 8px var(--color-film);
  transition: transform var(--dur-short) var(--ease-out);
}
.check input:checked + .check__box { background: var(--color-ok); }
.check input:checked + .check__box::after { transform: translateX(1.25rem); }
.check input:focus-visible + .check__box { outline: 2px solid var(--color-focus); outline-offset: 3px; }
/* สวิตช์ขนาดเล็กสำหรับตัวเลือกรายช็อต */
.check--mini { gap: var(--space-xs); color: var(--color-ink-2); }
.check--mini input { width: 2.375rem; height: 1.4375rem; }
.check--mini .check__box { width: 2.375rem; height: 1.4375rem; }
.check--mini .check__box::after { width: 1.1875rem; height: 1.1875rem; }
.check--mini input:checked + .check__box::after { transform: translateX(0.9375rem); }
.scene__animate:empty { display: none; }
.plan-tools { display: grid; gap: var(--space-2xs); padding: var(--space-sm) var(--space-md); border-radius: var(--radius-md); background: var(--color-fill-2); }
.plan-tools__note { font-size: var(--text-xs); color: var(--color-muted); }

/* การ์ดสไตล์ */
.styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-md) var(--space-sm); }
.style { position: relative; display: grid; gap: var(--space-xs); cursor: pointer; }
.style__art {
  display: block; aspect-ratio: 16 / 10; border-radius: 18px; overflow: hidden; background: var(--color-paper-2);
  box-shadow: 0 0 0 var(--rule-hair) var(--color-rule-2);
  transition: transform var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out);
}
.style__art .art { width: 100%; height: 100%; display: block; }
.style:hover .style__art { transform: translateY(-3px); }
.style:active .style__art { transform: scale(0.98); }
.style:has(input:checked) .style__art { outline: 2.5px solid var(--color-accent); outline-offset: 3px; }
.style__name { font-weight: 600; font-size: var(--text-sm); line-height: 1.4; padding-inline: var(--space-2xs); }
.style__hint { display: block; font-weight: 400; color: var(--color-muted); font-size: var(--text-xs); }
.style:has(input:checked) .style__name { color: var(--color-accent-deep); }

/* รูปทรงเฟรม */
.shapes { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.shapes:empty { display: none; }
.shape {
  position: relative; display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg) var(--space-sm) var(--space-sm);
  background: var(--color-surface); border-radius: var(--radius-card); cursor: pointer;
  box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2);
  transition: box-shadow var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.shape:hover { background: var(--color-paper-3); }
.shape:active { transform: scale(0.98); }
.shape:has(input:checked) { background: var(--color-paper-3); box-shadow: var(--shadow-card), 0 0 0 2px var(--color-accent); }
.shape__glyph { width: 2.75rem; height: 2.75rem; display: grid; place-items: center; flex: none; }
.shape__glyph i { display: block; border-radius: 5px; background: var(--color-fill-2); box-shadow: inset 0 0 0 1.5px var(--color-muted); transition: background-color var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out); }
.shape:has(input:checked) .shape__glyph i { background: var(--color-accent); box-shadow: none; }
.shape[data-aspect="16:9"] .shape__glyph i { width: 2.6rem; height: 1.46rem; }
.shape[data-aspect="9:16"] .shape__glyph i { width: 1.46rem; height: 2.6rem; border-radius: 6px; }
.shape[data-aspect="1:1"] .shape__glyph i { width: 2rem; height: 2rem; }
.shape__text { display: grid; line-height: 1.4; padding-right: var(--space-lg); }
.shape__text strong { font-weight: 600; font-size: var(--text-sm); }
.shape__text span { font-size: var(--text-xs); color: var(--color-ink-2); }
.shape .tick { top: 50%; right: var(--space-sm); margin-top: -0.8125rem; box-shadow: none; }

/* ตัวเลือกแบบแถบ (segmented control) */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--color-fill-2); border-radius: var(--radius-input); width: fit-content; max-width: 100%; margin-top: var(--space-xs); }
.seg label { position: relative; display: grid; padding: var(--space-xs) var(--space-lg); border-radius: 11px; cursor: pointer; line-height: 1.4; text-align: center; transition: background-color var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out); }
.seg label strong { font-weight: 600; font-size: var(--text-sm); white-space: nowrap; }
.seg label span { font-size: var(--text-xs); color: var(--color-muted); white-space: nowrap; }
.seg label:hover { background: var(--color-fill); }
.seg label:has(input:checked) { background: var(--color-muted); box-shadow: var(--shadow-thumb); }
.seg label:has(input:checked) strong { color: var(--color-ink); }
.seg label:has(input:checked) span { color: var(--color-ink); }

/* เวทีตัวอย่างด้านขวา */
.stage { position: sticky; top: var(--space-lg); display: grid; gap: var(--space-md); padding: var(--space-lg); border-radius: var(--radius-sheet); box-shadow: var(--shadow-float); }
.stage__label { font-size: var(--text-sm); color: var(--color-ink-2); font-weight: 500; }
.stage__canvas { position: relative; aspect-ratio: 1; }
.stage__frame {
  position: absolute; inset: 0; background: var(--color-paper-3);
  clip-path: inset(21.875% 0 round 18px);
  transition: clip-path var(--dur-long) var(--ease-out), opacity var(--dur-short) var(--ease-out);
}
.stage__frame .art { width: 100%; height: 100%; display: block; }
.stage__canvas[data-aspect="9:16"] .stage__frame { clip-path: inset(0 21.875% round 22px); }
.stage__canvas[data-aspect="1:1"] .stage__frame { clip-path: inset(0 round 22px); }
.stage__frame.is-swapping { opacity: 0.3; }
.stage__audio { position: absolute; inset: 21.875% 0; display: none; place-items: center; border-radius: 18px; background: var(--color-sun-soft); }
.kind__bars--lg { height: 56%; gap: 7px; }
.kind__bars--lg i { width: 7px; }
.stage__canvas[data-kind="audio"] .stage__frame { opacity: 0; }
.stage__canvas[data-kind="audio"] .stage__audio { display: grid; }
.stage__pins { position: absolute; right: 4%; bottom: 0; display: flex; }
.stage__pins img {
  width: 3.25rem; height: 3.25rem; object-fit: cover; border-radius: 10px; border: 3px solid var(--color-photo);
  box-shadow: 0 10px 18px -8px var(--color-film); margin-left: -0.9rem; transform: rotate(var(--r, 3deg));
  animation: pop var(--dur-long) var(--ease-out);
}
.stage__pins img:nth-child(odd) { --r: -5deg; }
.facts { display: grid; grid-template-columns: minmax(0, 1fr) auto; font-size: var(--text-sm); border-radius: var(--radius-input); background: var(--color-fill); padding: 0 var(--space-md); }
.facts dt, .facts dd { padding: var(--space-sm) 0; border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.facts dt:nth-last-of-type(1), .facts dd:nth-last-of-type(1) { border-bottom: 0; }
.facts dt { color: var(--color-ink); }
.facts dd { color: var(--color-muted); text-align: right; min-width: 0; overflow-wrap: anywhere; padding-left: var(--space-md); }
.stage__idea { font-size: var(--text-sm); color: var(--color-ink-2); overflow-wrap: anywhere; }
.stage__idea:empty { display: none; }

/* ---------- แถบปุ่มล่าง: แคปซูลกระจกลอย ---------- */
.bar {
  position: sticky; bottom: var(--space-md); z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-sm);
  margin: var(--space-lg) 0 var(--space-md);
  padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-lg);
  border-radius: var(--radius-sheet); box-shadow: var(--shadow-float);
}
.bar:has(> .btn:first-child) { padding-left: var(--space-xs); }
.bar__note { margin-right: auto; font-size: var(--text-sm); color: var(--color-ink-2); min-width: 0; }
.bar > .btn:first-child + .bar__note { margin-left: var(--space-xs); }

/* ---------- ปุ่ม ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: 3.125rem; padding: 0 var(--space-lg);
  border: 0; border-radius: var(--radius-pill);
  font-weight: 600; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out), opacity var(--dur-micro) var(--ease-out), box-shadow var(--dur-short) var(--ease-out);
}
.btn:active { transform: scale(0.96); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--color-accent); color: var(--color-accent-ink); box-shadow: var(--shadow-button); }
.btn--primary:hover { background: var(--color-accent-deep); }
.btn--primary:active { background: var(--color-accent-press); }
.btn--ghost { background: var(--color-fill-2); color: var(--color-ink); }
.btn--ghost:hover { background: var(--color-paper-3); }
.btn--small { min-height: 2.5rem; padding: 0 var(--space-md); font-size: var(--text-sm); }
.btn--icon { width: 3.125rem; padding: 0; flex: none; }
.btn--danger { color: var(--color-danger); }
.btn[data-state="loading"] { color: transparent; pointer-events: none; }
.btn[data-state="loading"]::after {
  content: ""; position: absolute; width: 1.25rem; height: 1.25rem; border-radius: var(--radius-pill);
  border: 2.5px solid var(--color-ink); border-right-color: transparent; animation: spin 700ms linear infinite;
}
.btn--primary[data-state="loading"]::after { border-color: var(--color-accent-ink); border-right-color: transparent; }
.btn[data-state="success"] { background: var(--color-ok-soft); color: var(--color-ok); box-shadow: none; }
.btn[data-state="error"] { background: var(--color-danger-soft); color: var(--color-danger); box-shadow: none; }

/* ---------- ขั้นที่ 2 ---------- */
.plan { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 24rem); gap: var(--space-2xl); align-items: start; flex: 1; }
.board { min-width: 0; padding-bottom: var(--space-xl); }
.tags { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-xs); }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 0.25rem 0.8rem; border-radius: var(--radius-pill); background: var(--color-fill-2); font-size: var(--text-sm); line-height: 1.6; }
.tag .icon { width: 1rem; height: 1rem; color: var(--color-accent-deep); }

.demo-note { display: flex; gap: var(--space-sm); align-items: flex-start; padding: var(--space-sm) var(--space-md); margin-bottom: var(--space-lg); border-radius: var(--radius-input); background: var(--color-sun-soft); font-size: var(--text-sm); line-height: 1.6; }
.demo-note .icon { margin-top: 0.2em; color: var(--color-sun); }
.demo-note a { color: var(--color-sun); }

.scenes { display: grid; gap: var(--space-md); }
.scene {
  position: relative; display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: var(--space-md);
  padding: var(--space-xs); background: var(--color-surface); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2);
  opacity: 0; transform: translateY(14px) scale(0.985); animation: reveal var(--dur-long) var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 70ms);
}
.scene::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--color-accent); opacity: 0; pointer-events: none; }
.scene.is-changed::after { animation: flash 1400ms var(--ease-out); }
@keyframes flash { 0% { opacity: 0.35; } 100% { opacity: 0; } }
.scene__thumb { position: relative; aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden; background: var(--color-paper-3); align-self: start; }
.scene__thumb .art, .scene__thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.scene__thumb img { animation: fade var(--dur-long) var(--ease-out); }
.scene__real {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 9px; border-radius: var(--radius-pill);
  background: var(--color-accent); color: var(--color-accent-ink); font-size: 0.6875rem; font-weight: 600; line-height: 1.5;
}
/* ตัวเลือกภาพตั้งต้นของฉาก */
.scene__start { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); padding-top: var(--space-xs); margin-top: var(--space-2xs); border-top: var(--rule-hair) solid var(--color-rule-2); }
.scene__start-label { font-size: var(--text-sm); color: var(--color-ink-2); margin-right: var(--space-2xs); }
.pick { position: relative; display: block; border-radius: 12px; cursor: pointer; transition: transform var(--dur-micro) var(--ease-out); }
.pick input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pick img { width: 2.75rem; height: 2.75rem; object-fit: cover; border-radius: 12px; display: block; opacity: 0.6; transition: opacity var(--dur-short) var(--ease-out); }
.pick__none { display: grid; place-items: center; height: 2.75rem; padding: 0 var(--space-sm); border-radius: 12px; background: var(--color-fill-2); font-size: var(--text-xs); font-weight: 500; white-space: nowrap; color: var(--color-ink-2); }
.pick:hover img { opacity: 0.85; }
.pick:active { transform: scale(0.95); }
.pick:has(input:checked) { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.pick:has(input:checked) img { opacity: 1; }
.pick:has(input:checked) .pick__none { color: var(--color-ink); }
.pick:has(input:focus-visible) { outline: 2px solid var(--color-focus); outline-offset: 4px; }
.scene__thumb--audio { display: grid; place-items: center; background: var(--color-sun-soft); }
.scene__num {
  position: absolute; left: 8px; top: 8px; min-width: 1.75rem; height: 1.75rem; padding: 0 0.45rem; display: grid; place-items: center;
  border-radius: var(--radius-pill);
  font-family: var(--font-display); font-weight: 700; font-size: var(--text-sm); font-variant-numeric: tabular-nums;
}
.scene__body { display: grid; gap: var(--space-xs); align-content: start; min-width: 0; padding: var(--space-xs) var(--space-sm) var(--space-xs) 0; }
.scene__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-sm); }
.scene__title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); line-height: var(--leading-tight); letter-spacing: var(--track-tight); overflow-wrap: anywhere; min-width: 0; }
.scene__desc { color: var(--color-ink-2); overflow-wrap: anywhere; }
.scene__say { display: flex; gap: var(--space-xs); align-items: flex-start; font-size: var(--text-sm); padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-sm); background: var(--color-fill); overflow-wrap: anywhere; }
.scene__say .icon { margin-top: 0.25em; width: 1rem; height: 1rem; color: var(--color-accent-deep); }
.scene__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); font-size: var(--text-sm); color: var(--color-ink-2); }
.scene__meta label { display: inline-flex; align-items: center; gap: var(--space-xs); }
.select { padding: 0.3rem 0.6rem; border-radius: var(--radius-sm); border: 0; background: var(--color-fill-2); font-variant-numeric: tabular-nums; cursor: pointer; }
.select option { background: var(--color-paper-2); color: var(--color-ink); }
.scene__edit { flex: none; }
.scene textarea.input { font-size: var(--text-base); min-height: 5rem; }
.scene__actions { display: flex; gap: var(--space-xs); justify-content: flex-end; }
.label { font-weight: 600; font-size: var(--text-sm); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; padding: 0.3rem 0.7rem; border: 0; border-radius: var(--radius-pill); background: none; color: var(--color-accent-deep); font-size: var(--text-sm); font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
.link-btn .icon { width: 1rem; height: 1rem; }
.link-btn:hover { background: var(--color-accent-soft); }
.link-btn:active { transform: scale(0.96); }
.link-btn.btn--danger { color: var(--color-danger); }
.link-btn.btn--danger:hover { background: var(--color-danger-soft); }

/* แชต */
.chat {
  position: sticky; top: var(--space-lg); display: flex; flex-direction: column; min-width: 0;
  max-height: calc(100dvh - 9.5rem); min-height: 24rem;
  border-radius: var(--radius-sheet); box-shadow: var(--shadow-float); overflow: hidden;
}
.chat__head { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-md) var(--space-lg); border-bottom: var(--rule-hair) solid var(--color-rule-2); }
.chat__avatar { flex: none; width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-accent-ink); box-shadow: var(--shadow-button); }
.chat__title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); line-height: var(--leading-tight); letter-spacing: var(--track-tight); }
.chat__sub { font-size: var(--text-xs); color: var(--color-muted); line-height: 1.4; }
.chat__log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-xs); padding: var(--space-md); overscroll-behavior: contain; }
.msg { max-width: 88%; padding: 0.55rem 0.95rem; border-radius: 20px; line-height: 1.55; overflow-wrap: anywhere; animation: msg-in var(--dur-long) var(--ease-out); }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
.msg--ai { align-self: flex-start; background: var(--color-paper-3); border-bottom-left-radius: 6px; transform-origin: left bottom; }
.msg--user { align-self: flex-end; background: var(--color-accent); color: var(--color-accent-ink); border-bottom-right-radius: 6px; transform-origin: right bottom; }
.msg--error { align-self: flex-start; background: var(--color-danger-soft); color: var(--color-ink); font-size: var(--text-sm); border-bottom-left-radius: 6px; }
.msg--typing { align-self: flex-start; display: inline-flex; gap: 5px; padding: 0.85rem 1rem; background: var(--color-paper-3); border-bottom-left-radius: 6px; }
.msg--typing i { width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--color-ink-2); animation: typing 900ms var(--ease-in-out) infinite alternate; }
.msg--typing i:nth-child(2) { animation-delay: 150ms; } .msg--typing i:nth-child(3) { animation-delay: 300ms; }
@keyframes typing { from { opacity: 0.25; transform: translateY(0); } to { opacity: 1; transform: translateY(-3px); } }
.chat__chips { padding: 0 var(--space-md) var(--space-sm); }
.chat__chips:empty { display: none; }
.chat__form { display: flex; align-items: flex-end; gap: var(--space-xs); padding: var(--space-sm) var(--space-md) var(--space-md); }
.chat__input { resize: none; max-height: 8rem; min-height: 2.75rem; border-radius: 22px; padding: 0.55rem var(--space-md); }
.chat__form .btn--icon { width: 2.75rem; min-height: 2.75rem; }

/* แผ่นยืนยันก่อนสร้างจริง */
.confirm { position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; place-items: center; padding: var(--space-md); background: var(--color-scrim); animation: fade var(--dur-short) var(--ease-out); }
.confirm__card { width: min(100%, 26rem); display: grid; gap: var(--space-sm); padding: var(--space-xl) var(--space-lg) var(--space-lg); text-align: center; border-radius: var(--radius-sheet); box-shadow: var(--shadow-float); background: var(--color-glass-strong); animation: card-in var(--dur-long) var(--ease-out); }
@keyframes card-in { from { opacity: 0; transform: scale(1.08); } }
.confirm__title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xl); line-height: var(--leading-tight); letter-spacing: var(--track-tight); }
.confirm__text { color: var(--color-ink-2); font-size: var(--text-sm); }
.confirm__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); margin-top: var(--space-md); }

/* ---------- ขั้นที่ 3 ---------- */
.make { flex: 1; padding-bottom: var(--space-xl); }
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: var(--space-lg); align-items: start; }
.result { display: grid; gap: var(--space-sm); min-width: 0; opacity: 0; transform: translateY(14px) scale(0.985); animation: reveal var(--dur-long) var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 70ms); }
.result__media { position: relative; border-radius: var(--radius-card); overflow: hidden; background: var(--color-surface); box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2); aspect-ratio: 16 / 9; }
.result[data-aspect="9:16"] .result__media { aspect-ratio: 9 / 16; }
.result[data-aspect="1:1"] .result__media { aspect-ratio: 1; }
.result[data-kind="audio"] .result__media { aspect-ratio: 16 / 7; display: grid; place-items: center; background: var(--color-sun-soft); }
.result__media video, .result__media img, .result__media .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.result__media audio { width: calc(100% - var(--space-lg)); position: relative; }
.result__wait { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: var(--space-xs); text-align: center; padding: var(--space-md); }
.result__wait::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, var(--color-fill-2) 50%, transparent 70%);
  transform: translateX(-100%); animation: shimmer 1700ms var(--ease-in-out) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.result__wait > * { position: relative; }
.result__state { font-weight: 600; }
.result__time { font-size: var(--text-sm); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.result__brush { width: 3.5rem; height: 3.5rem; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--color-accent-soft); color: var(--color-accent-deep); animation: breathe 1500ms var(--ease-in-out) infinite alternate; }
@keyframes breathe { from { transform: scale(0.92); opacity: 0.7; } to { transform: scale(1.06); opacity: 1; } }
.result__stamp { position: absolute; left: 10px; top: 10px; padding: 3px 11px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600; }
.result__error { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: var(--space-xs); padding: var(--space-md); text-align: center; background: var(--color-danger-soft); font-size: var(--text-sm); line-height: 1.55; overflow-wrap: anywhere; }
.result__error .icon { color: var(--color-danger); width: 1.75rem; height: 1.75rem; margin-inline: auto; }
.result__media.is-done > :is(video, img, .art, audio) { animation: fade var(--dur-long) var(--ease-out); }
.result__info { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-sm); padding-inline: var(--space-2xs); }
.result__title { font-family: var(--font-display); font-weight: 600; line-height: var(--leading-tight); letter-spacing: var(--track-tight); overflow-wrap: anywhere; min-width: 0; }
.result__title small { display: block; font-family: var(--font-body); font-weight: 400; font-size: var(--text-xs); color: var(--color-muted); letter-spacing: 0; }
.result__actions { display: flex; gap: var(--space-2xs); flex: none; }

.player { margin-bottom: var(--space-xl); display: grid; gap: var(--space-xs); max-width: 48rem; }
.player video { width: 100%; max-height: 60dvh; border-radius: var(--radius-card); background: var(--color-film); display: block; }
.player__note { font-size: var(--text-sm); color: var(--color-ink-2); }

/* ---------- ระหว่างรอ AI คิด ---------- */
.thinking { position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; place-items: center; padding: var(--space-md); background: var(--color-scrim); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: fade var(--dur-short) var(--ease-out); }
.thinking__card { width: min(100%, 26rem); display: grid; justify-items: center; gap: var(--space-sm); text-align: center; padding: var(--space-xl) var(--space-lg); border-radius: var(--radius-sheet); box-shadow: var(--shadow-float); background: var(--color-glass-strong); animation: card-in var(--dur-long) var(--ease-out); }
.sketch { width: min(100%, 19rem); height: auto; fill: none; stroke: var(--color-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sketch__frame > * { stroke-dasharray: 240; stroke-dashoffset: 240; animation: draw 3600ms var(--ease-in-out) infinite; animation-delay: calc(var(--n) * 500ms); }
.sketch__frame circle { stroke: var(--color-accent); }
.sketch__cap { stroke: var(--color-fill-2); stroke-width: 4; }
@keyframes draw { 0% { stroke-dashoffset: 240; } 35%, 80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -240; } }
.thinking__title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xl); line-height: var(--leading-tight); letter-spacing: var(--track-tight); }
.thinking__line { color: var(--color-ink-2); min-height: 1.7em; }
.thinking__line.is-swap { animation: msg-in var(--dur-long) var(--ease-out); }

/* ---------- แจ้งเตือน ---------- */
.toasts { position: fixed; left: 50%; top: var(--space-md); z-index: var(--z-toast); display: grid; gap: var(--space-xs); width: min(26rem, calc(100% - var(--space-xl))); transform: translateX(-50%); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: var(--space-sm); align-items: flex-start; padding: var(--space-sm) var(--space-md); border-radius: var(--radius-card); background: var(--color-glass-strong); box-shadow: var(--shadow-float); font-size: var(--text-sm); line-height: 1.55; animation: toast-in var(--dur-long) var(--ease-out); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(0.96); } }
.toast .icon { margin-top: 0.15em; color: var(--color-sun); }
.toast.is-leaving { opacity: 0; transition: opacity var(--dur-short) var(--ease-in); }

/* ---------- ภาพประกอบฉาก ---------- */
.fx-defs { position: absolute; }
.art { --a-sky: var(--v-sky, var(--ill-sky-day)); --a-sun: var(--v-sun, var(--ill-sun)); --a-far: var(--ill-hill-far); --a-near: var(--ill-hill-near); --a-line: transparent; --a-line-w: 0; }
.art .a-sky { fill: var(--a-sky); }
.art .a-sun { fill: var(--a-sun); stroke: var(--a-line); stroke-width: var(--a-line-w); transform: translate(var(--v-sx, 0), var(--v-sy, 0)); }
.art .a-glow { fill: var(--a-sun); opacity: 0; filter: url(#fx-glow); transform: translate(var(--v-sx, 0), var(--v-sy, 0)); }
.art .a-rays { stroke: var(--ill-cloud); stroke-width: 7; stroke-linecap: round; opacity: 0; fill: none; transform: translate(var(--v-sx, 0), var(--v-sy, 0)); }
.art .a-clouds { fill: var(--ill-cloud); stroke: var(--a-line); stroke-width: var(--a-line-w); opacity: 0; }
.art .a-hill-far { fill: var(--a-far); stroke: var(--a-line); stroke-width: var(--a-line-w); }
.art .a-hill-near { fill: var(--a-near); stroke: var(--a-line); stroke-width: var(--a-line-w); }
.art .a-path { fill: none; stroke: var(--ill-sky-warm); stroke-width: 4; stroke-linecap: round; opacity: 0.85; }
.art .a-crown { fill: var(--ill-tree); stroke: var(--a-line); stroke-width: var(--a-line-w); }
.art .a-trunk { fill: var(--ill-trunk); }
.art .a-shine { fill: var(--ill-cloud); opacity: 0; }
.art .a-haze { fill: var(--ill-wash); opacity: 0; filter: url(#fx-glow); }
.art .a-bar { fill: var(--color-film); opacity: 0; }
/* ช่วงเวลาของวัน */
.art--v1 { --v-sky: var(--ill-sky-warm); --v-sx: -64px; --v-sy: 6px; }
.art--v2 { --v-sky: var(--ill-sky-dusk); --v-sun: var(--ill-ember); --v-sx: -30px; --v-sy: 22px; }
.art--v3 { --v-sky: var(--ill-sky-night); --v-sun: var(--ill-moon); --v-sx: -84px; --v-sy: -4px; }
/* สไตล์ */
.art--real .a-glow { opacity: 0.75; }
.art--real .a-haze { opacity: 0.6; }
.art--real .a-land { filter: url(#fx-soft); }
.art--real .a-clouds { opacity: 0.55; filter: url(#fx-soft); }
.art--cinematic { --a-sky: var(--ill-sky-dusk); --a-sun: var(--ill-ember); --a-far: var(--ill-hill-teal); --a-near: var(--ill-hill-night); }
.art--cinematic .a-sun, .art--cinematic .a-glow { transform: translate(-24px, 24px); }
.art--cinematic .a-glow { opacity: 0.9; }
.art--cinematic .a-bar { opacity: 1; }
.art--cinematic .a-crown { fill: var(--ill-hill-night); }
.art--cinematic .a-path { opacity: 0.25; }
.art--cartoon { --a-line: var(--ill-shade); --a-line-w: 2.2; }
.art--cartoon .a-clouds { opacity: 1; }
.art--anime { --a-sky: var(--v-sky, var(--ill-sky-pastel)); --a-line: var(--ill-shade); --a-line-w: 0.7; }
.art--anime .a-clouds { opacity: 1; transform: scale(1.25); transform-origin: 30% 30%; }
.art--anime .a-rays { opacity: 0.35; }
.art--3d { --a-sky: var(--v-sky, var(--ill-sky-warm)); }
.art--3d .a-shine { opacity: 0.4; }
.art--3d .a-land { filter: drop-shadow(0 -2px 0 var(--ill-cloud)) drop-shadow(0 3px 3px var(--ill-shade)); }
.art--3d .a-clouds { opacity: 1; }
.art--watercolor { --a-sky: var(--ill-wash); }
.art--watercolor .a-land, .art--watercolor .a-sun { filter: url(#fx-water); opacity: 0.8; }
.art--watercolor .a-haze { opacity: 0.35; fill: var(--v-sky, var(--ill-sky-day)); y: 0; }

/* ---------- คลิปเล่าเรื่อง ---------- */
.kinds { grid-template-columns: repeat(auto-fit, minmax(10.25rem, 1fr)); }
.kind--story .kind__art { background: var(--color-film); }
.kind--story .kind__scene { position: absolute; inset: 0; }
.kind__caption { position: absolute; left: 12%; right: 12%; bottom: 12%; display: grid; gap: 4px; justify-items: center; }
.kind__caption i { display: block; height: 5px; border-radius: var(--radius-pill); background: var(--color-photo); width: 100%; transform-origin: left center; }
.kind__caption i:last-child { width: 62%; }
.kind:has(input:checked) .kind__caption i { animation: caption 2200ms var(--ease-in-out) infinite; }
.kind:has(input:checked) .kind__caption i:last-child { animation-delay: 350ms; }
@keyframes caption { 0% { transform: scaleX(0); } 45%, 100% { transform: scaleX(1); } }
.kind__bars--mini { position: absolute; left: 8%; top: 10%; height: 26%; gap: 3px; padding: 4px 7px; border-radius: var(--radius-pill); background: var(--color-glass-strong); }
.kind__bars--mini i { width: 3px; }

.select--wide { width: min(100%, 22rem); padding-block: 0.6rem; resize: none; cursor: pointer; }
.select--wide option { background: var(--color-paper-2); color: var(--color-ink); }
.file-btn { position: relative; width: fit-content; padding-inline: 0; }
.file-btn:has(input:focus-visible) { outline: 2px solid var(--color-focus); outline-offset: 3px; }
.chip--radio { cursor: pointer; }
.chip--radio:has(input:checked) { background: var(--color-accent); color: var(--color-accent-ink); font-weight: 600; }
.chip--radio:has(input:focus-visible) { outline: 2px solid var(--color-focus); outline-offset: 3px; }
#q-voice { gap: var(--space-lg); }

.scene__line { font-size: var(--text-lg); line-height: 1.5; overflow-wrap: anywhere; }
.scene__desc--small { font-size: var(--text-sm); color: var(--color-muted); }
.scene__opt { display: inline-flex; }
.scene__real--soft { background: var(--color-glass-strong); color: var(--color-ink); }
.scene__real--warn { background: var(--color-danger); color: var(--color-ink); }

.results--story { grid-template-columns: repeat(auto-fill, minmax(min(100%, 10.5rem), 1fr)); gap: var(--space-md); }
.results--story .result__title { font-size: var(--text-sm); }
.result__pills { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.pill { padding: 1px 9px; border-radius: var(--radius-pill); background: var(--color-fill-2); color: var(--color-ink-2); font-size: 0.75rem; line-height: 1.6; white-space: nowrap; }
.pill[data-state="done"] { background: var(--color-ok-soft); color: var(--color-ok); }
.pill[data-state="error"] { background: var(--color-danger-soft); color: var(--color-danger); }
.pill[data-state="working"] { background: var(--color-accent-soft); color: var(--color-accent-deep); }
.result__stamp--r { left: auto; right: 10px; padding: 5px; display: grid; }
.result__stamp--r .icon { width: 0.9rem; height: 0.9rem; }

.music-part { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-md); padding: var(--space-sm) var(--space-md); margin-bottom: var(--space-lg); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2); }
.music-part__icon { flex: none; width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--color-accent-soft); color: var(--color-accent-deep); }
.music-part > div { display: grid; line-height: 1.45; min-width: 0; margin-right: auto; }
.music-part > div span { font-size: var(--text-sm); color: var(--color-ink-2); overflow-wrap: anywhere; }
.music-part audio { height: 2.5rem; max-width: 100%; }

/* ---------- ขั้นตัดต่อ ---------- */
.edit { display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); gap: var(--space-2xl); align-items: start; flex: 1; }
.edit__view { position: sticky; top: var(--space-lg); display: grid; gap: var(--space-sm); }
.edit__screen { position: relative; border-radius: var(--radius-card); overflow: hidden; background: var(--color-film); box-shadow: var(--shadow-float), 0 0 0 var(--rule-hair) var(--color-rule); aspect-ratio: 9 / 16; max-height: calc(100dvh - 15rem); margin-inline: auto; }
.edit__screen[data-aspect="16:9"] { aspect-ratio: 16 / 9; width: 100%; }
.edit__screen canvas { width: 100%; height: 100%; display: block; }
.edit__busy { position: absolute; inset: auto 0 0 0; display: grid; gap: var(--space-xs); padding: var(--space-md); background: var(--color-glass-strong); font-size: var(--text-sm); text-align: center; }
.edit__bar { display: block; height: 6px; border-radius: var(--radius-pill); background: var(--color-fill-2); overflow: hidden; }
.edit__bar i { display: block; height: 100%; background: var(--color-accent); transform: scaleX(0); transform-origin: left center; transition: transform 200ms linear; }
.edit__transport { display: flex; align-items: center; gap: var(--space-sm); }
.edit__transport .icon { fill: currentColor; }
.edit__time { font-size: var(--text-sm); color: var(--color-ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.range { flex: 1; min-width: 0; width: 100%; height: 1.75rem; accent-color: var(--color-accent); cursor: pointer; }
.range:disabled { opacity: 0.4; cursor: not-allowed; }
.edit__side { min-width: 0; padding-bottom: var(--space-xl); }
.edit__side .head { margin-bottom: var(--space-lg); }
.edit__opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md) var(--space-lg); padding: var(--space-lg); margin-bottom: var(--space-xl); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2); }
.edit__opts .field:first-child { grid-column: 1 / -1; }
.shots { display: grid; gap: var(--space-xs); }
.shot { display: grid; grid-template-columns: 4rem minmax(0, 1fr); gap: var(--space-sm); align-items: center; padding: var(--space-xs); border-radius: var(--radius-input); background: var(--color-surface); box-shadow: 0 0 0 var(--rule-hair) var(--color-rule-2); transition: background-color var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out); }
.shot.is-current { background: var(--color-paper-3); box-shadow: 0 0 0 2px var(--color-accent); }
.shot__jump { position: relative; width: 4rem; aspect-ratio: 1; padding: 0; border: 0; border-radius: var(--radius-sm); overflow: hidden; background: var(--color-paper-3); color: var(--color-ink-2); cursor: pointer; }
.shot__jump img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot__hold { display: grid; place-items: center; height: 100%; font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); }
.shot__time { position: absolute; left: 3px; bottom: 3px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--color-glass-strong); color: var(--color-ink); font-size: 0.6875rem; line-height: 1.5; font-variant-numeric: tabular-nums; }
.shot__body { display: grid; gap: var(--space-2xs); min-width: 0; }
.shot__text { font-size: var(--text-sm); line-height: 1.5; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shot__opts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); font-size: var(--text-xs); color: var(--color-muted); }
.shot__opts .select { font-size: var(--text-xs); }
.shot__dur { font-variant-numeric: tabular-nums; margin-left: auto; padding-right: var(--space-xs); }
.credits { margin-top: var(--space-lg); font-size: var(--text-sm); color: var(--color-ink-2); }

/* ---------- หน้าประวัติโปรเจค ---------- */
.history { flex: 1; display: flex; flex-direction: column; }
.history .head { margin-bottom: var(--space-xl); }
.projects { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: var(--space-lg); align-content: start; padding-bottom: var(--space-xl); }
.projects:empty { display: none; }
.project {
  display: grid; grid-template-rows: auto 1fr; min-width: 0; overflow: hidden;
  background: var(--color-surface); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2);
  opacity: 0; transform: translateY(14px) scale(0.985); animation: reveal var(--dur-long) var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 60ms);
  transition: box-shadow var(--dur-short) var(--ease-out);
}
.project.is-current { box-shadow: var(--shadow-card), 0 0 0 2px var(--color-accent); }
.project__thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; background: var(--color-paper-3); cursor: pointer; overflow: hidden; }
.project__thumb img, .project__thumb .art { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--dur-long) var(--ease-out); }
.project__thumb:hover img, .project__thumb:hover .art { transform: scale(1.04); }
.project__thumb:focus-visible { outline-offset: -3px; }
.project__kind {
  position: absolute; left: 10px; top: 10px; display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 11px 3px 8px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600;
  background: var(--color-glass-strong); color: var(--color-ink);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
.project__kind .icon { width: 0.9rem; height: 0.9rem; }
.project__body { display: grid; gap: var(--space-2xs); align-content: start; padding: var(--space-md); min-width: 0; }
.project__name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); line-height: var(--leading-tight); letter-spacing: var(--track-tight); overflow-wrap: anywhere; }
.project__meta { font-size: var(--text-sm); color: var(--color-muted); }
.project__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs) var(--space-xs); margin-top: var(--space-sm); }
.project__actions .link-btn.btn--danger { margin-left: auto; }
.empty { flex: 1; padding: var(--space-2xl) var(--space-lg); border-radius: var(--radius-card); border: 1.5px dashed var(--color-rule); color: var(--color-ink-2); text-align: center; }

/* ---------- รายจ่าย ---------- */
.money-chip {
  margin-top: auto; display: grid; justify-items: center; gap: 1px; width: 100%;
  padding: var(--space-xs) var(--space-2xs); border-radius: var(--radius-input);
  background: var(--color-fill); color: var(--color-ink); text-decoration: none; text-align: center; line-height: 1.35;
  transition: background-color var(--dur-short) var(--ease-out);
}
.money-chip:hover { background: var(--color-fill-2); }
.money-chip__label { font-size: 0.6875rem; color: var(--color-muted); }
.money-chip strong { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.money-chip strong + .money-chip__label { margin-top: var(--space-2xs); }
.money-chip + .conn { margin-top: 0; }
/* ยอดเงินบาทตัวเล็กคู่กับยอดดอลลาร์ */
.baht { margin-left: 0.4em; font-family: var(--font-body); font-size: var(--text-xs); font-weight: 400; letter-spacing: 0; color: inherit; opacity: 0.68; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-chip .baht { display: block; margin-left: 0; font-size: 0.6875rem; line-height: 1.3; }
.money__value .baht { display: block; margin-left: 0; font-size: var(--text-sm); line-height: 1.4; }
.spend { flex: 1; padding-bottom: var(--space-2xl); }
.spend .head { margin-bottom: var(--space-lg); }
.money { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: var(--space-md); margin-bottom: var(--space-lg); }
.money__card { display: grid; gap: 2px; padding: var(--space-md) var(--space-lg); border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2); min-width: 0; }
.money__card--left { background: var(--color-left-card); }
/* ยอดที่จ่ายไปสีแดง ยอดคงเหลือสีเขียว เงินบาทตัวเล็กใช้สีเดียวกันแต่ไม่จางมาก เพื่อให้ยังอ่านออก */
.amt--spent { color: var(--color-spent); }
.amt--left { color: var(--color-left); }
.amt .baht { opacity: 0.92; }
.money__label { font-size: var(--text-sm); opacity: 0.8; }
.money__value { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xl); letter-spacing: var(--track-tight); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.money__hint { font-size: var(--text-xs); opacity: 0.7; }
.spend .demo-note { background: var(--color-fill); }
.spend .demo-note .icon { color: var(--color-ink-2); }
.spend .demo-note a { color: var(--color-accent-deep); }
.spend__tools { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-bottom: var(--space-lg); }
.spend__tools .seg { margin-top: 0; }
.spend__tools .seg label { padding-block: 0.4rem; }
.spend__grid { display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: var(--space-2xl); align-items: start; }
.cats { display: grid; gap: var(--space-xs); }
.cat { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-2xs) var(--space-sm); padding: var(--space-sm) var(--space-md); border-radius: var(--radius-input); background: var(--color-surface); box-shadow: 0 0 0 var(--rule-hair) var(--color-rule-2); }
.cat__icon { width: 2.25rem; height: 2.25rem; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--color-accent-soft); color: var(--color-accent-deep); }
.cat__name { display: grid; line-height: 1.4; font-weight: 600; }
.cat__name small { font-weight: 400; font-size: var(--text-xs); color: var(--color-muted); }
.cat__sum { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat__bar { grid-column: 1 / -1; height: 4px; border-radius: var(--radius-pill); background: var(--color-fill-2); overflow: hidden; }
.cat__bar i { display: block; height: 100%; background: var(--color-accent); transform-origin: left center; transition: transform var(--dur-long) var(--ease-out); }
.cat--total { grid-template-columns: minmax(0, 1fr) auto; background: none; box-shadow: none; border-top: var(--rule-hair) solid var(--color-rule); border-radius: 0; margin-top: var(--space-xs); padding-top: var(--space-md); }
.ledger { display: grid; border-radius: var(--radius-card); background: var(--color-surface); box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2); overflow: hidden; }
.ledger:empty { display: none; }
/* คลังผลงาน */
.works { flex: 1; padding-bottom: var(--space-2xl); }
.works .head { margin-bottom: var(--space-lg); }
.works .money { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.vid { flex-wrap: wrap; row-gap: var(--space-sm); }
.vid .row__main { flex: 1 1 12rem; }
.vid__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2xs); margin-left: auto; }
.vid__video { flex: 0 0 100%; width: 100%; max-height: 70vh; border-radius: var(--radius-md); background: var(--color-paper); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); margin-top: var(--space-sm); }
.pager__note { flex: 1; text-align: center; font-size: var(--text-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); }
.row + .row { box-shadow: inset 0 var(--rule-hair) 0 var(--color-rule-2); }
.row__icon { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--color-fill-2); color: var(--color-ink-2); }
.row__icon .icon { width: 1rem; height: 1rem; }
.row__main { display: grid; line-height: 1.45; min-width: 0; }
.row__label { font-weight: 600; font-size: var(--text-sm); overflow-wrap: anywhere; }
.row__detail { font-size: var(--text-xs); color: var(--color-muted); overflow-wrap: anywhere; }
.row__money { display: grid; justify-items: end; line-height: 1.45; white-space: nowrap; }
.row__money strong { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.row__money span { font-size: var(--text-xs); color: var(--color-muted); }

/* ---------- หน้าตั้งค่า (รายการแบบกลุ่มของ iOS) ---------- */
.settings { max-width: 44rem; width: 100%; padding-bottom: var(--space-md); }
.panel { display: grid; gap: var(--space-md); padding: var(--space-lg); margin-bottom: var(--space-lg); background: var(--color-surface); border-radius: var(--radius-sheet); box-shadow: var(--shadow-card), 0 0 0 var(--rule-hair) var(--color-rule-2); }
.panel__head { display: flex; align-items: flex-start; gap: var(--space-md); }
.panel__badge { flex: none; width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: 14px; background: var(--color-accent); color: var(--color-accent-ink); box-shadow: var(--shadow-button); }
.panel__badge--teal { background: var(--color-teal); }
.panel__badge .icon { width: 1.5rem; height: 1.5rem; }
.panel__title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xl); line-height: var(--leading-tight); letter-spacing: var(--track-tight); }
.panel__sub { color: var(--color-ink-2); font-size: var(--text-sm); }
.status { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0.2rem 0.75rem; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; background: var(--color-sun-soft); color: var(--color-sun); }
.status[data-state="live"] { background: var(--color-ok-soft); color: var(--color-ok); }
.status::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: var(--radius-pill); background: currentColor; }
.keyrow { display: flex; gap: var(--space-xs); }
.keyrow .input { flex: 1; min-width: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); }
.test-note { font-size: var(--text-sm); display: inline-flex; align-items: center; gap: 6px; }
.test-note[data-state="ok"] { color: var(--color-ok); }
.test-note[data-state="bad"] { color: var(--color-danger); }
.steps-list { display: grid; gap: var(--space-2xs); padding-left: 1.4em; list-style: decimal; font-size: var(--text-sm); color: var(--color-ink-2); }
.models { display: grid; border-radius: var(--radius-input); background: var(--color-fill); overflow: hidden; }
.model { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); cursor: pointer; transition: background-color var(--dur-micro) var(--ease-out); }
.model + .model { box-shadow: inset 0 var(--rule-hair) 0 var(--color-rule-2); }
.model input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.model:hover { background: var(--color-fill); }
.model:has(input:focus-visible) { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.model__dot { order: 2; flex: none; width: 1.5rem; height: 1.5rem; border-radius: var(--radius-pill); box-shadow: inset 0 0 0 1.5px var(--color-muted); display: grid; place-items: center; transition: background-color var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out); }
.model__dot::after { content: ""; width: 0.6rem; height: 0.6rem; border-radius: var(--radius-pill); background: var(--color-accent-ink); transform: scale(0); transition: transform var(--dur-short) var(--ease-out); }
.model:has(input:checked) .model__dot { background: var(--color-accent); box-shadow: none; }
.model:has(input:checked) .model__dot::after { transform: scale(1); }
.model__text { display: grid; line-height: 1.45; }
.model__text strong { font-weight: 600; }
.model__text span { font-size: var(--text-sm); color: var(--color-muted); }
.more { border-top: var(--rule-hair) solid var(--color-rule-2); padding-top: var(--space-md); }
.more summary { cursor: pointer; font-weight: 500; font-size: var(--text-sm); width: fit-content; border-radius: 6px; color: var(--color-accent-deep); }
.more__body { display: grid; gap: var(--space-md); margin-top: var(--space-md); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); }
.safe { display: flex; gap: var(--space-sm); align-items: flex-start; font-size: var(--text-sm); color: var(--color-ink-2); padding: var(--space-md); border-radius: var(--radius-card); background: var(--color-fill); margin-bottom: var(--space-lg); }
.safe .icon { margin-top: 0.2em; color: var(--color-accent-deep); }

/* ---------- จอแคบ ---------- */
@media (max-width: 1080px) {
  .idea, .plan, .edit, .spend__grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); }
  .edit__view { position: static; }
  .edit__screen { max-height: 70dvh; }
  .stage { position: static; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); align-items: center; }
  .stage__label, .stage__idea { grid-column: 1 / -1; }
  .idea__form { padding-bottom: var(--space-md); }
  .chat { position: static; max-height: 32rem; }
  .board { padding-bottom: 0; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    top: var(--space-xs); height: auto; margin: var(--space-xs) var(--space-sm) 0;
    flex-direction: row; justify-content: space-between; gap: var(--space-sm);
    padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-md); border-radius: var(--radius-pill);
  }
  .rail__brand { grid-auto-flow: column; align-items: center; gap: var(--space-xs); }
  .mark { width: 2rem; height: 2rem; }
  .rail__name { font-size: var(--text-sm); }
  .rail__links { display: flex; width: auto; gap: var(--space-2xs); }
  .rail__link { grid-auto-flow: column; align-items: center; gap: 6px; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-pill); }
  .rail__link .icon { width: 1.25rem; height: 1.25rem; }
  .conn, .money-chip { display: none; }
  .rail__link span:last-child { display: none; }
  .rail__link.is-current span:last-child { display: inline; }
  .main { padding-top: var(--space-lg); }
  .steps { margin-bottom: var(--space-lg); }
  .steps__item { font-size: var(--text-xs); }
  .kinds { grid-template-columns: minmax(0, 1fr); gap: var(--space-sm); }
  .kind { grid-template-columns: 7rem minmax(0, 1fr); column-gap: var(--space-md); padding: var(--space-xs); align-items: center; }
  .kind__art { grid-row: 1 / 3; }
  .kind__name { margin-top: 0; align-self: end; padding-inline: 0; }
  .kind__hint { align-self: start; padding-inline: 0; }
  .tick { top: 50%; margin-top: -0.8125rem; }
  .styles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { grid-template-columns: minmax(0, 1fr); }
  .stage__canvas { max-width: 13rem; }
  .scene { grid-template-columns: minmax(0, 1fr); }
  .scene__thumb { aspect-ratio: 16 / 7; }
  .scene__body { padding: 0 var(--space-sm) var(--space-sm); }
  .bar { flex-wrap: wrap; gap: var(--space-xs); padding: var(--space-xs); border-radius: var(--radius-card); bottom: var(--space-xs); }
  .bar__note { flex: 1 1 100%; order: -1; margin: 0; font-size: var(--text-xs); line-height: 1.5; padding: var(--space-2xs) var(--space-xs) 0; }
  .bar > .btn:first-child + .bar__note { margin-left: 0; }
  .bar__note:empty { display: none; }
  .bar .btn { flex: 1 1 auto; padding: 0 var(--space-md); }
  .seg { width: 100%; }
  .seg label { flex: 1; padding-inline: var(--space-xs); }
  .grid2, .edit__opts { grid-template-columns: minmax(0, 1fr); }
  .kind--story .kind__art { aspect-ratio: 16 / 10; }
  .panel__head { flex-wrap: wrap; }
  .status { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 150ms !important; animation-iteration-count: 1 !important; transition-duration: 150ms !important; }
  .reveal, .scene, .result { animation: reveal-reduced 150ms linear forwards; }
  @keyframes reveal-reduced { to { opacity: 1; transform: none; } }
  .sketch__frame > * { stroke-dashoffset: 0; animation: none; }
  .btn[data-state="loading"]::after { animation-duration: 1200ms !important; animation-iteration-count: infinite !important; }
}
