:root {
  color-scheme: light;
  --page: #ece7dc;
  --ink: #17191f;
  --muted: #6a6f78;
  --line: #d5cec1;
  --panel: #fffdf8;
  --panel-soft: #f7f2e8;
  --accent: #0f8f8b;
  --accent-2: #d84e38;
  --accent-3: #efb84b;
  --shadow: 0 24px 80px rgba(23, 25, 31, 0.18);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
}

img,
svg,
canvas,
video,
iframe {
  max-width: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.app-shell,
.app-shell * {
  min-width: 0;
}

pre,
code,
.message,
.message p,
.message a,
.chat-log {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.auth-screen,
.gallery-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: auto;
}

.gallery-screen {
  background:
    radial-gradient(circle at 18% 16%, rgba(15, 143, 139, 0.18), transparent 30%),
    radial-gradient(circle at 82% 10%, rgba(239, 184, 75, 0.18), transparent 28%),
    linear-gradient(135deg, rgba(255, 253, 248, 0.95), rgba(225, 237, 234, 0.96) 52%, rgba(246, 239, 227, 0.96));
}

.auth-screen[hidden],
.gallery-screen[hidden] {
  display: none;
}

.auth-screen {
  --auth-a: #0f8f8b;
  --auth-b: #efb84b;
  --auth-c: #17191f;
  --auth-glow: rgba(15, 143, 139, 0.34);
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 430px);
  align-items: stretch;
  min-height: 100vh;
  gap: clamp(18px, 4vw, 56px);
  padding: clamp(18px, 4vw, 48px);
  background:
    linear-gradient(115deg, rgba(255, 253, 248, 0.92), rgba(215, 236, 231, 0.92) 48%, rgba(255, 246, 225, 0.94)),
    var(--page);
}

.auth-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.32) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.24) 1px, transparent 1px);
  background-size: 88px 88px;
  mask-image: linear-gradient(90deg, black, transparent 78%);
  opacity: 0.55;
}

.auth-stage {
  position: relative;
  isolation: isolate;
  display: grid;
  align-content: end;
  min-width: 0;
  min-height: min(760px, calc(100vh - 128px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  padding: clamp(24px, 4vw, 48px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.12)),
    radial-gradient(circle at 70% 18%, color-mix(in srgb, var(--auth-b), transparent 62%), transparent 30%),
    linear-gradient(155deg, color-mix(in srgb, var(--auth-a), #ffffff 8%), rgba(235, 248, 244, 0.86) 46%, color-mix(in srgb, var(--auth-c), #000000 6%));
  box-shadow: 0 32px 120px rgba(23, 25, 31, 0.18);
  backdrop-filter: blur(24px);
  transition: background 1800ms ease, box-shadow 1800ms ease, border-color 1800ms ease;
}

.auth-screen[data-auth-scene] .auth-stage {
  border-color: color-mix(in srgb, var(--auth-a), #ffffff 62%);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.1)),
    radial-gradient(circle at 70% 18%, color-mix(in srgb, var(--auth-b), transparent 58%), transparent 30%),
    radial-gradient(circle at 20% 72%, var(--auth-glow), transparent 34%),
    linear-gradient(155deg, color-mix(in srgb, var(--auth-a), #ffffff 10%), rgba(245, 251, 247, 0.84) 45%, color-mix(in srgb, var(--auth-c), #000000 8%));
  box-shadow: 0 34px 120px color-mix(in srgb, var(--auth-a), transparent 74%);
}

.auth-scene-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.82;
  pointer-events: none;
  transition: opacity 1200ms ease, filter 1800ms ease;
}

.auth-screen[data-auth-scene="signup"] .auth-stage,
.auth-screen[data-auth-scene="name"] .auth-stage {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.12)),
    radial-gradient(circle at 72% 18%, rgba(216, 78, 56, 0.28), transparent 30%),
    linear-gradient(155deg, rgba(239, 184, 75, 0.88), rgba(229, 242, 236, 0.86) 45%, rgba(23, 25, 31, 0.9));
}

.auth-screen[data-auth-scene="google"] .auth-stage {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.12)),
    radial-gradient(circle at 70% 18%, rgba(66, 133, 244, 0.24), transparent 30%),
    linear-gradient(155deg, rgba(15, 143, 139, 0.88), rgba(246, 250, 255, 0.88) 48%, rgba(23, 25, 31, 0.9));
}

.auth-screen[data-auth-scene="submitting"] .auth-stage {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.12)),
    radial-gradient(circle at 70% 18%, rgba(71, 242, 209, 0.34), transparent 30%),
    linear-gradient(155deg, rgba(15, 143, 139, 0.96), rgba(255, 253, 248, 0.88) 45%, rgba(23, 25, 31, 0.94));
}

.auth-screen[data-auth-scene="error"] .auth-stage {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.1)),
    radial-gradient(circle at 70% 18%, rgba(216, 78, 56, 0.32), transparent 30%),
    linear-gradient(155deg, rgba(216, 78, 56, 0.82), rgba(255, 244, 233, 0.86) 47%, rgba(23, 25, 31, 0.92));
}

.auth-screen[data-auth-scene] .auth-stage {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.1)),
    radial-gradient(circle at 70% 18%, color-mix(in srgb, var(--auth-b), transparent 58%), transparent 30%),
    radial-gradient(circle at 20% 72%, var(--auth-glow), transparent 34%),
    linear-gradient(155deg, color-mix(in srgb, var(--auth-a), #ffffff 10%), rgba(245, 251, 247, 0.84) 45%, color-mix(in srgb, var(--auth-c), #000000 8%));
}

.auth-stage::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 10% auto 8% 58%;
  width: min(300px, 34vw);
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 999px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--auth-b), #ffffff 60%), rgba(255, 253, 248, 0.04));
  filter: blur(0.2px);
  transform: rotate(16deg);
  transition: background 1800ms ease, transform 1800ms ease;
}

