:root {
  color-scheme: dark;
  --bg: #070708;
  --bg-soft: #0b0b0d;
  --surface: #111113;
  --surface-2: #17171a;
  --surface-3: #202025;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f3f7;
  --text-2: #aaa7b2;
  --text-3: #716e78;
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --green: #55d6a7;
  --amber: #f4bb55;
  --red: #ef7373;
  --blue: #6ca9ff;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
}

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

html, body { width: 100%; height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; }
input, textarea { color: inherit; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #29292f; border-radius: 99px; }

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

.app-shell { width: 100%; height: 100%; background: var(--bg); }

.topbar {
  position: relative;
  z-index: 60;
  height: 60px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 7, 8, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, #9a6dff, #6841dd);
  box-shadow: 0 7px 24px rgba(139, 92, 246, 0.28);
}

.brand-badge {
  color: var(--accent-2);
  background: var(--accent-soft);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 99px;
  padding: 2px 7px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 33px;
  padding: 0 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease;
}

.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.045); }
.nav-item.active { color: var(--text); background: var(--surface-3); }

.nav-count {
  min-width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 9px;
}

.top-actions { justify-self: end; }
.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(244, 187, 85, 0.08);
}
.connection.online .connection-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(85, 214, 167, 0.08); }
.connection.offline .connection-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(239, 115, 115, 0.08); }

.main-shell { height: calc(100% - 60px); }
.view { display: none; width: 100%; height: 100%; }
.view.active { display: block; }

/* Canvas */
.create-view { position: relative; overflow: hidden; }
.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 42px 40px 205px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 44%, rgba(139, 92, 246, 0.07), transparent 34%),
    var(--bg);
}

.stage::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(255, 255, 255, 0.025);
  border-radius: 24px;
  pointer-events: none;
}

.stage-ambient {
  position: absolute;
  width: 520px;
  height: 270px;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.05);
  filter: blur(90px);
}

.stage-empty {
  position: relative;
  z-index: 2;
  width: min(560px, 90%);
  text-align: center;
  animation: appear 420ms ease both;
}

.stage-symbol {
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  color: var(--accent-2);
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.18), rgba(139, 92, 246, 0.035));
  box-shadow: 0 16px 70px rgba(139, 92, 246, 0.12);
}

.stage-empty h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.06;
  letter-spacing: -0.05em;
}

.stage-empty p {
  margin: 13px auto 0;
  color: var(--text-2);
  font-size: 13px;
}

.stage-start {
  margin-top: 24px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 650;
}
.stage-start:hover { border-color: var(--border-strong); color: var(--text); }

.stage-preview {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.stage-preview img,
.stage-preview video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.stage-preview audio { width: min(560px, 90%); }
.stage-preview-label {
  position: absolute;
  left: 50%;
  bottom: -28px;
  transform: translateX(-50%);
  color: var(--text-3);
  font-size: 10px;
  white-space: nowrap;
}

/* Composer */
.composer-dock {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(1080px, calc(100% - 48px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  align-items: end;
  gap: 12px;
}

.composer {
  position: relative;
  width: 100%;
  padding: 11px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: rgba(18, 18, 20, 0.96);
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.5) inset;
  backdrop-filter: blur(22px);
  transition: border-color 180ms ease, transform 180ms ease;
}
.composer:focus-within { border-color: rgba(139, 92, 246, 0.42); }
.composer-handle { display: none; }

.prompt-row {
  display: block;
}

#promptInput {
  width: 100%;
  max-height: 142px;
  min-height: 48px;
  resize: none;
  padding: 13px 12px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
#promptInput::placeholder { color: #68656e; }

.generate-button {
  width: 116px;
  height: 116px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0;
  border-radius: 20px;
  background: linear-gradient(145deg, #d4ff2f, #b6f20f);
  color: #101405;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 16px 44px rgba(190, 255, 22, 0.18);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}
.generate-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 18px 48px rgba(190, 255, 22, 0.28); }
.generate-button:disabled { cursor: wait; opacity: 0.55; }
.generate-cost { font-size: 9px; font-weight: 750; opacity: 0.58; }

.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 37px;
  padding: 7px 2px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.tool-chip {
  min-height: 31px;
  max-width: 190px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}
.tool-chip:hover, .tool-chip.open { color: var(--text); background: var(--surface-3); border-color: var(--border-strong); }
.tool-chip.enhance.active { color: var(--accent-2); border-color: rgba(139, 92, 246, 0.25); background: var(--accent-soft); }
.icon-chip { width: 32px; padding: 0; justify-content: center; overflow: visible; position: relative; }
.chip-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  padding: 0 3px;
  border: 2px solid var(--surface);
  border-radius: 99px;
  background: var(--accent);
  color: white;
  font-size: 8px;
}
.required-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); }
.composer-hint { margin-left: auto; padding-right: 5px; color: var(--text-3); font-size: 9.5px; white-space: nowrap; }

