:root {
  color: #f5f7ff;
  background: #070915;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(103, 90, 255, 0.2), transparent 32%),
    radial-gradient(circle at 92% 32%, rgba(15, 201, 178, 0.12), transparent 32%),
    #070915;
}

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

.shell {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.hero,
.connection-card,
.model-tabs,
.workspace,
.section-heading,
.result-heading {
  display: flex;
}

.hero {
  justify-content: space-between;
  align-items: flex-start;
  gap: 30px;
  margin-bottom: 28px;
}

.hero h1 {
  margin: 0;
  color: transparent;
  background: linear-gradient(110deg, #f7fbff 4%, #c8d7ff 43%, #8cebd8 92%);
  background-clip: text;
  -webkit-background-clip: text;
  font-size: clamp(40px, 7vw, 76px);
  letter-spacing: -0.055em;
  line-height: 0.98;
  text-shadow: 0 0 48px rgba(151, 179, 255, 0.13);
}

.eyebrow {
  margin: 0 0 9px;
  color: #8e82ff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.subtitle {
  margin: 10px 0 0;
  color: #9da4bf;
  font-size: 16px;
}

.slogan {
  margin: 19px 0 0;
  color: #dce5ff;
  font-size: clamp(18px, 2.2vw, 25px);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.dragon-seal {
  position: relative;
  display: grid;
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(203, 219, 255, 0.24);
  border-radius: 50%;
  color: #dce7ff;
  background:
    radial-gradient(circle at 34% 28%, rgba(236, 246, 255, 0.18), transparent 30%),
    linear-gradient(145deg, rgba(106, 124, 200, 0.22), rgba(56, 218, 190, 0.08));
  box-shadow:
    inset 0 0 28px rgba(175, 199, 255, 0.08),
    0 0 70px rgba(101, 125, 217, 0.15);
}

.dragon-seal::before,
.dragon-seal::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(190, 210, 255, 0.13);
  border-radius: 50%;
}

.dragon-seal::before {
  inset: 10px;
}

.dragon-seal::after {
  inset: 19px;
  border-style: dashed;
}

.dragon-seal span {
  position: absolute;
  top: 21px;
  color: #91a4dc;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.26em;
}

.dragon-seal strong {
  position: relative;
  z-index: 1;
  margin-top: 13px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 55px;
  font-weight: 400;
  text-shadow: 0 0 24px rgba(159, 189, 255, 0.26);
}

.connection-card,
.model-tabs,
.forms,
.result-panel,
.api-guide,
.local-history {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(12, 15, 33, 0.82);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
}

.connection-card {
  align-items: end;
  gap: 18px;
  border-radius: 18px;
  padding: 18px 20px;
}

.connection-card > div {
  min-width: 330px;
}

.connection-card label {
  flex: 1;
}

.connection-card span,
label > span,
.guide-grid span {
  display: block;
  margin-bottom: 7px;
  color: #858da9;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.storage-hint {
  margin-top: 6px;
  color: #68718d;
  font-size: 10px;
}

code {
  color: #9ef5dd;
  font-family: "Cascadia Code", Consolas, monospace;
}

.connection-card code {
  display: block;
  overflow: hidden;
  padding: 12px 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  outline: 0;
  padding: 12px 14px;
  color: #f4f6ff;
  background: #090c1d;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #8e82ff;
  box-shadow: 0 0 0 3px rgba(142, 130, 255, 0.12);
}

textarea {
  resize: vertical;
  line-height: 1.65;
}

.status {
  border-radius: 999px;
  padding: 9px 12px;
  color: #b6bdd4;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  white-space: nowrap;
}

.status.checking {
  color: #d0c9ff;
  background: rgba(142, 130, 255, 0.12);
}

.status.success {
  border: 1px solid rgba(71, 255, 183, 0.36);
  color: #75ffd0;
  background: rgba(40, 215, 160, 0.16);
  box-shadow: 0 0 22px rgba(40, 215, 160, 0.16);
  font-weight: 900;
}

.status.error {
  border: 1px solid rgba(255, 91, 112, 0.28);
  color: #ff9aaa;
  background: rgba(255, 73, 103, 0.1);
}

#apiKey.verified {
  border-color: rgba(71, 255, 183, 0.7);
  box-shadow: 0 0 0 3px rgba(40, 215, 160, 0.12);
}

#apiKey.invalid {
  border-color: rgba(255, 91, 112, 0.62);
}

