:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-2: #eef6f7;
  --surface: rgba(255, 255, 255, .78);
  --surface-strong: rgba(255, 255, 255, .92);
  --surface-soft: rgba(255, 255, 255, .58);
  --surface-tint: rgba(228, 243, 242, .62);
  --text: #111827;
  --text-soft: #475569;
  --text-muted: #728096;
  --line: rgba(148, 163, 184, .32);
  --line-strong: rgba(100, 116, 139, .42);
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-2: #2563eb;
  --accent-3: #db2777;
  --accent-soft: rgba(15, 118, 110, .11);
  --danger: #b42318;
  --danger-soft: rgba(254, 226, 226, .82);
  --warning: #92400e;
  --warning-soft: rgba(254, 243, 199, .82);
  --success-soft: rgba(209, 250, 229, .86);
  --shadow-sm: 0 10px 28px rgba(15, 23, 42, .08);
  --shadow-md: 0 20px 70px rgba(15, 23, 42, .14);
  --shadow-focus: 0 0 0 4px rgba(37, 99, 235, .15);
  --radius-sm: 14px;
  --radius: 22px;
  --radius-lg: 32px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 10%, rgba(20, 184, 166, .18), transparent 32vw),
    radial-gradient(circle at 88% 6%, rgba(37, 99, 235, .15), transparent 30vw),
    linear-gradient(135deg, #f8fbff 0%, var(--bg-2) 48%, #fdf7fb 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(15, 23, 42, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, .035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, .9), transparent 82%);
  pointer-events: none;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

h1,
h2,
p {
  margin-top: 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 56px);
}

.auth-shell {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(360px, 520px);
  gap: clamp(22px, 4vw, 52px);
  align-items: center;
}

.auth-intro {
  min-width: 0;
  padding: clamp(18px, 3vw, 36px);
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border: 1px solid rgba(255, 255, 255, .62);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(15, 118, 110, .98), rgba(37, 99, 235, .92));
  color: #fff;
  box-shadow: 0 18px 42px rgba(15, 118, 110, .24);
  font-weight: 900;
}

.brand-mark.small {
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 16px;
  font-size: 13px;
}

.eyebrow,
.kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-intro h1 {
  max-width: 620px;
  margin: 12px 0 18px;
  color: var(--text);
  font-size: clamp(40px, 6vw, 74px);
  line-height: .96;
  letter-spacing: 0;
}

.auth-intro p {
  max-width: 620px;
  margin-bottom: 24px;
  color: var(--text-soft);
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.8;
}

.auth-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-points span,
.hint {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid rgba(15, 118, 110, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .64);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
  backdrop-filter: blur(18px);
}

.auth-card,
.prompt-panel,
.result-panel,
.history-panel {
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(28px) saturate(1.15);
}

.auth-card {
  padding: clamp(20px, 3vw, 30px);
}

.auth-card-head,
.panel-heading,
.section-title,
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.auth-card h2,
.panel-heading h2,
.section-title h2 {
  margin: 4px 0 0;
  color: var(--text);
  font-size: clamp(22px, 2vw, 28px);
  line-height: 1.16;
}

.auth-panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .62);
}

.auth-tabs {
  width: 100%;
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 18px 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(241, 245, 249, .78);
}

.auth-tab-form {
  flex: 1;
  display: flex;
  margin: 0;
}

.auth-tabs span,
.auth-tabs a,
.auth-tabs button {
  min-height: 32px;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  text-decoration: none;
  font-weight: 900;
}

.auth-tabs .is-active,
.auth-tabs .active,
.auth-tabs [aria-current="page"] {
  background: #fff;
  color: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
}

.auth-switch {
  margin: 2px 0 0;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.auth-switch a {
  color: var(--accent-strong);
  font-weight: 900;
  text-decoration: none;
}

.guest-history .empty {
  margin: 0;
}

.auth-form,
.login-form {
  display: grid;
  gap: 14px;
}

.auth-form label,
.login-form label,
.field {
  display: grid;
  gap: 8px;
}

.auth-form label span,
.login-form label span,
.field span {
  color: #253244;
  font-size: 13px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .82);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease, transform .18s ease;
}

input,
select {
  height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 206px;
  padding: 14px;
  resize: vertical;
  line-height: 1.72;
}

textarea::placeholder,
input::placeholder {
  color: #92a0b4;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(37, 99, 235, .7);
  background: #fff;
  box-shadow: var(--shadow-focus);
}

button,
.result-actions a,
.result-actions button,
.history-card a {
  cursor: pointer;
  text-decoration: none;
}

.primary,
.login-form button,
.auth-form button {
  width: 100%;
  min-height: 52px;
  margin-top: 6px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 900;
  box-shadow: 0 16px 36px rgba(15, 118, 110, .24);
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease, filter .16s ease;
}

