:root {
  color-scheme: dark;
  --bg: #0b0c10;
  --panel: #121318;
  --panel-2: #1b1d23;
  --panel-3: #2b2e36;
  --line: #262932;
  --line-strong: #3a3e49;
  --text: #f4f7fb;
  --muted: #c4cad3;
  --soft: #727985;
  --accent: #00d9ff;
  --accent-text: #061014;
  --warn: #ffcf6b;
  --danger: #ff7a7a;
  --ok: #9fe3b0;
  --shadow: 0 24px 70px rgb(0 0 0 / 42%);
  --soft-shadow: 0 16px 40px rgb(0 0 0 / 28%);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100vw;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  overflow: hidden;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 110%, rgb(0 217 255 / 8%), transparent 32%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

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

button,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

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

.sidebar {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 12px 8px 10px;
  background: #101116;
  border-right: 1px solid #20232a;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 8px;
}

.brand-mark,
.spark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--accent-text);
  background: var(--accent);
  border-radius: 10px;
}

.brand-name {
  font-size: 15px;
  font-weight: 650;
}

.brand-subtitle {
  margin-top: 1px;
  color: var(--soft);
  font-size: 12px;
}

.new-button,
.settings-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  color: var(--text);
  background: #171920;
  border: 1px solid #2a2e38;
  border-radius: 12px;
  cursor: pointer;
}

.settings-button {
  min-height: 42px;
  color: #e7edf5;
  background: #14161d;
  border-color: #2a2f3a;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
}

.settings-button svg {
  width: 17px;
  height: 17px;
  color: #cbd3de;
}

.mobile-history-button {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.new-button:hover,
.settings-button:hover,
.history-item:hover,
.icon-button:hover {
  background: rgb(255 255 255 / 8%);
}

.settings-button:hover {
  border-color: #39404d;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.history-list {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 2px;
}

.history-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 8px;
  color: var(--text);
  background: #15171d;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  text-align: left;
}

.history-thumb {
  display: block;
  width: 38px;
  height: 38px;
  overflow: hidden;
  background: #303030;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.history-text {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  overflow: hidden;
  color: var(--soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-panel {
  padding: 6px 4px 0;
}

.workspace {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr) auto;
  width: 100%;
  min-width: 0;
  max-width: 100vw;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 22px;
  border-bottom: 1px solid rgb(255 255 255 / 4%);
}

.topbar .view-switch {
  margin-left: auto;
}

.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 38px;
  padding: 3px;
  background: #181a20;
  border: 1px solid #2b2f39;
  border-radius: 999px;
}

.view-button {
  min-width: 58px;
  height: 30px;
  padding: 0 12px;
  color: var(--soft);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.view-button.is-active {
  color: #071014;
  background: var(--accent);
}

.select-wrap,
.pill-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--soft);
  font-size: 13px;
}

.static-chip strong {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  color: var(--text);
  background: #181a20;
  border: 1px solid #2b2f39;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.pill-select {
  position: relative;
  height: 38px;
  padding: 0 10px 0 14px;
  background: #181a20;
  border: 1px solid #2b2f39;
  border-radius: 999px;
}

.pill-select::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 2px;
  border-right: 2px solid #d9e1ec;
  border-bottom: 2px solid #d9e1ec;
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
}

.pill-select select {
  height: 36px;
  padding: 0 34px 0 12px;
  color: var(--text);
  background: #181a20;
  border: 1px solid #2b2f39;
  border-radius: 12px;
  outline: none;
}

.pill-select select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.custom-select-button {
  min-width: 58px;
  height: 36px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
}

.custom-select-button:disabled {
  cursor: not-allowed;
}

.pill-select.is-disabled {
  opacity: .66;
}

.custom-select-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: none;
  min-width: 100%;
  max-height: 230px;
  overflow-y: auto;
  padding: 5px;
  background: #15171d;
  border: 1px solid #303743;
  border-radius: 14px;
  box-shadow: 0 18px 48px rgb(0 0 0 / 44%);
  scrollbar-color: #596170 #171920;
  scrollbar-width: thin;
}