.waterfall-veil {
  position: absolute;
  z-index: 1;
  inset: -18% 19% -10% auto;
  width: min(360px, 34vw);
  background:
    linear-gradient(180deg, transparent, color-mix(in srgb, var(--auth-b), #ffffff 70%) 20%, color-mix(in srgb, var(--auth-a), transparent 76%) 56%, transparent),
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--auth-b), #ffffff 52%) 0 2px, transparent 2px 18px);
  opacity: 0.78;
  transform: skewX(-8deg);
  animation: auth-fall 9s linear infinite;
  transition: opacity 1200ms ease, background 1800ms ease, filter 1800ms ease;
}

.auth-screen[data-auth-scene="submitting"] .waterfall-veil {
  animation-duration: 3.4s;
  opacity: 0.92;
}

.auth-screen[data-auth-scene="error"] .waterfall-veil {
  animation-duration: 12s;
  opacity: 0.62;
}

.story-copy,
.story-frames {
  position: relative;
  z-index: 2;
}

.story-copy {
  display: grid;
  min-width: 0;
  max-width: min(680px, 100%);
  gap: 14px;
  color: #fffdf8;
  text-shadow: 0 18px 50px rgba(23, 25, 31, 0.34);
}

.auth-screen[data-auth-scene] .story-copy p,
.auth-screen[data-auth-scene] .story-copy h1,
.auth-screen[data-auth-scene] .story-copy span {
  animation: auth-copy-in 320ms ease both;
}

.story-copy > *,
.auth-prologue,
.story-frames article {
  transition: opacity 220ms ease, transform 260ms ease, border-color 520ms ease, background 520ms ease, box-shadow 520ms ease;
}

.auth-screen.auth-scene-exit .story-copy > *,
.auth-screen.auth-scene-exit .auth-prologue,
.auth-screen.auth-scene-exit .story-frames article {
  opacity: 0;
  transform: translateY(12px) scale(0.985);
}

.auth-screen.auth-scene-enter .story-copy > *,
.auth-screen.auth-scene-enter .auth-prologue,
.auth-screen.auth-scene-enter .story-frames article {
  animation: auth-copy-in 420ms ease both;
}

.auth-screen[data-auth-scene] .story-copy h1 {
  animation-delay: 35ms;
}

.auth-screen[data-auth-scene] .story-copy span {
  animation-delay: 70ms;
}

.story-copy p,
.story-copy h1,
.story-copy span,
.story-frames p,
.story-frames strong,
.story-frames span,
.story-frames small {
  margin: 0;
}

.story-copy p {
  color: rgba(255, 253, 248, 0.72);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.story-copy h1 {
  max-width: min(11ch, 100%);
  font-size: clamp(3rem, 7vw, 6.4rem);
  line-height: 0.88;
  letter-spacing: 0;
  overflow-wrap: break-word;
}

.story-copy span {
  max-width: 560px;
  color: rgba(255, 253, 248, 0.82);
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  line-height: 1.45;
}

.story-frames {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: clamp(22px, 4vw, 48px);
}

.story-frames article {
  display: grid;
  gap: 8px;
  min-height: 132px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 253, 248, 0.18);
  color: #fffdf8;
  backdrop-filter: blur(18px);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.story-frames article.active {
  border-color: color-mix(in srgb, var(--auth-b), #ffffff 50%);
  background: color-mix(in srgb, var(--auth-a), rgba(255, 253, 248, 0.26) 78%);
  box-shadow: 0 18px 42px color-mix(in srgb, var(--auth-a), transparent 70%);
  transform: translateY(-4px);
  animation: auth-frame-lift 360ms ease both;
}

.story-frames small {
  color: rgba(255, 253, 248, 0.64);
  font-size: 0.72rem;
  font-weight: 900;
}

.story-frames strong {
  font-size: 1.1rem;
}

.story-frames span {
  color: rgba(255, 253, 248, 0.78);
  font-size: 0.86rem;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.auth-card {
  position: relative;
  z-index: 1;
  display: grid;
  align-self: center;
  justify-self: center;
  width: 100%;
  min-width: 0;
  max-width: 430px;
  gap: 16px;
  border: 1px solid color-mix(in srgb, var(--auth-a), #ffffff 72%);
  border-radius: var(--radius);
  padding: clamp(20px, 3vw, 30px);
  background: rgba(255, 253, 248, 0.76);
  box-shadow: 0 28px 90px rgba(23, 25, 31, 0.16);
  backdrop-filter: blur(28px);
  transition: border-color 1800ms ease, box-shadow 1800ms ease;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: -1;
  border: 1px solid color-mix(in srgb, var(--auth-a), transparent 78%);
  border-radius: 6px;
  pointer-events: none;
}

.auth-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.auth-brand > div {
  min-width: 0;
}

.auth-brand p,
.gallery-topline p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.auth-brand h1,
.gallery-topline h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
  overflow-wrap: break-word;
}

.auth-prologue {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.auth-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  background: rgba(255, 255, 255, 0.48);
}

.auth-mode-toggle button {
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.auth-mode-toggle button.active {
  background: var(--auth-c);
  color: #fff8e8;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--auth-a), transparent 76%);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
}

.auth-form label[hidden] {
  display: none;
}

.auth-form span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px;
  background: rgba(255, 253, 248, 0.88);
  color: var(--ink);
}

.auth-form input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--auth-a), transparent 42%);
  outline-offset: 2px;
}

.auth-form input:focus {
  border-color: color-mix(in srgb, var(--auth-a), #ffffff 35%);
}

.auth-card .primary-button {
  background: var(--auth-c);
  box-shadow: 0 14px 28px color-mix(in srgb, var(--auth-a), transparent 76%);
}

.auth-card .secondary-button:hover {
  border-color: color-mix(in srgb, var(--auth-b), #ffffff 28%);
  box-shadow: 0 12px 24px color-mix(in srgb, var(--auth-b), transparent 78%);
}

.google-auth-button {
  width: 100%;
}

.auth-status {
  min-height: 20px;
  margin: 0;
  color: var(--accent-2);
  font-size: 0.86rem;
  font-weight: 800;
}

body.auth-loading .app-shell,
body.signed-out .app-shell,
body.gallery-open .app-shell {
  display: none;
}

body.present-mode.auth-loading .app-shell,
body.present-mode.signed-out .app-shell {
  display: block;
}

body.present-mode .auth-screen,
body.present-mode .gallery-screen {
  display: none;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 30%) minmax(0, 1fr);
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.agent-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.92), rgba(247, 242, 232, 0.98)),
    var(--panel-soft);
}

.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.agent-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.agent-actions,
.gallery-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  overflow: hidden;
  max-width: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badge[hidden],
.agent-actions button[hidden] {
  display: none;
}

.usage-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin: 14px 18px 0;
  border: 1px solid color-mix(in srgb, var(--accent), var(--line) 72%);
  border-radius: var(--radius);
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(15, 143, 139, 0.12), rgba(239, 184, 75, 0.1)),
    rgba(255, 253, 248, 0.9);
  box-shadow: 0 12px 26px rgba(23, 25, 31, 0.08);
}

.usage-card[hidden] {
  display: none;
}

.usage-card div {
  display: grid;
  gap: 3px;
}

.usage-card span,
.usage-card small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.usage-card strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-card small {
  grid-column: 1 / -1;
  text-transform: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff8e8;
  font-weight: 900;
}

.agent-header h1,
.deck-meta h2 {
  margin: 0;
  letter-spacing: 0;
}

.agent-header h1 {
  font-size: 1.28rem;
}