.model-tabs {
  gap: 12px;
  margin-top: 18px;
  border-radius: 18px;
  padding: 10px;
}

.model-tab {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 14px;
  color: #b9bfd3;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.model-tab.active {
  border-color: rgba(142, 130, 255, 0.35);
  color: #fff;
  background: rgba(124, 108, 255, 0.14);
}

.model-tab strong,
.model-tab small {
  display: block;
}

.model-tab small {
  margin-top: 4px;
  color: #747e9e;
  font-family: "Cascadia Code", Consolas, monospace;
}

.model-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  color: #0c0d19;
  background: linear-gradient(135deg, #9d91ff, #52e0c1);
  font-weight: 900;
}

.workspace {
  align-items: stretch;
  gap: 18px;
  margin-top: 18px;
}

.forms,
.result-panel {
  min-width: 0;
  border-radius: 22px;
  padding: 26px;
}

.forms {
  flex: 0.9;
}

.result-panel {
  flex: 1.1;
  min-height: 570px;
}

.generator-form {
  width: 100%;
}

.section-heading,
.result-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

h2 {
  margin: 0;
  font-size: 25px;
}

.section-heading > code {
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(83, 226, 193, 0.08);
  font-size: 11px;
}

label {
  display: grid;
  gap: 1px;
}

.keyboard-hint {
  margin-top: 7px;
  color: #68718d;
  font-size: 11px;
  text-align: right;
}

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

.form-row.image-options {
  grid-template-columns: 1fr 1fr 0.75fr;
}

.submit-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  border: 0;
  border-radius: 13px;
  padding: 14px 17px;
  color: #090b16;
  background: linear-gradient(100deg, #9d91ff, #55e3c3);
  font-weight: 900;
  cursor: pointer;
}

.submit-button:disabled {
  cursor: wait;
  filter: grayscale(0.4);
  opacity: 0.6;
}

#latency {
  color: #7e87a5;
  font-size: 12px;
}

.result-meta,
.conversation-controls {
  display: flex;
  align-items: center;
}

.result-meta {
  justify-content: flex-end;
  gap: 12px;
}

.conversation-controls {
  gap: 8px;
  color: #7e87a5;
  font-size: 12px;
}

.conversation-controls strong {
  color: #70e8cb;
}

#clearConversationButton {
  border: 1px solid rgba(255, 105, 123, 0.2);
  border-radius: 8px;
  padding: 6px 9px;
  color: #ff9baa;
  background: rgba(255, 72, 99, 0.07);
  cursor: pointer;
  font-size: 11px;
}

.empty-result {
  display: grid;
  min-height: 430px;
  place-items: center;
  align-content: center;
  color: #717a99;
  text-align: center;
}

.empty-result span {
  color: #8e82ff;
  font-size: 46px;
}

.empty-result p {
  max-width: 320px;
  line-height: 1.7;
}

#rawResult {
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #dce1f4;
  font-family: inherit;
  line-height: 1.75;
}

#textResult {
  min-height: 430px;
  max-height: 650px;
  overflow: auto;
  border-radius: 14px;
  padding: 22px;
  background:
    radial-gradient(circle at 100% 0%, rgba(82, 224, 193, 0.055), transparent 34%),
    #080b1a;
  scrollbar-color: rgba(130, 138, 170, 0.45) transparent;
}

.conversation-empty {
  display: grid;
  min-height: 385px;
  place-items: center;
  align-content: center;
  color: #717a99;
  text-align: center;
}