.composer-context {
  max-height: 300px;
  margin-bottom: 9px;
  padding: 13px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #0d0d0f;
  animation: contextIn 180ms ease both;
}

.context-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.context-header > div { flex: 1; }
.context-title { margin: 0; font-size: 12px; font-weight: 700; }
.context-description { margin: 3px 0 0; color: var(--text-3); font-size: 10px; }
.context-close {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
}
.context-close:hover { color: var(--text); background: var(--surface-3); }

.attachment-tray {
  display: flex;
  gap: 6px;
  padding: 2px 2px 9px;
  overflow-x: auto;
}
.attachment-pill {
  flex: none;
  max-width: 190px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 9.5px;
}
.attachment-pill img, .attachment-pill video { width: 23px; height: 23px; object-fit: cover; border-radius: 5px; }
.attachment-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove { width: 20px; height: 20px; display: grid; place-items: center; background: transparent; color: var(--text-3); }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.upload-slot {
  position: relative;
  min-height: 92px;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-2);
}
.upload-slot:hover { border-color: rgba(139, 92, 246, 0.5); background: var(--accent-soft); }
.upload-slot.filled { border-style: solid; }
.slot-trigger {
  width: 100%;
  min-height: 90px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  background: transparent;
  color: var(--text-2);
  text-align: left;
}
.slot-thumb { width: 62px; height: 66px; flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 8px; background: #080809; color: var(--text-3); }
.slot-thumb img, .slot-thumb video { width: 100%; height: 100%; object-fit: cover; }
.slot-copy { min-width: 0; }
.slot-name { display: block; color: var(--text); font-size: 10.5px; font-weight: 650; }
.slot-help { display: block; margin-top: 3px; color: var(--text-3); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.66);
  color: white;
}

.script-box textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}
.voice-row, .option-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.option-button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 650;
}
.option-button:hover { color: var(--text); border-color: var(--border-strong); }
.option-button.active { color: var(--accent-2); border-color: rgba(139, 92, 246, 0.45); background: var(--accent-soft); }
.param-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.param-label { display: block; color: var(--text-3); font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

/* Collection */
.collection-view { padding: 34px clamp(22px, 4vw, 64px) 70px; overflow-y: auto; background: var(--bg); }
.collection-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--text-3); font-size: 9px; font-weight: 750; letter-spacing: 0.14em; }
.collection-header h1 { margin: 0; font-size: clamp(25px, 3vw, 38px); letter-spacing: -0.045em; }
.collection-tools { display: flex; align-items: center; gap: 8px; }
.search-box {
  width: min(260px, 30vw);
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-3);
}
.search-box input { width: 100%; border: 0; outline: none; background: transparent; color: var(--text); font-size: 11px; }
.search-box input::placeholder { color: var(--text-3); }
.new-creation {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border-radius: 10px;
  background: var(--text);
  color: #111;
  font-size: 10.5px;
  font-weight: 750;
}

