:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --border: #dddcd6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #6f6e69;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --grid: #e4e3dd;
  --liquid: #2a78d6;
  --vapor: #eb6834;
  --super: #1baf7a;
  --fill-alpha: 0.16;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --border: #383835;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9a998f;
    --accent: #86b6ef;
    --accent-ink: #0b0b0b;
    --grid: #2c2c2a;
    --liquid: #3987e5;
    --vapor: #d95926;
    --super: #199e70;
    --fill-alpha: 0.24;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; inset-inline-start: 8px; top: 8px; transform: translateY(-300%); background: var(--surface); padding: 8px 12px; z-index: 30; }
.skip:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; margin-inline-end: auto; }
.brand svg { flex: none; }
.site-nav { display: flex; gap: 4px 16px; flex-wrap: wrap; align-items: center; }
.site-nav a { color: var(--text-2); text-decoration: none; padding: 6px 2px; font-size: 15px; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); text-decoration: underline; }
.lang-menu { position: relative; font-size: 14px; }
.lang-menu summary { list-style: none; cursor: pointer; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; color: var(--text-2); user-select: none; }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary::after { content: "▾"; margin-inline-start: 6px; font-size: 11px; }
.lang-menu[open] summary { color: var(--text); border-color: var(--text-3); }
.lang-menu ul { position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 20; margin: 0; padding: 4px; list-style: none; min-width: 9.5em; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.16); }
.lang-menu li a { display: block; padding: 7px 10px; border-radius: 5px; }
.lang-menu li a:hover { background: var(--bg); text-decoration: none; }

/* Hero */
.hero { padding: 22px 0 6px; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.01em; }
.lead { color: var(--text-2); margin: 0; max-width: 72ch; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 2em 0 0.5em; }
h3 { font-size: 1.08rem; margin: 1.4em 0 0.3em; }

