:root {
  color-scheme: light;
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --ink: #17211d;
  --muted: #66736c;
  --line: #dbe2dd;
  --accent: #176b55;
  --accent-strong: #0e4f41;
  --blue: #315d8c;
  --amber: #9b6b13;
  --rose: #8c3f4f;
  --shadow: 0 18px 60px rgba(29, 39, 34, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 760px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

body {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(380px, 440px) minmax(0, 1fr);
  min-height: 100vh;
}

.input-pane {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 26px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  overflow: auto;
}

.brand-bar,
.workspace-header,
.section-heading,
.form-actions,
.toolbar,
.score-row,
.tabs {
  display: flex;
  align-items: center;
}

.brand-bar,
.workspace-header,
.form-actions {
  justify-content: space-between;
  gap: 16px;
}

.brand-bar {
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 27px;
  line-height: 1.18;
}

.workspace-header h2 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.18;
}

.status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid #bfd7ce;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #eaf5ef;
  font-size: 13px;
  font-weight: 700;
}

.generator-form,
.form-section {
  display: flex;
  flex-direction: column;
}

.generator-form {
  gap: 18px;
}

.form-section {
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.section-heading {
  gap: 12px;
}

.section-heading h2 {
  margin-bottom: 3px;
  font-size: 16px;
}

.section-heading p,
.empty-state p,
.image-preview p {
  margin-bottom: 0;
  color: var(--muted);
}

.section-heading p {
  font-size: 13px;
  line-height: 1.45;
}

.step-badge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #314139;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd9d3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 112px;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 85, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: #9aa59f;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.image-preview {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid #cfd9d3;
  border-radius: 8px;
  background: #ffffff;
}

.image-preview img {
  width: 74px;
  height: 74px;
  border-radius: 8px;
  object-fit: cover;
  background: #edf1ef;
}

.image-preview strong {
  display: block;
  overflow: hidden;
  margin-bottom: 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-field {
  gap: 8px;
}

.upload-control {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 6px;
  border: 1px solid #cfd9d3;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.upload-control input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  color: #ffffff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.upload-file-name {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 12px 28px rgba(23, 107, 85, 0.22);
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  color: var(--accent-strong);
  background: #eaf5ef;
}

.secondary-action:hover {
  background: #deeee6;
}

.workspace {
  min-width: 0;
  padding: 26px 30px 30px;
  overflow: auto;
}

.workspace-header {
  margin-bottom: 18px;
}

.toolbar {
  gap: 8px;
}

.icon-button,
.export-action {
  display: grid;
  place-items: center;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
}

.icon-button {
  width: 42px;
}

.export-action {
  grid-template-columns: auto auto;
  gap: 8px;
  width: auto;
  padding: 0 13px;
  font-weight: 800;
}

.export-action span {
  white-space: nowrap;
}

.icon-button:hover:not(:disabled),
.export-action:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button:disabled,
.export-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button svg,
.export-action svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.score-card {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.score-card span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.score-card strong {
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
}

.score-card:nth-child(2) strong {
  color: var(--blue);
}

.score-card:nth-child(3) strong {
  color: var(--amber);
}

.score-card:nth-child(4) strong {
  color: var(--rose);
}

.tabs {
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.tab-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.tab-button.active {
  color: #ffffff;
  background: var(--ink);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 460px;
  margin-top: 16px;
  border: 1px dashed #b9c5be;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  text-align: center;
  padding: 34px;
}

.empty-state h2 {
  max-width: 570px;
  margin: 16px auto 9px;
  font-size: 24px;
}

.empty-state p {
  max-width: 540px;
  line-height: 1.7;
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 20px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(23, 107, 85, 0.96), rgba(49, 93, 140, 0.92)),
    #176b55;
  font-size: 23px;
  font-weight: 900;
}

.result-area {
  margin-top: 16px;
}

.output-panel {
  display: none;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.output-panel.active {
  display: block;
}

.output-panel h1,
.output-panel h2,
.output-panel h3 {
  color: var(--ink);
  line-height: 1.28;
}

.output-panel h1 {
  margin-bottom: 16px;
  font-size: 30px;
}

.output-panel h2 {
  margin: 28px 0 10px;
  padding-top: 4px;
  font-size: 22px;
}

.output-panel h3 {
  margin: 20px 0 8px;
  font-size: 17px;
}

.output-panel p,
.output-panel li,
.output-panel td,
.output-panel th {
  color: #314139;
  font-size: 15px;
  line-height: 1.75;
}

.output-panel p {
  margin-bottom: 13px;
}

.output-panel ul,
.output-panel ol {
  margin: 8px 0 16px;
  padding-left: 22px;
}

.output-panel table {
  width: 100%;
  margin: 16px 0 20px;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.output-panel th,
.output-panel td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.output-panel th {
  color: #203028;
  background: #eef4f1;
  font-weight: 800;
}

.output-panel tr:last-child td {
  border-bottom: 0;
}

.meta-box,
.answer-box,
.warning-box {
  margin: 16px 0;
  padding: 16px;
  border-radius: 8px;
}

.meta-box {
  border: 1px solid #ccd9e6;
  background: #f1f6fb;
}

.answer-box {
  border-left: 4px solid var(--accent);
  background: #edf6f1;
}

.warning-box {
  border: 1px solid #ead7ae;
  background: #fff8e8;
}

.label-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #244238;
  background: #e8f1ed;
  font-size: 13px;
  font-weight: 800;
}

.code-panel pre,
.schema-block {
  overflow: auto;
  margin: 0;
  padding: 18px;
  border-radius: 8px;
  color: #dbeee6;
  background: #14211c;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.check-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.check-row:last-child {
  border-bottom: 0;
}

.check-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(23, 33, 29, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
}

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

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 380px minmax(0, 1fr);
  }

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

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

@media (max-width: 860px) {
  body {
    min-height: 100vh;
  }

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

  .input-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    flex-wrap: wrap;
  }

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

@media (max-width: 560px) {
  .input-pane,
  .workspace {
    padding: 22px 16px;
  }

  h1 {
    font-size: 25px;
  }

  .workspace-header h2,
  .output-panel h1 {
    font-size: 24px;
  }

  .form-section,
  .output-panel {
    padding: 16px;
  }

  .field-grid,
  .score-row {
    grid-template-columns: 1fr;
  }

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

  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab-button {
    flex: 0 0 auto;
  }

  .output-panel table {
    display: block;
    overflow-x: auto;
  }

  .toast {
    right: 16px;
    left: 16px;
    max-width: none;
  }
}
