:root {
  color-scheme: light;
  --page: #f3f6f7;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #182126;
  --muted: #6b777d;
  --line: #d9e2e6;
  --line-strong: #bdcbd1;
  --primary: #1587a4;
  --primary-dark: #0b657c;
  --primary-soft: #e5f4f7;
  --green: #2c8065;
  --green-soft: #e7f3ee;
  --coral: #c95e49;
  --coral-soft: #fff0ec;
  --violet: #7466a0;
  --violet-soft: #f1eef8;
  --radius: 7px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(21, 135, 164, 0.2);
  outline-offset: 2px;
}

h1,
h2,
p {
  margin: 0;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.topbar {
  display: flex;
  position: sticky;
  z-index: 20;
  top: 0;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  color: #ffffff;
  background: #202c31;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.25;
}

.brand p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  color: #aebbc0;
  font-size: 11px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #819096;
}

.model-ready .status-dot {
  background: #57bd98;
  box-shadow: 0 0 0 3px rgba(87, 189, 152, 0.13);
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 0;
  place-items: center;
  color: #435159;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
}

.icon-button.dark {
  color: #dbe5e8;
  border-color: #415057;
  background: #29363c;
}

.view-tabs {
  display: grid;
  position: sticky;
  z-index: 18;
  top: 72px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 49px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.view-tab {
  display: inline-flex;
  position: relative;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.view-tab.active {
  color: var(--primary-dark);
}

.view-tab.active::after {
  content: "";
  position: absolute;
  inset: auto 22% 0;
  height: 2px;
  background: var(--primary);
}

main {
  width: min(100%, 860px);
  margin: 0 auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#feedbackForm {
  border-inline: 1px solid var(--line);
  background: var(--surface);
}

.form-section {
  padding: 23px 18px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 18px;
}

.section-heading > span {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  place-items: center;
  color: var(--primary-dark);
  border: 1px solid #b8dce4;
  border-radius: 50%;
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 800;
}

.section-heading h2,
.result-section h2,
.history-header h2,
.settings-card h2 {
  font-size: 17px;
  line-height: 1.35;
}

.section-heading p,
.history-header p,
.settings-card header p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field-grid {
  display: grid;
  gap: 15px;
}

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

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #354147;
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field textarea,
#feedbackOutput {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: 0;
  background: #ffffff;
}

.field input {
  height: 43px;
  padding: 0 11px;
}

.field textarea {
  min-height: 82px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.55;
}

.field input:focus,
.field textarea:focus,
#feedbackOutput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 135, 164, 0.1);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #98a4aa;
}

.topic-field {
  margin-top: 15px;
}

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

.upload-box {
  display: grid;
  position: relative;
  min-width: 0;
  min-height: 220px;
  padding: 18px 12px;
  place-items: center;
  align-content: center;
  overflow: hidden;
  text-align: center;
  border: 1px dashed #aebdc3;
  border-radius: var(--radius);
  background: var(--surface-soft);
  cursor: pointer;
}

.upload-box.has-files {
  border-color: var(--primary);
  background: #f2fafb;
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius);
}

