:root {
  --bg: #070604;
  --app: #0c0906;
  --surface: rgba(18, 15, 10, 0.96);
  --surface-soft: rgba(34, 26, 15, 0.86);
  --text: #fff8e7;
  --muted: #c0b49d;
  --line: rgba(239, 203, 126, 0.20);
  --primary: #d7ad57;
  --primary-dark: #fff1bd;
  --primary-soft: rgba(215, 173, 87, 0.14);
  --accent: #fff1bd;
  --danger: #ff7a67;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.42);
  --radius: 24px;
  --fill-percent: 0%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -8%, rgba(215, 173, 87, 0.26), transparent 22rem),
    radial-gradient(circle at 120% 18%, rgba(255, 241, 189, 0.10), transparent 18rem),
    linear-gradient(180deg, #100c08 0%, var(--bg) 48%, #030201 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
button, input, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 540px);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.hero { padding: 0 0 14px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 64px;
  margin: 0 -14px 14px;
  padding: 10px 14px;
  background: rgba(7, 6, 4, 0.82);
  border-bottom: 1px solid rgba(239, 203, 126, 0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 900;
  text-decoration: none;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.brand span:last-child {
  display: block;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: linear-gradient(135deg, #fff1bd, #d7ad57 58%, #8a5b20);
  color: #080604;
  box-shadow: inset 0 0 0 1px rgba(255, 241, 189, 0.35), 0 12px 30px rgba(215, 173, 87, 0.20);
}
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-link, .ghost-button {
  white-space: nowrap;
}
.nav-link {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 850;
  font-size: 0.84rem;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
}

.hero-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}
.hero-copy {
  padding: 6px 2px 0;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.70rem;
  font-weight: 900;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 11ch;
  font-size: clamp(2.15rem, 12vw, 4.15rem);
  line-height: 0.92;
  letter-spacing: -0.075em;
  margin: 0 0 12px;
}
h2 { font-size: 1.22rem; margin-bottom: 10px; letter-spacing: -0.035em; }
h3 { margin-bottom: 10px; }
.hero-text {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
  margin-bottom: 0;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.hero-stats span {
  min-height: 48px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  color: var(--primary-dark);
  font-weight: 850;
  font-size: 0.78rem;
}

.converter-card, .result-card, .visual-card, .math-card, .table-card, .notes-card {
  width: 100%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.070), rgba(255, 255, 255, 0.026)), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.converter-card {
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.converter-card::before, .primary-result::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at top right, rgba(215, 173, 87, 0.16), transparent 13rem);
}
.card-header, .table-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 11px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid rgba(239, 203, 126, 0.18);
  font-weight: 900;
  font-size: 0.78rem;
  white-space: nowrap;
}
.field-label { display: block; font-weight: 900; margin: 15px 0 8px; }
.input-control {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
}
select.input-control {
  background-image: linear-gradient(45deg, transparent 50%, var(--primary-dark) 50%), linear-gradient(135deg, var(--primary-dark) 50%, transparent 50%);
  background-position: calc(100% - 20px) 24px, calc(100% - 14px) 24px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}