.custom-select-menu::-webkit-scrollbar {
  width: 6px;
}

.custom-select-menu::-webkit-scrollbar-track {
  background: #171920;
  border-radius: 999px;
}

.custom-select-menu::-webkit-scrollbar-thumb {
  background: #596170;
  border-radius: 999px;
}

.custom-select-menu::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.pill-select.is-open .custom-select-menu {
  display: grid;
  gap: 2px;
}

.custom-select-option {
  min-width: 78px;
  height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}

.custom-select-option:hover,
.custom-select-option[aria-selected="true"] {
  color: var(--text);
  background: #242832;
}

.custom-select-button:focus-visible,
.view-button:focus-visible,
.icon-button:focus-visible,
.send-button:focus-visible,
.prompt-box:focus-within {
  outline: 2px solid rgb(0 217 255 / 42%);
  outline-offset: 2px;
}

.quality-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  height: 38px;
  padding: 0 12px;
  color: var(--muted);
  background: #181a20;
  border: 1px solid #2b2f39;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px clamp(18px, 5vw, 72px) 38px;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100%;
  color: var(--muted);
  text-align: center;
}

.empty-state .spark {
  width: 40px;
  height: 40px;
  margin-bottom: 18px;
  border-radius: 10px;
  font-size: 20px;
}

.empty-state h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(32px, 6vw, 58px);
  font-weight: 720;
}

.empty-state p {
  margin: 10px 0 0;
  color: var(--soft);
  font-size: 15px;
}

.result-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  width: min(100%, 1080px);
  margin: 0 auto;
  align-items: start;
}

.stage.is-canvas-mode {
  overflow: hidden;
  padding: 12px;
}

.stage.is-sketch-mode {
  overflow: hidden;
  padding: 12px;
}

.canvas-workspace,
.sketch-workspace {
  position: absolute;
  inset: 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: #101116;
  border: 1px solid #242832;
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 4%);
}

.canvas-toolbar,
.sketch-toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  background: rgb(17 18 23 / 88%);
  border-bottom: 1px solid #242832;
  backdrop-filter: blur(12px);
}

.canvas-toolbar .icon-button,
.sketch-toolbar .icon-button {
  width: 34px;
  height: 34px;
}

.tool-segment {
  display: inline-flex;
  gap: 3px;
  height: 36px;
  padding: 3px;
  background: #171920;
  border: 1px solid #2a2e38;
  border-radius: 999px;
}

.tool-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--soft);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.tool-button.is-active {
  color: var(--accent-text);
  background: var(--accent);
}

.color-control {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: #171920;
  border: 1px solid #2a2e38;
  border-radius: 50%;
  cursor: pointer;
}

.color-control input {
  width: 24px;
  height: 24px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.range-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  color: var(--muted);
  background: #171920;
  border: 1px solid #2a2e38;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.range-control input {
  width: 116px;
  accent-color: var(--accent);
}

.range-control output {
  min-width: 22px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.sketch-reference-button {
  margin-left: auto;
  white-space: nowrap;
}

.sketch-surface-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 20%, rgb(0 217 255 / 7%), transparent 42%),
    #0d0e13;
}

#sketchCanvas {
  display: block;
  aspect-ratio: var(--sketch-ratio, 1 / 1);
  width: min(78vh, 78vw, 820px);
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: #ffffff;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 8px;
  box-shadow:
    0 28px 70px rgb(0 0 0 / 42%),
    0 0 0 1px rgb(0 0 0 / 10%);
  cursor: crosshair;
  touch-action: none;
}

.canvas-zoom-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 34px;
  color: var(--muted);
  background: #171920;
  border: 1px solid #2a2e38;
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.danger-button {
  margin-left: auto;
}