.primary:hover,
.login-form button:hover,
.auth-form button:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
  box-shadow: 0 20px 44px rgba(37, 99, 235, .24);
}

.primary:active,
.login-form button:active,
.auth-form button:active {
  transform: translateY(1px);
}

.primary:disabled {
  cursor: wait;
  opacity: .68;
  transform: none;
  box-shadow: none;
}

.ghost {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .66);
  color: var(--text-soft);
  font-weight: 900;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}

.ghost:hover {
  background: #fff;
  color: var(--text);
  transform: translateY(-1px);
}

.ghost.danger {
  border-color: rgba(248, 113, 113, .22);
  color: var(--danger);
}

.alert,
.notice,
.status {
  border-radius: 16px;
  line-height: 1.55;
}

.alert {
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px solid rgba(248, 113, 113, .34);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

.notice {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, .58);
  color: var(--text-soft);
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 34px;
}

.app-header {
  position: sticky;
  top: 14px;
  z-index: 10;
  width: min(1440px, calc(100% - 32px));
  margin: 14px auto 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 24px;
  background: rgba(255, 255, 255, .68);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(24px) saturate(1.2);
}

.brand-lockup,
.account-bar {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header h1 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: clamp(21px, 2.2vw, 30px);
  line-height: 1.08;
}

.account-bar > span {
  max-width: min(38vw, 260px);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .58);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu {
  position: relative;
}

.account-menu summary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .66);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  list-style: none;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}

.account-menu summary::-webkit-details-marker {
  display: none;
}

.account-menu summary:hover {
  background: #fff;
  color: var(--text);
  transform: translateY(-1px);
}

.password-form {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: min(340px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 22px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(24px) saturate(1.15);
}

.password-form label {
  display: grid;
  gap: 7px;
}

.password-form label span {
  color: #253244;
  font-size: 12px;
  font-weight: 900;
}

.password-form button {
  min-height: 46px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.inline-alert {
  width: min(1440px, calc(100% - 32px));
  margin: 14px auto 0;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  backdrop-filter: blur(18px);
}

.inline-alert.ok {
  border: 1px solid rgba(16, 185, 129, .28);
  background: var(--success-soft);
  color: #047857;
}

.inline-alert.error {
  border: 1px solid rgba(248, 113, 113, .34);
  background: var(--danger-soft);
  color: var(--danger);
}

.studio-layout {
  width: min(1440px, calc(100% - 32px));
  display: grid;
  grid-template-columns: minmax(330px, 470px) minmax(0, 1fr);
  gap: clamp(16px, 2.4vw, 28px);
  align-items: stretch;
  margin: 22px auto 0;
}

.prompt-panel,
.result-panel,
.history-panel {
  min-width: 0;
}

.prompt-panel {
  padding: clamp(18px, 2.2vw, 26px);
}

.panel-heading {
  margin-bottom: 18px;
}

.field.full {
  margin-bottom: 16px;
}

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

.status {
  min-height: 26px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  color: var(--text-soft);
  font-size: 13px;
}

.status:empty {
  min-height: 0;
  padding: 0;
}

.status.ok {
  border-color: rgba(16, 185, 129, .28);
  background: var(--success-soft);
  color: #047857;
}

.status.error {
  border-color: rgba(248, 113, 113, .34);
  background: var(--danger-soft);
  color: var(--danger);
}

.status.loading {
  border-color: rgba(245, 158, 11, .32);
  background: var(--warning-soft);
  color: var(--warning);
}

.result-panel {
  min-height: 640px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: clamp(16px, 2vw, 24px);
}

.preview-box {
  min-width: 0;
  min-height: 548px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .78), rgba(255, 255, 255, .46)),
    linear-gradient(45deg, rgba(15, 118, 110, .06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(37, 99, 235, .05) 25%, transparent 25%);
  background-size: auto, 28px 28px, 28px 28px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .78);
}

.placeholder,
.loading-card,
.success-card {
  width: min(390px, calc(100% - 28px));
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .74);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.7;
  box-shadow: var(--shadow-sm);
}

.placeholder strong,
.loading-card strong,
.success-card strong {
  color: var(--text);
  font-size: 15px;
}

.placeholder span,
.loading-card span,
.success-card span {
  color: var(--text-muted);
  font-size: 13px;
}

.loading-indicator {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(226, 232, 240, .9);
}

.loading-indicator::before {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  animation: loading-slide 1.25s ease-in-out infinite;
}

@keyframes loading-slide {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(245%);
  }
}

.result-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  justify-items: center;
}

.result-image {
  max-width: 100%;
  max-height: min(72vh, 760px);
  display: block;
  border-radius: 22px;
  object-fit: contain;
  box-shadow: 0 26px 70px rgba(15, 23, 42, .18);
}

.result-actions {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 4px;
}

.result-actions a,
.result-actions button,
.history-card a,
.history-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 999px;
  background: #111827;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-decoration: none;
}

