:root {
  --bg: #090912;
  --panel: rgba(20, 20, 34, 0.86);
  --panel-strong: #151525;
  --text: #f8f7ff;
  --muted: #a7a4bd;
  --line: rgba(255, 255, 255, 0.12);
  --hot: #ff2f8f;
  --acid: #a6ff00;
  --cyan: #27e3ff;
  --warning: #ffd166;
  --radius: 8px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 47, 143, 0.28), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(39, 227, 255, 0.22), transparent 24%),
    linear-gradient(135deg, #080811 0%, #12101f 50%, #0b0b13 100%);
  min-height: 100vh;
}

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

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

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  background:
    linear-gradient(115deg, rgba(255, 47, 143, 0.18), rgba(39, 227, 255, 0.08)),
    rgba(10, 10, 18, 0.72);
  box-shadow: var(--shadow);
}

.hero-badge {
  display: inline-flex;
  border: 1px solid rgba(166, 255, 0, 0.45);
  color: var(--acid);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  background: rgba(166, 255, 0, 0.08);
}
.hero-meta { display: flex; align-items: center; justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
.version-badge {
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 14px 0 4px;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

.hero-copy {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.subtitle {
  margin: 0;
  color: var(--cyan);
  font-size: 22px;
  font-weight: 700;
}

.intro {
  max-width: 520px;
  margin: 0;
  color: #dbd9ec;
  font-size: 16px;
  line-height: 1.7;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.input-panel,
.output-panel {
  padding: 20px;
}

.output-panel {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.panel-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.panel-title span {
  font-size: 20px;
  font-weight: 800;
}

.panel-title small {
  color: var(--muted);
}

.workspace-utilities {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 16px;
}

.workspace-utilities button {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
}

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

.output-tools button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

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

.generation-status-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid rgba(166, 255, 0, 0.34);
  border-radius: var(--radius);
  background:
    linear-gradient(120deg, rgba(166, 255, 0, 0.13), rgba(39, 227, 255, 0.09)),
    rgba(9, 9, 18, 0.82);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 14px 38px rgba(166, 255, 0, 0.08);
}

.generation-status-bar.is-active {
  display: flex;
  animation: statusPulse 1.8s ease-in-out infinite;
}

.generation-status-core {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.generation-spinner {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--acid);
  border-right-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.generation-status-core strong {
  display: block;
  color: var(--acid);
  font-size: 15px;
}

.generation-status-core p {
  margin: 4px 0 0;
  color: #e8e5f7;
  font-size: 13px;
  line-height: 1.45;
}

.generation-dots {
  display: inline-flex;
  gap: 5px;
  flex: 0 0 auto;
}

.generation-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0.45;
  animation: dotBlink 1s ease-in-out infinite;
}

.generation-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.generation-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

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

@keyframes dotBlink {
  0%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes statusPulse {
  0%, 100% {
    border-color: rgba(166, 255, 0, 0.28);
  }
  50% {
    border-color: rgba(39, 227, 255, 0.42);
  }
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label,
fieldset {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  color: #e8e6f5;
  font-size: 14px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 11px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(39, 227, 255, 0.12);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--warning);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.12);
}

select option {
  color: #111;
}

textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.55;
}

fieldset {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
}

legend {
  padding: 0 8px;
  color: #e8e6f5;
}

.optional-settings {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.optional-settings summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 11px 14px;
  color: #e8e6f5;
  cursor: pointer;
  list-style-position: inside;
}

.optional-settings summary::marker {
  color: var(--cyan);
}

.optional-settings summary small {
  color: var(--muted);
}

.optional-settings[open] summary {
  border-bottom: 1px solid var(--line);
}

.optional-settings summary:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.optional-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-row label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.choice-row input {
  width: auto;
  min-height: auto;
  accent-color: var(--hot);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
  position: sticky;
  bottom: 10px;
  z-index: 5;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 15, 27, 0.96);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

button {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
}

button.primary {
  border: 0;
  color: #090912;
  font-weight: 900;
  background: linear-gradient(135deg, var(--acid), var(--cyan) 52%, var(--hot));
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 24px;
}

.result-nav {
  position: sticky;
  top: -20px;
  z-index: 6;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 14px;
  padding: 10px 0;
  background: rgba(20, 20, 34, 0.98);
  scrollbar-width: thin;
}

.result-stale-notice {
  margin: 0 0 14px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 209, 102, 0.48);
  border-radius: var(--radius);
  color: #fff0bd;
  background: rgba(255, 209, 102, 0.09);
  font-size: 13px;
  line-height: 1.5;
}

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

.result-stack.is-stale {
  opacity: 0.72;
}

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

.result-nav a {
  flex: 0 0 auto;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  color: #e8e6f5;
  background: rgba(255, 255, 255, 0.07);
  font-size: 13px;
  text-decoration: none;
}

.result-nav a:hover,
.result-nav a:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
  outline: none;
}

.result-card {
  scroll-margin-top: 58px;
}

.empty-state strong {
  display: block;
  color: var(--text);
  font-size: 22px;
  margin-bottom: 10px;
}

.result-stack {
  display: grid;
  gap: 14px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
  overflow: hidden;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
}

.result-head h2 {
  margin: 0;
  font-size: 18px;
}

.copy-section {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.result-body {
  padding: 16px;
  color: #ebe9f8;
  line-height: 1.72;
  white-space: pre-wrap;
}

.result-body h3 {
  margin: 10px 0 6px;
  color: var(--acid);
  font-size: 16px;
}

.result-body p {
  margin: 0 0 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(12, 12, 20, 0.92);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.trial-access-dialog,
.feedback-dialog {
  width: min(420px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  max-height: min(86vh, 760px);
  overflow: hidden;
}

.trial-access-dialog::backdrop,
.feedback-dialog::backdrop {
  background: rgba(4, 4, 10, 0.78);
}

.trial-access-dialog form,
.feedback-dialog form {
  display: grid;
  gap: 16px;
  padding: 20px;
  max-height: inherit;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.trial-access-dialog label,
.feedback-dialog label {
  display: grid;
  gap: 8px;
  color: var(--text);
}

.feedback-dialog {
  width: min(720px, calc(100% - 24px));
}

.feedback-dialog select,
.feedback-dialog textarea,
.trial-access-dialog input {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

.feedback-dialog textarea::placeholder,
.trial-access-dialog input::placeholder {
  color: rgba(235, 233, 248, 0.58);
}

.feedback-dialog textarea {
  min-height: 96px;
  resize: vertical;
}

.feedback-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.trial-access-error,
.feedback-error {
  margin: 0;
  color: var(--warning);
}

.dialog-actions {
  position: sticky;
  bottom: -20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 -20px -20px;
  padding: 12px 20px 20px;
  background: linear-gradient(180deg, rgba(25, 24, 36, 0.86), var(--panel-strong) 34%);
  z-index: 1;
}

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

  .output-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .hero,
  .input-panel,
  .output-panel {
    padding: 16px;
  }

  .form-grid,
  .optional-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    grid-template-columns: 1fr 1fr;
    bottom: 6px;
    padding: 8px;
  }

  .actions .primary {
    grid-column: 1 / -1;
  }

  .panel-title {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .output-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .result-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .result-head h2 {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .toast {
    width: max-content;
    max-width: calc(100% - 24px);
    text-align: center;
  }

  .wide {
    grid-column: auto;
  }

  .trial-access-dialog,
  .feedback-dialog {
    width: calc(100% - 16px);
    max-height: 88dvh;
  }

  .trial-access-dialog form,
  .feedback-dialog form {
    padding: 16px;
    gap: 14px;
    -webkit-overflow-scrolling: touch;
  }

  .dialog-actions {
    bottom: -16px;
    margin: 0 -16px -16px;
    padding: 12px 16px 18px;
  }

  h1 {
    font-size: 30px;
  }

  .hero-copy {
    display: block;
  }

  .intro {
    margin-top: 10px;
  }
}

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