/* Tool */
.tool { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 16px; margin: 16px 0 8px; align-items: start; }
@media (max-width: 880px) { .tool { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card > h2 { margin: 0 0 10px; font-size: 1.05rem; }

.controls { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field label { font-size: 13px; color: var(--text-2); }
.field .combo { display: flex; }
@media (max-width: 520px) {
  .controls { display: grid; grid-template-columns: 1fr 1fr; }
  .controls .field:last-child { grid-column: 1 / -1; }
  .field .combo input { width: 100%; min-width: 0; flex: 1; }
  .card { padding: 12px 10px; }
  .site-nav { gap: 0 14px; }
}
.field input, .field select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); padding: 7px 9px; min-height: 40px;
}
.field input { width: 8.2em; border-start-start-radius: 7px; border-end-start-radius: 7px; font-variant-numeric: tabular-nums; unicode-bidi: plaintext; }
.field .combo select { border-inline-start: 0; border-start-end-radius: 7px; border-end-end-radius: 7px; }
.field > select { border-radius: 7px; }
.field input[aria-invalid="true"] { border-color: #d03b3b; }

.pt-chart { position: relative; width: 100%; height: 460px; touch-action: manipulation; cursor: crosshair; border-radius: 6px; user-select: none; -webkit-user-select: none; }
.pt-svg { display: block; width: 100%; height: 100%; font-family: var(--font); }
.reg { stroke: none; fill-opacity: var(--fill-alpha); }
.reg-liquid { fill: var(--liquid); }
.reg-vapor { fill: var(--vapor); }
.reg-super { fill: var(--super); }
.grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.frame { fill: none; stroke: var(--border); }
.sat { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; }
.bound { fill: none; stroke: var(--text-3); stroke-width: 1.25; stroke-dasharray: 5 4; }
.crit { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
.tick { fill: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.axis-title { fill: var(--text-2); font-size: 12.5px; }
.reg-label { fill: var(--text); font-size: 14px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-opacity: 0.55; }
.note { fill: var(--text-2); font-size: 12px; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-opacity: 0.6; }
.cross { fill: none; stroke: var(--text-3); stroke-width: 1; shape-rendering: crispEdges; }
.sel-line { fill: none; stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.sel { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.pt-tip {
  position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 9px; font-size: 13px; line-height: 1.35;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.14); font-variant-numeric: tabular-nums;
}
.pt-tip span { display: block; color: var(--text-2); }
.hint { color: var(--text-3); font-size: 13px; margin: 8px 0 0; }

/* T-s diagram and dew-point charts */
.dome-fill { fill: var(--text-3); fill-opacity: 0.12; stroke: none; }
.isobar { fill: none; stroke: var(--text-3); stroke-width: 1; opacity: 0.75; }
.iso-label { fill: var(--text-3); font-size: 11px; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-opacity: 0.7; }
.curve { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.curve-bubble { stroke: var(--liquid); }
.curve-dew { stroke: var(--vapor); }
.curve-label { fill: var(--text); font-size: 13px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-opacity: 0.7; }
.contour { fill: none; stroke: var(--liquid); stroke-width: 1.75; }
.contour-zero { stroke-width: 2.5; }
.contour-label { fill: var(--text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--surface); stroke-width: 3.5px; stroke-opacity: 0.85; }
.frost-fill { fill: var(--text-3); fill-opacity: 0.13; stroke: none; }
.phase.phase-wet::before { background: linear-gradient(90deg, var(--liquid) 50%, var(--vapor) 50%); }
.big-result { font-size: 14px; color: var(--text-2); }
.big-result strong { font-size: 1.5rem; color: var(--text); font-variant-numeric: tabular-nums; margin-left: 4px; white-space: nowrap; }
.controls-3 .field input { width: 7em; }
.controls-3 .field .combo input:only-child { border-radius: 7px; width: 10.5em; }
@media (max-width: 520px) { .controls-3 .field .combo input:only-child { width: 100%; } }

/* Results */
.res-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.res-head h2 { margin: 0; font-size: 1.05rem; }
.phase { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px 3px 9px; }
.phase::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); }
.phase-liquid::before { background: var(--liquid); }
.phase-vapor::before { background: var(--vapor); }
.phase-supercritical::before { background: var(--super); }
table { border-collapse: collapse; width: 100%; }
.res-table th, .res-table td { padding: 5px 4px; border-bottom: 1px solid var(--grid); font-size: 14.5px; text-align: start; vertical-align: baseline; }
.res-table th { font-weight: 400; color: var(--text-2); }
.res-table .num { text-align: end; unicode-bidi: plaintext; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.res-table .unit { color: var(--text-3); white-space: nowrap; width: 1%; padding-inline-start: 8px; unicode-bidi: plaintext; }
.res-msg { background: color-mix(in srgb, #d03b3b 10%, transparent); border: 1px solid #d03b3b; border-radius: 7px; padding: 8px 10px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.btn { font: inherit; font-size: 14px; min-height: 40px; padding: 7px 13px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--text-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.copy-status { font-size: 13px; color: var(--text-2); }
.res-foot { margin-top: 10px; }

/* Content */
.content { max-width: 78ch; }
.content p, .content li { color: var(--text); }
.content details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.content summary { font-weight: 600; cursor: pointer; }
.content details p { margin: 8px 0 2px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 12px 0; }
.data { font-size: 14px; font-variant-numeric: tabular-nums; min-width: 640px; }
.data th, .data td { padding: 6px 10px; text-align: end; unicode-bidi: plaintext; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.data thead th { position: sticky; top: 0; background: var(--surface); color: var(--text-2); font-weight: 600; border-bottom: 1px solid var(--border); }
.data thead small { display: block; font-weight: 400; color: var(--text-3); }
.data tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.data td:first-child, .data th:first-child { text-align: start; }
.todo { background: #fab21933; border: 1px dashed #c98500; border-radius: 4px; padding: 0 4px; }

/* Ads: space is reserved so the layout never shifts when an ad loads. */
.ad { margin: 20px auto; min-height: 280px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ad-label { display: block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); text-align: center; margin-bottom: 4px; }
.ad-preview { border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-3); font-size: 13px; }

/* Footer */
.site-footer { margin-top: 40px; border-top: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 14px; }
.site-footer .wrap { padding-top: 18px; padding-bottom: 24px; display: flex; flex-wrap: wrap; gap: 8px 22px; }
.site-footer p { margin: 0; flex-basis: 100%; }
.site-footer a { color: var(--text-2); }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media print { .site-header, .site-footer, .ad, .actions, .controls { display: none; } }

/* Scripts without Latin letter-spacing conventions */
:lang(zh) h1, :lang(hi) h1, :lang(ar) h1 { letter-spacing: 0; }
:lang(ar) body, :lang(hi) body { line-height: 1.75; }
.big-result strong, .pt-tip strong { unicode-bidi: plaintext; }
