/* language: CSS | file: public/styles.css | target: mobile Safari / PWA, RTL Persian
   Direction: instrument, not marketing. Flat surfaces, hairlines, one accent.
   Dials: ENERGY 1 / RHYTHM 2 / MOTION 1. See DESIGN.md for the reasons behind each choice. */

.diagnostic-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.diagnostic-choices .mini-btn { white-space: normal; text-align: right; }
.diagnostic-choices [aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.diagnostic-advice { color: var(--ink); line-height: 2; border-inline-start: 2px solid var(--line-2); padding-inline-start: 12px; }
.report-text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; user-select: text; }

/* self-hosted variable family: one file covers 100 to 900, no third-party request */
@font-face {
  font-family: "Vazirmatn";
  src: url("./fonts/Vazirmatn.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0c0e10;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.085);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --ink: #e7ebee;
  --ink-2: #a7b1b8;
  --ink-3: #7e8990;
  --accent: #3dbccd;
  --accent-ink: #04232a;
  --accent-soft: rgba(61, 188, 205, 0.13);
  --ok: #4fbf8b;
  --danger: #e8756f;
  --radius: 14px;
  --radius-sm: 12px;
  --radius-lg: 22px;
  --tap: 44px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  /* glass material: a translucent pane, a hairline that catches light, a specular edge on top */
  --glass: rgba(19, 23, 26, 0.62);
  --glass-2: rgba(32, 38, 42, 0.72);
  --glass-line: rgba(255, 255, 255, 0.09);
  --glass-line-2: rgba(255, 255, 255, 0.16);
  --specular: rgba(255, 255, 255, 0.08);
  --shadow-float: 0 18px 40px -22px rgba(0, 0, 0, 0.85);
}

[data-theme="light"] {
  --bg: #f3f4f5;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-2: rgba(255, 255, 255, 0.9);
  --line: rgba(18, 28, 34, 0.1);
  --line-2: rgba(18, 28, 34, 0.18);
  --ink: #14181b;
  --ink-2: #48535a;
  --ink-3: #667079;
  --accent: #0c7181;
  --accent-ink: #ffffff;
  --accent-soft: rgba(12, 113, 129, 0.1);
  --ok: #1f7a54;
  --danger: #b03b34;

  --glass: rgba(255, 255, 255, 0.6);
  --glass-2: rgba(255, 255, 255, 0.82);
  --glass-line: rgba(18, 28, 34, 0.08);
  --glass-line-2: rgba(18, 28, 34, 0.12);
  --specular: rgba(255, 255, 255, 0.95);
  --shadow-float: 0 18px 38px -26px rgba(18, 32, 40, 0.5);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* form controls do not inherit the page typeface by default; force it once, here */
button,
input,
select,
textarea,
optgroup,
option {
  font-family: inherit;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--ink);
  overflow-x: hidden;
}

/* the field lives on html so the body's own background cannot paint over the glass layers */
html {
  background: var(--bg);
}

body {
  background: transparent;
}

/* a still colour field for the glass to sit on: no motion, no orbs, just depth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(78% 58% at 92% -8%, rgba(61, 188, 205, 0.5), transparent 58%),
    radial-gradient(62% 52% at 0% 4%, rgba(96, 116, 255, 0.38), transparent 56%),
    radial-gradient(70% 46% at 104% 58%, rgba(56, 170, 190, 0.26), transparent 62%),
    radial-gradient(96% 62% at 46% 118%, rgba(45, 150, 170, 0.34), transparent 62%),
    var(--bg);
}

/* fine grain over the field: keeps large gradients from banding on an oled phone */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.03;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 120px 120px;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(78% 58% at 92% -8%, rgba(61, 188, 205, 0.42), transparent 58%),
    radial-gradient(62% 52% at 0% 4%, rgba(120, 138, 255, 0.34), transparent 56%),
    radial-gradient(70% 46% at 104% 58%, rgba(56, 170, 190, 0.2), transparent 62%),
    radial-gradient(96% 62% at 46% 118%, rgba(45, 150, 170, 0.24), transparent 62%),
    var(--bg);
}