.upload-icon.cyan {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.upload-icon.coral {
  color: #a84332;
  background: var(--coral-soft);
}

.upload-icon.green {
  color: var(--green);
  background: var(--green-soft);
}

.upload-icon.violet {
  color: var(--violet);
  background: var(--violet-soft);
}

.upload-box strong {
  margin-top: 9px;
  font-size: 14px;
}

.upload-box small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  margin-top: 12px;
  padding: 0 10px;
  color: var(--primary-dark);
  border: 1px solid #b8dce4;
  border-radius: var(--radius);
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.upload-button svg {
  width: 15px;
  height: 15px;
}

.file-count {
  margin-top: 6px;
  color: #849197;
  font-size: 11px;
}

.image-preview {
  display: flex;
  width: 100%;
  max-width: 220px;
  height: 0;
  margin-top: 0;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
}

.upload-box.has-files .image-preview {
  height: 38px;
  margin-top: 9px;
}

.image-preview img,
.image-preview em {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  object-fit: cover;
}

.image-preview em {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #ffffff;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
}

.optional-images {
  margin-top: 13px;
  border-top: 1px solid var(--line);
}

.optional-images summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 13px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.optional-images summary::-webkit-details-marker {
  display: none;
}

.optional-images[open] summary {
  margin-bottom: 13px;
}

.optional-grid .compact {
  min-height: 165px;
}

.generate-bar {
  position: sticky;
  z-index: 12;
  bottom: 0;
  padding: 12px 18px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.primary-button,
.secondary-button,
.quiet-button,
.copy-button {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 750;
}

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

.secondary-button {
  color: var(--primary-dark);
  border: 1px solid #b8dce4;
  background: var(--primary-soft);
}

.quiet-button {
  color: #a84332;
  background: transparent;
}

.copy-button {
  color: #ffffff;
  background: #253137;
}

#generateButton {
  width: 100%;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.result-section {
  margin-top: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.result-section header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.result-section header p {
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 750;
}

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

#feedbackOutput {
  min-height: 520px;
  padding: 14px;
  resize: vertical;
  font-size: 14px;
  line-height: 1.75;
}

.result-section footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.history-view {
  min-height: calc(100vh - 121px);
  padding: 20px 16px 40px;
  border-inline: 1px solid var(--line);
  background: #ffffff;
}

.history-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.history-header > span {
  color: var(--muted);
  font-size: 12px;
}

.history-list {
  display: grid;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 15px 2px;
  border-bottom: 1px solid var(--line);
}

.history-item strong,
.history-item p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.history-actions {
  display: flex;
  grid-row: 1 / 3;
  grid-column: 2;
  align-items: center;
  gap: 6px;
}

.history-actions button {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  color: #49575e;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.history-empty {
  display: grid;
  min-height: 320px;
  place-items: center;
  align-content: center;
  color: var(--muted);
  text-align: center;
}

.history-empty span {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 12px;
  place-items: center;
  color: var(--primary-dark);
  border-radius: 50%;
  background: var(--primary-soft);
}

.history-empty p {
  margin-top: 4px;
  font-size: 12px;
}

dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  overflow-y: auto;
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(20, 29, 34, 0.25);
}

dialog::backdrop {
  background: rgba(19, 27, 31, 0.55);
  backdrop-filter: blur(3px);
}

.settings-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  background: #ffffff;
}

.settings-card header {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
}

.settings-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--primary-dark);
  border-radius: var(--radius);
  background: var(--primary-soft);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #425057;
  font-size: 13px;
}

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

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 10px;
  color: #526168;
  border: 1px solid #cfe1d9;
  border-radius: var(--radius);
  background: var(--green-soft);
  font-size: 11px;
  line-height: 1.5;
}

.security-note svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--green);
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.loading-overlay {
  display: grid;
  position: fixed;
  z-index: 50;
  inset: 0;
  padding: 20px;
  place-items: center;
  background: rgba(20, 29, 34, 0.58);
  backdrop-filter: blur(4px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-panel {
  display: grid;
  width: min(100%, 320px);
  padding: 28px;
  place-items: center;
  text-align: center;
  border-radius: var(--radius);
  background: #ffffff;
}

.loading-panel p,
.loading-panel > span:last-child {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.spinner {
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
  border: 3px solid #dbe9ec;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

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

.toast {
  position: fixed;
  z-index: 70;
  right: 14px;
  bottom: calc(14px + var(--safe-bottom));
  left: 14px;
  max-width: 460px;
  margin: auto;
  padding: 11px 13px;
  color: #ffffff;
  border-radius: var(--radius);
  background: #263238;
  box-shadow: 0 12px 34px rgba(20, 29, 34, 0.2);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #9f4433;
}

@media (max-width: 620px) {
  .two-cols,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .form-section {
    padding: 21px 15px;
  }

  .upload-box {
    min-height: 210px;
  }

  .settings-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .settings-actions button {
    width: 100%;
  }

  .result-section {
    margin-top: 8px;
    padding: 15px;
  }

  .result-section header {
    align-items: flex-start;
  }

  .copy-button {
    width: 40px;
    padding: 0;
    font-size: 0;
  }
}

@media (min-width: 861px) {
  body {
    padding-bottom: 40px;
  }

  .topbar,
  .view-tabs {
    padding-inline: max(24px, calc((100vw - 860px) / 2));
  }

  .generate-bar {
    position: static;
  }
}
