:root {
  color-scheme: light;
  --ink: #1d2529;
  --muted: #66737a;
  --paper: #f7f7f3;
  --surface: #ffffff;
  --line: #d9ded8;
  --blue: #2d5f73;
  --green: #58745a;
  --amber: #b57935;
  --rose: #a25555;
  --shadow: 0 18px 50px rgba(32, 44, 48, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(45, 95, 115, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(45, 95, 115, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

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

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

body.auth-locked .app-shell {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin-bottom: 12px;
  font-size: 42px;
}

.login-copy {
  margin-bottom: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(242, 246, 239, 0.72);
}

.auth-tab {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.auth-tab.active {
  background: var(--ink);
  color: #fff;
}

.wechat-login {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.wechat-login .secondary-button {
  width: 100%;
}

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

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.user-pill:hover {
  border-color: var(--blue);
  background: #fff;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 64px);
  font-weight: 500;
}

h2 {
  font-size: 18px;
}

.mode-switch {
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
}

.mode-button,
.copy-button,
.icon-tool-button,
.secondary-button,
.icon-button {
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 40px;
  border-radius: 7px;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.mode-button {
  padding: 0 18px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.mode-button.active {
  background: var(--ink);
  color: #fff;
}

.workbench {
  display: grid;
  grid-template-columns: 300px minmax(430px, 1.15fr) minmax(340px, 0.85fr);
  gap: 16px;
  align-items: stretch;
}

.workbench[hidden] {
  display: none !important;
}

.reference-panel,
.control-panel,
.output-panel {
  min-width: 0;
}

.reference-panel {
  display: grid;
  gap: 12px;
}

.upload-block,
.control-panel,
.output-panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.upload-block {
  padding: 14px;
}

.upload-block[hidden] {
  display: none;
}

.upload-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.upload-head > div {
  flex: 1;
  min-width: 0;
}

.upload-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.chip {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 28px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.identity .chip {
  background: var(--rose);
}

.outfit .chip {
  background: var(--amber);
}

.scene .chip {
  background: var(--green);
}

.extra-reference .chip {
  background: var(--blue);
}

.add-reference-button {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  border: 1px dashed rgba(45, 95, 115, 0.38);
  border-radius: 8px;
  background: rgba(238, 244, 239, 0.82);
  color: var(--blue);
  font-weight: 900;
  cursor: pointer;
}

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

.add-reference-button span {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  line-height: 1;
}

.add-reference-button:hover {
  border-color: var(--blue);
  background: #eef6f1;
}

.magic-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  margin-left: auto;
  border: 1px solid rgba(88, 116, 90, 0.28);
  border-radius: 8px;
  background: #edf4ed;
  color: var(--green);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
}

.magic-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.magic-button.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px dashed #aeb9b1;
  border-radius: 8px;
  background: #f0f2ec;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

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

.preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.dropzone.has-image span {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 4;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(29, 37, 41, 0.78);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

.dropzone.has-image {
  cursor: zoom-in;
}

.delete-slot-button,
.history-delete-button {
  position: absolute;
  z-index: 7;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(29, 37, 41, 0.74);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}

.delete-slot-button {
  top: 10px;
  right: 10px;
}

.delete-slot-button[hidden] {
  display: none;
}

.delete-slot-button:hover,
.history-delete-button:hover {
  background: var(--rose);
  transform: translateY(-1px);
}

.scene-image-tools {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  display: flex;
  gap: 7px;
}

.scene-image-tools .magic-button {
  margin-left: 0;
}

.dropzone.has-image .preview {
  display: block;
}

.dropzone.masking {
  cursor: crosshair;
}

.dropzone.masking input {
  pointer-events: none;
}

.mask-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: none;
  touch-action: none;
}

.dropzone.masking .mask-canvas {
  display: block;
}

.dropzone.masking span {
  pointer-events: none;
}

.mask-toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 7px;
  align-items: center;
  margin-top: 9px;
  padding: 8px;
  border: 1px solid rgba(88, 116, 90, 0.22);
  border-radius: 8px;
  background: #f5f8f1;
}

.mask-toolbar[hidden] {
  display: none;
}

.mask-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.mask-toolbar input {
  padding: 0;
  accent-color: var(--green);
}

.image-history {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 9px;
}

.image-history[hidden] {
  display: none;
}

.history-thumb-wrap {
  position: relative;
  min-width: 0;
}

.history-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef1ea;
  cursor: pointer;
}

.history-delete-button {
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  opacity: 0;
  font-size: 11px;
}

.history-thumb-wrap:hover .history-delete-button,
.history-thumb-wrap:focus-within .history-delete-button {
  opacity: 1;
}

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

.history-thumb.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(45, 95, 115, 0.16);
}

.history-thumb span {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(29, 37, 41, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.scene-analysis {
  margin-top: 9px;
  padding: 10px;
  border: 1px solid rgba(88, 116, 90, 0.22);
  border-radius: 8px;
  background: #f5f8f1;
}

.scene-analysis p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #334046;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.scene-analysis-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 8px;
  margin-top: 9px;
}

.control-panel,
.output-panel {
  padding: 18px;
}

.control-panel {
  display: flex;
  flex-direction: column;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field span,
.checks legend {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.help-dot {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border: 1px solid rgba(45, 95, 115, 0.35);
  border-radius: 999px;
  color: var(--blue);
  font-size: 11px;
  font-style: normal;
  line-height: 1;
  background: rgba(255, 255, 255, 0.78);
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  outline: none;
}

textarea,
input {
  padding: 12px;
}

select {
  padding: 0 12px;
  height: 44px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(45, 95, 115, 0.14);
}

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

.checks {
  display: grid;
  gap: 9px;
  margin: 2px 0 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6f0;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #334046;
  font-size: 14px;
  line-height: 1.4;
}

.checks input {
  width: 17px;
  height: 17px;
  accent-color: var(--blue);
}

.icon-button {
  width: 42px;
  background: #eef2ec;
  color: var(--blue);
  font-size: 22px;
}

.copy-button {
  padding: 0 18px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.prompt-toolbuttons {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.icon-tool-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  min-width: 40px;
  padding: 0;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.generate-box {
  display: grid;
  gap: 10px;
  margin-bottom: 13px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6f0;
}

.output-panel .generate-box {
  gap: 13px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.output-panel .model-picker,
.output-panel .generate-button,
.output-panel .hint {
  grid-column: 1 / -1;
}

.prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 10px;
}

.prompt-head span {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.model-picker small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field.compact {
  margin-bottom: 0;
}

.memory-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.memory-options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
}

.memory-options input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcf8;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.generate-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--rose), var(--blue));
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

.generate-button.is-stopping {
  background: linear-gradient(135deg, #9f2f3a, #253344);
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.secondary-button {
  flex: 1;
  background: #eef2ec;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 800;
}

button:hover {
  transform: translateY(-1px);
}

#prompt-output {
  flex: 1;
  min-height: 650px;
  resize: vertical;
  line-height: 1.65;
  font-size: 14px;
}

.prompt-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.prompt-lock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcf8;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.prompt-lock input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.result-view {
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcf8;
}

.preview-placeholder {
  display: none;
  place-items: center;
  min-height: 360px;
  padding: 24px;
  background: #eef1ea;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.result-grid {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.result-view[data-count="1"] .result-grid {
  grid-template-columns: 1fr;
}

.result-view[data-count="2"] .result-grid,
.result-view[data-count="4"] .result-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-card {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 0;
  overflow: hidden;
  border: 1px dashed rgba(42, 96, 114, 0.25);
  border-radius: 8px;
  background: #eef1ea;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  text-align: center;
}

.result-view[data-count="1"] .result-card {
  min-height: 360px;
}

.result-card.is-loading {
  color: var(--blue);
  background: linear-gradient(135deg, rgba(166, 87, 91, 0.08), rgba(42, 96, 114, 0.12));
}

.result-card.is-failed {
  color: #a6575b;
  background: rgba(166, 87, 91, 0.08);
}

.result-card.is-stopped {
  color: var(--muted);
  background: rgba(29, 37, 41, 0.05);
}

.result-card.is-done {
  cursor: zoom-in;
  border-style: solid;
  background: #e9ede8;
}

.result-card > img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: contain;
  background: #e9ede8;
}

.result-card-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  background: linear-gradient(180deg, transparent, rgba(29, 37, 41, 0.82));
}

.result-card-bar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card-bar a {
  flex: 0 0 auto;
  color: #fff;
  text-decoration: none;
}

.result-card-status {
  padding: 18px;
}

.result-view > img#result-image {
  display: none;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: #e9ede8;
}

.result-view.has-image > img#result-image {
  display: none;
}

.result-view.has-image .preview-placeholder {
  display: none;
}

.result-view.is-loading .preview-placeholder {
  color: var(--blue);
}

.result-view figcaption {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.result-view.is-empty figcaption,
.result-view.is-loading figcaption {
  display: none;
}

.result-view a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.result-history {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(29, 37, 41, 0.92);
  scrollbar-width: thin;
}

.result-history[hidden] {
  display: none;
}

.result-thumb {
  position: relative;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  padding: 0;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #11191c;
  cursor: pointer;
}

.result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-thumb.active {
  border-color: #19d2ad;
  box-shadow: 0 0 0 2px rgba(25, 210, 173, 0.18);
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: 1fr auto auto;
  place-items: center;
  gap: 12px;
  padding: 36px;
  background: rgba(10, 14, 16, 0.88);
}

.image-lightbox[hidden] {
  display: none;
}

.account-drawer {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 14, 16, 0.42);
}

.account-drawer[hidden] {
  display: none;
}

.account-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.account-card .lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border-color: var(--line);
  background: rgba(242, 246, 239, 0.88);
  color: var(--ink);
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.account-stat {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(242, 246, 239, 0.72);
}

.account-stat span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.account-stat strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
}

.account-section {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.account-section p {
  color: var(--muted);
  line-height: 1.55;
}

.wallet-page[hidden] {
  display: none;
}

.wallet-page {
  width: min(1520px, calc(100vw - 48px));
  margin: 0 auto 40px;
}

.wallet-shell {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid rgba(42, 96, 114, 0.12);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 80px rgba(26, 45, 54, 0.08);
}

.wallet-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(42, 96, 114, 0.1);
}

.wallet-hero h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 28px;
}

.wallet-hero p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
}

.wallet-user {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font-weight: 850;
  white-space: nowrap;
}

.wallet-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wallet-stats .account-stat {
  min-height: 100px;
  border-radius: 18px;
  background: #fff;
}

.wallet-section {
  display: grid;
  gap: 12px;
}

.wallet-section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

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

.wallet-method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wallet-amount-grid .choice-button,
.payment-card {
  min-height: 86px;
  border: 1px solid rgba(42, 96, 114, 0.12);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.wallet-amount-grid .choice-button {
  font-size: 22px;
}

.payment-card {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 16px;
  text-align: center;
}

.payment-card span {
  font-size: 16px;
}

.payment-card small {
  color: var(--muted);
  font-weight: 750;
}

.wallet-amount-grid .choice-button:hover,
.wallet-amount-grid .choice-button.active,
.payment-card:hover,
.payment-card.active {
  border-color: rgba(30, 184, 196, 0.62);
  background: linear-gradient(135deg, rgba(210, 255, 249, 0.96), rgba(245, 255, 221, 0.82));
  color: var(--blue);
}

.recharge-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.recharge-amount-field,
.recharge-method-field,
.recharge-note-field,
.recharge-qr-button,
.recharge-form .secondary-button,
.recharge-form .hint {
  grid-column: 1 / -1;
}

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

.recharge-choice-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-button {
  min-height: 48px;
  border: 1px solid rgba(42, 96, 114, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.choice-button:hover,
.choice-button.active {
  border-color: rgba(30, 184, 196, 0.62);
  background: linear-gradient(135deg, rgba(210, 255, 249, 0.94), rgba(246, 255, 221, 0.78));
  color: var(--blue);
}

.recharge-qr-button {
  min-height: 46px;
  border-radius: 999px;
}

.recharge-note-field textarea {
  min-height: 82px;
  resize: vertical;
}

.recharge-orders {
  display: grid;
  gap: 8px;
}

.recharge-order {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.recharge-order > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.recharge-order strong {
  color: var(--ink);
  font-size: 18px;
}

.recharge-order span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(42, 96, 114, 0.1);
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.recharge-order.approved span {
  background: rgba(26, 135, 84, 0.1);
  color: #198754;
}

.recharge-order.rejected span {
  background: rgba(166, 87, 91, 0.12);
  color: #a6575b;
}

.recharge-order p {
  margin: 0;
  font-size: 12px;
}

.recharge-note {
  word-break: break-word;
}

.recharge-order-actions,
.admin-key-row {
  display: flex;
  gap: 8px;
}

.admin-key-row input {
  flex: 1;
}

.admin-section {
  background: rgba(242, 246, 239, 0.38);
}

.tracker-page[hidden] {
  display: none !important;
}

.tracker-page {
  width: min(1520px, calc(100vw - 48px));
  margin: 0 auto 40px;
}

.tracker-shell {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid rgba(42, 96, 114, 0.12);
  border-radius: 24px;
  background:
    radial-gradient(circle at 18% 0%, rgba(35, 201, 187, 0.13), transparent 34%),
    radial-gradient(circle at 68% 0%, rgba(255, 216, 239, 0.38), transparent 32%),
    rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 80px rgba(26, 45, 54, 0.08);
}

.tracker-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(42, 96, 114, 0.1);
}

.tracker-hero h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 28px;
}

.tracker-hero p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
}

.tracker-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(460px, 1.22fr);
  gap: 16px;
}

.tracker-section {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(42, 96, 114, 0.12);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 46px rgba(26, 45, 54, 0.06);
}

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

.tracker-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tracker-section-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.tracker-record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tracker-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.tracker-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(42, 96, 114, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
}

.tracker-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.tracker-card h4 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 17px;
}

.tracker-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.tracker-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.tracker-stat {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(42, 96, 114, 0.1);
  border-radius: 14px;
  background: #f6faf8;
}

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

.tracker-stat strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.tracker-records {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(42, 96, 114, 0.1);
}

.tracker-records > div {
  display: grid;
  gap: 4px;
}

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

.tracker-records span {
  color: var(--muted);
  font-size: 12px;
}

.tracker-empty {
  grid-column: 1 / -1;
  padding: 42px 20px;
  border: 1px dashed rgba(42, 96, 114, 0.18);
  border-radius: 18px;
  background: rgba(246, 250, 248, 0.7);
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.mini-button.danger {
  color: #a6575b;
}

.pay-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(13, 20, 22, 0.48);
  backdrop-filter: blur(12px);
}

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

.pay-modal-card {
  position: relative;
  width: min(92vw, 420px);
  display: grid;
  gap: 14px;
  padding: 26px;
  border: 1px solid rgba(42, 96, 114, 0.16);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(19, 29, 32, 0.22);
}

.pay-modal-card h2 {
  margin: 0;
  font-size: 28px;
}

.pay-confirm {
  display: grid;
  gap: 14px;
  padding: 14px 0 4px;
}

.pay-confirm[hidden] {
  display: none;
}

.pay-confirm div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-weight: 850;
}