body {
  font-family: Vazirmatn, system-ui, "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.85;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

button,
a,
summary,
select,
label,
[role="button"] {
  cursor: pointer;
}

button:disabled,
select:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- shell ---------- */

.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 13px;
  border-bottom: 1px solid var(--glass-line);
  background: var(--glass);
  box-shadow: inset 0 1px 0 var(--specular);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
}

.brand {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.4;
  color: var(--ink);
}

.brand p {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background 0.15s;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--line-2);
}

.icon-btn:active {
  background: var(--surface-2);
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 8px;
}

.view.has-cta {
  padding-bottom: 96px;
}

/* ---------- sections ---------- */

.block {
  margin-bottom: 22px;
}

.block-title {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* ---------- tabs ---------- */
/* ---------- operator cells ---------- */

.op-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: 62px;
  min-width: 0;
  padding: 10px 12px;
  text-align: right;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: inset 0 1px 0 var(--specular);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.op-card:hover {
  border-color: var(--line-2);
}

.op-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 1px 0 var(--glass-line-2), 0 8px 20px -16px var(--accent);
}

.op-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.op-card[aria-pressed="true"] .op-name {
  color: var(--accent);
}

.op-en {
  font-size: 10.5px;
  color: var(--ink-3);
  direction: ltr;
  unicode-bidi: isolate;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.op-check {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.op-card {
  position: relative;
}

.op-card[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- advanced panel ---------- */

.adv {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 14px;
}

.adv summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--tap);
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.adv summary::-webkit-details-marker {
  display: none;
}

.adv summary::after {
  content: "+";
  font-size: 17px;
  line-height: 1;
  color: var(--ink-3);
  font-weight: 400;
}

.adv[open] summary::after {
  content: "−";
}

.adv summary:hover {
  color: var(--ink);
}

.adv-body {
  border-top: 1px solid var(--line);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.field .sub {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-3);
}

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

input,
select {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-height: var(--tap);
  width: 100%;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

input::placeholder {
  color: var(--ink-3);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* custom listbox: an OS menu would render outside this surface, so the app draws its own */
.sel {
  position: relative;
}

.sel-btn {
  width: 100%;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-align: start;
  transition: border-color 0.15s var(--ease);
}

.sel-btn:hover {
  border-color: var(--line-2);
}

.sel-btn[aria-expanded="true"] {
  border-color: var(--accent);
}

.sel-val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sel-arrow {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg);
  transition: transform 0.15s var(--ease);
}

.sel-btn[aria-expanded="true"] .sel-arrow {
  margin-top: 3px;
  transform: rotate(225deg);
}

.sel-menu {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 6px);
  z-index: 40;
  margin: 0;
  padding: 4px;
  max-height: 260px;
  overflow: auto;
  list-style: none;
  background: var(--glass-2);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--specular), var(--shadow-float);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
}

.sel-menu-up {
  top: auto;
  bottom: calc(100% + 6px);
}

.sel-menu li {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}

.sel-menu li:hover,
.sel-menu li.is-active {
  background: var(--surface-2);
  color: var(--ink);
}

.sel-menu li[aria-selected="true"] {
  color: var(--accent);
  font-weight: 600;
}

[data-theme="light"] .sel-menu {
  box-shadow: 0 12px 28px rgba(15, 23, 28, 0.14);
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap);
  border-top: 1px solid var(--line);
}

.switch:first-of-type {
  border-top: 0;
}

.switch-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
}

.switch-label small {
  display: block;
  font-size: 10.5px;
  color: var(--ink-3);
  font-weight: 400;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  min-height: 0;
}

.track {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.track::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink-3);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}

