/* Light IMAG-style workspace layout */

.app-shell.is-entered {
  background: transparent;
}

.app-shell.is-entered .workspace-screen {
  --workspace-bg: transparent;
  --workspace-panel: rgba(11, 25, 26, 0.7);
  --workspace-panel-soft: rgba(255, 255, 255, 0.055);
  --workspace-ink: #eef6f3;
  --workspace-body: #b7c8c3;
  --workspace-muted: #81928d;
  --workspace-line: rgba(213, 239, 232, 0.16);
  --workspace-line-strong: rgba(213, 239, 232, 0.3);
  --workspace-accent: #48c8b4;
  --workspace-accent-soft: rgba(72, 200, 180, 0.14);
  display: block;
  min-height: 100dvh;
  width: 100%;
  padding: 22px;
  background: transparent;
  color: var(--workspace-ink);
  opacity: 1;
  transform: none;
}

.app-shell.is-entered .portal-screen {
  display: none;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 76px 292px minmax(0, 1fr);
  gap: 18px;
  width: 100%;
  min-height: calc(100dvh - 44px);
}

.primary-rail,
.model-drawer,
.creator-stage {
  min-height: calc(100dvh - 44px);
}

.primary-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 14px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.home-trigger,
.module-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--workspace-muted);
  transition: 160ms ease;
}