.agent-header p,
.deck-meta p,
.message p {
  margin: 0;
  color: var(--muted);
}

.chat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 18px 20px;
}

.message {
  max-width: 92%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(23, 25, 31, 0.06);
}

.message.user {
  align-self: flex-end;
  border-color: var(--ink);
  background: var(--ink);
  color: #fff8e8;
}

.message.user p {
  color: #fff8e8;
}

.message.assistant {
  align-self: flex-start;
}

.message.pending p::after {
  content: "";
  display: inline-block;
  width: 26px;
  height: 8px;
  margin-left: 8px;
  background: radial-gradient(circle, var(--accent) 0 3px, transparent 4px) 0 50% / 9px 8px repeat-x;
  animation: pulse-dots 900ms infinite ease-in-out;
}

.message p {
  font-size: 0.94rem;
  line-height: 1.45;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.source-list a {
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 7px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-box {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: #f6efe3;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-list[hidden] {
  display: none;
}

.brand-logo-slot[hidden] {
  display: none;
}

.brand-logo-chip {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--panel);
  box-shadow: 0 6px 16px rgba(23, 25, 31, 0.05);
}

.brand-logo-chip img {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: contain;
  background: linear-gradient(135deg, #fff, #eee7dc);
}

.brand-logo-chip strong,
.brand-logo-chip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-logo-chip strong {
  font-size: 0.84rem;
}

.brand-logo-chip span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.brand-logo-chip button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
}

.brand-logo-slot:not([hidden]) {
  display: grid;
  gap: 8px;
}

.brand-logo-size {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  background: var(--panel);
}

.brand-logo-size i {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.brand-logo-size input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.brand-logo-size-value {
  min-width: 38px;
  text-align: right;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.attachment-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  max-width: 100%;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 8px;
  background: var(--panel);
  box-shadow: 0 6px 16px rgba(23, 25, 31, 0.05);
}

.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 800;
}

.attachment-chip small {
  color: var(--muted);
  font-size: 0.72rem;
}

.attachment-chip button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
}

.prompt-box textarea {
  width: 100%;
  min-height: 124px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel);
  color: var(--ink);
  line-height: 1.45;
}

.prompt-box textarea:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent), transparent 42%);
  outline-offset: 2px;
}

.prompt-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.prompt-options {
  position: relative;
}

.prompt-options summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  list-style: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

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

.prompt-options[open] summary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff8e8;
}

.prompt-option-list {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  display: grid;
  min-width: 220px;
  gap: 10px;
  border: 1px solid rgba(23, 25, 31, 0.12);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 18px 42px rgba(23, 25, 31, 0.18);
  backdrop-filter: blur(18px);
}

.logo-upload-button {
  min-width: 64px;
  font-weight: 900;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
  user-select: none;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.switch-track {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #e5ded2;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 2px 7px rgba(23, 25, 31, 0.24);
  transition: transform 160ms ease;
}

.switch-control input:checked + .switch-track {
  border-color: color-mix(in srgb, var(--accent), #0b524f 28%);
  background: var(--accent);
}

.switch-control input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
}

.switch-control input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 72%);
}

.switch-control input:disabled + .switch-track,
.switch-control input:disabled ~ span:last-child {
  cursor: not-allowed;
  opacity: 0.55;
}

.switch-copy {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
}

.beta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--accent-2), #ffffff 46%);
  border-radius: 999px;
  padding: 2px 6px;
  background: color-mix(in srgb, var(--accent-2), #ffffff 86%);
  color: #8d2e20;
  font-size: 0.62rem;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.upload-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
  pointer-events: none;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: var(--radius);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  padding: 0 16px;
  background: var(--ink);
  color: #fff8e8;
  box-shadow: 0 10px 20px rgba(23, 25, 31, 0.2);
}

.secondary-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.icon-button {
  width: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.canvas-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(15, 143, 139, 0.12), transparent 30%),
    linear-gradient(300deg, rgba(216, 78, 56, 0.1), transparent 34%),
    linear-gradient(180deg, #fffaf0, #e5ded2);
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  flex-wrap: wrap;
  padding: 16px 22px;
  border-bottom: 1px solid rgba(23, 25, 31, 0.1);
}

.deck-meta {
  min-width: 0;
  flex: 1 1 200px;
}

.deck-meta p {
  max-width: 100%;
  overflow: hidden;
  margin-bottom: 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.deck-meta h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.12rem;
}

.toolbar-actions {
  display: flex;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.canvas-toolbar .secondary-button {
  flex: 0 0 auto;
  padding: 0 12px;
}

.canvas-toolbar .secondary-button span {
  white-space: nowrap;
}

body.edit-mode .deck-meta h2 {
  font-size: 1rem;
}

body.edit-mode .deck-meta p {
  display: none;
}

.export-panel {
  position: absolute;
  top: 74px;
  right: 28px;
  z-index: 12;
  width: min(360px, calc(100vw - 56px));
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 24px 70px rgba(23, 25, 31, 0.18);
  backdrop-filter: blur(18px);
}

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

.export-panel header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.export-panel p,
.export-panel h3 {
  margin: 0;
}

.export-panel p {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.export-panel h3 {
  margin-top: 2px;
  font-size: 1rem;
}

.export-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.export-options .secondary-button {
  justify-content: flex-start;
  width: 100%;
}

.editor-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 28px;
  border-bottom: 1px solid rgba(23, 25, 31, 0.1);
  background: rgba(255, 253, 248, 0.82);
  backdrop-filter: blur(12px);
}

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

.editor-selection {
  flex: 0 0 auto;
  min-width: 168px;
  max-width: 240px;
}

.editor-selection p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.editor-group {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.editor-group:first-of-type {
  border-left: 0;
  padding-left: 0;
}

.editor-history-group {
  gap: 4px;
}

.editor-nudge-group {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  grid-template-rows: repeat(2, 28px);
  gap: 4px;
  align-items: center;
}

.editor-nudge-group .tool-button {
  width: 28px;
  height: 28px;
}

.editor-nudge-group #nudgeUpBtn {
  grid-column: 2;
}

.editor-nudge-group #nudgeLeftBtn {
  grid-column: 1;
  grid-row: 2;
}

.editor-nudge-group #nudgeRightBtn {
  grid-column: 3;
  grid-row: 2;
}

.editor-nudge-group #nudgeDownBtn {
  grid-column: 2;
  grid-row: 2;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
}

.tool-button:hover,
.secondary-button.active,
.icon-button.active {
  background: var(--ink);
  color: #fff8e8;
}

.tool-button:disabled,
.tool-button[aria-disabled="true"],
.editor-panel input:disabled,
.editor-panel select:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.tool-button[aria-disabled="true"] {
  pointer-events: none;
}