.switch input:checked + .track {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.switch input:checked + .track::after {
  transform: translateX(-18px);
  background: var(--accent);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- custom apn rows ---------- */

.apn-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.apn-row input {
  min-height: 38px;
  padding: 7px 9px;
  font-size: 12px;
  font-family: inherit;
  letter-spacing: 0.02em;
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.mini-btn:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

.mini-btn.accent {
  color: var(--accent);
  border-color: var(--accent);
}

.mini-btn.danger {
  color: var(--danger);
  border-color: var(--line-2);
}

/* ---------- hint, summary, cta ---------- */

.hint {
  margin: 0 0 12px;
  font-size: 11.5px;
  line-height: 1.85;
  color: var(--ink-3);
}

.recover {
  display: flex;  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: inset 0 1px 0 var(--specular);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
}

.recover-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.recover-label {
  font-size: 10.5px;
  color: var(--ink-3);
}

.recover-meta {
  font-size: 12.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recover .mini-btn {
  flex: none;
}

.linkdown {
  display: grid;
  gap: 2px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--glass);
  box-shadow: inset 0 1px 0 var(--specular);
  font-size: 11.5px;
  color: var(--ink-2);
}

.linkdown b {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.guard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
}

.guard-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.guard-row b {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.guard-row span {
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-3);
}

.switch {
  flex: none;
  width: 44px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 13px;
  background: var(--surface-2);
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}

.switch span {
  display: block;
  width: 18px;
  height: 18px;
  margin: 3px;
  border-radius: 50%;
  background: var(--ink-3);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}

.switch[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.switch[aria-checked="true"] span {
  background: var(--accent-ink);
  transform: translateX(-18px);
}

.cloud-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  background: var(--glass-2);
  box-shadow: inset 0 1px 0 var(--specular);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  color: var(--ink);
  text-decoration: none;
}

.cloud-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.cloud-row b {
  font-size: 12.5px;
  font-weight: 600;
}

.cloud-row span {
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-3);
}

.cloud-row .cloud-go {
  flex: none;
  font-size: 18px;
  line-height: 1;
  color: var(--accent);
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.sum-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sum-item span {
  font-size: 10px;
  color: var(--ink-3);
}

.sum-item b {
  color: var(--ink);
  font-weight: 600;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sum-item b.mono {
  font-family: inherit;
  direction: ltr;
  color: var(--ink);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.cta-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(58px + env(safe-area-inset-bottom));
  z-index: 26;
  max-width: 460px;
  margin: 0 auto;
  padding: 8px 16px;
  /* same pane as the tab bar so the two read as one shelf, not a black strip cut into the field */
  background: var(--glass);
  border-top: 1px solid var(--glass-line);
  box-shadow: inset 0 1px 0 var(--specular);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

.cta {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 10px 22px -22px var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter 0.15s var(--ease);
}

/* one sweep while the only long action runs: motion that reports work, nothing ambient */
.cta[data-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 25%, rgba(255, 255, 255, 0.4) 50%, transparent 75%);
  transform: translateX(-110%);
  animation: cta-sweep 1.1s linear infinite;
  pointer-events: none;
}

@keyframes cta-sweep {
  to {
    transform: translateX(110%);
  }
}

.cta:hover {
  filter: brightness(1.06);
}

.cta:active {
  filter: brightness(0.94);
}

.cta[disabled] {
  filter: saturate(0.5);
}

.cta.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-2);
  font-weight: 600;
}

.cta.ghost:hover {
  border-color: var(--ink-3);
  filter: none;
}

/* ---------- plain cards ---------- */

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 1px 0 var(--specular);
  padding: 13px 14px;
  margin-bottom: 10px;
}

.card h3 {
  margin: 0 0 5px;
  font-size: 13px;
  font-weight: 600;
}

.card p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.9;
}

.card .muted {
  color: var(--ink-3);
  font-size: 11.5px;
}


.result {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 12.5px;
}

.result.ok {
  border-color: var(--ok);
}

.result.bad {
  border-color: var(--danger);
}

.result .kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-2);
}

.result .kv b {
  font-family: inherit;
  direction: ltr;
  color: var(--ink);
  font-weight: 500;
  letter-spacing: 1px;
}

/* ---------- steps ---------- */