.danger-button:hover {
  color: var(--danger);
  border-color: rgb(255 122 122 / 38%);
}

.canvas-viewport {
  position: relative;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  background:
    linear-gradient(rgb(255 255 255 / 4%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 4%) 1px, transparent 1px),
    radial-gradient(circle at 50% 20%, rgb(0 217 255 / 8%), transparent 38%),
    #0d0e13;
  background-size: 36px 36px, 36px 36px, auto, auto;
}

.canvas-viewport:active {
  cursor: grabbing;
}

.canvas-board {
  position: absolute;
  inset: 0;
  width: 2400px;
  height: 1600px;
  transform-origin: 0 0;
}

.canvas-item {
  position: absolute;
  touch-action: none;
  user-select: none;
}

.canvas-item .image-card {
  width: 100%;
  border-radius: 14px;
  box-shadow: 0 16px 38px rgb(0 0 0 / 36%);
}

.canvas-item.is-selected .image-card {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px rgb(0 217 255 / 22%),
    0 20px 48px rgb(0 0 0 / 44%);
}

.canvas-item .image-frame {
  cursor: move;
}

.canvas-item .image-actions {
  min-height: 42px;
  padding: 5px;
}

.canvas-item .icon-button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.is-dragging-image .prompt-box {
  border-color: rgb(0 217 255 / 72%);
  box-shadow:
    0 0 0 2px rgb(0 217 255 / 18%),
    var(--shadow);
}

.image-card {
  flex: 0 1 var(--card-width, 360px);
  width: min(100%, var(--card-width, 360px));
  overflow: hidden;
  background: #171920;
  border: 1px solid #292d36;
  border-radius: 16px;
  box-shadow: var(--soft-shadow);
}

.image-card.is-portrait {
  --card-width: 320px;
}

.image-card.is-landscape {
  --card-width: 520px;
}

.loading-card {
  box-shadow: none;
}

.image-frame {
  display: grid;
  place-items: center;
  aspect-ratio: var(--image-ratio, 1 / 1);
  background:
    linear-gradient(45deg, #17191f 25%, transparent 25%),
    linear-gradient(-45deg, #17191f 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #17191f 75%),
    linear-gradient(-45deg, transparent 75%, #17191f 75%);
  background-color: #20232b;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-fallback {
  width: min(78%, 260px);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.image-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  min-height: 48px;
  padding: 7px;
  background: #15171d;
}

.icon-button.ok {
  color: var(--accent);
  border-color: rgb(0 217 255 / 42%);
}

.icon-button:disabled,
.icon-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .45;
}

.loading-frame {
  position: relative;
}

.loading-content {
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}

.loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgb(255 255 255 / 16%);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}

.loading-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.loading-timer {
  color: var(--soft);
  font-size: 13px;
}

.composer {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 0 clamp(18px, 5vw, 64px) 26px;
  background: linear-gradient(180deg, rgb(11 12 16 / 0), var(--bg) 22%);
}

.quick-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.reference-strip {
  display: flex;
  justify-content: flex-start;
}

.reference-list {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  overflow-x: auto;
  padding: 0 2px 4px;
}

.reference-item {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  overflow: hidden;
  color: var(--muted);
  background: #242731;
  border: 1px solid #4a5060;
  border-radius: 12px;
  transform: rotate(-4deg);
}

.reference-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgb(0 217 255 / 18%);
}

.reference-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #303030;
}

.reference-remove-button {
  position: absolute;
  top: auto;
  right: -6px;
  bottom: -6px;
  width: 28px;
  height: 28px;
  color: var(--text);
  background: #3a3f4b;
  border-color: rgb(255 255 255 / 18%);
  border-radius: 50%;
}

.reference-upload-button {
  color: #f5f7fb;
  background: #353a43;
  border-color: #3d444f;
  border-radius: 50%;
}