.pay-confirm strong {
  color: var(--ink);
  font-size: 18px;
}

.pay-modal-qr-frame {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed rgba(42, 96, 114, 0.28);
  border-radius: 22px;
  background: rgba(242, 246, 239, 0.78);
}

.pay-modal-qr-frame img {
  width: min(72vw, 240px);
  height: min(72vw, 240px);
  border-radius: 18px;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 18px 44px rgba(19, 29, 32, 0.14);
}

.pay-modal-qr-frame span {
  padding: 0 24px;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}

.pay-modal-qr-frame[hidden] {
  display: none;
}

.lightbox-stage {
  position: relative;
  display: grid;
  place-items: center;
  max-width: min(96vw, 1280px);
  max-height: 86vh;
}

.image-lightbox img {
  max-width: min(96vw, 1280px);
  max-height: 86vh;
  object-fit: contain;
  border-radius: 8px;
  background: #101416;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.42);
}

.lightbox-mask-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: none;
  transform: translate(-50%, -50%);
  touch-action: none;
  cursor: crosshair;
}

.image-lightbox.mask-editor .lightbox-mask-canvas {
  display: block;
}

.lightbox-mask-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(242, 246, 239, 0.94);
}

.lightbox-mask-toolbar[hidden] {
  display: none;
}