.home-trigger {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.home-trigger:hover,
.module-button:hover,
.module-button.is-active {
  border-color: #b9ddd4;
  background: var(--workspace-accent-soft);
  color: var(--workspace-accent);
  transform: translateY(-1px);
}

.module-button.is-active {
  position: relative;
}

.module-button.is-active::after {
  content: "";
  position: absolute;
  right: -10px;
  width: 3px;
  height: 26px;
  border-radius: 999px;
  background: var(--workspace-accent);
}

.home-trigger svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.primary-menu {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.module-button svg {
  width: 22px;
  height: 22px;
}

.module-copy {
  display: none;
}

.model-drawer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  gap: 22px;
  padding: 24px 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.drawer-head {
  padding: 4px 4px 24px;
  border-bottom: 1px solid rgba(213, 239, 232, 0.2);
}

.drawer-head > span {
  display: inline-flex;
  color: #6cddca;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-transform: uppercase;
}

.panel-kicker {
  color: var(--workspace-accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.drawer-head strong {
  display: block;
  margin-top: 11px;
  color: #f0f8f5;
  font-size: 27px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.drawer-head p {
  margin: 8px 0 0;
  color: #c3d6d0;
  font-size: 15px;
  font-weight: 560;
  line-height: 1.45;
}

.module-desc {
  max-width: 26ch;
  margin-top: 19px !important;
  padding-top: 17px;
  border-top: 1px solid rgba(213, 239, 232, 0.2);
  color: #a9beb8 !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  line-height: 1.62 !important;
  letter-spacing: 0.01em;
}

.brand-menu {
  display: grid;
  align-content: start;
  gap: 11px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.brand-menu::-webkit-scrollbar {
  display: none;
}

.brand-button {
  display: grid;
  gap: 8px;
  width: calc(100% - 3px);
  padding: 17px 15px 16px;
  border: 1px solid rgba(213, 239, 232, 0.2);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.065);
  color: #bfd1cc;
  text-align: left;
  transition: 160ms ease;
}

.brand-button:hover,
.brand-button.is-active {
  border-color: rgba(164, 231, 216, 0.78);
  background: rgba(72, 200, 180, 0.16);
  color: #eef8f4;
  transform: translateX(2px);
}

.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand-name {
  color: inherit;
  font-size: 16px;
  font-weight: 780;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.brand-count {
  display: inline-grid;
  place-items: center;
  flex: 0 0 27px;
  min-width: 27px;
  height: 27px;
  border: 1px solid rgba(213, 239, 232, 0.36);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: #c0d8d1;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.brand-tagline {
  margin: 0;
  color: #9fb7b0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.brand-button.is-active .brand-count {
  border-color: rgba(164, 231, 216, 0.62);
  background: rgba(72, 200, 180, 0.12);
  color: #d9f3ec;
}

.brand-button.is-active .brand-tagline {
  color: #b8d5ce;
}

.creator-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  container: creator-stage / inline-size;
}

.command-capsule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 54px;
  padding: 10px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.capsule-route {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--workspace-body);
  font-size: 15px;
  font-weight: 680;
}

.capsule-route strong {
  color: var(--workspace-body);
  font-size: 15px;
  font-weight: 760;
}

.capsule-route span {
  min-width: 0;
  white-space: nowrap;
}

.capsule-route span:first-child {
  color: var(--workspace-body);
  font-weight: 680;
}

.capsule-route span:last-child {
  color: var(--workspace-body);
  font-size: 15px;
  font-weight: 680;
}

.capsule-route span:not(:last-child)::after {
  content: "/";
  margin-left: 9px;
  color: var(--workspace-body);
}

.stage-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(220px, 1fr) auto;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.main-work-area,
.output-panel {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.main-work-area {
  grid-column: 1;
  grid-row: 2;
  align-self: end;
  display: grid;
  align-content: center;
  gap: 26px;
  width: min(100%, 1220px);
  margin-inline: auto;
  padding: 28px 0 42px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.main-work-area::-webkit-scrollbar {
  display: none;
}

.generation-results {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: minmax(0, 1220px) 164px;
  grid-template-rows: auto minmax(0, 1fr);
  column-gap: 16px;
  row-gap: 18px;
  width: min(100%, 1400px);
  min-width: 0;
  min-height: 0;
  margin-left: auto;
  padding: 14px 0 0;
}

.generation-results-head {
  grid-column: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.generation-results-head h2 {
  margin: 8px 0 0;
  color: var(--workspace-ink);
  font-size: clamp(22px, 2vw, 28px);
  font-weight: 760;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.generation-results-head p {
  margin: 8px 0 0;
  color: var(--workspace-body);
  font-size: 14px;
  line-height: 1.5;
}

.generation-gallery {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  min-height: 0;
  align-content: stretch;
}

.generation-history {
  grid-column: 2;
  grid-row: 1 / 3;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
  min-height: 0;
}

.generation-history h3 {
  margin: 8px 0 0;
  color: var(--workspace-body);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.generation-history-list {
  display: grid;
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.generation-history-item {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--workspace-line-strong);
  border-radius: 8px;
  background: rgba(4, 18, 19, 0.52);
}

.generation-history-preview {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.generation-history-preview:focus-visible,
.generation-history-download:focus-visible,
.generation-history-remove:focus-visible {
  outline: 2px solid #7ae3d0;
  outline-offset: -2px;
}

.generation-history-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.generation-history-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(238, 246, 243, 0.8);
  border-radius: 50%;
  background: rgba(4, 24, 25, 0.94);
  color: #f2fffb;
  cursor: pointer;
}

.generation-history-download {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: none;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(238, 246, 243, 0.8);
  border-radius: 50%;
  background: rgba(4, 24, 25, 0.94);
  color: #f2fffb;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}

.generation-history-item:hover .generation-history-download,
.generation-history-item:focus-within .generation-history-download {
  display: grid;
}

.generation-history-download:hover,
.generation-history-download:focus-visible {
  border-color: #b8fff0;
  background: var(--workspace-accent);
  color: #062b26;
}

.generation-history-remove:hover {
  background: var(--workspace-accent);
  color: #062b26;
}

.generation-history-empty {
  display: grid;
  place-items: center;
  align-self: start;
  min-height: 80px;
  border: 1px dashed var(--workspace-line-strong);
  border-radius: 8px;
  color: var(--workspace-muted);
  font-size: 13px;
}

@container creator-stage (max-width: 1400px) {
  .generation-results {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(220px, 1fr) auto;
    width: min(100%, 1220px);
    margin-inline: auto;
  }

  .generation-history {
    grid-column: 1;
    grid-row: 3;
    grid-template-rows: auto auto;
    gap: 10px;
  }

  .generation-history-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: minmax(82px, 112px);
  }
}

@container creator-stage (max-width: 640px) {
  .generation-history-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.generation-gallery.has-results {
  padding: 10px;
  border: 1px dashed var(--workspace-line-strong);
  border-radius: 12px;
  overflow: hidden;
}

.generation-gallery.has-results[data-image-count="1"] {
  grid-template-columns: minmax(0, 1fr);
}

.generation-gallery.has-results[data-image-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.generation-gallery.has-results[data-image-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

  .generation-gallery.has-results[data-image-count="4"],
.generation-gallery.has-results[data-image-count="5"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.generation-result {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--workspace-line);
  border-radius: 10px;
  background: rgba(4, 18, 19, 0.52);
}

.generation-empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 190px;
  padding: 24px;
  border: 1px dashed var(--workspace-line-strong);
  border-radius: 12px;
  text-align: center;
}

.generation-empty-mark {
  display: inline-flex;
  align-items: flex-end;
  gap: 4px;
  height: 25px;
  margin-bottom: 12px;
}

.generation-empty-mark i {
  display: block;
  width: 5px;
  border-radius: 999px;
  background: rgba(183, 220, 212, 0.68);
}

.generation-empty-mark i:nth-child(1) { height: 12px; }
.generation-empty-mark i:nth-child(2) { height: 22px; background: var(--workspace-accent); }
.generation-empty-mark i:nth-child(3) { height: 16px; }

.generation-empty strong {
  color: var(--workspace-ink);
  font-size: 15px;
  font-weight: 760;
}

.generation-empty p {
  max-width: 30ch;
  margin: 7px 0 0;
  color: var(--workspace-muted);
  font-size: 12px;
  line-height: 1.55;
}

.generation-image {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: rgba(2, 12, 13, 0.62);
}

.generation-preview-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: rgba(2, 12, 13, 0.62);
  color: inherit;
  cursor: zoom-in;
}

.generation-preview-button:focus-visible {
  outline: 2px solid #7ae3d0;
  outline-offset: -4px;
}

.generation-result-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1;
}

.generation-download-button,
.generation-remove-button {
  position: static;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(238, 246, 243, 0.8);
  border-radius: 50%;
  background: rgba(4, 24, 25, 0.94);
  color: #f2fffb;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.generation-download-button:hover,
.generation-download-button:focus-visible,
.generation-remove-button:hover,
.generation-remove-button:focus-visible {
  border-color: #b8fff0;
  background: var(--workspace-accent);
  color: #062b26;
  transform: scale(1.06);
}

.generation-remove-icon {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2.2;
}

.generation-download-icon {
  display: block;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.panel-intro,
.output-panel-head,
.params-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-intro {
  width: 100%;
  max-width: 1220px;
  margin-inline: auto;
}

.panel-intro h1,
.output-panel h2 {
  margin: 0;
  color: var(--workspace-ink);
  letter-spacing: -0.035em;
}

.panel-intro h1 {
  font-size: clamp(26px, 2.6vw, 38px);
  line-height: 1.1;
}

.panel-intro p {
  margin: 10px 0 0;
  color: var(--workspace-body);
  font-size: 15px;
  line-height: 1.55;
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  min-width: 0;
  min-height: 202px;
  padding: 0;
  border: 1px solid rgba(126, 209, 195, 0.28);
  border-radius: 14px;
  background: rgba(8, 27, 28, 0.94);
  box-shadow: 0 18px 40px rgba(0, 10, 11, 0.3);
  overflow: hidden;
}

.attach-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--workspace-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--workspace-body);
  transition: 160ms ease;
}

.attach-button:hover {
  border-color: #b9ddd4;
  color: var(--workspace-accent);
}

.attach-button svg,
.send-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

textarea {
  grid-column: 1;
  width: 100%;
  min-width: 0;
  min-height: 132px;
  padding: 18px 20px 14px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #e8f6f2;
  font-size: 15px;
  font-weight: 560;
  line-height: 1.55;
}

textarea::placeholder {
  color: #8ea9a1;
}

.creator-panel textarea {
  font-size: 16px;
  padding-right: min(52%, 360px);
}

.reference-import {
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 12px 16px;
  border-top: 1px solid rgba(126, 209, 195, 0.2);
  background: rgba(14, 49, 48, 0.88);
}

.reference-import[hidden] {
  display: none;
}

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

.reference-import-title {
  color: #d9f2ec;
  font-size: 12px;
  font-weight: 760;
}

.reference-import-hint {
  overflow: hidden;
  color: #9ab7af;
  font-size: 11px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-import-message {
  min-height: 15px;
  color: #f0b79f;
  font-size: 11px;
  line-height: 1.4;
}

.reference-mode-hint {
  max-width: 360px;
  overflow: hidden;
  color: #9ab7af;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-import-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}

.reference-import-actions[hidden],
.reference-mode-hint[hidden] {
  display: none;
}

.composer-controls #referenceUploadControl {
  margin-left: auto;
}

.reference-preview-list {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex-wrap: wrap;
}

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

.composer > .reference-preview-list {
  position: absolute;
  top: 10px;
  right: 12px;
  width: min(52%, 330px);
  justify-content: flex-end;
  max-width: calc(100% - 24px);
  z-index: 2;
}

.reference-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px dashed rgba(99, 214, 192, 0.62);
  border-radius: 8px;
  background: rgba(72, 200, 180, 0.1);
  color: #9be3d4;
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.reference-upload:hover {
  border-color: #7ae3d0;
  background: rgba(72, 200, 180, 0.2);
  color: #d1fff5;
  transform: translateY(-1px);
}

.reference-upload:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.reference-upload svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.reference-preview {
  position: relative;
  display: grid;
  grid-template-rows: 78px auto;
  gap: 5px;
  width: 96px;
  min-width: 96px;
  height: 106px;
  align-content: start;
  padding: 4px;
  border: 1px solid rgba(126, 209, 195, 0.24);
  border-radius: 8px;
  background: rgba(20, 59, 57, 0.88);
  color: #c7e2dc;
  font-size: 12px;
  cursor: zoom-in;
  text-align: left;
  overflow: hidden;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.reference-preview[hidden] {
  display: none;
}

.reference-preview img {
  display: block;
  width: 78px;
  height: 78px;
  border-radius: 6px;
  object-fit: cover;
}

.reference-preview span {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-preview:hover {
  border-color: rgba(122, 227, 208, 0.72);
  background: rgba(27, 77, 73, 0.96);
  transform: translateY(-1px);
}

.reference-preview button {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid rgba(238, 246, 243, 0.62);
  border-radius: 50%;
  background: rgba(4, 24, 25, 0.88);
  color: #f2fffb;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.reference-remove-icon {
  display: block;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.reference-preview button:hover {
  border-color: #b8fff0;
  background: #48c8b4;
  color: #062b26;
  transform: scale(1.06);
}

.reference-image-modal,
.reference-limit-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 14, 15, 0.78);
  backdrop-filter: blur(8px);
}

.reference-image-modal[hidden],
.reference-limit-modal[hidden] {
  display: none;
}

.reference-image-modal-surface,
.reference-limit-modal-surface {
  width: min(720px, 100%);
  max-height: min(88dvh, 780px);
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(126, 209, 195, 0.32);
  border-radius: 14px;
  background: rgba(9, 31, 32, 0.98);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

.reference-image-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.reference-image-modal .panel-kicker,
.reference-limit-modal .panel-kicker {
  color: #48c8b4;
}

.reference-image-modal-head h2,
.reference-limit-modal-surface h2 {
  margin: 5px 0 0;
  color: var(--workspace-ink, #eef6f3);
  font-size: 18px;
  line-height: 1.25;
}

.reference-image-modal-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid rgba(126, 209, 195, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--workspace-body, #b7c8c3);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.reference-image-modal-close:hover {
  border-color: rgba(122, 227, 208, 0.7);
  color: var(--workspace-ink);
}

/* Keep the workspace rail clear enough for the background and labels. */
.app-shell.is-entered .model-drawer {
  background: transparent;
  border: 0;
  backdrop-filter: none;
}

.app-shell.is-entered .model-drawer::before {
  display: none;
}

.reference-image-modal-surface > img {
  display: block;
  width: 100%;
  max-height: 68dvh;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.2);
  object-fit: contain;
}

.reference-image-modal-surface > p {
  margin: 12px 0 0;
  overflow: hidden;
  color: var(--workspace-body, #b7c8c3);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-image-modal.is-generation-preview .reference-image-modal-surface {
  width: min(1180px, 100%);
  max-height: 92dvh;
}

.reference-image-modal.is-generation-preview .reference-image-modal-surface > img {
  max-height: calc(92dvh - 124px);
}

.reference-limit-modal-surface {
  width: min(420px, 100%);
}

.reference-limit-modal-surface > p {
  margin: 12px 0 20px;
  color: var(--workspace-body, #b7c8c3);
  font-size: 13px;
  line-height: 1.6;
}

.reference-limit-modal-confirm {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid #79e4d1;
  border-radius: 8px;
  background: #48c8b4;
  color: #062b26;
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
}

.reference-limit-modal-confirm:hover {
  background: #6be0cd;
}

.reference-image-modal-close:focus-visible,
.reference-limit-modal-confirm:focus-visible,
.reference-preview:focus-visible {
  outline: 2px solid #7ae3d0;
  outline-offset: 2px;
}

body.reference-modal-open {
  overflow: hidden;
}

.composer-controls {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 66px;
  padding: 10px 12px 11px;
  border-top: 1px solid rgba(126, 209, 195, 0.22);
  background: rgba(10, 36, 36, 0.96);
  color-scheme: dark;
  overflow-x: auto;
  scrollbar-width: none;
}

.composer-controls::-webkit-scrollbar {
  display: none;
}

.composer-controls > * {
  flex: 0 0 auto;
}

.mode-chip,
.select-chip {
  min-height: 39px;
  padding: 0 12px;
  border: 1px solid rgba(141, 210, 198, 0.44);
  border-radius: 999px;
  background: rgba(14, 48, 47, 0.92);
  color: #d8ebe6;
  color-scheme: dark;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.mode-chip {
  appearance: none;
  min-width: 76px;
  padding-right: 27px;
  cursor: pointer;
}

.select-chip {
  appearance: none;
  min-width: 76px;
  padding-right: 27px;
  color: #d8ebe6;
  cursor: pointer;
}

.select-chip option,
.mode-chip option {
  background: #0d3030;
  color: #e8f6f2;
}

.model-chip {
  max-width: 164px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Keep the mode selector identical to the other workspace selectors in its resting state. */
.mode-chip.is-active {
  border-color: rgba(141, 210, 198, 0.44);
  background: rgba(14, 48, 47, 0.92);
  color: #d8ebe6;
}

.mode-chip:hover,
.select-chip:hover,
.select-chip:focus-visible {
  border-color: #63d8c3;
  background: rgba(72, 200, 180, 0.17);
  color: #c4fff3;
  transform: translateY(-1px);
}

.model-chip::after {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 11px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  transform: translateY(-2px) rotate(45deg);
}

.mode-control {
  position: relative;
}

.mode-control::after,
.composer-select:not(.mode-control)::after {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  color: #8ae6d3;
  pointer-events: none;
  transform: translateY(-65%) rotate(45deg);
}

.composer-select {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.composer-select[hidden],
.composer-controls > [hidden] {
  display: none !important;
}

.cost-copy {
  margin-left: auto;
  color: var(--workspace-muted);
  font-size: 12px;
  white-space: nowrap;
}

.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 134px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid #79e4d1;
  border-radius: 10px;
  background: #48c8b4;
  color: #062b26;
  font-size: 14px;
  font-weight: 760;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(30, 145, 126, 0.28);
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.send-button:hover {
  background: #6be0cd;
  box-shadow: 0 10px 22px rgba(30, 145, 126, 0.36);
  transform: translateY(-1px);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.78;
  transform: none;
}

.generation-submit-status {
  display: none;
  max-width: 260px;
  overflow: hidden;
  color: #a8c9c1;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generation-submit-status[data-state="error"] {
  color: #f0b79f;
}

.generation-submit-status[data-state="success"] {
  color: #8ee8d5;
}

.generation-submit-status[hidden] {
  display: none;
}

.send-button:focus-visible,
.reference-upload:focus-visible,
.reference-preview button:focus-visible,
.mode-chip:focus-visible,
.select-chip:focus-visible {
  outline: 2px solid #7ae3d0;
  outline-offset: 2px;
}

.params-container {
  display: none;
}

.params-heading {
  align-items: center;
  padding-top: 18px;
}

.creator-panel .panel-kicker {
  font-size: 11px;
}

.params-hint {
  color: var(--workspace-muted);
  font-size: 12px;
}

.param-section {
  display: grid;
  gap: 10px;
}

.section-title {
  margin: 0;
  color: var(--workspace-body);
  font-size: 12px;
  font-weight: 760;
}

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

.option-grid.wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.option-grid.compact-grid {
  grid-template-columns: repeat(3, minmax(0, 92px));
}

.option-btn {
  display: grid;
  gap: 3px;
  place-items: center;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--workspace-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--workspace-body);
  transition: 160ms ease;
}

.option-btn.compact {
  min-height: 39px;
}

.option-btn:hover,
.option-btn.is-active {
  border-color: #9fd5c9;
  background: var(--workspace-accent-soft);
  color: var(--workspace-accent);
}

.option-label {
  color: currentColor;
  font-size: 15px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.option-desc {
  color: var(--workspace-muted);
  font-size: 11px;
}

.option-btn.is-active .option-desc {
  color: #5f988e;
}

.output-panel {
  grid-column: 2;
  grid-row: 1;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
  gap: 22px;
  padding: 8px 0 24px 24px;
}

.output-panel h2 {
  font-size: 24px;
  line-height: 1.1;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--workspace-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--workspace-muted);
}

.icon-button:hover {
  border-color: #b9ddd4;
  color: var(--workspace-accent);
}

.monitor-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--workspace-line);
  border-bottom: 1px solid var(--workspace-line);
}

.monitor-summary div {
  display: grid;
  gap: 6px;
  padding: 14px 10px;
  border-right: 1px solid var(--workspace-line);
}

.monitor-summary div:last-child {
  border-right: 0;
}

.monitor-summary span {
  color: var(--workspace-muted);
  font-size: 10px;
}

.monitor-summary strong {
  color: var(--workspace-ink);
  font-size: 20px;
  font-weight: 760;
}

.output-empty {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 260px;
  padding: 22px;
  border: 1px dashed var(--workspace-line-strong);
  border-radius: 12px;
  text-align: center;
}

.empty-mark {
  display: inline-flex;
  align-items: flex-end;
  gap: 4px;
  height: 28px;
  margin-bottom: 14px;
}

.empty-mark i {
  display: block;
  width: 5px;
  border-radius: 999px;
  background: #b7dcd4;
}

.empty-mark i:nth-child(1) { height: 13px; }
.empty-mark i:nth-child(2) { height: 23px; background: var(--workspace-accent); }
.empty-mark i:nth-child(3) { height: 17px; }

.output-empty h3 {
  margin: 0;
  color: var(--workspace-ink);
  font-size: 15px;
}

.output-empty p {
  max-width: 25ch;
  margin: 8px 0 0;
  color: var(--workspace-muted);
  font-size: 12px;
  line-height: 1.55;
}

.output-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--workspace-muted);
  font-size: 11px;
}

.output-footer span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--workspace-body);
}

@media (max-width: 1280px) {
  .workspace-grid {
    grid-template-columns: 70px 258px minmax(0, 1fr);
  }

  .stage-content {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(220px, 1fr) auto;
  }
}

@media (max-width: 980px) {
  .app-shell.is-entered .workspace-screen {
    padding: 12px;
  }

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

  .model-drawer {
    grid-column: 2;
    grid-row: 1;
    min-height: auto;
  }

  .creator-stage {
    grid-column: 2;
    grid-row: 2;
    min-height: auto;
  }

  .primary-rail {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .stage-content {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 1fr) auto;
  }

  .output-panel {
    grid-column: 1;
    grid-row: 1;
    min-height: 420px;
  }

  .main-work-area {
    grid-column: 1;
    grid-row: 2;
  }

  .generation-results {
    grid-column: 1;
    grid-row: 1;
    min-height: 300px;
  }
}

@media (max-width: 640px) {
  .app-shell.is-entered .workspace-screen {
    padding: 8px;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .primary-rail,
  .model-drawer,
  .creator-stage {
    grid-column: 1;
    min-height: auto;
  }

  .primary-rail {
    grid-row: 1;
    flex-direction: row;
    justify-content: flex-start;
    min-height: 58px;
    padding: 7px;
    overflow-x: auto;
  }

  .home-trigger,
  .module-button {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }

  .module-button svg {
    width: 20px;
    height: 20px;
  }

  .primary-menu {
    flex-direction: row;
    width: auto;
    flex: 0 0 auto;
  }

  .module-button.is-active::after {
    right: auto;
    bottom: -7px;
    width: 20px;
    height: 2px;
  }

  .model-drawer {
    grid-row: 2;
    padding: 16px;
  }

  .brand-menu {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .brand-menu::-webkit-scrollbar {
    display: none;
  }

  .brand-button {
    flex: 0 0 220px;
  }

  .creator-stage {
    grid-row: 3;
  }

  .command-capsule {
    min-height: 48px;
    padding-inline: 12px;
  }

  .capsule-route span:last-child {
    display: none;
  }

  .main-work-area,
  .output-panel {
    padding: 18px;
    border-radius: 13px;
  }

  .generation-results {
    padding: 14px 0 0;
  }

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

  .panel-intro {
    display: grid;
  }

  .composer-controls {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .reference-import {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .reference-import-hint {
    white-space: normal;
  }

  .reference-import .reference-import-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .mode-chip,
  .select-chip,
  .cost-copy {
    flex: 0 0 auto;
  }

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

  .option-grid.compact-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Auth and admin surfaces share the ambient canvas with the existing portal. */
.auth-screen,
.admin-screen {
  display: none;
  width: 100%;
  min-height: 100dvh;
  color: var(--ink);
}

.app-shell.is-auth .portal-screen,
.app-shell.is-auth .workspace-screen,
.app-shell.is-auth .admin-screen,
.app-shell.is-admin .portal-screen,
.app-shell.is-admin .workspace-screen,
.app-shell.is-admin .auth-screen,
.app-shell.is-admin-email .portal-screen,
.app-shell.is-admin-email .workspace-screen,
.app-shell.is-admin-email .auth-screen,
.app-shell.is-admin-email .admin-screen {
  display: none;
}

.app-shell.is-auth .auth-screen {
  display: grid;
  place-items: center;
  padding: 28px;
}

.app-shell.is-admin .admin-screen {
  display: block;
  padding: 28px;
}

.admin-primary-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: rgba(9, 22, 23, 0.38);
}

.admin-primary-menu-button {
  min-height: 34px;
  padding: 0 15px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
}

.admin-primary-menu-button:hover,
.admin-primary-menu-button.is-active {
  background: var(--blue-soft);
  color: var(--ink);
}

.registration-panel {
  display: none;
}

.auth-panel[hidden],
.auth-panel.is-hidden {
  display: none !important;
}

.registration-panel.is-visible {
  display: grid;
}

.auth-panel-subline {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.auth-inline-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cyan);
  font: inherit;
  font-weight: 760;
  cursor: pointer;
}

.auth-inline-link:hover {
  color: #9ae8db;
}

.verification-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.verification-row.is-optional {
  grid-template-columns: 1fr;
}

.verification-button {
  min-height: 46px;
  white-space: nowrap;
}

.auth-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  color: var(--body);
  font-size: 12px;
  font-weight: 700;
}

.auth-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--cyan);
}

.email-settings-form {
  display: grid;
  gap: 18px;
}

.email-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.email-settings-wide {
  grid-column: 1 / -1;
}

.email-settings-wide textarea {
  width: 100%;
  min-height: 260px;
  padding: 13px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  outline: 0;
  resize: vertical;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.email-settings-wide textarea:focus {
  border-color: var(--cyan);
}

.email-settings-wide small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.email-settings-actions {
  display: flex;
  gap: 10px;
}

.email-settings-actions .auth-submit {
  width: auto;
  min-width: 150px;
}

.admin-api-inline {
  width: min(1420px, 100%);
  margin: 18px auto 0;
  scroll-margin-top: 24px;
}

.admin-api-inline[hidden] {
  display: none;
}

.admin-pricing-inline {
  width: min(1420px, 100%);
  margin: 18px auto 0;
  scroll-margin-top: 24px;
}

.admin-pricing-inline[hidden] {
  display: none;
}

.admin-topups-inline {
  width: min(1420px, 100%);
  margin: 18px auto 0;
  scroll-margin-top: 24px;
}

.admin-topups-inline[hidden] {
  display: none;
}

.admin-payment-inline { width: min(1180px, 100%); margin: 18px auto 0; scroll-margin-top: 24px; }
.admin-payment-inline[hidden] { display: none; }
.payment-settings-form { display: grid; gap: 18px; }
.payment-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
.payment-basic-grid { align-items: stretch; }
.payment-basic-grid .auth-field { min-width: 0; }
.payment-basic-grid .auth-field input,
.payment-basic-grid .auth-field select { box-sizing: border-box; width: 100%; min-height: 46px; }
.payment-settings-wide { grid-column: 1 / -1; }
.payment-settings-heading { margin: 5px 0 -4px; padding-top: 16px; border-top: 1px solid var(--workspace-line); color: var(--workspace-ink); font-size: 14px; }
.payment-limits-grid { max-width: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.payment-limits-grid .auth-field { min-width: 0; }
.payment-limits-grid small { min-height: 15px; color: var(--workspace-muted); font-size: 11px; line-height: 1.35; }
.payment-control-grid { display: grid; grid-template-columns: 1fr 1fr 1.15fr 1.7fr; gap: 16px; padding: 16px 0 18px; border-top: 1px solid var(--workspace-line); border-bottom: 1px solid var(--workspace-line); }
.payment-control-block { display: grid; align-content: center; gap: 10px; min-height: 60px; padding: 0 16px; border-right: 1px solid var(--workspace-line); }
.payment-control-label { color: var(--workspace-muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.payment-switch, .payment-method-choice { display: inline-flex; align-items: center; gap: 8px; color: var(--workspace-body); font-size: 12px; font-weight: 700; white-space: nowrap; }
.payment-switch input { position: absolute; opacity: 0; pointer-events: none; }
.payment-switch-track { position: relative; width: 34px; height: 19px; border-radius: 99px; background: rgba(255,255,255,.16); transition: background 160ms ease; }
.payment-switch-track::after { position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; border-radius: 50%; background: #9aa9a8; content: ""; transition: transform 160ms ease, background 160ms ease; }
.payment-switch input:checked + .payment-switch-track { background: #25bfa8; }
.payment-switch input:checked + .payment-switch-track::after { background: #fff; transform: translateX(15px); }
.payment-setting-label { display: grid; align-content: center; gap: 10px; min-height: 60px; color: var(--workspace-body); font-size: 12px; font-weight: 700; }
.payment-setting-label select,
.payment-basic-grid .auth-field select { min-height: 46px; padding: 0 13px; border: 1px solid rgba(117, 218, 203, 0.28); border-radius: 8px; background: rgba(20, 55, 57, 0.82); color: #e3f4ef; color-scheme: dark; font: inherit; font-weight: 650; }
.payment-setting-label select:hover,
.payment-setting-label select:focus,
.payment-basic-grid .auth-field select:hover,
.payment-basic-grid .auth-field select:focus { border-color: rgba(117, 218, 203, 0.62); background: rgba(25, 68, 69, 0.95); outline: none; }
.payment-setting-label select option,
.payment-basic-grid .auth-field select option { background: #123638; color: #e3f4ef; }
.payment-method-choice input { width: 16px; height: 16px; accent-color: #43cdb8; }
.payment-method-block { border-right: 0; }
.payment-method-list { display: flex; align-items: center; gap: 22px; }
.payment-method-list { min-height: 38px; }

@media (max-width: 900px) { .payment-control-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .payment-control-block:nth-child(2) { border-right: 0; } .payment-method-block { grid-column: 1 / -1; border-top: 1px solid var(--workspace-line); padding-top: 12px; } }
@media (max-width: 760px) { .payment-settings-grid { grid-template-columns: 1fr; } .payment-settings-wide { grid-column: auto; } }

.pricing-settings-form,
.pricing-topups {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.pricing-table-wrap {
  overflow-x: auto;
}

.pricing-table input {
  width: 120px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.pricing-table input:focus {
  border-color: var(--cyan);
  outline: 0;
}

.pricing-type-muted {
  color: var(--muted);
  font-size: 12px;
}

.pricing-topups h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
}

.pricing-topups p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.workspace-balance {
  color: var(--workspace-body);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.workspace-topup-button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--workspace-line);
  border-radius: 7px;
  background: transparent;
  color: var(--workspace-body);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.workspace-topup-button:hover {
  border-color: var(--workspace-line-strong);
  background: var(--workspace-accent-soft);
  color: var(--workspace-ink);
}

.workspace-billing-message {
  color: var(--workspace-muted);
  font-size: 11px;
  white-space: nowrap;
}

.topup-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 14, 15, 0.78);
  backdrop-filter: blur(8px);
}

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

.topup-modal-surface {
  width: min(480px, 100%);
  padding: 24px;
  border: 1px solid rgba(126, 209, 195, 0.32);
  border-radius: 14px;
  background: rgba(9, 31, 32, 0.98);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

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

.topup-modal-head h2 { margin: 5px 0 0; color: var(--workspace-ink); font-size: 21px; }
.topup-modal-head p { margin: 7px 0 0; color: var(--workspace-muted); font-size: 12px; }

.topup-balance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 18px;
  padding: 15px 16px;
  border: 1px solid rgba(126, 209, 195, 0.2);
  border-radius: 10px;
  background: rgba(72, 200, 180, 0.08);
}

.topup-balance-card span { color: var(--workspace-muted); font-size: 12px; }
.topup-balance-card strong { color: var(--workspace-ink); font-size: 20px; }
.topup-field label { display: block; margin-bottom: 8px; color: var(--workspace-body); font-size: 12px; font-weight: 700; }
.topup-input-wrap { display: flex; align-items: center; border: 1px solid rgba(126, 209, 195, 0.32); border-radius: 9px; background: rgba(0, 0, 0, 0.16); }
.topup-input-wrap input { width: 100%; min-width: 0; padding: 12px 13px; border: 0; outline: 0; background: transparent; color: var(--workspace-ink); font: inherit; font-size: 18px; font-weight: 700; }
.topup-input-wrap span { padding-right: 13px; color: var(--workspace-muted); font-size: 12px; }
.topup-presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.topup-presets button { min-height: 34px; border: 1px solid rgba(126, 209, 195, 0.24); border-radius: 8px; background: rgba(255, 255, 255, 0.035); color: var(--workspace-body); cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; }
.topup-presets button:hover, .topup-presets button.is-active { border-color: #65d9c3; background: rgba(72, 200, 180, 0.16); color: var(--workspace-ink); }
.topup-order-summary { display: flex; justify-content: space-between; margin-top: 20px; padding-top: 14px; border-top: 1px solid rgba(126, 209, 195, 0.16); color: var(--workspace-muted); font-size: 13px; }
.topup-order-summary strong { color: var(--workspace-ink); }
.topup-message { min-height: 18px; margin: 12px 0 0; color: var(--workspace-muted); font-size: 12px; }
.topup-message.is-error { color: #ffaaa4; }
.topup-modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 14px; }
.topup-submit-button { min-height: 38px; padding: 0 17px; border: 1px solid #79e4d1; border-radius: 8px; background: #48c8b4; color: #062b26; cursor: pointer; font: inherit; font-size: 12px; font-weight: 800; }
.topup-submit-button:hover { background: #6be0cd; }
.topup-submit-button:disabled { cursor: not-allowed; opacity: .5; }

@media (max-width: 560px) {
  .topup-modal { padding: 14px; }
  .topup-modal-surface { padding: 19px; }
  .topup-presets { grid-template-columns: repeat(3, 1fr); }
}

.api-settings-form {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.api-provider-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.api-provider-card {
  display: grid;
  gap: 15px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
}

.api-provider-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--hairline);
}

.api-provider-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: -0.02em;
}

.api-provider-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.api-provider-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  color: var(--body);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.api-provider-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  padding-top: 1px;
}

.api-test-button {
  min-height: 30px;
  padding-inline: 12px;
  font-size: 11px;
}

.api-test-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.api-test-state {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.api-test-state.is-success {
  color: var(--lime);
}

.api-test-state.is-error {
  color: #ff9e92;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 0.8fr);
  align-items: center;
  gap: clamp(32px, 7vw, 112px);
  width: min(980px, 100%);
}

.auth-intro {
  max-width: 430px;
}

.auth-kicker {
  display: inline-block;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.auth-intro h1,
.admin-header h1 {
  margin: 13px 0 0;
  color: var(--ink);
  font-size: clamp(34px, 5vw, 62px);
  font-weight: 760;
  letter-spacing: -0.05em;
  line-height: 1.02;
}

.auth-intro p,
.admin-header p {
  max-width: 34ch;
  margin: 18px 0 0;
  color: var(--body);
  font-size: 14px;
  line-height: 1.7;
}

.auth-panel,
.admin-panel {
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-lg);
  background: rgba(9, 22, 23, 0.62);
  backdrop-filter: blur(18px) saturate(125%);
}

.auth-panel {
  display: grid;
  gap: 17px;
  padding: clamp(24px, 4vw, 38px);
}

.auth-panel-head,
.admin-panel-head,
.admin-header,
.admin-header-actions,
.workspace-session,
.admin-identity {
  display: flex;
  align-items: center;
}

.auth-panel-head,
.admin-panel-head,
.admin-header {
  justify-content: space-between;
  gap: 16px;
}

.auth-panel-head h2,
.admin-panel-head h2 {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 21px;
  letter-spacing: -0.03em;
}

.auth-panel .panel-kicker {
  font-size: 12px;
  letter-spacing: 0.08em;
}

.auth-signal,
.admin-refresh-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.auth-signal i,
.admin-refresh-state::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px var(--green-soft);
  content: "";
}

.auth-field {
  display: grid;
  gap: 8px;
  color: var(--body);
  font-size: 12px;
  font-weight: 700;
}

.auth-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  outline: 0;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  font: inherit;
  font-weight: 560;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}

.auth-field input::placeholder {
  color: var(--dim);
}

.auth-field input:focus {
  border-color: var(--cyan);
  background: rgba(255, 255, 255, 0.075);
}

.form-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.form-message-error {
  color: #ffad9b;
}

.auth-submit,
.auth-back,
.admin-ghost-button,
.admin-logout-button,
.workspace-logout-button,
.admin-action-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
  transition: 160ms var(--ease);
}

.auth-submit {
  width: 100%;
  background: var(--cyan);
  color: #062529;
}

.auth-submit:hover {
  background: #9ae8db;
  transform: translateY(-1px);
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.auth-back,
.admin-ghost-button,
.workspace-logout-button {
  border-color: var(--hairline);
  background: transparent;
  color: var(--body);
}

.auth-back:hover,
.admin-ghost-button:hover,
.workspace-logout-button:hover {
  border-color: var(--hairline-strong);
  background: var(--blue-soft);
  color: var(--ink);
}

.admin-logout-button {
  border-color: rgba(255, 173, 155, 0.26);
  background: rgba(255, 173, 155, 0.06);
  color: #ffad9b;
}

.admin-logout-button:hover {
  border-color: rgba(255, 173, 155, 0.58);
  background: rgba(255, 173, 155, 0.12);
}

.admin-layout {
  display: grid;
  gap: 18px;
  width: min(1420px, 100%);
  margin: 0 auto;
}

.admin-header {
  align-items: flex-end;
  padding: 10px 4px 12px;
}

.admin-header h1 {
  font-size: clamp(30px, 4vw, 52px);
}

.admin-header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.admin-identity {
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
  margin-right: 8px;
  color: var(--muted);
  font-size: 11px;
}

.admin-identity strong {
  color: var(--ink);
  font-size: 13px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.admin-stat {
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 17px 18px;
  border-right: 1px solid var(--hairline);
}

.admin-stat:last-child {
  border-right: 0;
}

.admin-stat span {
  color: var(--muted);
  font-size: 11px;
}

.admin-stat strong {
  color: var(--ink);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}

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

.admin-email-inline {
  width: min(1420px, 100%);
  margin: 18px auto 0;
  scroll-margin-top: 24px;
}

.admin-email-inline[hidden] {
  display: none;
}

.admin-users-content[hidden] {
  display: none;
}

.admin-inline-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--hairline);
}

.admin-inline-head h2 {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 21px;
  letter-spacing: -0.03em;
}

.admin-inline-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.admin-email-inline .email-settings-form {
  margin-top: 18px;
}

.admin-panel {
  min-width: 0;
  padding: 20px;
}

.admin-table-wrap {
  margin-top: 18px;
  overflow-x: auto;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 660px;
}

.admin-users-table th,
.admin-users-table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  white-space: nowrap;
}

.admin-users-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.admin-users-table td {
  color: var(--body);
  font-size: 12px;
}

.admin-users-table td:first-child {
  color: var(--ink);
  font-weight: 760;
}

.admin-role,
.admin-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 11px;
}

.admin-status.is-enabled {
  border-color: rgba(137, 234, 195, 0.36);
  color: var(--lime);
}

.admin-status.is-disabled {
  color: var(--muted);
}

.admin-action-button {
  min-height: 28px;
  padding-inline: 10px;
  border-color: var(--hairline);
  background: rgba(255, 255, 255, 0.045);
  color: var(--body);
  font-size: 11px;
}

.admin-action-button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.admin-create-form {
  display: grid;
  gap: 15px;
  margin-top: 20px;
}

.workspace-session {
  justify-content: flex-end;
  gap: 17px;
}

.workspace-logout-button {
  min-height: 36px;
  padding-inline: 14px;
  border-color: var(--workspace-line);
  color: var(--workspace-body);
  font-size: 14px;
}

@media (max-width: 900px) {
  .auth-layout,
  .admin-content-grid,
  .api-provider-grid {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    max-width: 560px;
  }

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-header-actions {
    justify-content: flex-start;
  }

  .admin-inline-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .app-shell.is-auth .auth-screen,
  .app-shell.is-admin .admin-screen {
    padding: 16px;
  }

  .auth-layout {
    gap: 22px;
  }

  .auth-intro h1,
  .admin-header h1 {
    font-size: 34px;
  }

  .auth-panel,
  .admin-panel {
    padding: 16px;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  .admin-stat {
    min-height: 70px;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
  }

  .admin-stat:last-child {
    border-bottom: 0;
  }

  .admin-header-actions {
    width: 100%;
  }

  .admin-header-actions > button {
    flex: 1 1 auto;
  }

  .workspace-session {
    justify-content: space-between;
  }

  .email-settings-grid {
    grid-template-columns: 1fr;
  }

  .email-settings-wide {
    grid-column: auto;
  }

  .verification-row {
    grid-template-columns: 1fr;
  }

  .email-settings-actions {
    flex-direction: column;
  }

  .email-settings-actions .auth-submit {
    width: 100%;
  }
}