.filter-row { display: flex; gap: 6px; margin: 26px 0 18px; overflow-x: auto; }
.filter-button {
  flex: none;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: transparent;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 650;
}
.filter-button:hover { color: var(--text); border-color: var(--border-strong); }
.filter-button.active { color: var(--text); background: var(--surface-3); border-color: var(--border-strong); }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 15px; align-items: start; }
.creation-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  transition: transform 170ms ease, border-color 170ms ease;
}
.creation-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.card-media {
  position: relative;
  width: 100%;
  min-height: 170px;
  max-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050506;
  cursor: pointer;
}
.card-media img, .card-media video { width: 100%; height: 100%; object-fit: contain; background: #050506; }
.card-poster { position: absolute; inset: 0; }
.card-video { position: absolute; inset: 0; opacity: 0; transition: opacity 180ms ease; }
.card-video.ready { opacity: 1; }
.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
  background: radial-gradient(circle at 50% 42%, #17171a 0, #080809 62%);
  font-size: 9px;
}
.video-placeholder.hidden { display: none; }
.card-media audio { width: calc(100% - 24px); }
.card-overlay { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; background: rgba(0, 0, 0, 0.2); transition: opacity 160ms ease; }
.card-media:hover .card-overlay { opacity: 1; }
.play-button { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.92); color: #111; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); }
.card-state { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; color: var(--text-3); text-align: center; font-size: 10px; }
.card-state.failed { color: var(--red); }
.progress-ring { width: 28px; height: 28px; border: 2px solid rgba(139, 92, 246, 0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 900ms linear infinite; }

.card-body { padding: 11px 12px 12px; }
.card-prompt { margin: 0; min-height: 34px; color: var(--text-2); font-size: 10.5px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.status-tag, .meta-tag {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 0 7px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.status-tag.completed { color: var(--green); background: rgba(85, 214, 167, 0.1); }
.status-tag.processing { color: var(--blue); background: rgba(108, 169, 255, 0.1); }
.status-tag.pending { color: var(--amber); background: rgba(244, 187, 85, 0.1); }
.status-tag.failed { color: var(--red); background: rgba(239, 115, 115, 0.1); }
.card-time { color: var(--text-3); font-size: 8.5px; }
.card-actions { display: flex; gap: 2px; margin-left: auto; }
.card-action { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 7px; background: transparent; color: var(--text-3); }
.card-action:hover { color: var(--text); background: var(--surface-3); }

.empty-library { grid-column: 1 / -1; min-height: 48vh; display: grid; place-items: center; text-align: center; color: var(--text-3); }
.empty-library-icon { width: 54px; height: 54px; display: grid; place-items: center; margin: 0 auto 14px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); }
.empty-library h3 { margin: 0; color: var(--text-2); font-size: 14px; }
.empty-library p { margin: 5px 0 0; font-size: 10px; }
.retry-button { margin-top: 13px; padding: 8px 12px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); font-size: 10px; }
.load-more-wrap { grid-column: 1 / -1; display: flex; justify-content: center; padding: 14px 0 4px; }
.load-more-button {
  min-height: 38px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 700;
}
.load-more-button:hover { color: var(--text); background: var(--surface-2); }

/* Dialogs */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.76); backdrop-filter: blur(8px); }
.picker-dialog {
  width: min(760px, calc(100% - 32px));
  max-height: min(760px, calc(100% - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: #0e0e10;
  box-shadow: var(--shadow);
}
.dialog-shell { display: flex; flex-direction: column; max-height: min(760px, calc(100vh - 32px)); padding: 18px; }
.dialog-header { display: flex; align-items: flex-start; gap: 16px; }
.dialog-header > div { flex: 1; }
.dialog-header h2 { margin: 0; font-size: 20px; letter-spacing: -0.035em; }
.dialog-close { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.dialog-close:hover { color: var(--text); background: var(--surface-3); }
.dialog-search { height: 42px; display: flex; align-items: center; gap: 9px; margin: 16px 0 5px; padding: 0 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text-3); }
.dialog-search input { flex: 1; border: 0; outline: none; background: transparent; color: var(--text); font-size: 11px; }
.picker-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 15px; overflow-y: auto; padding: 1px 2px 4px; }
.picker-option {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  text-align: left;
}
.picker-option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.picker-option.active { border-color: rgba(139, 92, 246, 0.58); background: var(--accent-soft); }
.picker-icon { width: 35px; height: 35px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-3); color: var(--text-2); }
.picker-option.active .picker-icon { color: var(--accent-2); background: rgba(139, 92, 246, 0.17); }
.picker-copy { flex: 1; min-width: 0; }
.picker-name { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 11.5px; font-weight: 700; }
.picker-desc { margin-top: 4px; color: var(--text-3); font-size: 9.5px; line-height: 1.45; }
.picker-cost { flex: none; color: var(--text-3); font-size: 9px; font-weight: 700; }
.tier { padding: 1px 5px; border-radius: 99px; font-size: 7px; font-weight: 800; text-transform: uppercase; }
.tier.premium { color: var(--amber); background: rgba(244, 187, 85, 0.1); }
.tier.padrão { color: var(--blue); background: rgba(108, 169, 255, 0.1); }
.tier.econômico { color: var(--green); background: rgba(85, 214, 167, 0.1); }
.tier.auto { color: var(--accent-2); background: var(--accent-soft); }

