:root {
  color-scheme: light;
  --ink: #102a43;
  --muted: #627d98;
  --line: #d9e2ec;
  --paper: #f7fafc;
  --white: #ffffff;
  --blue: #168aad;
  --blue-dark: #0b7285;
  --blue-soft: #dff3f7;
  --orange: #f6a04d;
  --green: #5c946e;
  --shadow: 0 10px 30px rgba(16, 42, 67, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 26px 0 34px; }
.topbar { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 2px solid var(--blue); border-radius: 50%; color: var(--blue);
  font-size: 30px; line-height: 1; transform: rotate(-12deg);
}
.eyebrow { margin: 0 0 4px; color: var(--blue-dark); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: 24px; line-height: 1.1; }
.lesson-tag { margin-left: auto; color: var(--muted); font-size: 13px; }

.lesson-intro {
  display: flex; align-items: end; justify-content: space-between; gap: 24px;
  margin: 36px 0 22px; padding-bottom: 22px; border-bottom: 1px solid var(--line);
}
.lesson-intro h2 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 44px); line-height: 1.08; letter-spacing: 0; }
.lesson-intro p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 15px; }
.formula-chip { display: flex; align-items: center; gap: 14px; color: var(--blue-dark); font-size: 14px; white-space: nowrap; }
.formula-chip span { padding: 10px 14px; border: 1px solid #b7dfe5; border-radius: 6px; background: var(--blue-soft); }
.formula-chip strong { color: var(--orange); font-size: 20px; }

.workspace { display: grid; grid-template-columns: minmax(260px, 0.75fr) minmax(380px, 1.5fr) minmax(250px, 0.75fr); gap: 18px; align-items: stretch; }
.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--white); box-shadow: var(--shadow); }
.control-panel, .result-panel { padding: 24px; }
.panel-heading { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; }
.panel-heading h3, .scene-header h3 { margin: 0; font-size: 19px; }
.step-number { color: var(--orange); font-size: 12px; font-weight: 900; letter-spacing: 0.08em; }
.mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: -8px 0 9px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: #f7fafc; }
.mode-button { min-height: 34px; border: 0; border-radius: 4px; padding: 0 5px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; }
.mode-button.is-active { color: var(--white); background: var(--blue); }
.mode-description { min-height: 18px; margin: 0 0 16px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
.input-with-unit { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 5px; background: #fbfdff; overflow: hidden; }
.input-with-unit:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22, 138, 173, 0.12); }
input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 11px 10px; color: var(--ink); background: transparent; font-weight: 800; }
.input-with-unit em { padding-right: 10px; color: var(--muted); font-size: 12px; font-style: normal; white-space: nowrap; }
.button-row { display: flex; gap: 10px; margin-top: 24px; }
.button { min-height: 42px; border: 1px solid transparent; border-radius: 5px; padding: 0 14px; font-weight: 800; transition: transform 160ms ease, background 160ms ease, border-color 160ms ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { flex: 1; color: white; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-primary.is-playing { background: var(--orange); }
.button-icon { margin-right: 6px; }
.button-quiet { color: var(--muted); border-color: var(--line); background: white; }
.button-quiet:hover { color: var(--ink); border-color: #a8b8c7; }
.input-message { min-height: 18px; margin: 14px 0 0; color: #b54708; font-size: 12px; }

.scene-panel { min-width: 0; padding: 24px 24px 18px; overflow: hidden; }
.scene-header { display: flex; align-items: center; justify-content: space-between; }
.live-readout { display: grid; justify-items: end; gap: 2px; color: var(--muted); font-size: 11px; }
.live-readout strong { color: var(--blue); font-size: 23px; line-height: 1; }
.pool-scene { position: relative; height: 360px; margin: 8px -8px 0; overflow: hidden; background: #eaf6f8; }
.sun { position: absolute; top: 28px; right: 50px; width: 42px; height: 42px; border-radius: 50%; background: #ffd166; box-shadow: 0 0 0 10px rgba(255, 209, 102, 0.18); }
.cloud { position: absolute; height: 14px; border-radius: 20px; background: white; opacity: 0.9; }
.cloud::before, .cloud::after { content: ""; position: absolute; bottom: 0; border-radius: 50%; background: white; }
.cloud::before { left: 18px; width: 28px; height: 28px; }
.cloud::after { left: 42px; width: 20px; height: 20px; }
.cloud-one { top: 74px; left: 58px; width: 78px; }
.cloud-two { top: 120px; right: 122px; width: 60px; transform: scale(0.75); }
.pipe { position: absolute; top: 86px; left: 56%; width: 28px; height: 92px; border: 8px solid #7b8794; border-bottom: 0; border-radius: 10px 10px 0 0; transform: translateX(-50%); }
.input-pipe-two { display: none; top: 126px; left: 37%; }
.pipe::after { content: ""; position: absolute; left: 4px; bottom: -20px; width: 5px; height: 24px; border-radius: 0 0 5px 5px; background: #4db6ca; }
.water-drop { position: absolute; left: 2px; bottom: -32px; width: 9px; height: 15px; border-radius: 55% 55% 60% 60%; background: #168aad; animation: drip 1.1s ease-in infinite; }
@keyframes drip { 0%, 55% { opacity: 0; transform: translateY(-9px); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(18px); } }
.outlet-pipe { display: none; top: auto; bottom: 116px; left: 88%; width: 44px; height: 28px; border: 0; border-right: 8px solid #7b8794; border-bottom: 8px solid #7b8794; border-radius: 0 0 10px 0; transform: none; }
.outlet-pipe::after { left: auto; right: -16px; bottom: -20px; }
.drain-drop { left: auto; right: -19px; bottom: -35px; animation-delay: 0.4s; }
.pool-scene[data-mode="dual-in"] .input-pipe-two { display: block; }
.pool-scene[data-mode="in-out"] .outlet-pipe { display: block; }
.pool-shadow { position: absolute; right: 14%; bottom: 47px; left: 14%; height: 22px; border-radius: 50%; background: rgba(16, 42, 67, 0.15); filter: blur(4px); }
.pool { position: absolute; right: 12%; bottom: 58px; left: 12%; height: 162px; overflow: hidden; border: 8px solid #415a70; border-radius: 8px 8px 22px 22px; background: #e9eef2; box-shadow: 0 12px 0 #c7d1da, 0 18px 0 rgba(16, 42, 67, 0.12); }
.water { position: absolute; right: 0; bottom: 0; left: 0; height: 0%; overflow: hidden; background: #168aad; transition: height 160ms linear; }
.wave { position: absolute; top: -8px; width: 140%; height: 20px; border-radius: 48%; border-top: 4px solid rgba(255, 255, 255, 0.42); }
.wave-one { left: -20%; animation: wave 3s linear infinite; }
.wave-two { left: -50%; opacity: 0.38; animation: wave 4.5s linear reverse infinite; }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(20%); } }
.pool-depth { position: absolute; right: 12px; bottom: 10px; color: rgba(16, 42, 67, 0.62); font-size: 11px; font-weight: 800; }
.scene-ground { position: absolute; right: -5%; bottom: 0; left: -5%; height: 58px; background: #b7d7bd; border-top: 5px solid #91bd9b; }
.animation-status { display: flex; align-items: center; gap: 8px; min-height: 24px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #a8b8c7; }
.status-dot.is-active { background: var(--orange); box-shadow: 0 0 0 4px rgba(246, 160, 77, 0.15); }
.status-dot.is-done { background: var(--green); }
.status-time { margin-left: auto; font-variant-numeric: tabular-nums; }

.result-list { border-top: 1px solid var(--line); }
.result-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 17px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.result-line strong { color: var(--ink); font-size: 16px; white-space: nowrap; }
.result-highlight { margin: 0 -8px; padding: 17px 8px; background: #fff7eb; }
.result-highlight strong { color: #b95e08; }
.hint-box { display: flex; gap: 10px; margin-top: 26px; padding: 13px; border-left: 3px solid var(--orange); background: #fffaf3; color: var(--muted); font-size: 12px; line-height: 1.8; }
.hint-box p { margin: 0; }
.hint-icon { display: grid; place-items: center; flex: 0 0 19px; height: 19px; border-radius: 50%; color: white; background: var(--orange); font-weight: 900; }

.app-footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 20px; color: var(--muted); font-size: 12px; }
.app-footer span:last-child { text-align: right; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 1fr 1.35fr; }
  .result-panel { grid-column: 1 / -1; }
  .result-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; border: 0; }
  .result-line { display: block; padding: 14px; border: 1px solid var(--line); border-radius: 5px; }
  .result-line strong { display: block; margin-top: 8px; }
  .result-highlight { margin: 0; background: #fff7eb; }
  .hint-box { margin-top: 16px; }
}

@media (max-width: 700px) {
  .app-shell { width: min(100% - 28px, 560px); padding-top: 18px; }
  .lesson-tag { display: none; }
  .lesson-intro { display: block; margin-top: 28px; }
  .formula-chip { margin-top: 18px; }
  .workspace { display: flex; flex-direction: column; }
  .scene-panel { order: -1; }
  .pool-scene { height: 290px; }
  .pool { right: 8%; left: 8%; }
  .pipe { left: 60%; }
  .result-list { display: block; }
  .result-line, .result-highlight { display: flex; margin: 0; border-radius: 0; border-right: 0; border-left: 0; }
  .result-line strong { margin-top: 0; }
  .app-footer { display: block; line-height: 1.8; }
  .app-footer span:last-child { display: block; text-align: left; }
}
