:root {
  color-scheme: light;
  --bg-1: #f4f8f4;
  --bg-2: #dfeee3;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --text: #173222;
  --muted: #627064;
  --line: rgba(23, 50, 34, 0.1);
  --primary: #1f7a45;
  --primary-strong: #165b33;
  --warning: #c67d10;
  --danger: #be3d3d;
  --success: #1d7a57;
  --shadow: 0 18px 42px rgba(22, 58, 38, 0.12);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(31, 122, 69, 0.22), transparent 35%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(23, 50, 34, 0.08);
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.95em;
}

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

.page-shell {
  width: min(1120px, calc(100% - 20px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.hero-card,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  margin-bottom: 16px;
}

.hero-card {
  padding: 22px 20px 18px;
}

.card {
  padding: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(30px, 5vw, 42px);
}

h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.hero-copy,
.muted {
  color: var(--muted);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.pill-neutral {
  background: rgba(31, 122, 69, 0.1);
  color: var(--primary-strong);
}

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

.field,
fieldset.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.field span,
.field legend {
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(23, 50, 34, 0.12);
  border-radius: var(--radius-md);
  padding: 14px 15px;
  color: var(--text);
  background: var(--surface-strong);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(31, 122, 69, 0.72);
  box-shadow: 0 0 0 4px rgba(31, 122, 69, 0.12);
  transform: translateY(-1px);
}

textarea {
  resize: vertical;
  min-height: 130px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.segment {
  position: relative;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(23, 50, 34, 0.12);
  background: var(--surface-strong);
  font-weight: 700;
  color: var(--muted);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.segment input:checked + span {
  background: rgba(31, 122, 69, 0.14);
  border-color: rgba(31, 122, 69, 0.44);
  color: var(--primary-strong);
  transform: translateY(-1px);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  box-shadow: 0 14px 30px rgba(22, 91, 51, 0.2);
}

.secondary-button {
  background: rgba(31, 122, 69, 0.11);
  color: var(--primary-strong);
}

.ghost-button {
  background: rgba(23, 50, 34, 0.07);
  color: var(--text);
}

.danger-button {
  background: rgba(190, 61, 61, 0.12);
  color: var(--danger);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.status-text {
  min-height: 22px;
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 700;
}

.status-text.success {
  color: var(--success);
}

.status-text.warning {
  color: var(--warning);
}

.status-text.error {
  color: var(--danger);
}

.analysis-stack {
  display: grid;
  gap: 12px;
}

.analysis-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  overflow: hidden;
}

.analysis-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 0;
}

.analysis-card-head h3 {
  margin-bottom: 0;
}

.analysis-card-body {
  padding: 12px 16px 16px;
}

.analysis-card-body p {
  margin-bottom: 10px;
  line-height: 1.7;
}

.analysis-list,
.analysis-ordered {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

.analysis-list li,
.analysis-ordered li {
  margin-bottom: 8px;
}

.analysis-tone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.tone-green {
  border-left: 5px solid #2f9d62;
}

.tone-green .analysis-tone {
  background: rgba(47, 157, 98, 0.14);
  color: #1b6f44;
}

.tone-yellow {
  border-left: 5px solid #d39d23;
}

.tone-yellow .analysis-tone {
  background: rgba(211, 157, 35, 0.14);
  color: #8a6200;
}

.tone-red {
  border-left: 5px solid #d24f4f;
}

.tone-red .analysis-tone {
  background: rgba(210, 79, 79, 0.14);
  color: #952f2f;
}

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

.trend-item {
  border-radius: var(--radius-md);
  border: 1px solid rgba(23, 50, 34, 0.08);
  background: rgba(245, 250, 247, 0.95);
  padding: 12px;
}

.trend-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.trend-value {
  font-size: 18px;
  font-weight: 800;
}

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

.history-item {
  display: grid;
  gap: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  padding: 14px;
}

.history-item.is-selected {
  border-color: rgba(31, 122, 69, 0.36);
  box-shadow: 0 10px 24px rgba(31, 122, 69, 0.08);
}

.history-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-title-row h3 {
  margin-bottom: 0;
}

.history-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-mini-pill {
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(31, 122, 69, 0.1);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
}

.history-meta,
.history-preview {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.empty-state {
  border: 1px dashed rgba(23, 50, 34, 0.18);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.68);
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

@media (min-width: 760px) {
  .page-shell {
    width: min(1120px, calc(100% - 36px));
    padding-top: 28px;
  }

  .hero-card {
    padding: 28px 28px 24px;
  }

  .card {
    padding: 22px;
  }

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

  .history-item {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

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

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