.lightbox-mask-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.lightbox-mask-toolbar input {
  accent-color: var(--green);
}

.image-lightbox p {
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  font-weight: 800;
}

.lightbox-close {
  position: fixed;
  top: 22px;
  right: 24px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-open {
  overflow: hidden;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

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

  .reference-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
  }

  #prompt-output {
    min-height: 520px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    padding: 18px 0;
  }

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

  .workbench,
  .reference-panel,
  .output-panel .generate-box,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-button {
    flex: 1;
  }
}

/* Alphai visual refresh: style-only overrides, no behavior changes. */
:root {
  --ink: #101820;
  --muted: #6d7a86;
  --paper: #fbfcfd;
  --surface: #ffffff;
  --line: #e6edf3;
  --blue: #0f6674;
  --green: #23c9bb;
  --amber: #c48238;
  --rose: #b75f68;
  --shadow: 0 18px 48px rgba(30, 43, 56, 0.08);
  --soft-shadow: 0 10px 28px rgba(30, 43, 56, 0.06);
  --radius-card: 20px;
  --radius-field: 13px;
}

body {
  background:
    radial-gradient(circle at 47% 21%, rgba(35, 201, 187, 0.13), transparent 24%),
    radial-gradient(circle at 60% 18%, rgba(255, 151, 203, 0.12), transparent 22%),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 52%, #f7fafb 100%);
  background-size: auto;
  color: var(--ink);
  letter-spacing: 0;
}