@counter-style fa-num {
  system: numeric;
  symbols: "۰" "۱" "۲" "۳" "۴" "۵" "۶" "۷" "۸" "۹";
}

.steps {
  counter-reset: step;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  position: relative;
  counter-increment: step;
  padding: 9px 32px 9px 0;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--ink-2);
}

.steps li:first-child {
  border-top: 0;
}

.steps li::before {
  content: counter(step, fa-num);
  position: absolute;
  inset-inline-start: 0;
  top: 9px;
  width: 22px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
}

.steps li b {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- labels, chips, history ---------- */

.badge {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}

.badge.on {
  color: var(--ok);
  border-color: var(--ok);
}

.badge.off {
  color: var(--ink-3);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 11.5px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}

.chip:hover {
  border-color: var(--line-2);
  color: var(--ink);
}

.hist-item {
  display: grid;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.hist-item:first-child {
  border-top: 0;
}

.hist-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.hist-title {
  font-size: 13px;
  font-weight: 600;
}

.hist-meta {
  font-size: 10.5px;
  color: var(--ink-3);
  direction: ltr;
  text-align: right;
  font-family: inherit;
}

.hist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

/* ---------- tabbar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  max-width: 460px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 0 4px env(safe-area-inset-bottom);
  background: var(--glass);
  border-top: 1px solid var(--glass-line);
  box-shadow: inset 0 1px 0 var(--specular);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}

.tab {
  position: relative;
  border: 0;
  background: transparent;
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 56px;
  padding: 9px 0 6px;
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 500;
  transition: color 0.15s var(--ease);
}

.tab svg {
  width: 20px;
  height: 20px;
}

.tab[aria-current="page"] {
  color: var(--accent);
}

/* the selected tab reads as a lit pane of glass behind its icon, not a bar under it */
.tab[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  width: 42px;
  height: 27px;
  margin-left: -21px;
  border-radius: 9px;
  background: var(--accent-soft);
  box-shadow: inset 0 1px 0 var(--glass-line-2);
}

/* ---------- sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  align-items: end;
}

.sheet[hidden] {
  display: none;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 10, 0.5);
}

[data-theme="light"] .sheet-backdrop {
  background: rgba(210, 220, 226, 0.36);
}

.sheet-panel {
  position: relative;
  overflow: hidden;
  max-width: 460px;
  width: 100%;
  margin: 0 auto;
  background: var(--glass-2);
  border: 1px solid var(--glass-line);
  border-bottom: 0;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 1px 0 var(--specular), 0 -22px 48px -28px rgba(0, 0, 0, 0.75);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
  animation: sheet-in 0.16s var(--ease);
}

/* a single travelling light along the top edge when a file is ready, then it is gone */
.sheet-beam {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 42%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  pointer-events: none;
}

.sheet-panel.is-fresh .sheet-beam {
  animation: sheet-beam 1.15s ease-out 1;
}

@keyframes sheet-beam {
  0% {
    opacity: 0;
    transform: translateX(-130%);
  }
  18% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translateX(320%);
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(14px);
    opacity: 0.6;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.sheet-head .icon-btn {
  width: 40px;
  height: 40px;
}

.sheet-body {
  padding: 14px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  overflow: auto;
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink-2);
}

.sheet-body pre {
  direction: ltr;
  text-align: left;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px;
  font-size: 10.5px;
  line-height: 1.6;
  overflow: auto;
  max-height: 50dvh;
  font-family: inherit;
  white-space: pre;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 8px);
  z-index: 80;
  max-width: 88vw;
  padding: 10px 14px;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-sm);
  background: var(--glass-2);
  box-shadow: inset 0 1px 0 var(--specular), var(--shadow-float);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  color: var(--ink);
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.err {
  border-color: var(--danger);
}

/* ---------- misc ---------- */

.empty {
  padding: 44px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12.5px;
}

.empty svg {
  opacity: 0.6;
  margin-bottom: 8px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 12px 0;
}

.footnote {
  margin: 16px 0 4px;
  font-size: 10.5px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.9;
}

.card a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

a.link {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