.tool-button.danger:hover {
  background: var(--accent-2);
  color: #fff8e8;
}

.editor-panel select,
.number-input {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
}

.editor-panel select {
  width: 96px;
  padding: 0 8px;
}

.number-input {
  width: 58px;
  padding: 0 7px;
}

.editor-color-group label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 6px;
  background: var(--panel);
  color: var(--muted);
}

.editor-color-group input[type="color"] {
  width: 22px;
  height: 22px;
  border: 0;
  padding: 0;
  background: transparent;
}

.studio-tools-panel {
  display: grid;
  grid-template-columns: minmax(250px, 0.95fr) minmax(220px, 0.8fr) minmax(250px, 0.95fr) minmax(220px, 0.9fr);
  gap: 12px;
  max-height: 280px;
  overflow: auto;
  padding: 12px 28px;
  border-bottom: 1px solid rgba(23, 25, 31, 0.1);
  background:
    linear-gradient(90deg, rgba(15, 143, 139, 0.08), transparent 32%),
    rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(16px);
}

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

body.edit-mode .agent-panel .chat-log,
body.edit-mode .agent-panel .prompt-box {
  display: none;
}

body.presenter-sidebar .agent-panel .chat-log,
body.presenter-sidebar .agent-panel .prompt-box,
body.presenter-sidebar .agent-panel .usage-card,
body.presenter-sidebar .agent-panel .editor-panel,
body.presenter-sidebar .agent-panel .studio-tools-panel,
body.presenter-sidebar .agent-panel .export-panel {
  display: none;
}

.agent-panel .editor-panel {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 10px;
  overflow: visible;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.9);
}

/* The full edit area (selection controls + tools) scrolls together as one
   region instead of pinning the top section. */
.edit-scroll-region {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.edit-mode .edit-scroll-region {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}

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

.agent-panel .editor-selection {
  min-width: 0;
  max-width: none;
}

.agent-panel .editor-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 10px;
  padding-left: 0;
  border-top: 1px solid var(--line);
  border-left: 0;
}

.agent-panel .editor-group:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.agent-panel .editor-history-group,
.agent-panel .editor-nudge-group {
  justify-content: start;
}

.agent-panel .editor-nudge-group {
  display: grid;
}

.agent-panel .editor-font-group select {
  flex: 1 1 140px;
  width: auto;
}

.agent-panel .number-input {
  width: 68px;
}

.agent-panel .studio-tools-panel {
  grid-template-columns: 1fr;
  flex: 0 0 auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding: 14px;
  border-bottom: 0;
  background:
    linear-gradient(180deg, rgba(15, 143, 139, 0.08), transparent 30%),
    rgba(247, 242, 232, 0.92);
}

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

.agent-panel .brand-kit-grid,
.agent-panel .tool-button-grid,
.agent-panel .asset-actions,
.agent-panel .asset-search-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.agent-panel .asset-search-row input {
  grid-column: 1 / -1;
}

.edit-ai-status {
  position: relative;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px 12px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent), white 68%);
  border-radius: var(--radius);
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(230, 246, 242, 0.72)),
    rgba(255, 253, 248, 0.86);
  box-shadow: 0 14px 34px rgba(15, 143, 139, 0.12);
}

.edit-ai-status::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.62), transparent);
  transform: translateX(-100%);
  animation: statusSheen 1.8s ease-in-out infinite;
}

.edit-ai-status[data-state="done"] {
  border-color: rgba(15, 143, 139, 0.32);
}

.edit-ai-status[data-state="error"] {
  border-color: color-mix(in srgb, var(--accent-2), white 54%);
  box-shadow: 0 14px 34px rgba(216, 78, 56, 0.12);
}

.edit-ai-status[data-state="done"]::before,
.edit-ai-status[data-state="error"]::before {
  animation: none;
  opacity: 0;
}

.edit-ai-orb,
.edit-ai-copy,
.edit-ai-meter {
  position: relative;
}

.edit-ai-orb {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff8e8;
  box-shadow: 0 10px 22px rgba(23, 25, 31, 0.18);
}

.edit-ai-status[data-state="working"] .edit-ai-orb {
  animation: editPulse 1.25s ease-in-out infinite;
}

.edit-ai-status[data-state="error"] .edit-ai-orb {
  background: var(--accent-2);
}

.edit-ai-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.edit-ai-copy strong,
.edit-ai-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-ai-copy strong {
  font-size: 0.86rem;
  font-weight: 950;
}

.edit-ai-copy span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.edit-ai-meter {
  grid-column: 1 / -1;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15, 143, 139, 0.12);
}

.edit-ai-meter span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  animation: statusMeter 1.2s ease-in-out infinite;
}

.edit-ai-status[data-state="done"] .edit-ai-meter span,
.edit-ai-status[data-state="error"] .edit-ai-meter span {
  width: 100%;
  animation: none;
}

.agent-panel .brand-kit-grid input[type="text"],
.agent-panel .brand-kit-grid select {
  grid-column: span 2;
}

.tool-section {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  border: 1px solid rgba(23, 25, 31, 0.09);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255, 255, 255, 0.64);
  box-shadow: 0 10px 28px rgba(23, 25, 31, 0.06);
}

.tool-section header {
  display: grid;
  gap: 4px;
}

.tool-section header span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 950;
  text-transform: uppercase;
}

.tool-section header small {
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.35;
}

.ai-option-button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff8e8;
}

.slide-ai-bar {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  border: 1px solid color-mix(in srgb, var(--accent), var(--line) 55%);
  border-radius: var(--radius);
  padding: 12px;
  background:
    linear-gradient(120deg, rgba(15, 143, 139, 0.16), rgba(108, 140, 255, 0.08) 60%, transparent),
    rgba(255, 253, 248, 0.92);
}

.slide-ai-head {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.slide-ai-head strong {
  font-size: 0.98rem;
  color: var(--ink);
}

.slide-ai-head small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.slide-ai-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.slide-ai-form textarea {
  width: 100%;
  min-height: 46px;
  resize: vertical;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-size: 0.86rem;
  line-height: 1.35;
}

.slide-ai-form textarea:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent), transparent 35%);
  outline-offset: 1px;
}

.slide-ai-form button {
  white-space: nowrap;
}

.edit-ai-apply-bar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(23, 25, 31, 0.12);
  border-radius: var(--radius);
  padding: 12px;
  background:
    linear-gradient(90deg, rgba(15, 143, 139, 0.12), transparent 42%),
    rgba(255, 253, 248, 0.88);
}
.edit-ai-apply-bar strong,
.edit-ai-apply-bar small {
  display: block;
  min-width: 0;
}

.edit-ai-apply-bar strong {
  font-size: 0.96rem;
}

