:root {
  --ink: #102033;
  --muted: #3d5168;
  --line: #c5d2e0;
  --bg: #e7edf2;
  --white: #ffffff;
  --navy: #0e1c2f;
  --blue: #0b5cab;
  --blue-soft: #e7f0fa;
  --danger: #8d1d1d;
  --pad: 14px;
  color-scheme: light;
  font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

button, input, select { font: inherit; color: inherit; }

.phone {
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: max(8px, env(safe-area-inset-top)) var(--pad) 8px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  background: var(--navy);
  display: grid;
  place-items: center;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  display: block;
}

.brand-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-size: 20px;
  font-weight: 720;
  letter-spacing: -0.03em;
  line-height: 1;
  white-space: nowrap;
}

.pages {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  justify-content: flex-end;
}

.page-tab, .pro-btn, .seg-btn, .picker-close, .upgrade-buy, .chooser-row {
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
}

.page-tab {
  padding: 0 14px;
  font-weight: 700;
  color: var(--blue);
  white-space: nowrap;
}

.page-tab.is-on {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

.pro-btn {
  padding: 0 16px;
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
  font-weight: 750;
  white-space: nowrap;
  flex: 0 0 auto;
}

.pro-btn[hidden] { display: none; }

.home {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.home[hidden], .reference[hidden] { display: none; }

.readout {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  background: var(--navy);
  color: var(--white);
  padding: 10px var(--pad) 8px;
  border-bottom: 1px solid #08111c;
}

.readout-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b7c7da;
}

.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
}

.figure {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

.figure-label {
  display: block;
  font-size: 12px;
  color: #b7c7da;
}

.figure-value {
  font-size: clamp(26px, 4.2vh, 42px);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.figure-value,
.figure-aside,
.readout-note,
.readout-stop {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.figure-value small {
  margin-left: 4px;
  font-size: 0.42em;
  font-weight: 650;
  letter-spacing: 0;
}

.figure-aside, .readout-note, .readout-stop, .disclaimer, .locked-line {
  margin: 8px 0 0;
}

.figure-aside, .readout-note {
  color: #f3d48a;
  font-size: 14px;
}

.readout-stop {
  font-size: 20px;
  line-height: 1.35;
  font-weight: 680;
}

.disclaimer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 2px;
}

.inputs {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px var(--pad) max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
  row-gap: 8px;
  align-content: start;
}

.inputs .disclaimer,
.inputs .sheet-open {
  grid-column: 1 / -1;
}

.inputs > * { min-width: 0; }

.field {
  margin: 0;
  padding: 0;
  border: 0;
}

.field legend, .locked-line span, .sheet-open span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.seg-btn {
  min-height: 36px;
  height: auto;
  max-width: 100%;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

.seg-btn.is-on {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}

.sheet-open, .locked-line {
  width: 100%;
  max-width: 100%;
  text-align: left;
  padding: 10px 16px;
  border-radius: 16px;
}

.sheet-open {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  height: max-content;
  min-height: 46px;
  align-self: start;
  padding: 6px 36px 6px 12px;
  border: 1px solid var(--line);
  background: var(--white);
  white-space: normal;
}

.sheet-open::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--blue);
  border-bottom: 2px solid var(--blue);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.sheet-open span,
.sheet-open b,
.sheet-open small {
  display: block;
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.sheet-open b, .locked-line b {
  font-size: 16px;
}

.sheet-open small, .locked-line {
  color: var(--muted);
}

.locked-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  min-height: 40px;
  margin: 0;
  padding: 8px 12px;
  background: var(--white);
  border: 1px solid var(--line);
}

.locked-line span { margin: 0; }

.reference {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 12px var(--pad) max(10px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
}

.ref-caption, .ref-symbols h2 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.ref-draw {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
}

.ref-draw svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}

.symbol-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.symbol-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 12px;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.symbol-row b,
.symbol-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.symbol-row span { color: var(--muted); font-size: 13px; }

.picker-backdrop, .profile-backdrop, .splash-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 17, 28, 0.46);
}

.picker-panel, #access-layer .profile-menu, #splash-layer .splash-card {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(92dvh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 18px 18px 0 0;
  padding: 12px var(--pad) max(12px, env(safe-area-inset-bottom));
}

.picker-head, .profile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.picker-head h2, .profile-head h2, .splash-card h2 { margin: 0; font-size: 20px; }

.picker-head p, .profile-hint, .upgrade .why, .splash-lead, .splash-free, .splash-price {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.4;
}

.picker-close, .profile-cancel, .splash-dismiss, .upgrade-remove {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 750;
  cursor: pointer;
}

.picker-tools { display: grid; gap: 8px; margin: 8px 0; }

.picker-search {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
}

.picker-filters { display: flex; gap: 6px; overflow: auto; }

.picker-filters select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  padding: 0 8px;
}

.picker-body { overflow: auto; min-height: 0; }