.app-shell {
  width: min(1520px, calc(100% - 44px));
  padding: 24px 0 34px;
}

.topbar {
  align-items: center;
  padding: 8px 0 18px;
  margin-bottom: 8px;
}

.eyebrow {
  margin-bottom: 4px;
  color: #2b7180;
  font-size: 11px;
  letter-spacing: 0.04em;
}

h1 {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: clamp(36px, 4vw, 56px);
  font-weight: 850;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 19px;
  font-weight: 850;
}

.user-pill,
.secondary-button {
  min-height: 38px;
  border-color: var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 22px rgba(27, 43, 54, 0.05);
}

.user-pill {
  padding: 0 14px;
  color: #1d6775;
}

.workbench {
  grid-template-columns: minmax(270px, 310px) minmax(470px, 1.08fr) minmax(360px, 0.82fr);
  gap: 18px;
  align-items: start;
}

.upload-block,
.control-panel,
.output-panel,
.login-card,
.account-card {
  border-color: var(--line);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
}

.reference-panel {
  gap: 12px;
}

.upload-block {
  padding: 13px;
}

.upload-head {
  gap: 9px;
  margin-bottom: 10px;
}

.upload-head h2 {
  font-size: 17px;
  line-height: 1.25;
}

.upload-head p {
  margin-top: 2px;
  font-size: 12px;
  color: #7a8792;
}