.edit-ai-apply-bar small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.brand-kit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.brand-kit-grid input[type="text"],
.brand-kit-grid select,
.brand-kit-grid button,
.versions-row select {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 850;
}

.brand-kit-grid input[type="text"],
.brand-kit-grid select {
  grid-column: span 2;
  padding: 0 9px;
}

.brand-kit-grid label {
  display: grid;
  min-width: 0;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-kit-grid input[type="color"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2px;
  background: var(--panel);
}

.tool-button-grid,
.asset-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.asset-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, auto) auto;
  gap: 8px;
}

.asset-search-row input,
.asset-search-row select {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 9px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 850;
}

.tool-button-grid .secondary-button,
.asset-actions .secondary-button,
.versions-row .secondary-button,
.asset-search-row .secondary-button,
.brand-kit-grid .secondary-button,
.brand-kit-grid .primary-button,
.edit-ai-apply-bar .primary-button {
  width: 100%;
  min-width: 0;
  padding: 0 10px;
}

.versions-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.versions-row select {
  width: 100%;
  padding: 0 9px;
}

.asset-library-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
  min-height: 42px;
}

.asset-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  background: var(--panel);
}

.asset-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: calc(var(--radius) - 2px);
  object-fit: cover;
  background: var(--panel-soft);
}

.asset-model-preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 58px;
  overflow: hidden;
  border-radius: calc(var(--radius) - 2px);
  background: linear-gradient(135deg, rgba(23, 25, 31, 0.08), rgba(15, 143, 139, 0.12));
}

.asset-model-preview img {
  position: absolute;
  inset: 0;
}

.asset-model-preview span {
  position: relative;
  z-index: 1;
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(23, 25, 31, 0.78);
  color: #fff8e8;
  font-size: 0.68rem;
  font-weight: 950;
}

.asset-card small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 850;
}

.asset-card div {
  display: flex;
  gap: 4px;
}

.asset-card button {
  flex: 1;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.asset-library-list .gallery-empty {
  grid-column: 1 / -1;
  min-height: 42px;
  padding: 10px;
  font-size: 0.78rem;
}

.deck-workspace {
  display: grid;
  place-items: center;
  min-height: 0;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 28px;
  container-type: size;
}

.slide-stage {
  position: relative;
  width: min(100%, 1120px, calc(100cqh * 16 / 9));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(23, 25, 31, 0.12);
  border-radius: var(--radius);
  background: #08090d;
  box-shadow: var(--shadow);
}

.presentation-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #08090d;
  touch-action: manipulation;
}

/* Dedicated full-deck render used only while exporting; overlays the stage. */
.lyllic-export-frame {
  position: absolute;
  inset: 0;
}

.legacy-deck-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(92vw, 760px);
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(240, 182, 79, 0.5);
  background: linear-gradient(180deg, rgba(255, 246, 224, 0.98), rgba(255, 240, 206, 0.98));
  color: #5a4413;
  box-shadow: 0 18px 44px rgba(23, 25, 31, 0.18);
}

.legacy-deck-banner[hidden] { display: none; }

.legacy-deck-banner > svg,
.legacy-deck-banner > [data-lucide] {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: #b67d12;
}

.legacy-deck-banner-text {
  display: grid;
  gap: 2px;
  line-height: 1.3;
}

.legacy-deck-banner-text strong { font-size: 0.95rem; }
.legacy-deck-banner-text span { font-size: 0.82rem; opacity: 0.86; }

.legacy-deck-banner .primary-button {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}

body.edit-mode .presentation-frame {
  touch-action: none;
}

.stage-nav-button {
  display: none;
  position: fixed;
  top: 50%;
  z-index: 30;
  width: 60px;
  height: 76px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: #08090d;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  transform: translateY(-50%);
  place-items: center;
}

.stage-nav-button svg {
  width: 34px;
  height: 34px;
  stroke-width: 2.4;
}

.stage-nav-button:disabled {
  cursor: default;
  opacity: 0.32;
}

.stage-nav-button:not(:disabled):hover,
.stage-nav-button:not(:disabled):focus-visible {
  background: rgba(255, 255, 255, 0.92);
  transform: translateY(-50%) scale(1.04);
}

.stage-nav-prev {
  left: max(18px, env(safe-area-inset-left));
}

.stage-nav-next {
  right: max(18px, env(safe-area-inset-right));
}

.deck-footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 18px 28px 24px;
  border-top: 1px solid rgba(23, 25, 31, 0.08);
}

.thumbnail-rail {
  display: flex;
  gap: 10px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px;
}

.thumbnail-wrap {
  position: relative;
  flex: 0 0 136px;
  border-radius: var(--radius);
}

.thumbnail-wrap.dragging {
  opacity: 0.45;
}

.thumbnail-wrap.drop-before::before,
.thumbnail-wrap.drop-after::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.thumbnail-wrap.drop-before::before {
  left: -7px;
}

.thumbnail-wrap.drop-after::after {
  right: -7px;
}

.thumbnail {
  width: 100%;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.thumbnail.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent), transparent 72%);
}

.thumbnail-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  color: #c0392b;
  opacity: 0;
  transition: opacity 140ms ease;
  cursor: pointer;
}

.thumbnail-delete i {
  width: 14px;
  height: 14px;
}

.thumbnail-wrap:hover .thumbnail-delete,
.thumbnail-delete:focus-visible {
  opacity: 1;
}

.thumbnail-drop-line {
  display: none;
}

.thumbnail small,
.thumbnail span {
  display: block;
}

.thumbnail small {
  color: var(--muted);
  font-size: 0.72rem;
}

.thumbnail span {
  overflow: hidden;
  margin-top: 5px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.gallery-screen {
  display: flex;
  flex-direction: column;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(23, 25, 31, 0.1);
  background: rgba(255, 253, 248, 0.58);
  backdrop-filter: blur(22px);
}

.gallery-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.gallery-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 253, 248, 0.68);
  box-shadow: 0 18px 54px rgba(23, 25, 31, 0.08);
  backdrop-filter: blur(22px);
}

.gallery-filters {
  display: flex;
  align-items: center;
  min-width: min(460px, 100%);
  gap: 10px;
}

.gallery-search {
  display: flex;
  align-items: center;
  flex: 1 1 220px;
  min-width: 0;
  gap: 8px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

.gallery-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.segmented-control {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.segmented-control button {
  min-height: 38px;
  border: 0;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.segmented-control button.active {
  background: var(--ink);
  color: #fff8e8;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.gallery-card,
.gallery-loading-card,
.gallery-empty {
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.74);
  box-shadow: 0 18px 48px rgba(23, 25, 31, 0.11);
  backdrop-filter: blur(20px);
}

.gallery-card {
  position: relative;
  display: grid;
  gap: 14px;
  overflow: hidden;
  padding: 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.gallery-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.58), transparent 44%);
}

.gallery-card:hover {
  border-color: color-mix(in srgb, var(--accent), white 34%);
  box-shadow: 0 24px 62px rgba(23, 25, 31, 0.14);
  transform: translateY(-2px);
}

.gallery-card > * {
  position: relative;
}

.gallery-card-preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 132px;
  overflow: hidden;
  border: 1px solid rgba(23, 25, 31, 0.1);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 143, 139, 0.82), rgba(239, 184, 75, 0.72)),
    var(--ink);
  color: #fff8e8;
}

