:root {
  --bg: #0b1220;
  --bg2: #111827;
  --card: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #f97316;
  --accent2: #38bdf8;
  --ok: #22c55e;
  --warn: #eab308;
  --danger: #ef4444;
  --pad: 14px;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 48px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #0f172a 0%, #0f172aee 100%);
  border-bottom: 1px solid var(--border);
  padding: 10px var(--pad) 8px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #0f172a;
  font-weight: 900;
}
.offline-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  white-space: nowrap;
}
.offline-pill.online { color: var(--ok); border-color: #166534; }
.offline-pill.offline { color: var(--warn); border-color: #854d0e; }

main {
  padding: var(--pad);
  max-width: 520px;
  margin: 0 auto;
}

.tab-panel[hidden] { display: none !important; }

h1, h2, h3 { margin: 0 0 0.5rem; line-height: 1.2; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; color: #e2e8f0; }
.lede { color: var(--muted); margin: 0 0 1rem; font-size: 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card.accent { border-color: #c2410c; background: #1c1917; }
.callout {
  background: #172554;
  border: 1px solid #1d4ed8;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  color: #dbeafe;
}
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
}
input, select, button, textarea {
  font: inherit;
  color: var(--text);
}
input, select, textarea {
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button {
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
button.primary {
  background: var(--accent);
  color: #0f172a;
  border-color: #ea580c;
}
button.ghost { background: transparent; }
button.seg {
  flex: 1;
  min-width: 0;
  background: var(--bg2);
}
button.seg.active {
  background: var(--accent);
  color: #0f172a;
  border-color: #ea580c;
}
.seg-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.stat {
  background: var(--bg2);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
}
.stat .v {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent2);
}
.stat .k { color: var(--muted); font-size: 0.8rem; font-weight: 700; }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.list li:last-child { border-bottom: 0; }
.fit-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 8px 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px 4px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  min-height: var(--tap);
  cursor: pointer;
}
.fit-row.active {
  background: #1c1917;
  border-radius: 12px;
  border-bottom-color: transparent;
  outline: 1px solid #c2410c;
}
.fit-row .title { font-weight: 700; }
.fit-row .meta { color: var(--muted); font-size: 0.88rem; }
.fit-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  object-position: top center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
}
.fit-thumb.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}
.fit-main { min-width: 0; }
.fit-side { text-align: right; }
.fit-detail .dim-big {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent2);
  margin-top: 6px;
}
.fit-figure {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  object-position: top center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.chip {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  background: #334155;
  color: #e2e8f0;
}
.chip.ok { background: #14532d; color: #bbf7d0; }
.chip.pending { background: #713f12; color: #fde68a; }

.step {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.step .n {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f172a;
  font-weight: 900;
  display: grid;
  place-items: center;
}
.tip-title { font-weight: 800; margin-bottom: 4px; }

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  background: #0f172af2;
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  backdrop-filter: blur(8px);
}
.nav button {
  min-height: 56px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  border-radius: 10px;
}
.nav button .ico { font-size: 1.15rem; line-height: 1; }
.nav button.active { color: var(--accent); background: #1c1917; }

.diagram {
  width: 100%;
  height: auto;
  background: var(--bg2);
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.examples details {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg2);
}
.examples summary { font-weight: 800; cursor: pointer; }
.result-big {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.03em;
}
a.icc {
  color: var(--accent2);
  font-weight: 700;
  word-break: break-all;
}
.checklist { margin: 8px 0 0; padding-left: 1.2rem; }
.checklist li { margin: 4px 0; }
.status-line { font-size: 0.85rem; color: var(--muted); margin-top: 8px; }