.chip {
  min-width: 42px;
  height: 26px;
  border-radius: 999px;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.22);
}

.identity .chip,
.outfit .chip,
.scene .chip,
.extra-reference .chip {
  background: linear-gradient(135deg, #1199a7, #27d4c1);
}

.dropzone {
  aspect-ratio: 3 / 4;
  border-color: #d7e1e8;
  border-radius: 15px;
  background: #f4f7f5;
  color: #71808a;
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.dropzone.has-image span {
  left: 9px;
  bottom: 9px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.74);
  font-size: 12px;
}

.preview {
  object-fit: cover;
}

.delete-slot-button,
.history-delete-button {
  border-color: rgba(255, 255, 255, 0.68);
  background: rgba(16, 24, 32, 0.66);
  box-shadow: 0 8px 18px rgba(16, 24, 32, 0.14);
}

.delete-slot-button {
  top: 9px;
  right: 9px;
  width: 28px;
  height: 28px;
  border-radius: 10px;
}

.scene-image-tools {
  right: 9px;
  bottom: 9px;
}

.magic-button {
  flex-basis: 32px;
  width: 32px;
  height: 32px;
  border-color: rgba(35, 201, 187, 0.32);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.84);
  color: #0f6674;
  box-shadow: 0 8px 18px rgba(16, 24, 32, 0.1);
  font-size: 16px;
}

