/* Refined design (mockup). Loaded after app.css; everything is scoped to :root.v2.
   Principles: one hero (the answer), one accent used only for meaning, hairlines over fills,
   tight flat-sided figures, fewer containers, no decorative icons. */

:root.v2 {
  --accent: #e0973a;            /* deeper amber: the answer and the current selection only */
  --accent-soft: rgba(224, 151, 58, 0.14);
  --warn: #d9a400;
  --danger: #e5484d;
  --bg: #f3f2ef;                /* warm paper */
  --surface: #ffffff;
  --card: #ffffff;
  --raised: #fbfaf8;
  --text: #121314;
  --muted: rgba(18, 19, 20, 0.56);
  --faint: rgba(18, 19, 20, 0.34);
  --hair: rgba(18, 19, 20, 0.10);
  --separator: rgba(18, 19, 20, 0.10);
  --fill: rgba(18, 19, 20, 0.05);
  --bar: rgba(243, 242, 239, 0.86);
  --on-accent: #ffffff;
  --glass: #eceee9; --ink: #18191a; --rim: rgba(18, 19, 20, 0.22);
}
@media (prefers-color-scheme: dark) {
  :root.v2:not(.light) {
    --bg: #0d0e0f;              /* graphite */
    --surface: #151718;
    --card: #151718;
    --raised: #1b1d1f;
    --text: #eeeeeb;
    --muted: rgba(238, 238, 235, 0.56);
    --faint: rgba(238, 238, 235, 0.30);
    --hair: rgba(238, 238, 235, 0.09);
    --separator: rgba(238, 238, 235, 0.09);
    --fill: rgba(238, 238, 235, 0.06);
    --bar: rgba(13, 14, 15, 0.84);
    --on-accent: #111;
    --glass: #c9ccc6; --ink: #121314; --rim: rgba(238, 238, 235, 0.16);
  }
}
:root.v2.dark {
    --bg: #0d0e0f;              /* graphite */
    --surface: #151718;
    --card: #151718;
    --raised: #1b1d1f;
    --text: #eeeeeb;
    --muted: rgba(238, 238, 235, 0.56);
    --faint: rgba(238, 238, 235, 0.30);
    --hair: rgba(238, 238, 235, 0.09);
    --separator: rgba(238, 238, 235, 0.09);
    --fill: rgba(238, 238, 235, 0.06);
    --bar: rgba(13, 14, 15, 0.84);
    --on-accent: #111;
    --glass: #c9ccc6; --ink: #121314; --rim: rgba(238, 238, 235, 0.16);
}
:root.v2.night {
  --bg: #000; --surface: #0b0b0b; --card: #0b0b0b; --raised: #101010; --text: #fff;
  --muted: rgba(255, 255, 255, 0.6); --faint: rgba(255, 255, 255, 0.32); --hair: rgba(255, 255, 255, 0.12);
  --separator: rgba(255, 255, 255, 0.12); --bar: rgba(0, 0, 0, 0.9); --on-accent: #000;
  --glass: #0e0e0e; --ink: #8a8a8a; --rim: rgba(255, 255, 255, 0.18);
}

.v2 body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
.v2 .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "ss01" 1; }
.v2 .label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted);
}

/* MARK: Header — the rifle is the title; the compact answer takes over once the hero scrolls away */

.v2 #appbar { background: var(--bar); border-bottom: 1px solid transparent; }
.v2 body.past-hero #appbar { border-bottom-color: var(--hair); }
.v2 .appbar-inner { justify-content: space-between; gap: 12px; height: 56px; }
.v2 .rifle-pick { position: relative; display: flex; flex-direction: column; min-width: 0; cursor: pointer; padding: 4px 0; }
.v2 .rifle-pick .name { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; display: flex; align-items: center; gap: 6px; }
.v2 .rifle-pick .name .icon { width: 14px; height: 14px; color: var(--faint); }
.v2 .rifle-pick .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2 .header-answer { display: none; align-items: baseline; gap: 12px; font-size: 17px; font-weight: 600; }
.v2 body.past-hero .rifle-pick { display: none; }
.v2 body.past-hero .header-answer { display: flex; }
.v2 .header-answer .d { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent); margin-left: 3px; }
.v2 .header-answer .r { font-size: 13px; font-weight: 500; color: var(--muted); }
.v2 .icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--hair); background: transparent;
  color: var(--muted); display: grid; place-items: center; flex: none;
}
.v2 .icon-btn .icon { width: 18px; height: 18px; }
.v2 .icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.v2 .page { padding-top: calc(56px + var(--safe-top) + 6px); }

