:root {
  --bg: #f7f3ee;
  --surface: #fffdf9;
  --surface-strong: #ffffff;
  --ink: #211b18;
  --muted: #6f625b;
  --line: #ded4cb;
  --accent: #b23a52;
  --accent-dark: #87283d;
  --teal: #14746f;
  --shadow: 0 22px 55px rgba(47, 31, 25, 0.12);
  --radius: 8px;
  color-scheme: light;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(178, 58, 82, 0.08), transparent 30%),
    linear-gradient(250deg, rgba(20, 116, 111, 0.1), transparent 28%),
    var(--bg);
}

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

button {
  cursor: pointer;
}

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

.topbar,
.workspace,
.dialog-header,
.dialog-body,
.editor-title,
.actions,
.add-row,
.result-header {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  font-size: clamp(30px, 5vw, 52px);
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 18px;
}

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

.control-panel,
.result-panel,
.option-dialog {
  background: rgba(255, 253, 249, 0.92);
  border: 1px solid rgba(222, 212, 203, 0.88);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.control-panel {
  width: min(100%, 480px);
  padding: 20px;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

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

textarea,
input {
  padding: 12px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(178, 58, 82, 0.72);
  box-shadow: 0 0 0 4px rgba(178, 58, 82, 0.12);
}

.full-field {
  margin-top: 16px;
}

.full-field textarea {
  resize: vertical;
  min-height: 104px;
}

.actions {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.secondary-button,
.icon-text-button,
.square-button {
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button {
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
}

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

.secondary-button,
.icon-text-button,
.square-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
}

.secondary-button:hover,
.icon-text-button:hover,
.square-button:hover {
  border-color: rgba(178, 58, 82, 0.45);
}

.icon-text-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}

.square-button {
  width: 42px;
  padding: 0;
  font-size: 24px;
}

.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.result-panel {
  flex: 1;
  min-width: 0;
  padding: 20px;
}

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

#statusText {
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

#promptOutput {
  width: 100%;
  min-height: 560px;
  resize: vertical;
  line-height: 1.75;
  font-size: 15px;
}

.option-dialog {
  width: min(920px, calc(100% - 28px));
  padding: 0;
}

.option-dialog::backdrop {
  background: rgba(26, 20, 18, 0.42);
  backdrop-filter: blur(5px);
}

.dialog-header {
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-body {
  min-height: 480px;
}

.category-tabs {
  width: 220px;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: rgba(247, 243, 238, 0.6);
}

.category-tab {
  display: block;
  width: 100%;
  min-height: 38px;
  margin-bottom: 8px;
  padding: 0 12px;
  text-align: left;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  font-weight: 800;
}

.category-tab[aria-selected="true"] {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.option-editor {
  flex: 1;
  min-width: 0;
  padding: 18px;
}

.editor-title {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.option-list {
  display: grid;
  gap: 10px;
  max-height: 330px;
  overflow: auto;
  padding-right: 4px;
}

.option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}

.delete-option {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--accent-dark);
  background: #fff;
  font-weight: 900;
}

.add-row {
  gap: 8px;
  margin-top: 14px;
}

.add-row input {
  min-height: 40px;
}

@media (max-width: 860px) {
  .workspace,
  .dialog-body {
    flex-direction: column;
  }

  .control-panel {
    width: 100%;
  }

  #promptOutput {
    min-height: 360px;
  }

  .category-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

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

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

  .control-panel,
  .result-panel,
  .option-editor {
    padding: 14px;
  }
}
