:root {
  color-scheme: dark;
  --bg: #050b14;
  --surface: rgba(5, 18, 31, 0.78);
  --surface-strong: rgba(5, 31, 48, 0.9);
  --text: #e7faff;
  --muted: #8eb0c2;
  --line: rgba(65, 210, 255, 0.34);
  --line-soft: rgba(95, 255, 219, 0.16);
  --accent: #27e4ff;
  --accent-dark: #70fff1;
  --accent-green: #68f2bd;
  --warning: #f8d477;
  --shadow: 0 18px 70px rgba(0, 211, 255, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(5, 11, 20, 0.54), rgba(3, 8, 15, 0.97)),
    url("./assets/holographic-cockpit-bg.png") center top / cover fixed,
    var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(39, 228, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(39, 228, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 78%);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 30px 0 42px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(39, 228, 255, 0.24);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 18px rgba(39, 228, 255, 0.8);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(39, 228, 255, 0.45);
}

.status,
.help-button,
.icon-button,
.tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-dark);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  padding: 8px 12px;
  font-size: 14px;
}

.help-button,
.icon-button,
.tab {
  cursor: pointer;
}

.help-button {
  min-height: 40px;
  padding: 0 14px;
}

.help-button:hover,
.icon-button:hover,
.tab:hover {
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(39, 228, 255, 0.22), 0 0 24px rgba(39, 228, 255, 0.28);
}

.icon-button {
  width: 36px;
  height: 36px;
  font-size: 24px;
  line-height: 1;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(39, 228, 255, 0.95);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  min-height: 40px;
  padding: 0 16px;
  color: var(--muted);
}

.tab.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(39, 228, 255, 0.24), rgba(39, 228, 255, 0.08));
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(39, 228, 255, 0.18), 0 0 28px rgba(39, 228, 255, 0.22);
}

.panel {
  display: none;
  gap: 18px;
}

.panel.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: start;
}

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

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

fieldset,
.results {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

fieldset::before,
.results::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(39, 228, 255, 0.14), transparent 28%),
    radial-gradient(circle at 100% 0%, rgba(104, 242, 189, 0.11), transparent 34%);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 16px;
}

legend {
  padding: 0 6px;
  color: var(--accent-dark);
  font-weight: 700;
  text-shadow: 0 0 12px rgba(112, 255, 241, 0.35);
}

label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: rgba(0, 9, 19, 0.64);
  box-shadow: inset 0 0 18px rgba(39, 228, 255, 0.06);
}

input:focus {
  outline: 2px solid rgba(39, 228, 255, 0.22);
  border-color: var(--accent);
}

.toggle {
  grid-template-columns: 18px 1fr;
  align-items: center;
  margin-top: 20px;
  color: var(--text);
}

.toggle input {
  min-height: auto;
}

.results {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.result-main {
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    radial-gradient(circle at 78% 44%, rgba(39, 228, 255, 0.16), transparent 32%),
    var(--surface-strong);
}

.result-main span,
.metric-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.result-main strong {
  display: block;
  margin: 8px 0;
  color: var(--accent-dark);
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: 0;
  text-shadow: 0 0 24px rgba(39, 228, 255, 0.72);
}

.result-main small {
  color: var(--warning);
  font-size: 13px;
}

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

.metric-row div {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 13, 25, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.metric-row strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.formula {
  margin: 16px 0 0;
  padding: 12px;
  border-left: 3px solid var(--accent);
  background: rgba(3, 21, 36, 0.72);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.formula-dialog {
  width: min(880px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 90px rgba(0, 211, 255, 0.2);
  backdrop-filter: blur(18px);
}

.formula-dialog::backdrop {
  background: rgba(2, 8, 16, 0.72);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
}

.dialog-head h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.formula-doc {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.formula-doc h3 {
  margin: 0 0 10px;
  font-size: 18px;
  letter-spacing: 0;
}

.formula-doc p,
.formula-doc li {
  color: var(--muted);
  line-height: 1.7;
}

.formula-doc ul {
  margin: 0;
  padding-left: 20px;
}

.formula-doc pre {
  margin: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(0, 9, 19, 0.72);
}

.formula-doc code {
  color: #d8fbff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
}

@media (max-width: 980px) {
  .panel.active {
    grid-template-columns: 1fr;
  }

  .results {
    position: static;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100vw - 20px, 1320px);
    padding-top: 18px;
  }

  .topbar,
  .tabs {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .tab {
    width: 100%;
  }
}