.magic-button.active {
  background: #0f6674;
  border-color: #0f6674;
}

.image-history {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.history-thumb-wrap {
  flex: 0 0 auto;
}

.history-thumb {
  width: 42px;
  height: 42px;
  border-color: #e1e9ef;
  border-radius: 10px;
  background: #f3f6f7;
}

.history-thumb.active {
  border-color: #22cbbb;
  box-shadow: 0 0 0 2px rgba(35, 201, 187, 0.16);
}

.history-thumb span {
  left: 3px;
  bottom: 3px;
  padding: 1px 4px;
  font-size: 9px;
}

.history-delete-button {
  top: -5px;
  right: -5px;
  width: 20px;
  height: 20px;
}

.scene-analysis,
.mask-toolbar,
.checks,
.generate-box {
  border-color: #e4edf0;
  border-radius: 14px;
  background: rgba(246, 250, 247, 0.78);
}

.scene-analysis p {
  color: #34434c;
  font-size: 12px;
  line-height: 1.55;
}

.mini-button {
  min-height: 32px;
  border-color: #dfe8ee;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  color: #566875;
}

.scene-analysis-actions {
  gap: 7px;
}

.add-reference-button {
  min-height: 46px;
  border-color: rgba(35, 201, 187, 0.38);
  border-radius: 14px;
  background: rgba(235, 252, 250, 0.46);
  color: #0f6674;
}

.add-reference-button span {
  background: #0f6674;
}

.add-reference-button:hover {
  border-color: #23c9bb;
  background: rgba(226, 252, 249, 0.72);
}

.control-panel {
  position: relative;
  min-height: calc(100vh - 132px);
  padding: 22px;
  overflow: hidden;
}

.control-panel::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(circle at 8% 9%, rgba(35, 201, 187, 0.2), transparent 28%),
    radial-gradient(circle at 94% 7%, rgba(255, 151, 203, 0.2), transparent 26%),
    rgba(255, 255, 255, 0.9);
}

.output-panel {
  padding: 18px;
}

.panel-title {
  margin-bottom: 16px;
}

.field {
  gap: 7px;
  margin-bottom: 14px;
}

.field span,
.checks legend,
.prompt-head span {
  color: #176878;
  font-size: 12px;
  font-weight: 850;
}

textarea,
input,
select {
  border-color: #dfe8ee;
  border-radius: var(--radius-field);
  background: rgba(255, 255, 255, 0.82);
}

textarea,
input {
  padding: 13px 14px;
}

select {
  height: 44px;
  padding: 0 13px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(35, 201, 187, 0.75);
  box-shadow: 0 0 0 4px rgba(35, 201, 187, 0.13);
}

.prompt-mode-field {
  max-width: 100%;
}

.prompt-head {
  margin-top: 10px;
}

.prompt-toolbuttons {
  gap: 7px;
}

.icon-tool-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  border-color: #dfe8ee;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.62);
  color: #6d7a86;
  box-shadow: none;
  font-size: 15px;
}

.icon-tool-button:hover {
  border-color: rgba(35, 201, 187, 0.55);
  background: rgba(235, 252, 250, 0.78);
  color: #0f6674;
}

#prompt-output {
  min-height: 650px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  color: #21313a;
  line-height: 1.68;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.generate-box {
  padding: 14px;
}