.input-control:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(215, 173, 87, 0.14); background: rgba(255, 255, 255, 0.095); }
.input-large { font-size: 1.2rem; font-weight: 900; }
.inch-row { display: grid; grid-template-columns: 1fr; gap: 10px; }
.primary-button, .secondary-button, .ghost-button, .chip-button {
  border: 0;
  border-radius: 18px;
  min-height: 52px;
  padding: 0 16px;
  font-weight: 900;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.primary-button {
  width: 100%;
  color: #080604;
  background: linear-gradient(135deg, #fff1bd, var(--primary) 55%, #8a5b20);
  box-shadow: 0 14px 34px rgba(215, 173, 87, 0.24);
}
.secondary-button { color: var(--primary-dark); background: var(--primary-soft); border: 1px solid rgba(239, 203, 126, 0.16); }
.ghost-button { color: var(--primary-dark); background: rgba(215, 173, 87, 0.09); border: 1px solid rgba(239, 203, 126, 0.14); }
.chip-button { min-height: 44px; padding: 0 10px; color: var(--primary-dark); background: rgba(255, 255, 255, 0.055); border: 1px solid var(--line); }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover, .chip-button:hover { transform: translateY(-1px); }
.primary-button:active, .secondary-button:active, .ghost-button:active, .chip-button:active { transform: translateY(0); }
button:disabled { opacity: 0.52; cursor: not-allowed; transform: none !important; }
.step-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.hint { color: var(--muted); line-height: 1.5; font-size: 0.92rem; }
.validation { min-height: 22px; margin-bottom: 0; color: var(--danger); font-weight: 850; line-height: 1.45; }

.content-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 0 20px;
}
.result-panel { display: flex; flex-direction: column; gap: 14px; }
.result-card { padding: 18px; }
.primary-result {
  position: relative;
  overflow: hidden;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.result-number { display: flex; align-items: baseline; gap: 8px; font-size: clamp(3.3rem, 18vw, 5.4rem); font-weight: 950; letter-spacing: -0.08em; line-height: 0.95; }
.unit { font-size: 1rem; color: var(--muted); letter-spacing: 0; }
.result-sentence { color: var(--muted); line-height: 1.55; min-height: 45px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 18px; }
.details-grid div {
  padding: 12px;
  border: 1px solid rgba(239, 203, 126, 0.13);
  border-radius: 16px;
  background: rgba(255,255,255,0.045);
}
dt { color: var(--muted); font-size: 0.70rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; }
dd { margin: 4px 0 0; font-size: 1rem; font-weight: 950; overflow-wrap: anywhere; }
.meter { height: 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.34); }
.meter span { display: block; height: 100%; width: var(--fill-percent); background: linear-gradient(90deg, #8a5b20, var(--primary), #fff1bd); border-radius: inherit; transition: width 0.35s ease; }
.visual-card {
  padding: 18px;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  align-items: center;
}
.tank-visual {
  position: relative;
  width: 112px;
  height: 154px;
  border: 7px solid rgba(239, 203, 126, 0.34);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255,241,189,.12), 0 18px 36px rgba(0, 0, 0, 0.32);
}
.tank-liquid {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--fill-percent);
  background: linear-gradient(180deg, #fff1bd, var(--primary), #8a5b20);
  transition: height 0.35s ease;
}
.tank-liquid::before {
  content: "";
  position: absolute;
  left: -20%;
  right: -20%;
  top: -18px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.26);
}
.tank-shine {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 28px;
  height: 96px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.50), rgba(255,255,255,0.05));
}
.visual-card p { color: var(--muted); line-height: 1.5; margin-bottom: 0; }
.math-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.math-card code { display: block; padding: 14px; border-radius: 18px; background: rgba(255, 255, 255, 0.06); color: var(--primary-dark); line-height: 1.55; overflow-x: auto; font-size: 0.88rem; }
.points-card { background: var(--surface-soft); border-radius: 20px; padding: 16px; border: 1px solid rgba(239,203,126,0.12); }
.points-grid { display: grid; gap: 10px; }
.points-grid div { background: rgba(255, 255, 255, 0.055); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.points-grid span { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; }
.points-grid strong { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.table-card, .notes-card { padding: 18px; }
.table-header { flex-direction: column; }
.table-actions { width: 100%; display: grid; grid-template-columns: 1fr; gap: 10px; align-items: stretch; }
.table-filter { min-width: 0; }
.table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--line); border-radius: 18px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 100%; }
th, td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--line); font-size: 0.90rem; }
th { position: sticky; top: 0; background: #100c08; color: var(--primary-dark); font-size: 0.70rem; text-transform: uppercase; letter-spacing: 0.08em; z-index: 1; }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover { background: rgba(255, 255, 255, 0.045); }
.notes-card ul { margin: 14px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }
.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(92vw, 440px);
  padding: 14px 16px;
  border-radius: 18px;
  color: var(--primary-dark);
  background: rgba(16, 12, 8, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-weight: 900;
  text-align: center;
  z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .app-shell { width: min(100% - 32px, 980px); padding-left: 0; padding-right: 0; }
  .topbar { margin-left: 0; margin-right: 0; padding-left: 18px; padding-right: 18px; border: 1px solid rgba(239,203,126,0.14); border-radius: 24px; top: 12px; }
  .brand span:last-child { max-width: none; }
  .hero-grid { display: grid; grid-template-columns: 0.92fr 1.08fr; gap: 20px; align-items: stretch; }
  .hero-copy { padding: 18px 0; display: flex; flex-direction: column; justify-content: center; }
  .content-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; }
  .result-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
  .math-card, .table-card, .notes-card { grid-column: 1 / -1; }
  .inch-row { grid-template-columns: 1fr auto; }
  .primary-button { width: auto; min-width: 132px; }
  .table-header { flex-direction: row; align-items: flex-start; }
  .table-actions { width: auto; min-width: 360px; grid-template-columns: 1fr auto; }
  .math-card { display: grid; grid-template-columns: 1.35fr 0.65fr; }
}

@media (max-width: 390px) {
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .topbar { margin-left: -10px; margin-right: -10px; padding-left: 10px; padding-right: 10px; }
  .brand span:last-child { max-width: 126px; }
  .nav-link { padding: 10px; font-size: 0.78rem; }
  .ghost-button { padding: 0 11px; min-height: 42px; border-radius: 999px; }
  .step-row { gap: 6px; }
  .chip-button { font-size: 0.82rem; padding: 0 6px; }
  .details-grid { grid-template-columns: 1fr; }
  .visual-card { grid-template-columns: 1fr; }
  .tank-visual { width: 132px; justify-self: center; }
  .hero-stats { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; color: #111; }
  .topbar, .step-row, .result-actions, .table-actions, .toast { display: none !important; }
  .app-shell { width: 100%; }
  .converter-card, .result-card, .visual-card, .math-card, .table-card, .notes-card { box-shadow: none; break-inside: avoid; }
  .content-grid, .result-panel, .hero-grid { display: block; }
  .hero { padding-bottom: 10px; }
}