.reference-upload-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.prompt-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  align-items: end;
  gap: 18px;
  width: min(100%, 1254px);
  min-height: 176px;
  margin: 0 auto;
  padding: 24px;
  background: #1a1c22;
  border: 1px solid #272b34;
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.prompt-main {
  display: grid;
  align-content: space-between;
  gap: 22px;
  min-width: 0;
  min-height: 128px;
}

.prompt-main:has(.reference-strip.is-hidden) {
  align-content: space-between;
}

.prompt-box textarea {
  width: 100%;
  max-height: 180px;
  min-height: 44px;
  resize: none;
  overflow-y: auto;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 16px;
  line-height: 1.55;
}

.prompt-box textarea::placeholder {
  color: #7e858f;
}

.send-button,
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--muted);
  background: #181a20;
  border: 1px solid #2b2f39;
  border-radius: 12px;
  cursor: pointer;
}

.reference-upload-button.icon-button {
  width: 38px;
  height: 38px;
  color: #f5f7fb;
  background: #353a43;
  border-color: #3d444f;
  border-radius: 50%;
}

.reference-upload-button.icon-button:hover {
  background: #444b56;
  border-color: #535c69;
}

.mobile-history-button.icon-button {
  position: fixed;
  display: none;
}

.send-button {
  width: 46px;
  height: 46px;
  color: #111318;
  background: #f2f5f8;
  border-color: #f2f5f8;
  border-radius: 50%;
}

.send-button:disabled {
  cursor: wait;
  opacity: .64;
}

.error-line {
  min-height: 20px;
  color: var(--soft);
  font-size: 13px;
  text-align: center;
}

.error-line.is-error {
  color: var(--danger);
}

.error-line.is-info {
  color: var(--muted);
}

.error-line.is-ok {
  color: var(--ok);
}

.settings-dialog {
  width: min(420px, calc(100vw - 32px));
  color: var(--text);
  background: #1a1c22;
  border: 1px solid #303540;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgb(0 0 0 / 52%);
}

.settings-dialog form {
  display: grid;
  gap: 18px;
  margin: 0;
}

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

.config-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.config-list div {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 12px;
}

.config-list dt {
  color: var(--soft);
}

.config-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.config-field {
  align-items: center;
}

.config-field input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  color: var(--text);
  background: #111318;
  border: 1px solid #2b2f39;
  border-radius: 12px;
  outline: none;
}

.config-field input:focus {
  border-color: var(--line-strong);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-width: 74px;
  height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  cursor: pointer;
}

.primary-button {
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
}

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

.is-hidden {
  display: none;
}

