:root {
  --bg: #f5f3ee;
  --surface: #fffdfa;
  --surface-strong: #ffffff;
  --ink: #18211f;
  --muted: #65716e;
  --line: #ddd8cf;
  --primary: #0f766e;
  --primary-dark: #0a5d58;
  --accent: #d97706;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(24, 33, 31, 0.09);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.11), transparent 34%),
    linear-gradient(315deg, rgba(217, 119, 6, 0.12), transparent 28%),
    var(--bg);
  min-height: 100vh;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app-header,
.app-shell,
.history-panel {
  width: min(1440px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 30px 0 20px;
}

.app-header h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}

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

.header-actions,
.button-row,
.panel-title-row,
.history-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions,
.history-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.side-stack {
  display: grid;
  gap: 18px;
  position: sticky;
  top: 14px;
}

.panel {
  background: rgba(255, 253, 250, 0.95);
  border: 1px solid rgba(221, 216, 207, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel-title-row {
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel h2 {
  font-size: 20px;
}

.feedback-form,
.settings-grid {
  display: grid;
  gap: 16px;
}

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

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

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
  padding: 11px 12px;
  min-height: 44px;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.8);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.13);
}

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

.full-width {
  grid-column: 1 / -1;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  border-radius: 8px;
  min-height: 42px;
  padding: 0 15px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
}

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

.secondary-btn {
  background: #e6f2ef;
  color: var(--primary-dark);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.danger-btn {
  background: #fff1ef;
  color: var(--danger);
}

.status-pill {
  display: inline-grid;
  place-items: center;
  align-self: flex-start;
  border-radius: 999px;
  background: #f3eadc;
  color: #7a4a07;
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.ready {
  background: #dff6ef;
  color: var(--primary-dark);
}

.button-row {
  margin-top: 16px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin: 12px 0 0;
}

.output-panel textarea {
  min-height: 250px;
}

.toast {
  color: var(--primary-dark);
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 700;
}

.history-panel {
  margin-top: 18px;
  margin-bottom: 32px;
}

.history-tools input {
  width: min(360px, 100%);
}

.history-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.history-item h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.history-meta,
.history-preview {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-stack {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-header,
  .app-shell,
  .history-panel {
    width: min(100% - 20px, 1440px);
  }

  .app-header,
  .panel-title-row,
  .history-item {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header {
    padding-top: 20px;
  }

  .header-actions,
  .history-tools,
  .button-row,
  .history-actions {
    justify-content: stretch;
  }

  .header-actions button,
  .button-row button,
  .history-actions button,
  .history-tools input {
    flex: 1 1 auto;
  }

  .two-columns,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

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