: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;
}

.auth-loading {
  display: none;
  min-height: 100vh;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
}

.auth-loading strong {
  color: var(--ink);
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.auth-loading span {
  font-size: 14px;
}

body.auth-pending .auth-loading {
  display: grid;
}

body.auth-pending .app-shell,
body.auth-pending .login-screen {
  display: none !important;
}

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

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

.login-shell {
  width: min(440px, 100%);
}

.login-logo {
  margin: 0 0 18px;
  color: var(--ink);
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -0.04em;
  text-align: center;
}

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

.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;
}

.login-method-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.login-only[hidden],
.password-login-only[hidden],
.phone-auth-only[hidden] {
  display: none !important;
}

.login-method {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.login-method.active {
  border-color: rgba(14, 139, 145, 0.3);
  background: rgba(14, 139, 145, 0.09);
  color: var(--blue);
}

.auth-alternate {
  display: block;
  margin: 14px auto 0;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.admin-login-entry {
  margin-top: 6px;
  color: var(--blue);
}

.auth-alternate:hover {
  color: var(--blue);
}

.auth-agreement {
  margin-top: 14px;
  line-height: 1.55;
  text-align: center;
}

.phone-field,
.sms-code-field {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.phone-field {
  overflow: hidden;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.phone-field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 5px rgba(65, 219, 204, 0.14);
}

.phone-prefix {
  display: grid;
  place-items: center;
  min-width: 66px;
  border-right: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
}

.phone-field input,
.phone-field input:focus {
  min-width: 0;
  border: 0;
  box-shadow: none;
}

.sms-code-field input {
  min-width: 0;
  flex: 1;
}

.sms-send-button {
  flex: 0 0 126px;
  border: 1px solid rgba(14, 139, 145, 0.25);
  border-radius: 8px;
  background: rgba(14, 139, 145, 0.08);
  color: var(--blue);
  cursor: pointer;
  font-weight: 800;
}

.sms-send-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.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%;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  width: 100%;
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 30px;
  height: 30px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.password-toggle:hover {
  background: rgba(42, 96, 114, 0.08);
  color: var(--blue);
}

.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 {
  position: relative;
  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);
  cursor: help;
}

.help-dot::after {
  position: absolute;
  z-index: 80;
  top: calc(100% + 10px);
  left: -8px;
  width: 250px;
  padding: 12px 14px;
  border: 1px solid #dfe8ee;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(30, 43, 56, 0.14);
  color: #34434c;
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.65;
  text-align: left;
  white-space: pre-line;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
  pointer-events: none;
}

.help-dot:hover::after,
.help-dot:focus::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

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 .generate-button,
.output-panel .hint {
  grid-column: 1 / -1;
}

.generation-cost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(21, 175, 177, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.generation-cost strong {
  color: #f2a51a;
  font-size: 18px;
  line-height: 1;
  white-space: nowrap;
}

.generate-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px 0 22px;
}

.generate-submit > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  background: #fff;
  color: #0f6674;
  white-space: nowrap;
}

.generate-submit > strong {
  flex: 1;
  text-align: left;
  color: #ffd36a;
  font-size: 17px;
  white-space: nowrap;
}

.generate-submit.is-stopping > strong {
  display: none;
}

.generate-submit.is-stopping > span {
  flex: 1;
  background: transparent;
  color: #fff;
}

.generate-submit:disabled {
  cursor: not-allowed;
  filter: saturate(0.55);
  opacity: 0.78;
}

.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-timeout {
  color: #8a641d;
  background: rgba(226, 174, 67, 0.1);
}

.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;
}

.admin-console-modal {
  position: fixed;
  inset: 0;
  z-index: 48;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 14, 16, 0.52);
}

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

.admin-console-card {
  width: min(1180px, 100%);
  min-height: 220px;
}

.admin-console-card > h2 {
  margin: 0 48px 18px 0;
}

.admin-auth-view {
  width: min(420px, 100%);
  margin: 18px auto;
  text-align: center;
}

.admin-auth-view h2 {
  margin: 0 0 20px;
}

.admin-login-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
}