.gallery-card-preview::before {
  content: "";
  position: absolute;
  inset: -24% 18% auto auto;
  width: 58%;
  height: 150%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.56), transparent 72%);
  filter: blur(18px);
  opacity: 0.66;
  transform: rotate(18deg);
}

.gallery-card-preview svg {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  opacity: 0.82;
}

.gallery-card-preview span {
  position: relative;
  font-size: 3rem;
  font-weight: 900;
}

.gallery-card-copy {
  display: grid;
  gap: 6px;
}

.gallery-card-copy p,
.gallery-card-copy h3,
.gallery-card-copy span {
  margin: 0;
}

.gallery-card-copy p {
  overflow: hidden;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.gallery-card-copy h3 {
  display: -webkit-box;
  overflow: hidden;
  min-height: 48px;
  font-size: 1.02rem;
  line-height: 1.18;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.gallery-card-copy span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.gallery-card-copy .template-badge {
  display: inline-flex;
  width: fit-content;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 50%);
  border-radius: var(--radius);
  padding: 3px 6px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
}

.gallery-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.gallery-card-actions .secondary-button {
  flex: 1 1 auto;
}

.gallery-card-actions .icon-button {
  flex: 0 0 40px;
}

.gallery-loading-card,
.gallery-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  padding: 30px;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.gallery-loading-card {
  gap: 10px;
}

.gallery-empty svg {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

.gallery-empty span {
  color: var(--ink);
  font-size: 1rem;
}

.gallery-empty small {
  max-width: 340px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.primary-button svg,
.secondary-button svg,
.icon-button svg,
.gallery-search svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  stroke-width: 2.25;
}

.gallery-loading-card svg {
  animation: spin 900ms linear infinite;
}

.icon-button.danger:hover {
  background: var(--accent-2);
  color: #fff8e8;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff8e8;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 9, 13, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.busy-overlay[hidden] {
  display: none;
}

.busy-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(360px, calc(100vw - 48px));
  padding: 28px 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(247, 242, 232, 0.98));
  box-shadow: 0 30px 80px rgba(8, 9, 13, 0.4);
  text-align: center;
}

.busy-overlay-card strong {
  font-size: 1.02rem;
  color: var(--ink);
}

.busy-overlay-card span {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.1em;
}

.busy-spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent), transparent 70%);
  border-top-color: var(--accent);
  animation: busy-spin 0.8s linear infinite;
}

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

.busy-overlay-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent), transparent 80%);
  overflow: hidden;
}

.busy-overlay-bar[hidden] {
  display: none;
}

.busy-overlay-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 220ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .busy-spinner { animation-duration: 1.6s; }
}

.presenter-panel {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(15, 143, 139, 0.12), transparent 34%),
    rgba(247, 242, 232, 0.92);
}

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

.presenter-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 18px 42px rgba(23, 25, 31, 0.12);
}

.presenter-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.presenter-card p,
.presenter-card h2 {
  margin: 0;
}

#presenterTimer {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

#presenterTitle {
  margin-top: 4px;
  font-size: 1.34rem;
  line-height: 1.12;
}

#presenterNotesText {
  margin-top: 18px;
  color: #303640;
  font-size: 1rem;
  line-height: 1.62;
  overflow-y: auto;
}

.presenter-next {
  display: grid;
  gap: 4px;
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.presenter-next span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.presenter-next strong {
  font-size: 0.95rem;
}

body.present-mode {
  background: #08090d;
}

body.present-mode .app-shell {
  display: block;
  height: 100vh;
  height: 100dvh;
}

body.present-mode .agent-panel,
body.present-mode .canvas-toolbar,
body.present-mode .editor-panel,
body.present-mode .export-panel,
body.present-mode .studio-tools-panel,
body.present-mode .deck-footer {
  display: none;
}

body.present-mode .canvas-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  background: #08090d;
}

body.present-mode .deck-workspace {
  display: block;
  padding: 0;
}

body.present-mode .slide-stage {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
  box-shadow: none;
}

body.present-mode .stage-nav-button {
  display: none;
}

@keyframes pulse-dots {
  0%, 100% {
    opacity: 0.38;
  }

  50% {
    opacity: 1;
  }
}

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

@keyframes statusSheen {
  0% {
    transform: translateX(-110%);
  }

  55%, 100% {
    transform: translateX(110%);
  }
}

@keyframes editPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 10px 22px rgba(23, 25, 31, 0.18), 0 0 0 0 rgba(15, 143, 139, 0.24);
  }

  50% {
    transform: scale(1.04);
    box-shadow: 0 14px 26px rgba(23, 25, 31, 0.2), 0 0 0 8px rgba(15, 143, 139, 0);
  }
}

@keyframes statusMeter {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(240%);
  }
}

@keyframes auth-fall {
  from {
    background-position: 0 -220px, 0 0;
  }

  to {
    background-position: 0 220px, 0 0;
  }
}

@keyframes auth-copy-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes auth-frame-lift {
  from {
    transform: translateY(2px);
  }

  to {
    transform: translateY(-4px);
  }
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: minmax(300px, 35%) minmax(0, 1fr);
  }

  .agent-header,
  .canvas-toolbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .editor-panel {
    padding-left: 16px;
    padding-right: 16px;
  }

  .canvas-toolbar .secondary-button span {
    font-size: 0.86rem;
  }
}

@media (hover: none) {
  .thumbnail-delete {
    opacity: 1;
  }
}

