/* Farm planner. Same tokens, type and parts as the live site (site/index.html,
   site/kit.html): studio-grey ground, ink type, one blue accent, Inter Tight
   for display, Sora for body, JetBrains Mono for small labels. Panels over the
   3D scene are the kit page's frosted light bar, lifted onto rounded cards;
   the camera's own view is the landing page's dark "real software" card. */
:root {
  color-scheme: light;
  --ground:  #DEDFE3;   /* page, and the table the 3D model sits on */
  --paper:   #F4F5F7;   /* kit page ground */
  --panel:   #E9EAEE;
  --card:    #FFFFFF;
  --ink:     #0B0C10;
  --muted:   #545866;
  --muted-2: #6B6F7B;
  --line:    #D3D5DB;
  --line-2:  #B9BCC5;
  --rule:    rgba(11,12,16,0.10);
  --blue:    #2732D6;   /* the one accent */
  --blue-dk: #1F29BD;
  --blue-soft: rgba(39,50,214,0.08);
  --alert:   #E2483C;   /* semantic only */
  --night:   #0D0E12;   /* the real-software card */
  --night-ink: #E9ECF2;
  --frost:   rgba(255,255,255,0.86);
  --shadow:  0 10px 34px rgba(11,12,16,0.12), 0 1px 2px rgba(11,12,16,0.06);

  --display: "Inter Tight", "Helvetica Neue", Arial, sans-serif;
  --body:    Sora, "Helvetica Neue", Arial, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, Menlo, monospace;
  --ease:    cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--blue); color: #fff; }
:where(a, button, input, select, summary, label):focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--blue); flex: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.3rem; border-radius: 999px; border: 1px solid transparent;
  font-family: var(--body); font-size: .92rem; font-weight: 500; text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: transform .15s var(--ease), background .2s, border-color .2s, color .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-dk); }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: var(--blue); }
.btn-ink.armed { background: var(--blue); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line-2); }
.btn-ghost.armed { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); color: var(--blue); }
.btn-ghost.danger:hover { border-color: var(--alert); color: var(--alert); }
.btn-sm { padding: .48rem .9rem; font-size: .82rem; }

/* ---------------------------------------------------------------- top bar */
/* The kit page's bar: frosted paper, hairline under it, logo left, back link right. */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  height: 60px; padding: 0 max(16px, env(safe-area-inset-left, 0px));
  background: rgba(244,245,247,0.82);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(11,12,16,0.06);
}
.logo { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none;
  font-family: var(--body); font-weight: 700; font-size: 1.2rem; letter-spacing: -0.03em; }
.logo svg { width: 28px; height: 28px; }
.back { margin-left: auto; }
.back a { font-size: .86rem; text-decoration: none; color: var(--muted-2); white-space: nowrap; }
.back a:hover { color: var(--ink); }
.estimate-pill {
  margin-left: auto;
  font-family: var(--mono); font-size: .66rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--blue); background: var(--blue-soft); border-radius: 999px; padding: .32rem .7rem; white-space: nowrap;
}
.estimate-pill + .back { margin-left: 0; }
.landing-open .bar .search, .landing-open .estimate-pill { display: none; }
.landing-open .estimate-pill + .back { margin-left: auto; }

