:root {
  color-scheme: dark;
  --bg: #08111c;
  --panel: #101b2a;
  --panel-2: #142234;
  --panel-3: #0b1521;
  --line: #26384d;
  --line-soft: rgba(108, 137, 168, .18);
  --text: #edf5fb;
  --muted: #8da0b5;
  --muted-2: #61748b;
  --teal: #63ddd0;
  --teal-dark: #123b3d;
  --orange: #f5bd68;
  --red: #ff7f7b;
  --blue: #82a4ff;
  --radius: 16px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 82% -10%, #183c4a 0, transparent 34%), var(--bg); color: var(--text); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.app-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 16px 22px; border-right: 1px solid var(--line); background: rgba(8, 17, 28, .92); backdrop-filter: blur(16px); display: flex; flex-direction: column; z-index: 5; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 34px; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid rgba(99, 221, 208, .7); border-radius: 10px; color: var(--teal); background: rgba(99, 221, 208, .05); font-weight: 900; }
.brand strong { display: block; letter-spacing: .13em; font-size: 15px; }
.brand small { display: block; margin-top: 4px; color: var(--muted-2); font: 8px ui-monospace, monospace; letter-spacing: .08em; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 12px 13px; border: 1px solid transparent; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 13px; transition: .2s ease; }
.nav-item span { color: var(--muted-2); font: 10px ui-monospace, monospace; }
.nav-item:hover, .nav-item.active { color: var(--text); border-color: var(--line-soft); background: #132235; }
.nav-item.active span { color: var(--teal); }
.side-note { margin-top: auto; padding: 12px 10px; color: var(--muted-2); font-size: 10px; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 12px rgba(99, 221, 208, .7); }

.main-content { width: 100%; max-width: 1520px; margin: 0 auto; padding: 0 clamp(22px, 4.5vw, 72px) 40px; }
.topbar { height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); color: var(--muted-2); font-size: 11px; }
.crumb span { margin: 0 7px; color: #3f5269; }
.top-status { display: flex; align-items: center; gap: 14px; }
.status-badge { color: var(--teal); font: 9px ui-monospace, monospace; letter-spacing: .08em; }
.version { color: #52667d; }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 34px; padding: 38px 0 30px; }
.eyebrow, .result-kicker, .panel-index { margin: 0; color: var(--teal); font: 9px ui-monospace, monospace; letter-spacing: .16em; }
.hero h1 { margin: 9px 0 12px; font-size: clamp(32px, 4.2vw, 54px); line-height: 1; letter-spacing: -.045em; }
.hero h1 span { color: var(--teal); }
.hero-copy { margin: 0; max-width: 670px; color: var(--muted); line-height: 1.75; font-size: 14px; }
.hero-trust { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: 430px; }
.hero-trust span { padding: 8px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(16, 27, 42, .72); color: var(--muted); font-size: 10px; white-space: nowrap; }
.hero-trust b { color: var(--text); font: 10px ui-monospace, monospace; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.section-heading h2 { margin: 8px 0 0; font-size: 23px; letter-spacing: -.02em; }
.model-badge, .section-note { padding: 7px 10px; border: 1px solid #3a5360; border-radius: 7px; color: var(--orange); font: 10px ui-monospace, monospace; }
.workspace { display: grid; grid-template-columns: minmax(360px, 430px) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.input-panel, .results-panel, .formula-card { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(150deg, rgba(20, 34, 52, .98), rgba(13, 23, 36, .98)); box-shadow: 0 24px 70px rgba(0, 0, 0, .16); }
.input-panel, .results-panel { padding: 20px; }
.panel-heading, .result-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading h3, .result-header h3 { margin: 7px 0 0; font-size: 19px; }
.autosave-note { color: var(--muted-2); font-size: 10px; }
.result-actions { display: flex; align-items: center; gap: 8px; }
.result-status { padding: 6px 8px; border: 1px solid rgba(99, 221, 208, .25); border-radius: 6px; color: var(--teal); background: rgba(99, 221, 208, .06); font: 9px ui-monospace, monospace; }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 20px 0 14px; padding: 4px; border-radius: 9px; background: var(--panel-3); }
.mode { min-height: 38px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.mode.active { color: var(--text); background: #24394d; box-shadow: inset 0 0 0 1px rgba(130, 164, 255, .08); }
.preset-row { display: flex; align-items: center; gap: 6px; overflow-x: auto; padding: 0 0 6px; scrollbar-width: none; }
.preset-row::-webkit-scrollbar { display: none; }
.preset-row > span { flex: 0 0 auto; color: var(--muted-2); font-size: 10px; }
.preset { flex: 0 0 auto; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font: 9px ui-monospace, monospace; }
.preset:hover { border-color: #3d6b72; color: var(--teal); }

.form-section { margin-top: 15px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.form-section-title { margin-bottom: 12px; color: #adbac9; font: 10px ui-monospace, monospace; }
.form-section-title span { margin-right: 8px; color: var(--teal); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field > span { display: block; margin-bottom: 6px; color: #a9b8c9; font-size: 11px; }
.field b { margin-left: 3px; color: #60758e; font: 9px ui-monospace, monospace; }
.field > div { display: flex; min-height: 42px; border: 1px solid #2b4057; border-radius: 8px; background: #0a1521; transition: .2s ease; }
.field > div:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(99, 221, 208, .09); }
.field input { width: 100%; min-width: 0; padding: 10px 11px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; }
.field i { display: grid; place-items: center; min-width: 40px; padding: 0 8px; border-left: 1px solid var(--line-soft); color: var(--muted-2); font: normal 10px ui-monospace, monospace; }
.hidden { display: none !important; }
.form-actions { display: flex; align-items: center; gap: 9px; margin-top: 22px; }
.text-button, .copy-button { padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.text-button:hover, .copy-button:hover:not(:disabled) { color: var(--text); border-color: #496079; }
.primary-button { min-height: 42px; margin-left: auto; padding: 10px 15px; border: 0; border-radius: 8px; background: var(--teal); color: #082127; font-weight: 800; cursor: pointer; }
.primary-button span { margin-left: 7px; }
.copy-button:disabled { opacity: .35; cursor: not-allowed; }
.error-box { margin-top: 13px; padding: 10px 12px; border: 1px solid #71424c; border-radius: 8px; background: #321d26; color: #ffc1bb; font-size: 11px; }

.results-panel { min-width: 0; }
.empty-state { min-height: 510px; display: grid; align-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-state > span { color: #39526d; font-size: 44px; }
.empty-state strong { margin-top: 12px; color: #b6c3d0; font-size: 14px; }
.empty-state p { margin: 8px 0 0; font-size: 11px; }
.headline-results { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 8px; margin: 21px 0 11px; }
.headline-results > div { min-width: 0; padding: 13px 14px; border: 1px solid var(--line-soft); border-radius: 9px; background: #0a1521; }
.headline-results .primary-result { border-color: rgba(99, 221, 208, .32); background: linear-gradient(135deg, rgba(18, 59, 61, .55), #0a1521); }
.headline-results small, .metric span { display: block; color: var(--muted); font-size: 10px; }
.headline-results strong { display: block; overflow: hidden; margin: 8px 0 4px; color: var(--teal); font-size: clamp(20px, 2vw, 27px); white-space: nowrap; text-overflow: ellipsis; }
.headline-results i, .metric i { color: var(--muted-2); font: normal 9px ui-monospace, monospace; }
.recommendation { margin-bottom: 11px; padding: 10px 12px; border-left: 2px solid var(--teal); background: rgba(99, 221, 208, .05); color: #b8c8d8; font-size: 11px; line-height: 1.65; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); }
.metric { min-width: 0; padding: 12px 13px; background: #111d2c; }
.metric strong { display: block; overflow: hidden; margin: 7px 0 3px; font-size: 17px; white-space: nowrap; text-overflow: ellipsis; }
.chart-card { margin-top: 12px; padding: 13px 14px 8px; border: 1px solid var(--line); border-radius: 10px; background: #09131f; }
.chart-title { display: flex; align-items: start; justify-content: space-between; gap: 16px; color: #b5c3d0; font-size: 11px; }
.chart-title small { display: block; margin-top: 4px; color: var(--muted-2); font-size: 9px; }
.chart-time { color: var(--muted-2); font: 9px ui-monospace, monospace; white-space: nowrap; }
canvas { display: block; width: 100%; height: 390px; }
.safety-note { display: flex; gap: 12px; margin-top: 12px; padding: 12px 13px; border: 1px solid #624d2e; border-radius: 9px; background: #211d17; }
.warning-icon { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; border: 1px solid #80643a; border-radius: 50%; color: var(--orange); font-weight: 800; }
.safety-note strong { color: var(--orange); font-size: 11px; }
.safety-note p { margin: 5px 0 0; color: #b9aa91; font-size: 10px; line-height: 1.7; }
.safety-note b { color: #f8d495; }

.formula-card { margin-top: 12px; box-shadow: none; }
.formula-card summary { display: flex; justify-content: space-between; gap: 16px; padding: 14px 17px; color: #b6c4d2; cursor: pointer; font-size: 12px; list-style: none; }
.formula-card summary::-webkit-details-marker { display: none; }
.formula-card summary small { color: var(--muted-2); }
.formula-card[open] summary { border-bottom: 1px solid var(--line); }
.formula-card > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding: 15px 17px; }
.formula-card code { padding: 9px; border-radius: 6px; background: #09131f; color: #a9ddd8; font: 10px ui-monospace, monospace; }
.formula-card p { grid-column: 1 / -1; margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.7; }

.more-tools { margin-top: 56px; }
.tool-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; }
.tool-card { min-height: 170px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(145deg, var(--panel-2), #0e1927); }
.tool-card.featured { border-color: #315d62; background: linear-gradient(145deg, #173139, #0e1927); }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.tool-icon { color: var(--teal); font-size: 23px; }
.available, .soon { color: var(--teal); font: 8px ui-monospace, monospace; letter-spacing: .1em; }
.soon { color: var(--muted-2); }
.tool-card h3 { margin: 22px 0 7px; font-size: 16px; }
.tool-card p { margin: 0; max-width: 350px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.tool-card a { display: inline-block; margin-top: 17px; color: var(--teal); text-decoration: none; font-size: 10px; }
footer { margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line); color: #53687f; font: 10px ui-monospace, monospace; }
footer span { float: right; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .workspace { grid-template-columns: 360px minmax(0, 1fr); }
  .headline-results { grid-template-columns: 1fr 1fr; }
  .headline-results .primary-result { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px 18px; border-right: 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: row; align-items: center; gap: 16px; }
  .brand { padding: 0; }
  .brand small { display: none; }
  .sidebar nav { display: flex; margin-left: auto; }
  .nav-item { padding: 9px 10px; }
  .side-note { display: none; }
  .main-content { padding-inline: 18px; }
  .workspace { grid-template-columns: 1fr; }
  .results-panel { min-height: auto; }
  .empty-state { min-height: 300px; }
}

@media (max-width: 620px) {
  .sidebar { gap: 8px; padding: 11px 13px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand strong { font-size: 13px; }
  .nav-item { font-size: 0; gap: 0; }
  .nav-item span { font-size: 9px; }
  .topbar { height: 50px; }
  .crumb { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .top-status { display: none; }
  .hero { display: block; padding: 27px 0 23px; }
  .hero h1 { font-size: 34px; }
  .hero-copy { font-size: 12px; }
  .hero-trust { justify-content: flex-start; margin-top: 16px; }
  .hero-trust span { padding: 6px 8px; font-size: 9px; }
  .section-heading { align-items: start; }
  .section-heading h2 { font-size: 20px; }
  .model-badge, .section-note { font-size: 8px; }
  .input-panel, .results-panel { padding: 16px; border-radius: 13px; }
  .field-grid { grid-template-columns: 1fr; }
  .form-actions { align-items: stretch; }
  .primary-button { flex: 1; }
  .headline-results { grid-template-columns: 1fr 1fr; }
  .headline-results .primary-result { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { padding: 11px; }
  .metric strong { font-size: 15px; }
  .chart-title { display: block; }
  .chart-time { display: block; margin-top: 7px; }
  canvas { height: 340px; }
  .formula-card > div { grid-template-columns: 1fr; }
  .formula-card p { grid-column: auto; }
  .tool-grid { grid-template-columns: 1fr; }
  .tool-card { min-height: 145px; }
  footer span { display: block; float: none; margin-top: 7px; }
}

@media (prefers-reduced-motion: no-preference) {
  .input-panel, .results-panel { animation: rise .45s ease both; }
  .results-panel { animation-delay: .05s; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
}