@media (max-width: 860px) {
  html,
  body.is-authenticated:not(.gallery-open):not(.present-mode) {
    height: auto;
    min-height: 100%;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .auth-screen {
    grid-template-columns: 1fr;
    align-content: start;
    gap: 18px;
  }

  .auth-stage {
    min-height: 390px;
  }

  .story-copy h1 {
    max-width: 12ch;
    font-size: clamp(3rem, 10vw, 5.6rem);
  }

  .story-frames {
    margin-top: 24px;
  }

  .auth-card {
    max-width: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: clip;
  }

  .agent-panel {
    min-height: 0;
    height: auto;
    min-width: 0;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-log {
    flex: 0 1 260px;
    min-height: 120px;
    max-height: min(32vh, 280px);
    max-height: min(32dvh, 280px);
  }

  .canvas-panel {
    height: auto;
    min-height: 0;
    overflow-x: clip;
    overflow-y: visible;
    grid-template-rows: auto auto auto minmax(220px, 1fr) auto;
  }

  .canvas-toolbar {
    position: sticky;
    top: 0;
    z-index: 18;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: rgba(255, 250, 240, 0.92);
    backdrop-filter: blur(18px);
  }

  .toolbar-actions {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    justify-content: flex-start;
  }

  .export-panel {
    position: fixed;
    top: max(76px, env(safe-area-inset-top));
    right: 18px;
    left: 18px;
    width: auto;
  }

  .editor-panel {
    align-items: center;
    flex-wrap: wrap;
    overflow-x: hidden;
    max-width: 100vw;
    padding: 9px 18px;
    scrollbar-width: thin;
  }

  .editor-selection {
    flex: 0 0 190px;
    max-width: 190px;
  }

  .studio-tools-panel {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    min-width: 0;
    max-width: 100vw;
    max-height: 46vh;
    max-height: 46dvh;
  }

  .deck-workspace {
    min-height: clamp(220px, 38vh, 460px);
    min-height: clamp(220px, 38dvh, 460px);
    overflow: hidden;
    max-width: 100vw;
  }

  .slide-stage {
    width: min(100%, calc(100vw - 36px), calc(100cqh * 16 / 9));
  }

  .deck-footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 640px) {
  .primary-button,
  .secondary-button,
  .icon-button {
    min-height: 44px;
  }

  .agent-header,
  .canvas-toolbar,
  .deck-footer,
  .gallery-header,
  .gallery-main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .auth-card {
    padding: 18px;
  }

  .auth-screen {
    padding: 16px;
  }

  .auth-stage {
    min-height: auto;
    padding: 18px;
  }

  .story-copy h1 {
    max-width: 100%;
    font-size: clamp(2.35rem, 12vw, 3.8rem);
    line-height: 0.94;
  }

  .story-copy span {
    font-size: 0.95rem;
  }

  .story-frames {
    grid-template-columns: 1fr;
    margin-top: 18px;
  }

  .story-frames article {
    min-height: auto;
  }

  .agent-header,
  .gallery-header,
  .gallery-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-actions,
  .gallery-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .gallery-filters {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    flex: 1;
  }

  .user-badge {
    max-width: min(180px, 42vw);
  }

  .agent-panel {
    min-height: 0;
  }

  .agent-header {
    gap: 12px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: 14px;
  }

  .chat-log {
    flex-basis: 180px;
    min-height: 96px;
    max-height: min(26vh, 210px);
    max-height: min(26dvh, 210px);
    padding: 12px 14px 14px;
  }

  .message {
    max-width: 96%;
    padding: 10px 12px;
  }

  .prompt-box {
    gap: 10px;
    padding: 12px 16px max(14px, env(safe-area-inset-bottom));
  }

  .prompt-box textarea {
    min-height: 96px;
    max-height: 28vh;
    max-height: 28dvh;
  }

  .canvas-toolbar {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .toolbar-actions {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
    flex-wrap: wrap;
    justify-content: flex-start;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .toolbar-actions::-webkit-scrollbar {
    display: none;
  }

  .canvas-toolbar .secondary-button {
    flex: 0 0 auto;
    padding: 0 12px;
  }

  .export-panel {
    top: max(76px, env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    width: auto;
  }

  .editor-panel {
    align-items: center;
    flex-wrap: wrap;
    overflow-x: hidden;
    padding: 8px 12px;
    scrollbar-width: none;
  }

  .editor-panel::-webkit-scrollbar {
    display: none;
  }

  .editor-selection {
    flex: 0 0 162px;
    max-width: 162px;
  }

  .editor-group {
    flex: 1 1 auto;
    min-width: 0;
    gap: 5px;
    padding-left: 8px;
  }

  .tool-button {
    width: 38px;
    height: 38px;
  }

  .editor-nudge-group {
    grid-template-columns: repeat(3, 32px);
    grid-template-rows: repeat(2, 32px);
  }

  .editor-nudge-group .tool-button {
    width: 32px;
    height: 32px;
  }

  .studio-tools-panel {
    grid-template-columns: 1fr;
    width: 100%;
    max-height: 52vh;
    max-height: 52dvh;
    padding: 10px 16px;
  }

  .edit-ai-apply-bar {
    grid-template-columns: 1fr;
  }

  .tool-button-grid,
  .asset-actions,
  .asset-search-row,
  .brand-kit-grid {
    grid-template-columns: 1fr;
  }

  .brand-kit-grid input[type="text"],
  .brand-kit-grid select {
    grid-column: auto;
  }

  .editor-selection {
    flex-basis: 100%;
    max-width: none;
  }

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

  .send-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .prompt-option-list {
    flex-direction: column;
    align-items: flex-start;
  }

  .send-actions .primary-button {
    flex: 1 1 126px;
  }

  .canvas-panel {
    min-height: 620px;
  }

  .deck-workspace {
    min-height: clamp(270px, 42vh, 430px);
    min-height: clamp(270px, 42dvh, 430px);
    padding: 16px;
  }

  .slide-stage {
    width: min(100%, calc(100vw - 32px), calc(100cqh * 16 / 9));
  }

  .deck-footer {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
    padding-top: 10px;
  }

  .thumbnail {
    flex-basis: 98px;
    min-height: 56px;
    padding: 8px;
  }

  .secondary-button span,
  .primary-button span {
    display: inline;
  }
}

@media (max-width: 430px) {
  .deck-meta {
    flex: 1 1 100%;
  }

  .deck-meta p {
    display: none;
  }

  .deck-meta h2 {
    font-size: 0.98rem;
  }

  .canvas-toolbar .secondary-button span {
    display: none;
  }

  .canvas-toolbar .secondary-button,
  .canvas-toolbar .icon-button {
    min-width: 44px;
  }

  .switch-control {
    align-self: flex-start;
  }

  .send-actions {
    justify-content: stretch;
  }

  .send-actions .icon-button,
  .send-actions #uploadBtn {
    flex: 0 0 44px;
  }

  .send-actions .logo-upload-button {
    flex: 0 0 auto;
  }

  .send-actions .primary-button {
    flex-basis: 100%;
  }
}

/* === Undo timeline, AI diff banner, share/unlock dialogs (added) === */
.timeline-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.timeline-empty {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.timeline-entry {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(23, 25, 31, 0.1);
  border-radius: var(--radius);
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  font: inherit;
  transition: border-color 120ms ease, transform 120ms ease, background 120ms ease;
}

.timeline-entry:hover:not(:disabled) {
  border-color: rgba(23, 25, 31, 0.32);
  transform: translateY(-1px);
}

.timeline-entry:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.timeline-entry .timeline-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent, #47f2d1);
  box-shadow: 0 0 0 2px rgba(71, 242, 209, 0.18);
}

.timeline-entry[data-kind="version"] .timeline-dot { background: #6c8cff; box-shadow: 0 0 0 2px rgba(108, 140, 255, 0.18); }
.timeline-entry[data-kind="draft"] .timeline-dot { background: #ffb84d; box-shadow: 0 0 0 2px rgba(255, 184, 77, 0.18); }
.timeline-entry[data-kind="ai-edit"] .timeline-dot { background: #c879ff; box-shadow: 0 0 0 2px rgba(200, 121, 255, 0.18); }

.timeline-entry .timeline-meta {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.timeline-entry .timeline-meta strong {
  font-size: 0.84rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-entry .timeline-meta small {
  font-size: 0.7rem;
  color: var(--muted);
}

.timeline-entry .timeline-badge {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid rgba(23, 25, 31, 0.12);
  border-radius: 999px;
  padding: 2px 7px;
}

.ai-diff-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 0 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(200, 121, 255, 0.12), rgba(71, 242, 209, 0.12));
  border: 1px solid rgba(200, 121, 255, 0.32);
  box-shadow: 0 10px 28px rgba(23, 25, 31, 0.06);
  flex-wrap: wrap;
}

.ai-diff-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ai-diff-summary > div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.ai-diff-summary strong { font-size: 0.92rem; }
.ai-diff-summary span { font-size: 0.78rem; color: var(--muted); }

.ai-diff-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

body.present-mode .ai-diff-banner { display: none; }

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-modal[hidden] { display: none; }

.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 9, 13, 0.55);
  backdrop-filter: blur(4px);
}

.app-modal-card {
  position: relative;
  z-index: 1;
  width: min(680px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(8, 9, 13, 0.35);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.diff-modal-card { width: min(960px, 96vw); }
.share-dialog-card, .unlock-dialog-card { width: min(520px, 96vw); }
.subscribe-modal-card { width: min(480px, 96vw); }

.subscribe-modal-body {
  padding: 6px 22px 4px;
  display: grid;
  gap: 16px;
}

.subscribe-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.subscribe-price-amount {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink, #17191f);
}

.subscribe-price-period {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.subscribe-benefits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 11px;
}

.subscribe-benefits li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.92rem;
  line-height: 1.35;
}

.subscribe-benefits li svg,
.subscribe-benefits li [data-lucide] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: #0f8f8b;
}

.subscribe-modal-state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 143, 139, 0.12);
  color: #0c6f6b;
  font-weight: 600;
  font-size: 0.9rem;
}

.subscribe-modal-state[hidden] { display: none; }

.upgrade-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(120deg, #0f8f8b, #47f2d1);
  color: #052a28;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15, 143, 139, 0.28);
}

.upgrade-button[hidden] { display: none; }
.upgrade-button svg, .upgrade-button [data-lucide] { width: 15px; height: 15px; }
.upgrade-button.is-pro {
  background: linear-gradient(120deg, #ffcf73, #f0b64f);
  color: #4a3608;
  box-shadow: 0 8px 20px rgba(240, 182, 79, 0.3);
}

.app-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 8px;
}

.app-modal-kicker {
  margin: 0 0 4px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.app-modal-header h3 { margin: 0; font-size: 1.2rem; }

.app-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 22px 18px;
  border-top: 1px solid rgba(23, 25, 31, 0.06);
}

.diff-modal-body {
  padding: 8px 22px 18px;
  display: grid;
  gap: 14px;
}

.diff-slide-row {
  border: 1px solid rgba(23, 25, 31, 0.08);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.diff-slide-row header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.diff-slide-row header strong { font-size: 0.95rem; }

.diff-slide-row .diff-jump {
  background: none;
  border: none;
  color: var(--accent, #2f70ff);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.diff-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.diff-col h4 {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.diff-col {
  border: 1px solid rgba(23, 25, 31, 0.08);
  border-radius: 10px;
  padding: 10px;
  background: rgba(248, 248, 250, 0.7);
  min-height: 80px;
}

.diff-col.diff-before { background: rgba(255, 230, 230, 0.4); }
.diff-col.diff-after { background: rgba(230, 255, 240, 0.5); }

.diff-field {
  margin: 0 0 6px;
  font-size: 0.82rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.diff-field span {
  font-weight: 800;
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 2px;
}

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

.share-dialog-body {
  padding: 8px 22px 0;
  display: grid;
  gap: 14px;
}

.share-dialog-field {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
}

.share-dialog-field span {
  font-weight: 700;
  font-size: 0.82rem;
}

.share-dialog-field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}

.share-dialog-field small {
  color: var(--muted);
  font-size: 0.74rem;
}

.share-dialog-status {
  margin: 0;
  min-height: 1em;
  font-size: 0.8rem;
  color: var(--muted);
}

.share-dialog-status[data-state="error"] { color: #c0392b; }
.share-dialog-status[data-state="success"] { color: #1f7a3a; }

.collaborators-deck-name {
  margin: 0;
  font-weight: 900;
  font-size: 0.95rem;
}

.collaborators-intro {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.collaborators-add-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.collaborators-add-row input {
  flex: 1 1 auto;
}

.collaborators-add-row .primary-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.collaborators-list {
  display: grid;
  gap: 8px;
  margin-top: 2px;
  max-height: 240px;
  overflow-y: auto;
}

.collaborators-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  text-align: center;
}

.collaborator-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.collaborator-id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.collaborator-avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.85rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent), #000 28%));
}

.collaborator-text {
  display: grid;
  min-width: 0;
}

.collaborator-text strong {
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collaborator-text span {
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-card-preview.shared {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 78%), color-mix(in srgb, var(--accent), transparent 92%));
}

.gallery-card-copy .shared-badge {
  display: inline-flex;
  width: fit-content;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 55%);
  border-radius: var(--radius);
  padding: 3px 7px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.unlock-dialog-hint {
  margin: 0;
  font-size: 0.82rem;
  padding: 8px 10px;
  background: rgba(108, 140, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
}

/* Responsive refinements for editing tools, slide-AI, and overlays */
@media (max-width: 860px) {
  .slide-ai-form {
    grid-template-columns: 1fr;
  }

  .slide-ai-form button {
    width: 100%;
    justify-content: center;
  }

  .thumbnail-wrap {
    flex-basis: 118px;
  }
}

@media (max-width: 640px) {
  .editor-panel {
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .editor-group {
    gap: 5px;
  }

  .busy-overlay-card {
    width: min(340px, calc(100vw - 32px));
    padding: 22px 20px;
  }

  .brand-logo-size {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
}