.conversation-empty span {
  color: #8e82ff;
  font-size: 42px;
}

.conversation-empty p {
  max-width: 320px;
  line-height: 1.7;
}

.conversation-turn {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 8px 2px 22px;
}

.conversation-turn + .conversation-turn {
  border-top: 1px solid rgba(255, 255, 255, 0.065);
  padding-top: 22px;
}

.conversation-message {
  display: grid;
  max-width: min(86%, 720px);
  gap: 5px;
}

.conversation-message.user {
  justify-self: end;
  justify-items: end;
}

.conversation-message.assistant {
  justify-self: start;
  justify-items: start;
}

.message-role {
  color: #7983a2;
  font-size: 11px;
  font-weight: 800;
}

.message-bubble {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px 16px 16px 5px;
  padding: 12px 15px;
  color: #dce1f4;
  background: rgba(25, 29, 52, 0.92);
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.conversation-message.user .message-bubble {
  border-color: rgba(142, 130, 255, 0.25);
  border-radius: 16px 16px 5px 16px;
  color: #f2f0ff;
  background: linear-gradient(135deg, rgba(115, 98, 225, 0.72), rgba(70, 91, 167, 0.62));
}

.conversation-message time {
  color: #606a89;
  font-size: 10px;
}

.conversation-turn.pending .conversation-message.assistant .message-bubble {
  color: #8c96b6;
  animation: conversation-pulse 1.25s ease-in-out infinite;
}

.conversation-turn.failed .conversation-message.assistant .message-bubble {
  border-color: rgba(255, 91, 112, 0.3);
  color: #ffacb8;
  background: rgba(92, 27, 42, 0.25);
}

.conversation-delete {
  position: absolute;
  right: 2px;
  bottom: 3px;
  border: 0;
  padding: 3px 0;
  color: #68718d;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
}

.conversation-delete:hover {
  color: #ff9baa;
}

@keyframes conversation-pulse {
  50% {
    opacity: 0.55;
  }
}

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

.media-grid img,
#videoPlayer {
  width: 100%;
  border-radius: 15px;
  background: #050711;
}

.media-grid img {
  min-height: 240px;
  object-fit: contain;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-track span {
  display: block;
  width: 4%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8e82ff, #52e0c1);
  transition: width 0.3s ease;
}

#videoStatus {
  color: #a0a8c2;
}

details {
  margin-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
}

summary {
  color: #7f89a6;
  cursor: pointer;
  font-size: 12px;
}

#rawResult {
  max-height: 260px;
  margin-top: 12px;
  font-size: 12px;
}

.api-guide {
  display: grid;
  grid-template-columns: 0.6fr 2fr;
  gap: 28px;
  margin-top: 18px;
  border-radius: 22px;
  padding: 26px;
}

.local-history {
  margin-top: 18px;
  border-radius: 22px;
  padding: 26px;
}

.history-heading,
.history-actions,
.history-tabs,
.history-card > header {
  display: flex;
  align-items: center;
}

.history-heading {
  justify-content: space-between;
  gap: 24px;
}

.history-heading h2 {
  margin-bottom: 8px;
}

.history-note {
  max-width: 760px;
  margin: 0;
  color: #858da9;
  font-size: 13px;
  line-height: 1.7;
}

.history-actions {
  justify-content: flex-end;
  gap: 12px;
}

#historyStorageStatus {
  color: #7f89a6;
  font-size: 12px;
  text-align: right;
}

.history-clear,
.history-delete {
  border: 1px solid rgba(255, 105, 123, 0.22);
  border-radius: 10px;
  color: #ff9baa;
  background: rgba(255, 72, 99, 0.08);
  cursor: pointer;
}

.history-clear {
  padding: 9px 12px;
  white-space: nowrap;
}

.history-delete {
  padding: 6px 9px;
  font-size: 11px;
}

.history-tabs {
  gap: 8px;
  margin-top: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}