.result-actions button,
.history-actions button {
  background: #fff;
  color: var(--text);
}

.history-panel {
  width: min(1440px, calc(100% - 32px));
  margin: 22px auto 0;
  padding: clamp(16px, 2vw, 22px);
}

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

.section-title form {
  margin: 0;
}

.section-title span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.history-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 13px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .66);
  border-radius: 22px;
  background: rgba(255, 255, 255, .6);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.history-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, .8);
  box-shadow: 0 14px 34px rgba(15, 23, 42, .1);
}

.history-thumb,
.history-card img,
.missing-thumb {
  width: 104px;
  height: 104px;
  border-radius: 18px;
}

.history-thumb {
  overflow: hidden;
  background: var(--surface-tint);
}

.history-card img {
  display: block;
  object-fit: cover;
}

.missing-thumb {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.history-card strong,
.history-card span,
.history-card p {
  display: block;
  margin: 0 0 7px;
  font-size: 12px;
}

.history-card strong {
  color: var(--text);
  font-weight: 900;
}

.history-card span,
.history-card p {
  color: var(--text-muted);
}

.history-card p {
  max-height: 4.2em;
  overflow: hidden;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.history-card a {
  min-height: 32px;
  padding: 0 12px;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.history-actions a,
.history-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.empty {
  grid-column: 1 / -1;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  background: rgba(255, 255, 255, .58);
  color: var(--text-muted);
  text-align: center;
}

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

@media (max-width: 1120px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    padding-bottom: 0;
  }

  .auth-intro h1,
  .auth-intro p {
    max-width: none;
  }

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

  .result-panel {
    min-height: 560px;
  }

  .preview-box {
    min-height: 470px;
  }
}

@media (min-width: 721px) and (max-width: 1120px) {
  .prompt-panel form {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
    gap: 16px;
    align-items: start;
  }

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

  .prompt-panel .grid,
  .prompt-panel .primary,
  .prompt-panel .status {
    grid-column: 2;
  }

  .field.full {
    grid-row: 1 / span 3;
  }
}

@media (max-width: 720px) {
  body {
    background:
      radial-gradient(circle at 12% 0%, rgba(20, 184, 166, .18), transparent 54vw),
      linear-gradient(135deg, #f8fbff 0%, #eef6f7 62%, #fff7fb 100%);
  }

  .auth-page {
    padding: 14px;
    place-items: stretch;
  }

  .auth-shell {
    align-content: start;
    gap: 16px;
  }

  .auth-intro {
    padding: 12px 4px 0;
  }

  .auth-intro h1 {
    font-size: clamp(34px, 12vw, 48px);
  }

  .auth-card {
    border-radius: 26px;
    padding: 16px;
  }

  .auth-panel {
    padding: 15px;
  }

  .app-header {
    position: static;
    width: calc(100% - 24px);
    margin-top: 12px;
    align-items: stretch;
    flex-direction: column;
    border-radius: 22px;
  }

  .account-bar {
    justify-content: space-between;
  }

  .account-bar > span {
    max-width: calc(100vw - 140px);
  }

  .account-menu {
    position: static;
  }

  .password-form {
    position: fixed;
    top: 104px;
    left: 12px;
    right: 12px;
    width: auto;
  }

  .studio-layout,
  .history-panel {
    width: calc(100% - 24px);
    margin-top: 14px;
  }

  .prompt-panel,
  .result-panel,
  .history-panel {
    border-radius: 26px;
  }

  .prompt-panel,
  .result-panel {
    padding: 15px;
  }

  .panel-heading,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

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

  textarea {
    min-height: 164px;
  }

  .result-panel {
    min-height: 450px;
  }

  .preview-box {
    min-height: 360px;
    border-radius: 22px;
  }

  .result-image {
    max-height: 58vh;
    border-radius: 18px;
  }

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

@media (max-width: 420px) {
  .auth-points span,
  .hint {
    width: 100%;
    justify-content: center;
  }

  .auth-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-tabs {
    width: 100%;
  }

  .auth-tabs span,
  .auth-tabs a,
  .auth-tabs button {
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  input,
  select {
    height: 46px;
  }

  .account-bar {
    flex-wrap: wrap;
  }

  .account-bar > span {
    max-width: 100%;
    flex: 1 1 100%;
  }

  .account-menu,
  .account-bar form {
    flex: 1;
  }

  .account-menu summary,
  .ghost {
    width: 100%;
  }

  .history-card {
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 11px;
    padding: 10px;
    border-radius: 20px;
  }

  .history-thumb,
  .history-card img,
  .missing-thumb {
    width: 86px;
    height: 86px;
    border-radius: 16px;
  }

  .primary,
  .login-form button,
  .auth-form button,
  .ghost,
  .result-actions a,
  .result-actions button,
  .history-card a,
  .history-actions button {
    white-space: normal;
  }
}
