:root {
  color-scheme: light;
  --bg: #f5f1ea;
  --surface: #fffaf3;
  --surface-strong: #ffffff;
  --ink: #231f1a;
  --muted: #71685e;
  --line: #ded2c2;
  --accent: #0f6f68;
  --accent-strong: #0a554f;
  --coffee: #7b4a28;
  --gold: #d6a23a;
  --danger: #b84b3d;
  --shadow: 0 18px 42px rgba(40, 31, 23, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(120deg, rgba(15, 111, 104, 0.1), transparent 34%),
    linear-gradient(180deg, #fbf8f2 0%, var(--bg) 100%);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans SC",
    system-ui,
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-header,
.section-heading,
.chart-header,
.legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-header {
  margin-bottom: 20px;
}

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

h1,
h2,
p,
dl {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 3.4vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 1.12rem;
  letter-spacing: 0;
}

.header-note {
  max-width: 420px;
  color: var(--muted);
  line-height: 1.7;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(560px, 1.18fr);
  gap: 20px;
  align-items: start;
}

.control-panel,
.chart-panel {
  display: grid;
  gap: 16px;
}

.panel,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.94);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.chart-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.mode-tabs label {
  min-width: 0;
}

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

.mode-tabs span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf9;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.mode-tabs input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.mode-note,
.formula,
.form-error,
.verdict {
  line-height: 1.6;
}

.mode-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.93rem;
}

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

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

label small {
  color: var(--coffee);
  font-size: 0.78rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf9;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background-color 0.16s ease;
}

input:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 111, 104, 0.16);
}

.ghost-button {
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--coffee);
  font-weight: 800;
  white-space: nowrap;
}

.form-error {
  min-height: 1.6em;
  margin-top: 10px;
  color: var(--danger);
  font-size: 0.9rem;
}

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

.metrics-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.metrics-grid dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.metrics-grid dd {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: clamp(1.22rem, 2.1vw, 1.72rem);
  font-weight: 900;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.verdict {
  margin-top: 14px;
  color: var(--coffee);
  font-weight: 800;
}

.formula {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-header {
  align-items: flex-start;
}

.chart-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  background: #efe7dc;
  color: var(--coffee);
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
}

.chart-status.success {
  background: rgba(15, 111, 104, 0.12);
  color: var(--accent);
}

.chart-status.warning {
  background: rgba(184, 75, 61, 0.12);
  color: var(--danger);
}

.chart-frame {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9;
}

#brewChart {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 620;
}

.grid-line {
  stroke: #eadfce;
  stroke-width: 1;
}

.plot-border {
  fill: none;
  stroke: #8d8072;
  stroke-width: 1.4;
}

.target-zone {
  fill: rgba(214, 162, 58, 0.18);
  stroke: var(--gold);
  stroke-width: 2;
}

.target-label {
  fill: #8b6215;
  font-size: 18px;
  font-weight: 900;
}

.ratio-line {
  stroke: rgba(15, 111, 104, 0.42);
  stroke-width: 1.6;
  stroke-dasharray: 8 7;
}

.point-guide {
  stroke: rgba(184, 75, 61, 0.34);
  stroke-width: 1.2;
  stroke-dasharray: 5 5;
}

.brew-point-ring {
  fill: rgba(184, 75, 61, 0.16);
  stroke: rgba(184, 75, 61, 0.52);
  stroke-width: 2;
}

.brew-point {
  fill: var(--danger);
  stroke: #ffffff;
  stroke-width: 3;
}

.axis-label,
.ratio-label,
.chart-caption {
  fill: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.axis-title {
  fill: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.point-label,
.out-label {
  fill: var(--danger);
  font-size: 17px;
  font-weight: 900;
}

.legend {
  justify-content: flex-start;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  width: 18px;
  height: 10px;
  border-radius: 999px;
}

.legend-target {
  background: rgba(214, 162, 58, 0.28);
  border: 1px solid var(--gold);
}

.legend-ratio {
  background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 11px);
}

.legend-point {
  background: var(--danger);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .app-header,
  .section-heading,
  .chart-header {
    align-items: flex-start;
  }

  .app-header {
    display: grid;
  }

  .panel,
  .chart-panel {
    padding: 14px;
  }

  .mode-tabs,
  .input-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .chart-status {
    white-space: normal;
  }
}