.history-tab {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 14px;
  color: #9da5bf;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.history-tab span {
  display: inline-grid;
  min-width: 23px;
  height: 23px;
  margin-left: 5px;
  place-items: center;
  border-radius: 999px;
  color: #c9d0e8;
  background: rgba(255, 255, 255, 0.07);
  font-size: 11px;
}

.history-tab.active {
  border-color: rgba(142, 130, 255, 0.34);
  color: #fff;
  background: rgba(124, 108, 255, 0.14);
}

.history-content {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.history-empty {
  margin-top: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  padding: 34px;
  color: #747e9e;
  text-align: center;
}

.history-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px;
  background: rgba(6, 9, 23, 0.68);
}

.history-card.conversations {
  grid-column: 1 / -1;
}

.history-card > header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.history-card time {
  color: #747e9e;
  font-size: 11px;
}

.history-card section + section {
  margin-top: 10px;
}

.history-card section > span {
  display: block;
  margin-bottom: 5px;
  color: #8e82ff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.history-card pre {
  max-height: 180px;
  margin: 0;
  overflow: auto;
  border-radius: 10px;
  padding: 11px;
  color: #d7dcef;
  background: #070a18;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-media-button {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: #050711;
  cursor: zoom-in;
}

.history-media-button img,
.history-media-button video {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: contain;
  background: #050711;
}

.history-play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  color: #080a17;
  background: rgba(104, 232, 204, 0.9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
  transform: translate(-50%, -50%);
}

.history-media-details {
  padding-top: 11px;
}

.history-media-details p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 7px;
  color: #cbd1e5;
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-media-details small {
  color: #717b9b;
  line-height: 1.5;
}

#historyPreviewDialog {
  width: min(1180px, calc(100% - 28px));
  max-width: none;
  border: 0;
  padding: 0;
  color: #fff;
  border-radius: 20px;
  background: #070a17;
  box-shadow: 0 32px 120px rgba(0, 0, 0, 0.72);
}

#historyPreviewDialog::backdrop {
  background: rgba(2, 4, 12, 0.86);
  backdrop-filter: blur(8px);
}

.history-preview-card {
  position: relative;
  display: grid;
  min-height: 240px;
  place-items: center;
  padding: 18px;
}

.history-preview-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  color: #fff;
  background: rgba(6, 8, 18, 0.82);
  cursor: pointer;
  font-size: 27px;
  line-height: 1;
}

#historyPreviewContent,
#historyPreviewContent img,
#historyPreviewContent video {
  max-width: 100%;
  max-height: 86vh;
}

#historyPreviewContent img,
#historyPreviewContent video {
  display: block;
  margin: auto;
  object-fit: contain;
}

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

.guide-grid article {
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 13px;
  background: rgba(255, 255, 255, 0.025);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100% - 48px));
  border: 1px solid rgba(142, 130, 255, 0.3);
  border-radius: 12px;
  padding: 13px 16px;
  color: #e8e5ff;
  background: #17162c;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .workspace,
  .api-guide {
    display: grid;
    grid-template-columns: 1fr;
  }

  .connection-card {
    display: grid;
    align-items: stretch;
  }

  .history-content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .connection-card > div {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 22px, 1380px);
    padding-top: 26px;
  }

  .hero,
  .model-tabs {
    display: grid;
  }

  .dragon-seal {
    display: none;
  }

  .history-heading,
  .history-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .result-heading,
  .result-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-meta {
    gap: 8px;
  }

  .conversation-message {
    max-width: 94%;
  }

  #textResult {
    padding: 16px;
  }

  #historyStorageStatus {
    text-align: left;
  }

  .model-tab {
    flex: 1;
  }

  .model-tabs,
  .form-row,
  .form-row.image-options,
  .guide-grid,
  .media-grid {
    grid-template-columns: 1fr;
  }

  .forms,
  .result-panel,
  .api-guide,
  .local-history {
    padding: 20px;
  }

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

  .history-tabs {
    overflow-x: auto;
  }
}