.preview-dialog { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0; border: 0; background: #050506; }
.preview-shell { width: 100%; height: 100%; display: flex; flex-direction: column; }
.preview-header { min-height: 58px; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: rgba(7, 7, 8, 0.94); }
.preview-copy { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; }
.preview-copy p { margin: 0; overflow: hidden; color: var(--text-2); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.preview-actions { display: flex; gap: 5px; }
.preview-action { height: 33px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 9px; background: var(--surface-2); color: var(--text-2); font-size: 9.5px; font-weight: 650; }
.preview-action:hover { color: var(--text); background: var(--surface-3); }
.preview-media { flex: 1; min-height: 0; display: grid; place-items: center; padding: 20px; overflow: hidden; }
.preview-media img, .preview-media video { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-media audio { width: min(640px, 90%); }

/* Feedback */
.toasts { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 7px; pointer-events: none; }
.toast { max-width: min(360px, calc(100vw - 32px)); padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); color: var(--text-2); box-shadow: var(--shadow); font-size: 10.5px; font-weight: 620; animation: toastIn 200ms ease both; }
.toast.ok { color: var(--green); border-color: rgba(85, 214, 167, 0.3); }
.toast.err { color: var(--red); border-color: rgba(239, 115, 115, 0.3); }
.spin-inline { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: white; border-radius: 50%; animation: spin 800ms linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes contextIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 820px) {
  .topbar { grid-template-columns: auto 1fr auto; height: 56px; padding: 0 12px; }
  .main-shell { height: calc(100% - 56px); }
  .brand-name { display: none; }
  .brand-badge { display: none; }
  .main-nav { justify-self: center; border: 0; background: transparent; padding: 0; }
  .nav-item { min-height: 32px; padding: 0 10px; }
  .connection span:last-child { display: none; }
  .stage { padding: 28px 18px 190px; }
  .stage::before { inset: 12px; }
  .composer-dock {
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100% - 20px);
    grid-template-columns: minmax(0, 1fr) 84px;
    gap: 8px;
  }
  .composer { border-radius: 17px; }
  .generate-button { width: 84px; height: 84px; border-radius: 17px; font-size: 12px; }
  .composer-toolbar { overflow-x: auto; scrollbar-width: none; }
  .composer-toolbar::-webkit-scrollbar { display: none; }
  .composer-hint { display: none; }
  .tool-chip { flex: none; }
  .collection-view { padding: 25px 16px 60px; }
  .collection-header { align-items: flex-start; }
  .collection-tools { flex: 1; justify-content: flex-end; }
  .search-box { width: min(220px, 40vw); }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); }
}

@media (max-width: 560px) {
  .topbar { padding: 0 9px; }
  .brand-mark { width: 29px; height: 29px; }
  .nav-item { padding: 0 8px; font-size: 10px; }
  .nav-count { display: none; }
  .stage { padding: 20px 12px 178px; }
  .stage-empty { transform: translateY(-18px); }
  .stage-empty h1 { font-size: 29px; }
  .stage-empty p { max-width: 290px; font-size: 11px; }
  .stage-symbol { width: 54px; height: 54px; margin-bottom: 19px; border-radius: 17px; }
  .composer { padding: 8px; }
  .composer-handle { display: block; width: 44px; height: 13px; margin: -4px auto 1px; background: transparent; position: relative; }
  .composer-handle::after { content: ""; position: absolute; left: 50%; top: 5px; width: 30px; height: 3px; transform: translateX(-50%); border-radius: 99px; background: #3b3940; }
  #promptInput { min-height: 42px; padding: 10px 8px; font-size: 12px; }
  .generate-button { width: 78px; height: 78px; border-radius: 16px; font-size: 11.5px; }
  .composer-dock { grid-template-columns: minmax(0, 1fr) 78px; }
  .generate-cost { font-size: 8px; }
  .composer-context { max-height: 42vh; padding: 10px; }
  .param-groups { grid-template-columns: 1fr; }
  .slot-grid { grid-template-columns: 1fr; }
  .composer.collapsed .attachment-tray,
  .composer.collapsed .composer-context,
  .composer.collapsed .composer-toolbar { display: none !important; }
  .composer.collapsed #promptInput { max-height: 42px; }
  .collection-header { display: block; }
  .collection-tools { margin-top: 16px; justify-content: stretch; }
  .search-box { flex: 1; width: auto; }
  .new-creation { width: 38px; padding: 0; justify-content: center; font-size: 0; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .card-media { min-height: 120px; }
  .card-body { padding: 9px; }
  .card-prompt { font-size: 9px; }
  .meta-tag { display: none; }
  .card-actions .card-action:nth-child(2) { display: none; }
  .picker-grid { grid-template-columns: 1fr; }
  .dialog-shell { padding: 14px; }
  .preview-copy p { display: none; }
  .preview-action span:last-child { display: none; }
  .preview-action { width: 33px; padding: 0; justify-content: center; }
  .toasts { right: 10px; bottom: 10px; }
}

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