/* ---------------------------------------------------------------- search */
.search { position: relative; display: flex; align-items: center; flex: 0 1 440px; margin-left: .75rem; }
.search svg { position: absolute; left: .9rem; width: 17px; height: 17px; fill: none; stroke: var(--muted-2); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search input {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: .55rem 1rem .55rem 2.5rem; font-size: .9rem; outline: none;
  transition: border-color .2s, box-shadow .2s; -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: #8B8F9A; }
.search input:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.search ul {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  list-style: none; margin: 0; padding: .35rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  max-height: 340px; overflow-y: auto; text-align: left;
}
.search li { padding: .6rem .75rem; border-radius: 10px; cursor: pointer; font-size: .92rem; }
.search li small { display: block; color: var(--muted-2); font-size: .78rem; }
.search li[aria-selected="true"], .search li:hover { background: var(--blue-soft); }
.search li.msg { color: var(--muted-2); cursor: default; background: none; font-size: .84rem; }

/* ---------------------------------------------------------------- landing */
/* The kit page's intro: blue eyebrow, big Inter Tight headline, muted lede. */
.landing {
  position: fixed; inset: 0; z-index: 15; overflow-y: auto;
  background: var(--paper);
  padding: calc(60px + clamp(28px, 6vw, 80px)) max(16px, env(safe-area-inset-left, 0px)) 4rem;
}
.landing-in { width: min(1100px, 100%); margin: 0 auto; }
.eyebrow { margin: 0 0 .6rem; color: var(--blue); font-weight: 600; font-size: .92rem; letter-spacing: -0.01em; }
.landing h1 {
  font-family: var(--display); font-weight: 700; letter-spacing: -0.045em; line-height: 1.0;
  font-size: clamp(2.4rem, 6vw, 4.4rem); margin: 0; text-wrap: balance;
}
.landing .lede { margin: 1rem 0 0; max-width: 40rem; color: var(--muted-2); font-size: clamp(1rem, 1.6vw, 1.18rem); text-wrap: pretty; }
.search.big { width: min(680px, 100%); margin: clamp(1.8rem, 4vw, 2.6rem) 0 0; flex: none; }
.search.big input { font-size: 1.04rem; padding: 1.1rem 10.5rem 1.1rem 3rem; border-radius: 16px; box-shadow: 0 1px 2px rgba(11,12,16,0.04); }
.search.big svg { left: 1.1rem; width: 20px; height: 20px; }
.search.big .btn { position: absolute; right: .45rem; padding: .78rem 1.25rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin-top: 1rem; color: var(--muted-2); font-size: .86rem; }
.chips span { margin-right: .2rem; }
.chips button {
  appearance: none; border: 0; background: none; cursor: pointer;
  padding: .4rem .85rem; border-radius: 999px; font-size: .84rem; color: var(--muted-2);
  transition: background .2s, color .2s;
}
.chips button:hover { background: var(--ink); color: #fff; }
.how { list-style: none; padding: 0; margin: clamp(2.6rem, 6vw, 4.4rem) 0 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.how .panel { position: static; background: var(--panel); border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; border-radius: 22px; padding: clamp(1.2rem, 2.2vw, 1.7rem); }
.how .n { font-family: var(--mono); font-size: .78rem; font-weight: 600; color: var(--blue); }
.how h3 { margin: 1.8rem 0 0; font-family: var(--body); font-weight: 600; font-size: 1.06rem; letter-spacing: -0.02em; }
.how p { margin: .45rem 0 0; color: var(--muted); font-size: .94rem; line-height: 1.5; }
.landing .fine { margin: 1.4rem 0 0; color: var(--muted-2); font-size: .8rem; }

/* ---------------------------------------------------------------- loading */
.loading {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(244,245,247,0.78); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.loading-in { width: min(320px, calc(100vw - 48px)); text-align: center; }
.loading-title { margin: 0 0 14px; font-family: var(--display); font-weight: 600; font-size: 1.15rem; letter-spacing: -0.02em; }
.progress { height: 3px; border-radius: 3px; background: rgba(11,12,16,0.10); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--blue); transition: width .25s; }

/* The site's dark "sent" pill. */
.hint {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 25;
  background: var(--ink); color: #fff; font-size: .86rem; font-weight: 500;
  padding: .55rem 1.05rem; border-radius: 999px; box-shadow: var(--shadow);
  pointer-events: none; max-width: calc(100vw - 2rem); text-align: center;
}
.hint.warn { background: var(--alert); }

/* ---------------------------------------------------------------- panels */
.panel {
  position: fixed; z-index: 10;
  background: var(--frost);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border: 1px solid rgba(11,12,16,0.06); border-radius: 22px;
  padding: 1.05rem 1.1rem;
  box-shadow: var(--shadow);
}
.panel h2 { font-family: var(--display); font-weight: 700; font-size: 1.22rem; letter-spacing: -0.035em; margin: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .8rem; }

.cams { top: 76px; left: 16px; width: 316px; max-height: calc(100vh - 76px - 40px); overflow-y: auto; overflow-x: hidden; }
.cam-list { list-style: none; margin: 0 0 .7rem; padding: 0; display: grid; gap: .4rem; }
.cam-list li {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .7rem; border-radius: 14px; cursor: pointer; font-size: .9rem; font-weight: 600; letter-spacing: -0.01em;
  background: var(--card); border: 1px solid var(--line); transition: border-color .2s, box-shadow .2s;
}
.cam-list li:hover { border-color: var(--line-2); }
.cam-list li.sel { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.cam-list .dot { width: 8px; height: 8px; }
.cam-list .meta { margin-left: auto; color: var(--muted-2); font-weight: 400; font-size: .74rem; }
.empty { color: var(--muted-2); font-size: .88rem; margin: 0; }

.editor { border-top: 1px solid var(--line); padding-top: .85rem; display: grid; gap: .7rem; }
.field { display: grid; gap: .32rem; font-size: .8rem; color: var(--muted-2); }
.field span { display: flex; justify-content: space-between; gap: .5rem; }
.field output { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.field select {
  width: 100%; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .6rem 2.2rem .6rem .75rem; font-size: .88rem; color: var(--ink); outline: none;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236B6F7B' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px;
}
.field select:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.field input[type=range] { width: 100%; accent-color: var(--blue); margin: 0; }
.type-note { margin: -.25rem 0 0; font-size: .76rem; color: var(--muted-2); line-height: 1.45; }
.ranges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
.ranges div { background: var(--paper); border-radius: 12px; padding: .45rem .55rem; }
.ranges i { display: block; width: 18px; height: 4px; border-radius: 2px; margin-bottom: .35rem; }
.ranges b { display: block; font-family: var(--display); font-weight: 700; font-size: 1.02rem; letter-spacing: -0.03em; line-height: 1.1; }
.ranges small { display: block; color: var(--muted-2); font-size: .66rem; line-height: 1.25; margin-top: .15rem; }
.row { display: flex; flex-wrap: wrap; gap: .4rem; }
.coords { margin: 0; font-family: var(--mono); font-size: .68rem; color: var(--muted-2); }

.side {
  position: fixed; right: 16px; top: 76px; bottom: 34px; z-index: 10;
  width: min(380px, 34vw); display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto; pointer-events: none; scrollbar-width: none;
}
.side::-webkit-scrollbar { display: none; }
.side > * { pointer-events: auto; flex: none; }
.summary { position: static; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; margin: 0 0 .8rem; }
.stats div { background: var(--paper); border-radius: 14px; padding: .55rem .7rem; }
.stats dt { font-size: .72rem; color: var(--muted-2); line-height: 1.3; }
.stats dd { margin: .1rem 0 0; font-family: var(--display); font-weight: 700; font-size: 1.35rem; letter-spacing: -0.04em; line-height: 1.15; }
.stats dd small { display: block; font-family: var(--body); font-weight: 400; color: var(--muted-2); font-size: .7rem; letter-spacing: 0; }
.stats .hl { background: var(--blue); color: #fff; }
.stats .hl dt, .stats .hl dd small { color: rgba(255,255,255,0.8); }
.toggle { display: flex; align-items: center; gap: .5rem; font-size: .84rem; cursor: pointer; }
.toggle input { accent-color: var(--blue); margin: 0; width: 15px; height: 15px; }
.trees-note { margin: .2rem 0 .7rem; font-size: .72rem; color: var(--muted-2); }
.legend { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: .3rem; font-size: .82rem; }
.legend li { display: flex; align-items: center; gap: .55rem; }
.legend i { width: 14px; height: 10px; border-radius: 3px; flex: none; }
.legend .px { margin-left: auto; color: var(--muted-2); font-family: var(--mono); font-size: .7rem; }
.fine { font-size: .78rem; color: var(--muted-2); }
.fine summary { cursor: pointer; color: var(--ink); font-weight: 500; }
.fine p { margin: .45rem 0 0; line-height: 1.5; }
.summary .cta { width: 100%; margin-top: .9rem; }

/* The kit page's thumbnail toggle: plain until pressed, then ink. */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(11,12,16,0.05); }
.seg button { appearance: none; border: 0; background: none; cursor: pointer; padding: .32rem .75rem; border-radius: 999px; font-size: .78rem; color: var(--muted-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------------------------------------------------------------- camera view */
/* The landing page's dark "real software" card. The view itself has no
   background: the WebGL canvas behind draws the camera's picture into its
   rectangle, so anything opaque there would hide it. */
.pip { margin: auto 0 0; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.pip-bar {
  display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem; background: var(--night); color: var(--night-ink);
  font-family: var(--mono); font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
}
.pip-bar .live { width: 8px; height: 8px; border-radius: 50%; background: #35DCDC; box-shadow: 0 0 9px #35DCDC; animation: blink 1.8s ease-in-out infinite; flex: none; }
@keyframes blink { 50% { opacity: .3; } }
.pip-sub { margin-left: auto; color: #8C93A3; letter-spacing: .06em; text-transform: none; font-weight: 500; white-space: nowrap; }
.pip-view { position: relative; width: 100%; aspect-ratio: 4 / 3; }
#pip-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.pip-note { margin: 0; padding: .65rem 1rem .8rem; background: var(--night); color: #B9C0CC; font-size: .76rem; line-height: 1.45; }
.pip-note b { color: var(--night-ink); font-weight: 600; }
.pip-off { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; text-align: center; padding: 1rem;
  background: rgba(13,14,18,0.9); color: var(--night-ink); font-size: .9rem; }

.attrib {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  padding: .4rem 16px; font-size: .66rem; color: var(--muted);
  background: linear-gradient(rgba(222,223,227,0), rgba(222,223,227,0.9));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attrib a { color: var(--muted); }

/* ------------------------------------------------------- shorter desktops */
@media (max-height: 820px) and (min-width: 761px) {
  .summary .fine { display: none; }
}
@media (max-height: 700px) and (min-width: 761px) {
  .summary .legend, .summary .trees-note { display: none; }
  .summary .stats { margin-bottom: .5rem; }
  .pip-note { display: none; }
}

/* ---------------------------------------------------------------- phones */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .bar { flex-wrap: wrap; height: auto; padding-block: .6rem; gap: .5rem; }
  .bar .search { order: 3; flex: 1 0 100%; margin-left: 0; }
  .hint { top: 118px; }
  .landing { padding-top: calc(60px + 28px); }
  .search.big { flex-wrap: wrap; }
  .search.big input { padding-right: 1rem; }
  .search.big svg { top: 1.25rem; }
  .search.big .btn { position: static; width: 100%; margin-top: .6rem; }
  .how { grid-template-columns: 1fr; }
  .how h3 { margin-top: 1rem; }
  /* Canvas takes the top half; panels scroll in a sheet below. */
  #gl { height: 52vh; }
  .side { display: contents; }
  .cams, .summary { position: fixed; left: 0; right: 0; width: auto; max-height: none; }
  .cams { top: 52vh; bottom: 0; overflow-y: auto; padding-bottom: 12rem; border-radius: 22px 22px 0 0; }
  .summary { top: auto; bottom: 0; border-radius: 0; padding: .55rem .8rem calc(.7rem + env(safe-area-inset-bottom, 0px)); max-height: 14rem; overflow-y: auto; }
  .summary .legend, .summary .fine, .summary .trees-note { display: none; }
  .summary .panel-head { margin-bottom: .45rem; }
  .summary h2 { font-size: 1rem; }
  .stats { grid-template-columns: repeat(4, 1fr); gap: .3rem; margin: 0 0 .4rem; }
  .stats div { padding: .35rem .45rem; border-radius: 10px; }
  .stats dt { font-size: .6rem; }
  .stats dd { font-size: .92rem; }
  .stats dd small { display: block; margin: 0; font-size: .6rem; }
  .summary .cta { margin-top: .5rem; padding: .6rem 1rem; }
  .pip { position: fixed; z-index: 10; margin: 0; right: 8px; top: calc(52vh - 8px); transform: translateY(-100%); width: 46vw; border-radius: 16px; }
  .pip-bar { padding: .45rem .6rem; font-size: .58rem; }
  .pip-sub, .pip-note { display: none; }
  /* Attribution is a licence condition, so it stays: tucked at the canvas's bottom-left. */
  .attrib { top: calc(52vh - 34px); bottom: auto; right: calc(46vw + 16px); white-space: normal; font-size: .55rem; line-height: 1.3; background: none; padding: 0 0 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .progress span { transition: none; }
  .pip-bar .live { animation: none; }
}
