:root {
  color-scheme: light;
  --bg: #f0ebe3;
  --bg-soft: #f8f5ef;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --soft: #a8a29e;
  --line: rgba(214, 211, 209, 0.72);
  --black: #090909;
  --black-hover: #1f1f1f;
  --danger: #b42318;
  --danger-bg: #fff1ef;
  --shadow: 0 24px 80px rgba(87, 83, 78, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.96), rgba(245, 239, 231, 0.96) 42%, rgba(240, 235, 227, 0.99) 100%);
  color: var(--text);
  font-family: "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 24px 18px;
}

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

.login-card {
  width: min(506px, calc(100vw - 32px));
  display: grid;
  gap: 18px;
  border-radius: 28px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  padding: 32px;
}

.lock-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 2px;
  border-radius: 18px;
  background: var(--black);
  color: #ffffff;
}

h1,
h2,
p {
  margin: 0;
}

.login-card h1 {
  text-align: center;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
}

.login-card p {
  margin-top: -8px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
}

label {
  color: #292524;
  font-size: 13px;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input,
select {
  height: 52px;
  padding: 0 16px;
}

textarea {
  min-height: 170px;
  resize: vertical;
  border: 0;
  background: transparent;
  padding: 18px 20px;
  line-height: 1.6;
  font-size: 15px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(68, 64, 60, 0.42);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(87, 83, 78, 0.1);
}

textarea:focus {
  box-shadow: none;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.send-button,
.icon-button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 14px;
  padding: 0 18px;
  font-weight: 720;
  white-space: nowrap;
}

.primary-button {
  background: var(--black);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--black-hover);
}

.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  color: var(--text);
}

.secondary-button:hover,
.ghost-button:hover {
  background: #ffffff;
}

.danger-button {
  min-height: 34px;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
}

.danger-button:hover {
  background: #ffe3df;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(231, 229, 228, 0.9);
  color: var(--muted);
  font-size: 20px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

.message {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.centered-message {
  text-align: center;
}

.app-message {
  width: min(980px, 100%);
  margin: 10px auto 0;
  padding: 0 4px;
}

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

.message.success {
  color: #047857;
}

.app-screen {
  min-height: 100vh;
}

.topnav {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(231, 229, 228, 0.76);
  padding: 10px 0;
}

.brand-row,
.session-row,
nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  padding: 5px 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

.nav-link {
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
}

.quota-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
}

.hero-line {
  width: min(980px, 100%);
  margin: 42px auto 18px;
}

.hero-line h1 {
  font-size: 32px;
  line-height: 1.12;
  font-weight: 800;
}

.hero-line p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.composer {
  width: min(980px, 100%);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.composer-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid rgba(231, 229, 228, 0.8);
  padding: 12px;
}

.composer-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.composer-control label,
.small-text {
  color: var(--muted);
  font-size: 13px;
}

.composer-control select {
  width: 150px;
  height: 38px;
  border-radius: 12px;
  padding: 0 10px;
}

.small-text {
  margin-left: auto;
}

.send-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--black);
  color: #ffffff;
}

.send-button:hover {
  background: var(--black-hover);
}

.history-section {
  width: min(1180px, 100%);
  margin: 22px auto 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  padding: 18px;
}

.section-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

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

.image-card {
  overflow: hidden;
  border: 1px solid rgba(231, 229, 228, 0.86);
  border-radius: 18px;
  background: #ffffff;
}

.image-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #f5f5f4;
  cursor: zoom-in;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.image-info {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.image-prompt {
  min-height: 40px;
  color: #292524;
  font-size: 14px;
  line-height: 1.45;
}

.image-meta {
  color: var(--muted);
  font-size: 12px;
}

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

.image-actions .secondary-button,
.image-actions .danger-button {
  min-height: 34px;
  border-radius: 10px;
  padding: 0 10px;
  font-size: 13px;
}

.empty-state {
  display: none;
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 42px 16px;
  color: var(--muted);
  text-align: center;
}

.empty-state.visible {
  display: block;
}

.preview-dialog {
  width: min(920px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.preview-dialog::backdrop {
  background: rgba(20, 20, 20, 0.54);
}

.preview-head,
.preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.preview-head {
  border-bottom: 1px solid var(--line);
  font-weight: 720;
}

.preview-actions {
  border-top: 1px solid var(--line);
}

.preview-dialog img {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #f5f5f4;
}

.admin-layout {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin: 0 auto;
}

.admin-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  padding: 18px;
}

.form-stack {
  display: grid;
  gap: 12px;
}

.controls-row {
  display: flex;
  align-items: end;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  color: #292524;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--black);
}

.new-key {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(68, 64, 60, 0.18);
  border-radius: 14px;
  background: #fafaf9;
  padding: 10px;
}

.new-key span {
  flex: 1;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  word-break: break-all;
}

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

.voucher-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.voucher-table th,
.voucher-table td {
  border-bottom: 1px solid rgba(231, 229, 228, 0.86);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.voucher-table th {
  color: var(--muted);
  font-weight: 720;
}

.voucher-key {
  font-family: "SFMono-Regular", Consolas, monospace;
  color: #292524;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .page-shell {
    padding: 0 14px 14px;
  }

  .topnav,
  .brand-row,
  .session-row,
  .section-head,
  .controls-row {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-row,
  nav {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .session-row {
    gap: 8px;
  }

  .hero-line {
    margin-top: 28px;
  }

  .hero-line h1 {
    font-size: 26px;
  }

  .composer-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-control {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-control select {
    width: 100%;
  }

  .small-text {
    margin-left: 0;
  }

  .send-button {
    width: 100%;
    border-radius: 14px;
  }

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

  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }

  .image-actions .secondary-button,
  .image-actions .danger-button {
    width: auto;
    flex: 1;
  }
}