.generate-button {
  min-height: 50px;
  border-radius: 13px;
  background: linear-gradient(135deg, #07252b, #0f6674);
  box-shadow: 0 12px 28px rgba(15, 102, 116, 0.18);
}

.generate-button:hover {
  background: linear-gradient(135deg, #061d22, #0a5b68);
}

.generate-button.is-stopping {
  background: linear-gradient(135deg, #8d3540, #273848);
}

.hint {
  color: #7a8792;
}

.result-view {
  border-color: var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
}

.preview-placeholder,
.result-card {
  border-radius: 14px;
  background: #f3f7f5;
}

.result-card {
  border-color: rgba(15, 102, 116, 0.18);
}

.result-card.is-loading {
  background:
    radial-gradient(circle at 50% 40%, rgba(35, 201, 187, 0.14), transparent 34%),
    #f5f9fb;
  color: #0f6674;
}

.result-card.is-done {
  background: #f5f8f8;
}

.result-history {
  border-color: #e2ebef;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
}

.result-thumb {
  flex-basis: 50px;
  width: 50px;
  height: 50px;
  border-color: #dfe8ee;
  border-radius: 12px;
  background: #f4f7f8;
}

.result-thumb.active {
  border-color: #22cbbb;
  box-shadow: 0 0 0 2px rgba(35, 201, 187, 0.18);
}

.lightbox-close,
.account-card .lightbox-close {
  border-radius: 12px;
}

.toast {
  border-radius: 13px;
  background: #101820;
}

@media (max-width: 1160px) {
  .reference-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dropzone {
    aspect-ratio: 3 / 4;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 22px, 560px);
  }

  .control-panel {
    min-height: auto;
  }

  .reference-panel {
    grid-template-columns: 1fr;
  }
}

/* Top navigation refresh */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(180px, auto) minmax(180px, 0.9fr);
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 10px 14px;
  margin: 0 0 18px;
  border: 1px solid rgba(215, 226, 226, 0.92);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 32px rgba(25, 40, 52, 0.06);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: inline-grid;
  gap: 1px;
  min-width: 0;
}

.brand-lockup .eyebrow {
  margin: 0;
  color: #54a6a8;
  font-size: 10px;
  line-height: 1.1;
}

.brand-lockup h1 {
  font-size: clamp(28px, 3vw, 40px);
  line-height: 0.95;
}

.top-nav {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 5px;
  border: 1px solid rgba(220, 230, 230, 0.9);
  border-radius: 999px;
  background: rgba(246, 250, 248, 0.86);
}

.top-nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 18px;
  border-radius: 999px;
  color: #6b7981;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.top-nav-item.active {
  color: #0f6674;
  background: #dffcf7;
  box-shadow: inset 0 0 0 1px rgba(35, 201, 187, 0.18);
}

.top-actions {
  justify-self: end;
}

.topbar .user-pill,
.topbar .secondary-button {
  min-height: 40px;
}