.is-loading .send-button svg {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

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

@media (max-width: 760px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
    height: auto;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 8;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    width: min(82vw, 320px);
    align-items: start;
    gap: 8px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    border-right: 0;
    border-bottom: 1px solid #262626;
    box-shadow: 20px 0 50px rgb(0 0 0 / 36%);
  }

  .history-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 7;
    display: none;
    background: rgb(0 0 0 / 52%);
  }

  .history-open .sidebar-backdrop {
    display: block;
  }

  .brand {
    grid-column: 1;
  }

  .history-open .brand {
    padding-left: 48px;
  }

  .mobile-history-button.icon-button {
    position: fixed;
    top: 10px;
    left: 12px;
    z-index: 9;
    display: inline-grid;
    background: #181818;
  }

  .history-open .mobile-history-button {
    left: 12px;
  }

  .new-button {
    grid-column: 1 / -1;
  }

  .history-header,
  .history-list {
    display: flex;
    grid-column: 1 / -1;
  }

  .history-list {
    min-height: 0;
    overflow-y: auto;
  }

  .settings-panel {
    grid-column: 1 / -1;
    width: 100%;
  }

  .new-button,
  .settings-button {
    width: auto;
    min-width: 42px;
  }

  .new-button {
    padding-inline: 12px;
  }

  .settings-button {
    font-size: 0;
  }

  .settings-button svg {
    margin: 0;
  }

  .workspace {
    grid-column: 1;
    grid-row: 1;
    min-height: calc(100dvh - 67px);
    height: auto;
    overflow: visible;
  }

  .topbar {
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    padding: 10px 12px 10px 58px;
  }

  .topbar .static-chip:nth-of-type(2) {
    display: none;
  }

  .static-chip strong {
    min-height: 34px;
    padding: 0 12px;
    font-size: 12px;
  }

  .view-switch {
    flex: 0 0 auto;
    height: 34px;
  }

  .view-button {
    min-width: 48px;
    height: 26px;
    padding: 0 9px;
    font-size: 12px;
  }

  .select-wrap span {
    display: none;
  }

  .stage {
    overflow: visible;
    padding: 18px 12px 290px;
  }

  .stage.is-canvas-mode {
    min-height: calc(100dvh - 56px);
    overflow: hidden;
    padding: 8px 8px 260px;
  }

  .stage.is-sketch-mode {
    min-height: calc(100dvh - 56px);
    overflow: hidden;
    padding: 8px 8px 260px;
  }

  .canvas-workspace,
  .sketch-workspace {
    inset: 8px 8px 292px;
    border-radius: 16px;
  }

  .canvas-toolbar,
  .sketch-toolbar {
    align-content: start;
    flex-wrap: wrap;
    gap: 6px;
    overflow: hidden;
    padding: 8px;
  }

  .canvas-toolbar .icon-button,
  .sketch-toolbar .icon-button {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
  }

  .tool-segment,
  .color-control,
  .range-control {
    flex: 0 0 auto;
  }

  .range-control {
    padding: 0 10px;
  }

  .range-control span {
    display: none;
  }

  .range-control input {
    width: min(92px, 24vw);
  }

  .sketch-reference-button {
    flex: 0 0 auto;
    width: 32px;
    min-width: 32px;
    height: 32px;
    overflow: hidden;
    padding: 0;
    color: transparent;
    border-radius: 10px;
    font-size: 0;
  }

  .sketch-reference-button::before {
    content: "+";
    color: var(--accent-text);
    font-size: 20px;
    line-height: 1;
  }

  .sketch-surface-wrap {
    padding: 10px;
  }

  .canvas-zoom-label {
    flex: 0 0 50px;
    height: 32px;
  }

  .canvas-item .image-actions {
    gap: 5px;
  }

  .composer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 4;
    padding: 0 10px 12px;
    background: linear-gradient(180deg, rgb(11 12 16 / 0), var(--bg) 34%);
  }

  .prompt-box {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 10px;
    min-height: 154px;
    padding: 16px;
    border-radius: 22px;
  }

  .prompt-main {
    gap: 14px;
    min-height: 116px;
  }

  .prompt-box textarea {
    min-height: 40px;
    font-size: 15px;
  }

  .quick-options {
    gap: 6px;
  }

  .pill-select {
    gap: 5px;
    height: 34px;
    padding: 0 9px 0 12px;
  }

  .pill-select span {
    display: none;
  }

  .custom-select-button,
  .quality-chip {
    height: 34px;
  }

  .custom-select-menu {
    max-height: 180px;
    bottom: calc(100% + 7px);
  }

  .icon-button {
    height: 34px;
  }

  .reference-upload-button.icon-button {
    width: 36px;
    height: 36px;
  }

  .send-button {
    width: 40px;
    height: 40px;
  }

  .reference-list {
    width: 100%;
  }

  .reference-item {
    width: 56px;
    height: 56px;
  }
}

@media (max-width: 380px) {
  .topbar {
    gap: 6px;
    padding: 10px 8px 10px 54px;
  }

  .static-chip strong {
    max-width: 104px;
    overflow: hidden;
    padding: 0 10px;
    text-overflow: ellipsis;
  }

  .view-switch {
    gap: 2px;
    padding: 3px;
  }

  .view-button {
    min-width: 42px;
    padding: 0 7px;
  }
}