/* MARK: Hero — the answer */

.v2 .hero {
  display: block; width: 100%; text-align: left; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--hair); border-radius: 22px; padding: 18px 20px 16px; margin: 4px 0 12px;
}
.v2 .hero-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.v2 .hero-axes { display: grid; grid-template-columns: 1fr 1px 1fr; gap: 18px; }
.v2 .hero-rule { background: var(--hair); }
.v2 .readout { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0 6px; }
.v2 .readout .val {
  font-size: 64px; line-height: 0.92; font-weight: 600; letter-spacing: -0.045em; font-variant-numeric: tabular-nums;
  display: inline-block;
}
.v2 .readout .side { display: flex; flex-direction: column; gap: 3px; padding-top: 6px; }
.v2 .readout .dir { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; color: var(--accent); }
.v2 .readout .unit { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted); }
.v2 .action { font-size: 14px; color: var(--muted); }
.v2 .action b { color: var(--text); font-weight: 600; }
.v2 .hero-stats {
  display: flex; justify-content: space-between; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--hair);
  font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.v2 .hero-stats b { color: var(--text); font-weight: 600; }
.v2 .hero-note { margin-top: 10px; font-size: 12.5px; color: var(--warn); display: flex; gap: 6px; align-items: center; }
.v2 .hero-note::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: none; }

@keyframes roll { from { transform: translateY(0.18em); opacity: 0.35; } }
.v2 .roll { animation: roll 0.22s cubic-bezier(.2, .8, .2, 1); }

/* MARK: Reticle */

.v2 .scope { background: var(--surface); border: 1px solid var(--hair); border-radius: 22px; padding: 18px 20px 14px; margin-bottom: 12px; }
.v2 .scope .reticle-wrap { max-width: 300px; margin: 2px auto 12px; }
.v2 .scope-caption { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.v2 .scope-caption b { color: var(--text); font-weight: 600; }

/* MARK: Conditions — one panel, hairline sections */

.v2 .panel { background: var(--surface); border: 1px solid var(--hair); border-radius: 22px; margin-bottom: 12px; overflow: hidden; }
.v2 .section { padding: 16px 20px; }
.v2 .section + .section { border-top: 1px solid var(--hair); }
.v2 .section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }

.v2 .big-input { display: flex; align-items: baseline; gap: 6px; }
.v2 .big-input .num {
  font: 600 34px/1 -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif; letter-spacing: -0.035em;
  width: 3.4ch; text-align: left; padding: 2px 0; font-variant-numeric: tabular-nums;
  field-sizing: content; min-width: 1ch;
}
.v2 .big-input .num:focus { background: var(--fill); padding: 2px 4px; }
.v2 .big-input .u { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }

/* Range ruler: scroll to set distance; the center line is the reading. */
.v2 .ruler { position: relative; margin: 6px -20px 0; height: 54px; }
.v2 .ruler-scroll {
  position: absolute; inset: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; touch-action: pan-x;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
.v2 .ruler-scroll::-webkit-scrollbar { display: none; }
.v2 .ruler-scroll { scroll-snap-type: x mandatory; overscroll-behavior-x: contain; }
.v2 .ruler-snap { position: absolute; top: 0; width: 1px; height: 1px; scroll-snap-align: center; pointer-events: none; }
.v2 .ruler-track { position: relative; height: 100%; }
.v2 .ruler-ticks {
  position: absolute; left: 0; right: 0; top: 6px; height: 30px;
  background-image:
    linear-gradient(90deg, var(--muted) 1px, transparent 1px),
    linear-gradient(90deg, var(--faint) 1px, transparent 1px);
  background-size: var(--major) 22px, var(--minor) 12px;
  background-repeat: repeat-x; background-position: 0 0, 0 0;
}
.v2 .ruler-label { position: absolute; top: 34px; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.v2 .ruler-needle { position: absolute; left: 50%; top: 0; width: 2px; height: 34px; margin-left: -1px; background: var(--accent); border-radius: 1px; pointer-events: none; }

.v2 .inline-row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 15px; }
.v2 .inline-row .k { color: var(--muted); }
.v2 .nudge { display: inline-flex; align-items: center; gap: 2px; }
.v2 .nudge button {
  width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--hair); background: transparent; color: var(--text);
  display: grid; place-items: center;
}
.v2 .nudge button .icon { width: 14px; height: 14px; }
.v2 .nudge .v { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Wind compass */
.v2 .wind { display: flex; align-items: center; gap: 18px; }
.v2 .compass { width: 168px; height: 168px; flex: none; touch-action: none; cursor: pointer; }
.v2 .compass svg { width: 100%; height: 100%; display: block; overflow: visible; }
.v2 .wind-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.v2 .wind-side .from { font-size: 13px; color: var(--muted); }

/* Atmosphere: four readings in a grid */
.v2 .grid4 { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--hair); margin: 12px -20px 0; }
.v2 .cell { padding: 12px 20px; display: flex; flex-direction: column; gap: 4px; }
.v2 .cell:nth-child(odd) { border-right: 1px solid var(--hair); }
.v2 .cell:nth-child(n+3) { border-top: 1px solid var(--hair); }
.v2 .cell .val { display: flex; align-items: baseline; gap: 4px; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.v2 .cell .val .num { width: 4.2ch; field-sizing: content; min-width: 1ch; text-align: left; font-size: 20px; font-weight: 600; padding: 0; letter-spacing: -0.02em; }
.v2 .cell .val .num:focus { padding: 0 4px; }
.v2 .cell .val .u { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.v2 .text-links { display: flex; gap: 18px; }
.v2 .text-link { border: 0; background: transparent; padding: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.v2 .text-link:hover { color: var(--text); }
.v2 .text-link.accent { color: var(--accent); }
.v2 .sensor-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0 0; font-size: 15px; }
.v2 .sensor-row .k { color: var(--muted); }
.v2 .sensor-row .v { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.v2 .sensor-row .icon-btn { width: 32px; height: 32px; }
.v2 .sensor-row .icon-btn .icon { width: 15px; height: 15px; }

/* MARK: Tab bar — hairline, accent only on the current tab */

.v2 #tabbar { background: var(--bar); border-top: 1px solid var(--hair); padding-top: 8px; }
.v2 .tab { color: var(--faint); background: none !important; font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em; }
.v2 .tab .icon { width: 24px; height: 24px; }
.v2 .tab .tab-rifles { width: 40px; }
.v2 .tab.on { color: var(--accent); }


.v2 .ruler-track { flex: none; }
@supports (field-sizing: content) {
  .v2 .big-input .num, .v2 .cell .val .num { width: auto; }
}
.v2 .nudge { gap: 8px; }

/* MARK: App shell */

.v2 .header-left { flex: 1; min-width: 0; display: flex; align-items: center; }
.v2 body[data-tab="solve"] .large-title { display: none; }
.v2 .large-title { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; margin: 8px 2px 14px; }
.v2 body:not([data-tab="solve"]) .page { padding-top: calc(56px + var(--safe-top)); }
.v2 .toolbar { gap: 8px; }
.v2 .toolbar-btn {
  height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--hair); background: transparent;
  color: var(--text); font-size: 15px; font-weight: 500;
}
.v2 .toolbar-btn.round-btn { width: 38px; height: 38px; padding: 0; }
.v2 .toolbar-btn .icon { width: 18px; height: 18px; color: var(--muted); }
.v2 .toolbar-btn:disabled { opacity: 0.35; }

/* MARK: Shared components on the other tabs and in panels */

.v2 hr { border-top-color: var(--hair); }
.v2 .card { background: var(--surface); border: 1px solid var(--hair); border-radius: 18px; padding: 12px 18px; }
.v2 .card.list { padding: 0 18px; }
.v2 .card.flush { padding: 2px 0; }
.v2 .section-title { font-size: 11px; font-weight: 600; letter-spacing: 0.09em; color: var(--muted); margin: 24px 18px 8px; }
.v2 .footnote { font-size: 12.5px; line-height: 1.4; margin: 8px 18px 14px; }
.v2 .card .footnote { margin: 6px 0 4px; }
.v2 .row { min-height: 48px; }
.v2 .row-label { font-size: 16px; }
.v2 .unit { font-size: 14px; }
.v2 select { color: var(--muted); font-size: 16px; }
.v2 .num, .v2 .text { font-size: 16px; font-variant-numeric: tabular-nums; }

/* Selection is monochrome (text on its inverse); amber stays reserved for the answer. */
.v2 .segmented { background: transparent; border: 1px solid var(--hair); border-radius: 10px; padding: 2px; }
.v2 .segmented button { color: var(--muted); font-size: 14px; font-weight: 500; border-radius: 8px; }
.v2 .segmented button.on { background: var(--text); color: var(--bg); box-shadow: none; font-weight: 600; }
.v2 .chip { background: transparent; border: 1px solid var(--hair); color: var(--muted); font-size: 14px; font-weight: 500; padding: 7px 14px; }
.v2 .chip.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.v2 .switch { background: var(--fill); outline: 1px solid var(--hair); outline-offset: -1px; }
.v2 .switch:checked { background: var(--accent); outline-color: transparent; }

.v2 .search { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; }
.v2 .primary { background: var(--text); color: var(--bg); border-radius: 14px; font-weight: 600; letter-spacing: -0.01em; }
.v2 .link { color: var(--accent); }
.v2 .list-row { min-height: 56px; }
.v2 .list-title { font-weight: 600; letter-spacing: -0.01em; }
.v2 .list-sub { font-size: 14px; }
.v2 .list-meta { font-size: 12.5px; }
.v2 .list-row.accent-text { color: var(--text); font-weight: 500; }
.v2 .list-row.accent-text .icon { color: var(--accent); }
.v2 .check-badge { background: var(--accent); color: var(--on-accent); }
.v2 .tag { color: var(--accent); background: var(--accent-soft); letter-spacing: 0.06em; }
.v2 .warning { color: var(--warn); }
.v2 .disclosure { font-size: 16px; }

.v2 .dope { font-size: 15px; }
.v2 .dope th { font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); padding-top: 12px; }
.v2 .dope td { border-top-color: var(--hair); padding-top: 11px; padding-bottom: 11px; }
.v2 .dope td.strong { font-weight: 600; }

.v2 .sheet-backdrop { background: rgba(0, 0, 0, 0.45); }
.v2 .sheet { background: var(--bg); border-radius: 20px 20px 0 0; }
.v2 .sheet-header { border-bottom-color: var(--hair); padding: 12px 18px; }
.v2 .sheet-header h2 { font-size: 16px; letter-spacing: -0.01em; }
@media (min-width: 700px) { .v2 .sheet { border-radius: 20px; } }

.v2 .reticle-wrap.small { max-width: 220px; }
.v2 .empty { font-size: 15px; }
.v2 .prose { font-size: 14.5px; }

/* Typeable angle between the − / + buttons */
.v2 .angle-field { display: inline-flex; align-items: baseline; justify-content: center; min-width: 52px; }
.v2 .angle-field .num.angle-input {
  width: 3ch; field-sizing: content; min-width: 1ch; text-align: right; padding: 4px 0; font-size: 16px; font-weight: 600;
}
.v2 .angle-field .num.angle-input:focus { padding: 4px 4px; }
.v2 .angle-field .deg { font-weight: 600; }
.v2 .angle-input::-webkit-outer-spin-button, .v2 .angle-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.v2 .angle-input { -moz-appearance: textfield; appearance: textfield; }