.picker-row, .chooser-row {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.chooser-row { min-height: 48px; }

.picker-name { display: grid; flex: 1; }

.picker-brand, .picker-pro { font-size: 12px; color: var(--blue); font-weight: 700; }

.picker-empty { color: var(--muted); }

.upgrade-actions { display: grid; gap: 8px; }

.upgrade-buy {
  width: 100%;
  height: auto;
  padding: 10px 16px;
  line-height: 1.25;
  white-space: normal;
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
  font-weight: 750;
}

@media (max-width: 520px) {
  :root { --pad: 10px; }
  .bar { gap: 6px; padding-top: 6px; padding-bottom: 6px; }
  .brand { gap: 6px; }
  .brand-mark { width: 30px; height: 30px; flex-basis: 30px; }
  .brand-name { font-size: 16px; }
  .pages { gap: 4px; }
  .page-tab, .pro-btn { min-height: 34px; padding: 0 10px; font-size: 13px; }
  .readout { padding: 8px var(--pad) 6px; }
  .readout-kicker { margin-bottom: 2px; }
  .inputs { column-gap: 8px; row-gap: 6px; padding-top: 6px; }
  .seg-btn { min-height: 32px; padding: 4px 8px; font-size: 12px; }
  .sheet-open { min-height: 42px; }
  .sheet-open b, .locked-line b { font-size: 15px; }
  .locked-line { min-height: 36px; padding: 6px 10px; }
  .disclaimer { font-size: 11px; line-height: 1.3; }
}

@media (max-width: 360px) {
  .bar { gap: 4px; padding-left: 8px; padding-right: 8px; }
  .brand { gap: 4px; }
  .brand-mark { width: 26px; height: 26px; flex-basis: 26px; }
  .brand-mark svg { width: 16px; height: 16px; }
  .brand-name { font-size: 14px; }
  .page-tab, .pro-btn { padding: 0 7px; font-size: 12px; }
  .figure-value { font-size: 24px; }
  .seg-btn { padding: 4px 6px; font-size: 11px; }
}

.upgrade-error { color: var(--danger); }

.splash-list { margin: 8px 0; padding-left: 18px; }

#splash-layer {
  pointer-events: none;
}

#splash-layer .splash-card {
  pointer-events: auto;
  top: 72px;
  bottom: auto;
  left: 16px;
  right: 16px;
  transform: none;
  max-width: 420px;
  margin: 0 auto;
  border-radius: 18px;
  max-height: min(46dvh, 360px);
}

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

.splash-x {
  border: 0;
  background: transparent;
  color: var(--ink, #102033);
  font-size: 28px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.is-secret {
  filter: blur(11px);
  user-select: none;
  pointer-events: none;
}

@media (min-width: 960px) {
  .bar, .readout, .inputs, .reference {
    padding-left: 28px;
    padding-right: 28px;
  }
  .inputs { column-gap: 20px; }
}

@media (max-height: 760px) {
  .bar { padding-top: 4px; padding-bottom: 4px; }
  .brand-mark { width: 28px; height: 28px; flex-basis: 28px; }
  .page-tab, .pro-btn { min-height: 32px; }
  .readout { padding-top: 6px; padding-bottom: 4px; }
  .readout-kicker { margin-bottom: 2px; font-size: 11px; }
  .figure-value { font-size: clamp(22px, 3.6vh, 32px); }
  .inputs { row-gap: 4px; padding-top: 6px; padding-bottom: 6px; }
  .field legend, .locked-line span, .sheet-open span { margin-bottom: 2px; }
  .seg-btn { min-height: 30px; padding: 3px 10px; }
  .sheet-open { min-height: 38px; padding-top: 4px; padding-bottom: 4px; }
  .locked-line { min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
  .disclaimer { font-size: 11px; line-height: 1.25; }
}

@media (max-width: 520px) and (max-height: 720px) {
  .bar { padding-top: 2px; padding-bottom: 2px; }
  .brand-mark { width: 24px; height: 24px; flex-basis: 24px; }
  .brand-name { font-size: 14px; }
  .page-tab, .pro-btn { min-height: 28px; padding: 0 8px; font-size: 12px; }
  .readout { padding-top: 4px; padding-bottom: 3px; }
  .figure-value { font-size: 22px; }
  .inputs { row-gap: 3px; padding-top: 4px; padding-bottom: 4px; }
  .field legend, .locked-line span, .sheet-open span { margin-bottom: 1px; font-size: 10px; }
  .seg { gap: 4px; }
  .seg-btn { min-height: 26px; padding: 2px 6px; font-size: 11px; }
  .sheet-open { min-height: 34px; padding-top: 3px; padding-bottom: 3px; }
  .sheet-open b, .locked-line b { font-size: 14px; }
  .locked-line { min-height: 28px; }
  .disclaimer { font-size: 10px; line-height: 1.25; }
}

@media (min-width: 880px) {
  .picker-panel, #access-layer .profile-menu {
    left: 50%;
    right: auto;
    width: min(640px, calc(100% - 32px));
    transform: translateX(-50%);
    bottom: 24px;
    border-radius: 18px;
  }
}

#access-layer .profile-menu,
#splash-layer .splash-card {
  overflow-y: auto;
}

.splash-kicker {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.pay-links {
  display: flex;
  gap: 16px;
  margin: 2px 0 10px;
}

.pay-links a {
  color: var(--blue);
  font-weight: 700;
  font-size: 13px;
}

a.page-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.legal {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px var(--pad) max(16px, env(safe-area-inset-bottom));
}

.legal h1 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.legal p {
  margin: 0 0 12px;
  line-height: 1.45;
}

.legal a {
  color: var(--blue);
  font-weight: 700;
}