.admin-login-form input,
.admin-usage-search input {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.admin-auth-hint {
  min-height: 22px;
  margin: 10px 0 0;
  color: #a6575b;
}

.admin-workspace[hidden],
.admin-auth-view[hidden],
.admin-tab-panel[hidden] {
  display: none !important;
}

.admin-workspace {
  display: grid;
  gap: 18px;
}

.admin-workspace-heading span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-workspace-heading h2,
.admin-panel-heading h3 {
  margin: 3px 0 0;
}

.admin-main-tabs,
.admin-subtabs {
  display: flex;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(242, 246, 239, 0.65);
}

.admin-main-tabs button,
.admin-subtabs button {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.admin-main-tabs button {
  flex: 1;
  padding: 11px 14px;
}

.admin-subtabs {
  width: fit-content;
  margin-bottom: 12px;
}

.admin-subtabs button {
  min-width: 90px;
  padding: 8px 16px;
}

.admin-main-tabs button.active,
.admin-subtabs button.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 5px 16px rgba(15, 102, 116, 0.1);
}

.admin-tab-panel {
  min-height: 360px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(249, 251, 249, 0.92);
}

.admin-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-panel-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-usage-search {
  display: grid;
  grid-template-columns: minmax(220px, 480px) 92px;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-provider-settings {
  display: grid;
  gap: 12px;
}

[data-admin-provider-panel][hidden] { display: none !important; }

.admin-provider-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; align-items: stretch; }
.admin-provider-mode-list { display: grid; gap: 12px; }
.admin-provider-section-title { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; color: var(--ink); }
.admin-provider-section-title:not(:first-child) { margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.admin-provider-section-title span { color: var(--muted); font-size: 12px; }
.admin-provider-detail-card { display: grid; grid-template-rows: auto auto 1fr auto; gap: 10px; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.admin-provider-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-provider-detail-heading strong { color: var(--ink); margin-right: 8px; }
.admin-provider-detail-heading div > span { color: var(--muted); font-size: 12px; }
.admin-provider-status { padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.admin-provider-status.configured { color: #198754; background: rgba(26, 135, 84, 0.1); }
.admin-provider-status.missing { color: #a6575b; background: rgba(166, 87, 91, 0.12); }
.admin-provider-detail-card label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.admin-provider-detail-card input,
.admin-provider-detail-card textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcf8; color: var(--ink); font: inherit; box-sizing: border-box; }
.admin-provider-detail-card input { overflow: hidden; text-overflow: ellipsis; }
.admin-provider-detail-card textarea { min-height: 64px; max-height: 120px; resize: vertical; }
.admin-provider-detail-card button { width: 100%; justify-content: center; }

.admin-provider-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.admin-provider-card strong { color: var(--ink); }
.admin-provider-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.admin-provider-control { display: grid; grid-template-columns: 240px 112px; gap: 8px; align-items: center; width: 360px; flex: 0 0 360px; }
.admin-provider-control select { width: 240px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font: inherit; }
.admin-provider-control button { width: 112px; min-width: 112px; white-space: nowrap; }
.admin-provider-hint { margin-top: 12px; }

.admin-reconciliation-list,
.admin-reconciliation-history { display: grid; gap: 12px; }
.admin-reconciliation-card,
.admin-reconciliation-history-row { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.admin-reconciliation-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.admin-reconciliation-card-heading p,
.admin-reconciliation-card p,
.admin-reconciliation-history-row p { margin: 5px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.admin-reconciliation-error { padding: 9px 10px; border-radius: 8px; background: rgba(226, 174, 67, 0.08); }
.admin-reconciliation-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.admin-reconciliation-actions .danger { color: #a6575b; border-color: rgba(166, 87, 91, 0.35); }
.admin-reconciliation-history-title { margin: 22px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.admin-reconciliation-hint { min-height: 20px; color: #a6575b; }

@media (max-width: 680px) {
  .admin-main-tabs {
    display: grid;
  }

  .admin-login-form,
  .admin-usage-search {
    grid-template-columns: 1fr;
  }

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

  .admin-provider-card,
  .admin-provider-control { align-items: stretch; flex-direction: column; }

  .admin-provider-list { grid-template-columns: 1fr; }
  .admin-provider-control { grid-template-columns: 1fr; width: 100%; flex-basis: auto; }
  .admin-provider-control select,
  .admin-provider-control button { width: 100%; min-width: 0; }
}

.account-card {
  position: relative;
  width: min(1080px, 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: 142px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(242, 246, 239, 0.72);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

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

.account-stat strong {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  color: var(--ink);
  font-size: 22px;
}

.account-stat-action {
  width: 100%;
  min-height: 38px;
  margin-top: auto;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.account-stat-action:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.account-stat-action-primary {
  border-color: transparent;
  background: var(--blue);
  color: #fff;
}

.account-stat-action-primary:hover {
  border-color: transparent;
  background: #214b5c;
  color: #fff;
}

.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;
}

.security-section {
  margin-bottom: 16px;
}

.security-section:has(.password-editor[hidden]) {
  display: none;
}

.security-heading {
  display: flex;
  align-items: center;
  gap: 16px;
}

.security-heading > p {
  flex: 1;
}

.security-toggle {
  width: auto;
  min-width: 120px;
}

.password-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(246, 250, 248, 0.76);
}

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

.security-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.security-actions .secondary-button {
  width: auto;
  min-width: 120px;
  min-height: 46px;
}

.security-actions .primary {
  border-color: transparent;
  background: var(--blue);
  color: #fff;
}

@media (max-width: 720px) {
  .security-heading { align-items: flex-start; flex-direction: column; }
  .password-editor { grid-template-columns: 1fr; }
  .security-actions { grid-column: 1; }
}

.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;
}

.usage-log-section {
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid rgba(42, 96, 114, 0.1);
}

.usage-log-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.usage-log-heading span {
  color: var(--muted);
  font-size: 12px;
}

.usage-log-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.usage-log-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.usage-log-table th,
.usage-log-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(42, 96, 114, 0.08);
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  vertical-align: middle;
}

.usage-log-table th {
  background: #f7faf9;
  color: #687781;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.usage-log-table tbody tr:last-child td {
  border-bottom: 0;
}

.usage-log-table td strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.usage-log-table td small {
  display: block;
  margin-top: 3px;
  color: #8b98a1;
  font-size: 11px;
}

.usage-cost,
.usage-balance {
  color: var(--ink) !important;
  font-weight: 850;
  white-space: nowrap;
}

.usage-channel {
  color: var(--ink) !important;
  font-weight: 800;
  white-space: nowrap;
}

.usage-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(166, 87, 91, 0.1);
  color: #a6575b;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.usage-status.succeeded {
  background: rgba(26, 135, 84, 0.1);
  color: #198754;
}

.usage-status.failed_refunded {
  background: rgba(42, 96, 114, 0.1);
  color: var(--blue);
}

.usage-status.processing,
.usage-status.timeout_unknown {
  background: rgba(242, 165, 26, 0.13);
  color: #b16f00;
}

.usage-log-empty {
  padding: 28px !important;
  text-align: center !important;
}

.token-rate {
  margin: -4px 0 0;
  color: var(--blue);
  font-size: 14px;
  font-weight: 850;
}

.energy-icon {
  display: inline;
  flex: 0 0 auto;
  margin-right: 3px;
  color: #ff9f1a;
  font-style: normal;
  font-weight: 950;
  text-shadow: 0 1px 8px rgba(255, 159, 26, 0.2);
}

@media (max-width: 640px) {
  .wallet-stats {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

.wallet-method-grid {
  display: grid;
  grid-template-columns: 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 {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-items: center;
  gap: 7px;
  min-height: 132px;
  padding: 18px 12px;
}

.recharge-option-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 3px;
  white-space: nowrap;
  color: #343a43;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.1;
}

.recharge-option-main .energy-icon {
  font-size: 25px;
}

.recharge-option-offer {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
}

.recharge-option-discount {
  color: #737b85;
}

.recharge-option-saving,
.recharge-option-benefit {
  color: #19a943;
}

.recharge-option-benefit {
  min-height: 18px;
  font-size: 13px;
  font-weight: 800;
  line-height: 18px;
}

.recharge-option-benefit.is-placeholder {
  visibility: hidden;
}

@media (max-width: 980px) {
  .wallet-amount-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .wallet-amount-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

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

.wallet-amount-grid .choice-button:hover,
.wallet-amount-grid .choice-button.active {
  border-color: #1677ff;
  background: #eaf2ff;
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(22, 119, 255, 0.1);
  transform: translateY(-1px);
}

.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;
  flex-wrap: wrap;
}

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

.admin-section {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(242, 246, 239, 0.38);
}

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

.admin-users {
  display: grid;
  gap: 8px;
}

.admin-user-summary {
  margin: 0;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
}

.admin-user-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-user-card strong {
  color: var(--ink);
}

.admin-user-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.admin-manual-recharge-button {
  flex: 0 0 auto;
  color: var(--blue);
  border-color: rgba(40, 120, 178, 0.24);
  background: rgba(236, 247, 255, 0.8);
}

.admin-disable-user-button {
  color: #a34b3d;
  border-color: rgba(163, 75, 61, 0.28);
  background: rgba(255, 244, 241, 0.9);
}

.admin-enable-user-button {
  color: #2e7a61;
  border-color: rgba(46, 122, 97, 0.28);
  background: rgba(239, 251, 245, 0.9);
}

.admin-delete-user-button {
  color: #a33c35;
  border-color: rgba(163, 60, 53, 0.32);
  background: rgba(255, 241, 239, 0.9);
}

.admin-manual-recharge-card {
  width: min(440px, calc(100vw - 32px));
}

.admin-manual-recharge-user {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.admin-user-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.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-modal-card.is-alipay h2 {
  color: #1677ff;
  font-size: clamp(30px, 7vw, 38px);
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.pay-modal-card.is-success .pay-modal-qr-frame {
  display: none;
}

.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-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.pay-confirm-actions button {
  min-width: 88px;
}

.wallet-history:has(.recharge-orders:empty) {
  display: none;
}

.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;
}

.pay-status {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 13px 15px;
  border: 1px solid rgba(22, 119, 255, 0.18);
  border-radius: 18px;
  background: rgba(22, 119, 255, 0.06);
}

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

.pay-status-icon {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 3px solid rgba(22, 119, 255, 0.2);
  border-top-color: #1677ff;
  border-radius: 50%;
  animation: pay-status-spin 0.85s linear infinite;
}

.pay-status strong {
  display: block;
  color: #1259b2;
  font-size: 17px;
  line-height: 1.35;
}

.pay-status p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
}

.pay-status.success {
  border-color: rgba(24, 145, 91, 0.24);
  background: rgba(24, 145, 91, 0.08);
}

.pay-status.success .pay-status-icon {
  border: 0;
  background: #18915b;
  animation: pay-status-pop 0.32s ease-out;
}

.pay-status.success .pay-status-icon::after {
  position: absolute;
  left: 8px;
  top: 4px;
  width: 8px;
  height: 13px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  content: "";
  transform: rotate(45deg);
}

.pay-status.success strong {
  color: #137549;
  font-size: 20px;
}

.pay-status.error {
  border-color: rgba(166, 87, 91, 0.24);
  background: rgba(166, 87, 91, 0.08);
}

.pay-status.error .pay-status-icon {
  border: 0;
  background: #a6575b;
  animation: none;
}

.pay-status.error .pay-status-icon::before,
.pay-status.error .pay-status-icon::after {
  position: absolute;
  left: 13px;
  top: 6px;
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: #fff;
  content: "";
  transform: rotate(45deg);
}

.pay-status.error .pay-status-icon::after {
  transform: rotate(-45deg);
}

.pay-status.error strong {
  color: #8f4247;
}

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

@keyframes pay-status-pop {
  0% { transform: scale(0.65); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.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;
}

.hint:empty {
  display: none;
}

/* Account identity and language switcher */
.top-actions {
  position: relative;
  flex-wrap: nowrap;
}

.language-switcher {
  position: relative;
}

.language-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(239, 244, 252, 0.94);
  color: #1683f8;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.language-button:hover,
.language-button[aria-expanded="true"] {
  background: #e5efff;
  transform: translateY(-1px);
}

.language-symbol {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -2px;
}

.language-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 10px);
  right: 0;
  width: 190px;
  padding: 8px;
  border: 1px solid rgba(33, 54, 77, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 40px rgba(28, 45, 72, 0.16);
}

.language-menu[hidden] {
  display: none;
}

.language-menu button {
  display: grid;
  grid-template-columns: 28px 1fr 18px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 6px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #1b2635;
  text-align: left;
  cursor: pointer;
}

.language-menu button:hover,
.language-menu button.active {
  background: #f0f5ff;
}

.language-menu button span {
  font-size: 19px;
}

.language-menu button strong {
  font-size: 14px;
  font-weight: 750;
}

.language-menu button i {
  visibility: hidden;
  color: #1677ff;
  font-style: normal;
  font-weight: 900;
}

.language-menu button.active i {
  visibility: visible;
}

.header-balance {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(33, 54, 77, 0.08);
  border-radius: 999px;
  background: rgba(255, 250, 235, 0.92);
  color: #344054;
  font-size: 14px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.header-balance[hidden] {
  display: none;
}

.header-balance-icon {
  color: #f5a000;
  font-size: 17px;
  line-height: 1;
}

.topbar .user-pill {
  min-height: 44px;
  gap: 8px;
  padding: 4px 12px 4px 5px;
  border: 0;
  background: rgba(239, 243, 250, 0.96);
  color: #344054;
  font-size: 14px;
  font-weight: 750;
}

.topbar .user-pill:hover {
  border-color: transparent;
  background: #e9eef7;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffb54b, #ffc865);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(255, 171, 55, 0.2);
}

.user-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chevron {
  color: #66758c;
  font-size: 17px;
  line-height: 1;
}

@media (max-width: 640px) {
  .language-button {
    width: 38px;
    height: 38px;
  }

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

  .header-balance {
    min-height: 38px;
    padding-inline: 9px;
    font-size: 13px;
  }

  .user-avatar {
    width: 31px;
    height: 31px;
    flex-basis: 31px;
  }

.user-name {
  max-width: 82px;
  }
}

/* Tracker dashboard: list-first workflow */
.tracker-shell {
  gap: 22px;
  padding: 30px;
  background:
    radial-gradient(circle at 12% 0%, rgba(35, 201, 187, 0.08), transparent 30%),
    radial-gradient(circle at 78% 0%, rgba(255, 216, 239, 0.2), transparent 28%),
    #f8fafb;
}

.tracker-hero {
  align-items: center;
  padding-bottom: 0;
  border-bottom: 0;
}

.tracker-hero h2 {
  margin-bottom: 6px;
  font-size: 30px;
}

.tracker-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.tracker-add-trigger {
  width: auto;
  min-width: 142px;
  min-height: 44px;
  padding-inline: 20px;
  border-radius: 13px;
}

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

.tracker-overview article {
  display: grid;
  gap: 9px;
  min-height: 112px;
  padding: 20px 22px;
  border: 1px solid rgba(42, 96, 114, 0.1);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 34px rgba(31, 48, 57, 0.045);
}

.tracker-overview span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

.tracker-list-section {
  padding: 0;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(31, 48, 57, 0.05);
}

.tracker-list-section .tracker-section-head {
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(42, 96, 114, 0.09);
}

.tracker-section-head > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.tracker-refresh-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(42, 96, 114, 0.12);
  border-radius: 10px;
  background: #f8fafb;
  color: #647180;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.tracker-list-section > .hint {
  margin: 0;
  padding: 0 22px;
}

.tracker-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.tracker-card {
  display: grid;
  grid-template-columns: minmax(230px, 1.65fr) repeat(3, minmax(110px, 0.72fr)) minmax(100px, 0.62fr) 100px;
  align-items: center;
  gap: 18px;
  min-height: 108px;
  padding: 18px 22px;
  border: 0;
  border-bottom: 1px solid rgba(42, 96, 114, 0.08);
  border-radius: 0;
  background: #fff;
  cursor: pointer;
  transition: background 150ms ease;
}

.tracker-card:last-child {
  border-bottom: 0;
}

.tracker-card:hover {
  background: #f7fbfb;
}

.tracker-account-cell {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.tracker-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #d7f7f4, #eef9d7);
  color: #087980;
  font-size: 17px;
  font-weight: 900;
}

.tracker-avatar.large {
  width: 52px;
  height: 52px;
  flex-basis: 52px;
  border-radius: 17px;
  font-size: 20px;
}

.tracker-account-cell h4,
.tracker-account-cell h2 {
  margin: 0 0 5px;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracker-account-cell h4 {
  font-size: 16px;
}

.tracker-account-cell h2 {
  font-size: 22px;
}

.tracker-account-cell p {
  max-width: 260px;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracker-metric-cell,
.tracker-time-cell {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.tracker-metric-cell > span,
.tracker-time-cell > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.tracker-metric-cell > strong,
.tracker-time-cell > strong {
  color: var(--ink);
  font-size: 17px;
}

.tracker-metric-cell small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracker-delta {
  width: max-content;
  font-size: 11px;
  font-weight: 850;
}

.tracker-delta.positive {
  color: #16a05d;
}

.tracker-delta.negative {
  color: #d95b61;
}

.tracker-delta.neutral {
  color: #98a2ad;
}

.tracker-row-action {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: #087980;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.tracker-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 22px;
  padding: 58px 20px;
  background: #fafcfc;
}

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

.tracker-empty p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.tracker-empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: #eaf7f5;
  color: #15999d;
  font-size: 23px;
}

.tracker-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 24, 28, 0.48);
  backdrop-filter: blur(10px);
}

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

.tracker-modal-card {
  position: relative;
  width: min(100%, 560px);
  max-height: min(88vh, 900px);
  overflow: auto;
  padding: 28px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(14, 25, 30, 0.24);
}

.tracker-modal-card .lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: #66717d;
}

.tracker-modal-heading {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 24px;
  padding-right: 40px;
}

.tracker-modal-heading h3,
.tracker-panel-heading h3 {
  margin: 0;
  color: var(--ink);
}

.tracker-modal-heading p,
.tracker-panel-heading span {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tracker-modal-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #e9f8f5;
  color: #0b8e92;
  font-size: 22px;
  font-weight: 700;
}

.tracker-add-card {
  display: grid;
  gap: 16px;
}

.tracker-add-card textarea {
  min-height: 82px;
}

.tracker-modal-actions {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  margin-top: 4px;
}

.tracker-modal-actions .generate-button {
  min-height: 48px;
}

.tracker-detail-card {
  width: min(1120px, 96vw);
  padding: 30px;
}

.tracker-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-right: 42px;
}

.tracker-detail-actions {
  display: flex;
  gap: 8px;
}

.tracker-detail-actions .secondary-button {
  width: auto;
  min-height: 38px;
  padding-inline: 14px;
}

.tracker-detail-actions .danger {
  color: #b55459;
}

.tracker-detail-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0;
}

.tracker-detail-stats article {
  display: grid;
  gap: 7px;
  padding: 15px;
  border: 1px solid rgba(42, 96, 114, 0.09);
  border-radius: 15px;
  background: #f8faf9;
}

.tracker-detail-stats article > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.tracker-detail-stats article > strong {
  color: var(--ink);
  font-size: 21px;
}

.tracker-detail-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(440px, 1.18fr);
  gap: 16px;
}

.tracker-history-panel,
.tracker-update-panel {
  padding: 18px;
  border: 1px solid rgba(42, 96, 114, 0.1);
  border-radius: 18px;
}

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

.tracker-panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 15px;
}

#tracker-detail-history {
  display: grid;
  gap: 0;
  max-height: 460px;
  overflow: auto;
}

.tracker-history-item {
  display: grid;
  gap: 6px;
  padding: 13px 2px;
  border-bottom: 1px solid rgba(42, 96, 114, 0.08);
}

.tracker-history-item > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tracker-history-item strong {
  color: var(--ink);
  font-size: 12px;
}

.tracker-history-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.tracker-history-item .tracker-history-title {
  color: #344451;
}

.tracker-detail-empty {
  padding: 40px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .tracker-card {
    grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(105px, 0.7fr)) minmax(90px, 0.55fr) 92px;
  }

  .tracker-card .tracker-metric-cell:nth-of-type(4) {
    display: none;
  }

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

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

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

  .tracker-overview {
    grid-template-columns: 1fr;
  }

  .tracker-overview article {
    min-height: 86px;
  }

  .tracker-card {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .tracker-account-cell,
  .tracker-row-action {
    grid-column: 1 / -1;
  }

  .tracker-time-cell {
    display: none;
  }

  .tracker-detail-card {
    padding: 22px;
  }

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

  .tracker-detail-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@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;
}

/* Workbench layout only: reference images sit horizontally above prompt mode.
   HTML and JavaScript behavior remain unchanged. */
.workbench {
  grid-template-columns: minmax(0, 1fr) minmax(390px, 440px);
  grid-template-rows: auto auto;
  gap: 18px 24px;
  align-items: start;
}

.reference-panel {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

.reference-panel .upload-block {
  min-width: 0;
}

.reference-panel > .identity .upload-head,
.reference-panel > .outfit .upload-head,
.reference-panel > .scene .upload-head {
  display: none;
}

.reference-panel > .identity,
.reference-panel > .outfit,
.reference-panel > .scene {
  padding: 10px;
}

.reference-panel > .identity .dropzone::before,
.reference-panel > .outfit .dropzone::before,
.reference-panel > .scene .dropzone::before {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 4;
  transform: translateX(-50%);
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.reference-panel > .identity .dropzone::before {
  content: "图 1";
}

.reference-panel > .outfit .dropzone::before {
  content: "图 2";
}

.reference-panel > .scene .dropzone::before {
  content: "图 3";
}

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

.reference-panel .add-reference-button {
  grid-column: 1 / -1;
  width: 100%;
}

.control-panel {
  grid-column: 1;
  grid-row: 2;
}

.output-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
}

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

  .reference-panel,
  .control-panel,
  .output-panel {
    grid-column: 1;
    grid-row: auto;
  }

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

@media (max-width: 680px) {
  .reference-panel {
    grid-template-columns: 1fr;
  }

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

/* Compact shared reference tray: presentation only; upload behavior is unchanged. */
@media (min-width: 981px) {
  .reference-panel {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--soft-shadow);
    backdrop-filter: blur(10px);
  }

  .reference-panel .upload-block {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .reference-panel .dropzone {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
  }

  .reference-panel .image-history {
    min-height: 42px;
    margin-top: 8px;
    overflow: hidden;
  }

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

@media (min-width: 681px) and (max-width: 980px) {
  .reference-panel {
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    overflow-x: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--soft-shadow);
  }

  .reference-panel .upload-block {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .reference-panel .dropzone {
    aspect-ratio: 1 / 1;
  }
}

@media (max-width: 680px) {
  .reference-panel .dropzone {
    aspect-ratio: 1 / 1;
  }
}

/* Progressive add tile: the empty state contains only this square upload slot. */
.reference-panel .add-reference-button {
  grid-column: auto;
  align-self: start;
  width: 100%;
  min-height: 0;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  border: 2px dashed #c8d4da;
  border-radius: 14px;
  background: #f7f9f8;
  color: #64737d;
  box-shadow: none;
}

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

.reference-panel .add-reference-button span {
  width: 54px;
  height: 54px;
  background: transparent;
  color: currentColor;
  font-size: 48px;
  font-weight: 300;
}

.reference-panel .add-reference-button strong {
  color: #71808a;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
}

.reference-panel .add-reference-button:hover,
.reference-panel .add-reference-button.is-dragover {
  border-color: #17bbae;
  background: #effaf8;
  color: #087582;
  transform: none;
}

.reference-panel .image-history {
  display: none !important;
}

.reference-panel .upload-head {
  display: none;
}

.reference-panel > [data-extra-reference="image-four"] .dropzone::before,
.reference-panel > [data-extra-reference="image-five"] .dropzone::before {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 4;
  transform: translateX(-50%);
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.reference-panel > [data-extra-reference="image-four"] .dropzone::before {
  content: "图 4";
}

.reference-panel > [data-extra-reference="image-five"] .dropzone::before {
  content: "图 5";
}

.reference-panel .upload-block[draggable="true"] {
  cursor: grab;
  min-width: 0;
}

.reference-panel .upload-block.is-dragging {
  opacity: 0.45;
}

.reference-panel .upload-block.is-drag-target .dropzone {
  border-color: #17bbae;
  box-shadow: 0 0 0 4px rgba(23, 187, 174, 0.16);
}

.slot-image-tools {
  position: absolute;
  right: 9px;
  bottom: 9px;
  z-index: 5;
  display: flex;
}

/* Unified reference-image tools: delete, mask and analyze. */
.reference-image-tools {
  position: absolute;
  z-index: 9;
  top: 9px;
  left: 9px;
  right: auto;
  bottom: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease, visibility 150ms ease;
  pointer-events: none;
}

.dropzone.has-image:hover .reference-image-tools,
.dropzone.has-image:focus-within .reference-image-tools {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.dropzone.has-image > span {
  display: none;
}

.reference-image-tools .reference-tool-button {
  position: static;
  display: inline-grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 9px;
  background: rgba(24, 35, 42, 0.76);
  color: #fff;
  box-shadow: 0 6px 16px rgba(16, 24, 32, 0.16);
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  transition: background 150ms ease, transform 150ms ease;
}

.reference-image-tools .reference-tool-button:hover,
.reference-image-tools .reference-tool-button:focus-visible {
  background: #0f6674;
  color: #fff;
  transform: translateY(-1px);
}

.reference-image-tools .delete-slot-button:hover,
.reference-image-tools .delete-slot-button:focus-visible {
  background: #b75f68;
}

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

@media (min-width: 981px) {
  .reference-panel .add-reference-button {
    max-width: none;
  }
}