.topbar .secondary-button {
  padding: 0 16px;
  color: #203137;
  font-weight: 850;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .top-nav {
    order: 3;
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .top-actions,
  .top-nav {
    justify-self: stretch;
  }

  .top-actions {
    justify-content: space-between;
  }
}

/* Full-width product navigation */
.topbar {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-bottom: 24px;
  min-height: 68px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  justify-content: start;
  gap: 28px;
  padding: 0 max(28px, calc((100vw - 1520px) / 2 + 22px));
  border: 0;
  border-bottom: 1px solid rgba(220, 230, 230, 0.84);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(25, 40, 52, 0.04);
}

.brand-lockup {
  display: flex;
  align-items: center;
}

.brand-lockup h1 {
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.top-nav {
  justify-self: start;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.top-nav-item {
  min-height: 40px;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #202b31;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
}

.top-nav-item.active {
  color: #0f6674;
  background: transparent;
  box-shadow: inset 0 -2px 0 #23c9bb;
}

.top-actions {
  justify-self: end;
  gap: 12px;
}

.topbar .user-pill {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: #ffffff;
}

.account-actions {
  display: flex;
  justify-content: flex-end;
}

.account-actions .secondary-button {
  min-width: 120px;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    padding-inline: 18px;
  }

  .top-nav {
    order: initial;
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: 1fr auto;
    min-height: auto;
    padding-block: 12px;
  }

  .top-nav {
    grid-column: 1 / -1;
    order: 3;
  }

  .top-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 980px) {
  .tracker-page {
    width: min(100% - 22px, 760px);
  }

  .tracker-layout,
  .tracker-list {
    grid-template-columns: 1fr;
  }

  .tracker-hero {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .tracker-shell {
    padding: 18px;
  }

  .tracker-record-grid,
  .tracker-stats {
    grid-template-columns: 1fr;
  }

  .tracker-card-head {
    flex-direction: column;
  }

  .tracker-card-actions {
    justify-content: flex-start;
  }
}

/* Final layout polish: spacing and column rhythm only. */
.topbar {
  grid-template-columns: minmax(210px, 0.65fr) minmax(320px, auto) minmax(210px, 1fr);
  gap: clamp(42px, 5vw, 92px);
  padding-inline: max(42px, calc((100vw - 1520px) / 2 + 28px));
}

.brand-lockup {
  justify-self: start;
}

.top-nav {
  justify-self: start;
  gap: clamp(22px, 2.4vw, 42px);
}

.top-nav-item {
  padding-inline: 0;
}

.top-actions {
  justify-self: end;
}

.app-shell {
  width: min(1540px, calc(100% - 56px));
}

.workbench {
  grid-template-columns: minmax(300px, 340px) minmax(560px, 1fr) minmax(390px, 440px);
  gap: 24px;
  align-items: stretch;
}

.reference-panel,
.control-panel,
.output-panel {
  min-height: calc(100vh - 142px);
}

.reference-panel {
  align-content: start;
}

.control-panel,
.output-panel {
  height: 100%;
}

.control-panel {
  display: flex;
  flex-direction: column;
}

#prompt-output {
  flex: 1 1 auto;
  min-height: 560px;
}

.output-panel {
  display: flex;
  flex-direction: column;
}

.output-panel .generate-box {
  flex: 0 0 auto;
}

.result-view {
  flex: 1 1 auto;
  min-height: 380px;
}

.result-history {
  flex: 0 0 auto;
}

@media (max-width: 1280px) {
  .app-shell {
    width: min(1180px, calc(100% - 32px));
  }

  .workbench {
    grid-template-columns: minmax(270px, 320px) minmax(470px, 1fr) minmax(340px, 400px);
    gap: 18px;
  }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 22px;
    padding-inline: 22px;
  }

  .top-nav {
    gap: 18px;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .reference-panel,
  .control-panel,
  .output-panel {
    min-height: auto;
  }

  #prompt-output {
    min-height: 420px;
  }
}

/* Layout correction: nav stays near the logo, columns share one baseline. */
.topbar {
  grid-template-columns: auto 1fr auto;
  gap: 44px;
  justify-content: stretch;
}

.top-nav {
  justify-self: start;
  gap: 28px;
}

.top-nav-item {
  min-width: auto;
  padding-inline: 0;
  text-align: center;
}

.workbench {
  align-items: stretch;
}

.reference-panel,
.control-panel,
.output-panel {
  min-height: calc(100vh - 136px);
}

.reference-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.add-reference-button {
  margin-top: auto;
  flex: 0 0 auto;
}

.result-view {
  flex: 0 0 auto;
  min-height: 360px;
}

.result-history {
  margin-top: 10px;
}

@media (max-width: 980px) {
  .topbar {
    gap: 24px;
  }

  .top-nav {
    gap: 18px;
  }

  .reference-panel,
  .control-panel,
  .output-panel {
    min-height: auto;
  }

  .add-reference-button {
    margin-top: 0;
  }
}

/* Compact workbench correction: keep the add-reference button close to image 3. */
.reference-panel,
.control-panel,
.output-panel {
  min-height: auto;
}

.reference-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.add-reference-button {
  margin-top: 0;
}

.control-panel,
.output-panel {
  height: auto;
}

#prompt-output {
  flex: 0 0 auto;
  height: clamp(560px, 58vh, 700px);
  min-height: 0;
}

.result-view {
  flex: 0 0 auto;
  min-height: 340px;
}

.result-history {
  margin-top: 10px;
}
