/* Shared by the catalog, model and upload pages. The look borrows a spreadsheet's own
   vocabulary: gridlines, cells, a formula bar. */
:root {
  --paper: #fafcfd;
  --ink: #1c2733;
  --quiet: #5b6b7b;
  --grid: #d6e0ea;
  --lens: #0b6e75;
  --lens-ink: #ffffff;
  --selected: #e3f2f1;
  --warn: #9a3412;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #152029;
    --ink: #e4ecf2;
    --quiet: #93a4b4;
    --grid: #2c3c4a;
    --lens: #5cc3c9;
    --lens-ink: #0d1a20;
    --selected: #1b3138;
    --warn: #fdba74;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #152029;
  --ink: #e4ecf2;
  --quiet: #93a4b4;
  --grid: #2c3c4a;
  --lens: #5cc3c9;
  --lens-ink: #0d1a20;
  --selected: #1b3138;
  --warn: #fdba74;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 "Avenir Next", Avenir, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
main { max-width: 46rem; margin: 0 auto; padding: 2.5rem 16px 4rem; }
a { color: var(--lens); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--lens);
  outline-offset: 2px;
}

.masthead { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 2rem; }
.wordmark { font-size: 1.05rem; font-weight: 600; letter-spacing: 0.01em; color: var(--ink); text-decoration: none; }
.wordmark span { color: var(--lens); }
h1 { font-size: 2.1rem; line-height: 1.15; font-weight: 600; margin: 0 0 0.6rem; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 2.2rem 0 0.6rem; }
p { margin: 0 0 1rem; max-width: 38rem; }
.quiet { color: var(--quiet); }
.price { white-space: nowrap; }

/* The formula bar: a name box, then fx, then the input */
.formula-bar { display: grid; grid-template-columns: auto auto 1fr; border: 1px solid var(--grid); border-radius: 4px; background: var(--paper); }
.formula-bar > * { padding: 0.55rem 0.7rem; }
.formula-bar .name-box { border-right: 1px solid var(--grid); color: var(--quiet); min-width: 7.5rem; }
.formula-bar .fx { border-right: 1px solid var(--grid); color: var(--lens); font-style: italic; font-family: Georgia, serif; }
.formula-bar input { border: 0; background: transparent; color: inherit; font: inherit; min-width: 0; }
.formula-bar input:focus-visible { outline: none; }
.formula-bar:focus-within { border-color: var(--lens); }

/* A sheet: rows of label | cell, ruled like a grid */
.sheet { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1rem; }
.sheet th, .sheet td { border: 1px solid var(--grid); padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; }
.sheet th { font-weight: 500; width: 55%; }
.sheet th small { display: block; color: var(--quiet); font-weight: 400; }
/* A cell's value fills the whole cell, however tall its label makes the row */
.sheet td.cell { position: relative; padding: 0; min-width: 6rem; }
.sheet td.cell input, .sheet td.cell output {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 0.7rem; border: 0; background: transparent; color: inherit; font: inherit; text-align: right;
}
.sheet td.cell input[type="checkbox"] { inset: 50% 0.7rem auto auto; width: 1.1rem; height: 1.1rem; transform: translateY(-50%); }
.sheet td.cell input:focus-visible { outline: 2px solid var(--lens); outline-offset: -2px; background: var(--selected); }
.sheet td.cell output.filled { background: var(--selected); }
/* Numbers line up on the right, like a sheet's: no spinner arrows taking room */
input[type="number"] { appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* The catalog: one ruled row per model */
.models { list-style: none; padding: 0; margin: 1.2rem 0 0; border-top: 1px solid var(--grid); }
.models li { border-bottom: 1px solid var(--grid); }
.models a { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 1.2rem; padding: 0.85rem 0.25rem; color: inherit; text-decoration: none; }
.models a:hover, .models a:focus-visible { background: var(--selected); }
.models .title { font-weight: 600; color: var(--lens); }
.models .about { grid-column: 1 / -1; color: var(--quiet); font-size: 0.93rem; }

button, .button {
  font: inherit; font-weight: 600; color: var(--lens-ink); background: var(--lens);
  border: 1px solid var(--lens); border-radius: 4px; padding: 0.55rem 1.1rem; cursor: pointer;
}
button.secondary { color: var(--lens); background: transparent; }
button:disabled { opacity: 0.55; cursor: progress; }

label { display: block; margin: 0.8rem 0 0.25rem; font-weight: 500; }
input[type="text"], input[type="number"], input[type="url"], textarea {
  width: 100%; padding: 0.5rem 0.65rem; font: inherit; color: inherit; background: var(--paper);
  border: 1px solid var(--grid); border-radius: 4px;
}
textarea { min-height: 4.5rem; resize: vertical; }
input[type="file"] { font: inherit; color: var(--quiet); max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; color: var(--lens); background: transparent;
  border: 1px solid var(--lens); border-radius: 4px; padding: 0.45rem 1rem; margin-right: 0.8rem; cursor: pointer;
}
.hint { color: var(--quiet); font-size: 0.9rem; margin: 0.25rem 0 0; }

.status { border-left: 3px solid var(--lens); padding: 0.4rem 0.9rem; margin: 1rem 0; }
.status.error { border-color: var(--warn); color: var(--warn); }
.status:empty { display: none; }

@media (max-width: 34rem) {
  h1 { font-size: 1.7rem; }
  .formula-bar .name-box { display: none; }
  .formula-bar { grid-template-columns: auto 1fr; }
  .sheet th { width: 50%; }
}
@media (prefers-reduced-motion: no-preference) {
  .sheet td.cell output.filled { transition: background-color 0.4s; }
}
