/* Plimsoll: an instrument screen. Black, white and one lemon; square-cut
   Chakra Petch; large figures with fixed-width digits; a gauge made of ticks;
   hairline rows. A signal orange is kept for what is over a line. The light
   appearance is the same instrument on white, with black ticks, because lemon
   can't be read on white. */

@font-face { font-family: "Chakra Petch"; font-weight: 500; font-display: swap; src: url("fonts/chakra-petch-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 600; font-display: swap; src: url("fonts/chakra-petch-latin-600-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #000000;
  --grey: #666666;
  --off: #e4e4e4;
  --frame: #e4e4e4;
  --lemon: #f2ea3a;
  --alert: #c22f0a;
  /* the gauge: what a lit tick is, and the ripple after a quit */
  --tick: #000000;
  --done: #a39b00;
  --focus: #000000;
  --glow: 0;
  --type: "Chakra Petch", "Bahnschrift", "DIN Alternate", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --ink: #ffffff;
    --grey: #8d8d8d;
    --off: #2b2b2b;
    --frame: #141414;
    --alert: #ff5c36;
    --tick: #f2ea3a;
    --done: #ffffff;
    --focus: #f2ea3a;
    --glow: 1;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --ink: #ffffff;
  --grey: #8d8d8d;
  --off: #2b2b2b;
  --frame: #141414;
  --alert: #ff5c36;
  --tick: #f2ea3a;
  --done: #ffffff;
  --focus: #f2ea3a;
  --glow: 1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 500 15px/1.4 var(--type); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 500; }

.label, h2, h3, .chip, .banner strong, thead th, .power, .tag {
  font-size: 14px; font-weight: 500; line-height: 18px; letter-spacing: 0.09em; text-transform: uppercase;
}
.label, h3 { color: var(--grey); }
.footnote { color: var(--grey); font-size: 13px; line-height: 18px; }

/* ---------- Buttons: square, outlined, inverting under the finger ---------- */

button {
  font: inherit; color: var(--ink); background: none; border: 1px solid var(--off); border-radius: 0;
  padding: 6px 12px; cursor: pointer; transition: scale 90ms ease-out, border-color 90ms ease-out;
}
button:hover:not(:disabled) { border-color: var(--ink); }
button:active:not(:disabled) { background: var(--ink); color: var(--bg); scale: 0.98; }
button:disabled { color: var(--grey); cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
button.outline, button.solid { border-color: var(--ink); font-size: 14px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; }
button.solid { background: var(--ink); color: var(--bg); }
button.solid:active:not(:disabled) { background: var(--bg); color: var(--ink); }
button.danger { background: var(--alert); border-color: var(--alert); color: var(--bg); }

/* ---------- The header, which is the title bar in Entry for desktop ---------- */

/* env(titlebar-area-*) keeps clear of the system's own buttons. In a browser
   the fallbacks make it an ordinary header. */
.bridge {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: max(52px, env(titlebar-area-height, 52px));
  padding: 6px 16px;
  padding-left: calc(env(titlebar-area-x, 0px) + 16px);
  padding-right: calc(100% - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100%) + 16px);
  background: var(--bg); border-bottom: 1px solid var(--off);
  app-region: drag; -webkit-app-region: drag; user-select: none;
}
.bridge button { app-region: no-drag; -webkit-app-region: no-drag; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; min-width: 0; }
.brand svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; }
.chip { font-size: 11px; line-height: 14px; padding: 3px 7px 2px; border: 1px solid var(--off); color: var(--grey); white-space: nowrap; }
.chip.live { border-color: var(--ink); color: var(--ink); }
.chip.sample { background: var(--lemon); border-color: var(--lemon); color: #000; }

/* The button that makes the window small, and back. */
.shrink { order: 1; flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-color: transparent; }
.shrink svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
.shrink .out, :root[data-compact] .shrink .in { display: none; }
:root[data-compact] .shrink .out { display: inline; }
.brand { margin-right: auto; }

ui-tabs-list { position: relative; display: flex; gap: 2px; }
ui-tabs-list button { border: 0; color: var(--grey); font-size: 13px; letter-spacing: 0.09em; text-transform: uppercase; white-space: nowrap; padding: 9px 10px; }
ui-tabs-list button[aria-selected="true"] { color: var(--ink); }
ui-tabs-list button:hover:not(:disabled) { color: var(--ink); }
ui-tabs-indicator {
  position: absolute; bottom: 0; left: 0; height: 3px; background: var(--tick);
  width: var(--active-tab-width); translate: var(--active-tab-left) 0;
  transition: translate 260ms cubic-bezier(0.2, 0.7, 0.2, 1), width 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
  pointer-events: none;
}

main { padding: 16px; max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Sample data: striped like a hazard board, so it can't pass for real ---------- */

.banner { position: relative; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 11px 14px 11px 28px; border: 1px solid var(--off); }
.banner::before { content: ""; position: absolute; inset: -1px auto -1px -1px; width: 12px; background: repeating-linear-gradient(135deg, var(--lemon) 0 5px, #000 5px 10px); }
.banner p { flex: 1 1 260px; color: var(--grey); }
.banner strong { color: var(--ink); margin-right: 4px; }
.banner-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.setup { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.setup .label { margin-right: 4px; }

.segmented { display: inline-flex; width: fit-content; border: 1px solid var(--ink); }
ui-segmented-control-item { display: block; padding: 5px 13px; font-size: 13px; line-height: 20px; letter-spacing: 0.09em; text-transform: uppercase; cursor: pointer; user-select: none; }
ui-segmented-control-item[data-checked] { background: var(--ink); color: var(--bg); }

/* ---------- The screen ---------- */

.panel { display: grid; grid-template-columns: minmax(0, 540px) minmax(0, 1fr); gap: 16px; align-items: start; }
.screen, .apps, .card { border: 1px solid var(--frame); border-radius: 18px; min-width: 0; }
.screen { padding: 28px 32px 24px; }

.hero { display: block; }
.top { display: flex; justify-content: space-between; gap: 12px; }
.top .label:last-child { margin-right: -0.09em; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.read { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; min-height: 108px; padding-bottom: 2px; }
.value { display: flex; align-items: baseline; margin-left: -4px; font-size: 88px; line-height: 76px; letter-spacing: -0.02em; white-space: nowrap; }
.value small { margin-left: 8px; color: var(--grey); font-size: 28px; letter-spacing: 0; }
.figs span { display: inline-block; }
.figs span[data-digit] { width: 0.6em; text-align: center; }
.value .figs span[data-digit="1"]:first-child { margin-left: -0.105em; }
.verdict { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 0; text-align: right; padding-bottom: 6px; }
.verdict .label { margin-right: -0.09em; }
.verdict h1 { font-size: 28px; line-height: 30px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.screen.is-over .verdict h1, .screen.is-over .verdict .label { color: var(--alert); }

/* The gauge. These CSS ticks show without WebGL; with it, the canvas draws
   them and the elements keep the meter's meaning and size. */
.stage { position: relative; height: 56px; margin-top: 20px; cursor: crosshair; }
.ticks { display: block; position: relative; height: 56px; background: repeating-linear-gradient(90deg, var(--off) 0 4px, transparent 4px 8px); }
.ticks-fill { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--tick) 0 4px, transparent 4px 8px); transition: width 560ms cubic-bezier(0.25, 0.46, 0.45, 0.94); }
.screen.is-over .ticks-fill { background: repeating-linear-gradient(90deg, var(--alert) 0 4px, transparent 4px 8px); }
#tide { position: absolute; left: 0; top: -26px; width: 100%; height: 108px; pointer-events: none; display: block; }
.stage.is-drawn .ticks { background: none; }
.stage.is-drawn .ticks-fill { visibility: hidden; }
.stage:not(.is-drawn) #tide { visibility: hidden; }
/* Above the canvas, so the glow never washes over the numbers. */
.scale { position: relative; z-index: 1; display: flex; justify-content: space-between; margin-top: 10px; color: var(--grey); font-size: 13px; line-height: 16px; letter-spacing: 0.06em; }

.why { margin-top: 12px; min-height: 21px; }
.also { margin-top: 2px; color: var(--grey); font-size: 13px; }

.rows { margin-top: 14px; border-top: 1px solid var(--off); }
.row {
  display: grid; grid-template-columns: 150px minmax(0, 1fr) 104px; align-items: center; gap: 0 6px;
  width: 100%; min-height: 42px; padding: 2px 0; text-align: left; border: 0; border-bottom: 1px solid var(--off);
}
button.row:hover:not(:disabled) { border-color: var(--ink); }
button.row:active:not(:disabled) { scale: 1; }
button.row:active .row-note, button.row:active small { color: inherit; }
.row-name { display: flex; flex-direction: column; min-width: 0; font-size: 18px; line-height: 21px; }
.row-note { color: var(--grey); font-size: 11.5px; line-height: 15px; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-size { text-align: right; white-space: nowrap; font-size: 18px; line-height: 24px; }
.row-size small { color: var(--grey); font-size: 14px; }
.row .line { display: block; }
.line ui-meter-track, .line-track { display: block; position: relative; height: 4px; background: var(--off); }
.line ui-meter-indicator { display: block; height: 100%; background: var(--ink); transition: width 560ms cubic-bezier(0.25, 0.46, 0.45, 0.94); }

.action {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 48px; margin-top: 18px; padding: 8px 16px;
  border: 1px solid var(--ink); font-size: 15px; font-weight: 600; line-height: 20px; letter-spacing: 0.09em; text-transform: uppercase; text-align: left;
}
.action span:first-child { overflow-wrap: anywhere; }
.action span:last-child { white-space: nowrap; }
.action:disabled { border-color: var(--off); }
.screen.is-over .action:not(:disabled) { border-color: var(--alert); }
.screen.is-over .action:not(:disabled):active { background: var(--alert); }

/* ---------- Graphs ---------- */

.tide { display: block; width: 100%; height: 28px; overflow: visible; }
.card .tide { height: 76px; border-bottom: 1px solid var(--off); }
.tide-grid { stroke: var(--off); stroke-width: 1; vector-effect: non-scaling-stroke; }
.tide-area { fill: var(--ink); opacity: 0.07; }
.tide-line { fill: none; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }

/* ---------- By app ---------- */

.apps { padding: 24px 24px 14px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.linkish { border: 0; padding: 2px 4px; color: var(--grey); font-size: 13px; letter-spacing: 0.09em; text-transform: uppercase; }
.linkish[aria-pressed="true"] { color: var(--ink); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
thead th { font-size: 11.5px; color: var(--grey); text-align: right; padding: 0 6px 8px; border-bottom: 1px solid var(--off); }
thead th:first-child { text-align: left; padding-left: 0; width: 30%; }
thead th:last-child { width: 64px; }
thead button { font: inherit; letter-spacing: inherit; text-transform: inherit; border: 0; padding: 0; color: inherit; }
thead th[aria-sort] button { color: var(--ink); box-shadow: 0 2px 0 var(--tick); }
tbody th { text-align: left; font-weight: 500; padding: 9px 6px 9px 0; }
tbody tr { border-bottom: 1px solid var(--off); }
.app-name { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { display: block; font-size: 10px; line-height: 13px; color: var(--grey); white-space: nowrap; }
td { padding: 9px 6px; }
.number { text-align: right; white-space: nowrap; }
.number.over span { color: var(--alert); font-weight: 600; }
/* The tick two thirds along each small bar is the load line. */
.bar { display: block; position: relative; height: 4px; margin-top: 5px; background: var(--off); }
.bar::after { content: ""; position: absolute; left: 66.7%; top: -3px; width: 2px; height: 10px; background: var(--tick); }
.bar b { display: block; height: 100%; background: var(--ink); }
.over .bar b { background: var(--alert); }
tr.is-over th .app-name { color: var(--alert); font-weight: 600; }
.act { text-align: right; padding-right: 0; }
.quit { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 7px; }
.hidden-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.apps .footnote { margin-top: 10px; }

/* ---------- All readings and settings ---------- */

.all h2, .apps h2, .card h2 { line-height: 18px; }
.quality { margin-bottom: 12px; }
.quality.good .label { color: var(--ink); }
.quality.fair .label { color: var(--ink); }
.quality.poor .label { color: var(--alert); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card { padding: 18px 20px; }
.card header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.card .figure { font-size: 28px; line-height: 32px; white-space: nowrap; }
.card .stats { margin-top: 6px; color: var(--grey); font-size: 12.5px; }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.settings .card { display: flex; flex-direction: column; gap: 13px; align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; width: 100%; }
.fields { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.field { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; width: 100%; }
.field output { font-size: 18px; white-space: nowrap; }
.field ui-slider { grid-column: 1 / -1; }
ui-slider-control { display: flex; align-items: center; height: 24px; padding: 0 5px; cursor: pointer; touch-action: none; }
ui-slider-track { position: relative; flex: 1; height: 12px; background: repeating-linear-gradient(90deg, var(--off) 0 3px, transparent 3px 6px); }
ui-slider-indicator { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--tick) 0 3px, transparent 3px 6px); }
ui-slider-thumb { width: 8px; height: 24px; background: var(--ink); }
ui-slider-thumb:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
ui-checkbox { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; margin-top: 1px; border: 1px solid var(--ink); }
ui-checkbox[data-checked] { background: var(--ink); }
ui-checkbox-indicator { width: 10px; height: 5px; border: solid var(--bg); border-width: 0 0 2.5px 2.5px; rotate: -45deg; translate: 0 -1px; }
ui-checkbox:not([data-checked]) ui-checkbox-indicator { visibility: hidden; }

.powers { list-style: none; margin: 0; padding: 0; width: 100%; border-top: 1px solid var(--off); }
.powers li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--off); }
.power { font-size: 11.5px; color: var(--grey); }
.power.granted { color: var(--ink); }
.power.denied { color: var(--alert); }
kbd { font: 12px var(--type); border: 1px solid var(--off); padding: 0 5px; margin-left: 8px; }

/* ---------- The question before a quit, and short notes ---------- */

.backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.72); }
.sheet {
  position: fixed; z-index: 31; top: 50%; left: 50%; translate: -50% -50%; width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px); overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: 24px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--ink); border-radius: 18px;
}
ui-alert-dialog-title { font-size: 24px; line-height: 28px; overflow-wrap: anywhere; }
ui-alert-dialog-description { display: block; color: var(--grey); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.sheet-actions button { padding: 9px 14px; }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 15px; max-width: calc(100vw - 32px); width: max-content; z-index: 40; }

/* In a short window, like Entry's default one, the quit button stays in sight. */
@media (min-width: 981px) and (max-height: 840px) {
  main { padding-top: 12px; gap: 10px; }
  .screen { padding: 18px 28px 16px; }
  .value { font-size: 72px; line-height: 62px; }
  .read { min-height: 84px; }
  .stage { margin-top: 14px; height: 48px; }
  .ticks { height: 48px; }
  .scale { margin-top: 8px; }
  .why { margin-top: 8px; }
  .rows { margin-top: 10px; }
  .action { margin-top: 12px; min-height: 44px; }
}

@media (max-width: 980px) {
  .panel { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
  .bridge { flex-wrap: wrap; row-gap: 2px; }
  main { padding: 10px; }
  .screen { padding: 20px 16px 18px; }
  .apps { padding: 18px 14px 12px; }
  .value { font-size: 60px; line-height: 54px; }
  .value small { font-size: 20px; margin-left: 5px; }
  .read { min-height: 86px; gap: 10px; }
  .verdict h1 { font-size: 21px; line-height: 24px; }
  .label { font-size: 12px; }
  .row { grid-template-columns: 124px minmax(0, 1fr) 88px; }
  thead th { font-size: 10px; letter-spacing: 0.03em; padding-left: 3px; padding-right: 3px; }
  .row-name, .row-size { font-size: 16px; }
  thead th:first-child { width: 34%; }
  thead th:nth-child(4), td.net { display: none; }
  .settings { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Compact: the screen on its own, in a small window ---------- */

:root[data-compact] .bridge { flex-wrap: nowrap; gap: 8px; }
:root[data-compact] .brand { gap: 7px; font-size: 14px; letter-spacing: 0.12em; }
:root[data-compact] .brand svg { width: 18px; height: 18px; }
/* The apps table, the other views and setting up wait in the full view. */
:root[data-compact] ui-tabs-list, :root[data-compact] .apps, :root[data-compact] .setup { display: none; }
:root[data-compact] main { padding: 8px; gap: 8px; max-width: 480px; }
/* Sample data still says so. */
:root[data-compact] .banner { padding: 6px 8px 6px 22px; gap: 6px; font-size: 12px; }
:root[data-compact] .banner p { flex-basis: 100%; }
:root[data-compact] .banner strong { font-size: 11px; line-height: 14px; }
:root[data-compact] #banner-why { display: none; }
:root[data-compact] .banner-actions { gap: 6px; }
:root[data-compact] .banner ui-segmented-control-item { padding: 2px 10px; font-size: 11.5px; line-height: 18px; }
:root[data-compact] .banner button.solid { padding: 3px 8px; font-size: 11.5px; }
:root[data-compact] .screen { padding: 14px 14px 12px; }
:root[data-compact] .value { font-size: 54px; line-height: 48px; }
:root[data-compact] .read { min-height: 72px; }
:root[data-compact] .stage, :root[data-compact] .ticks { height: 40px; }
:root[data-compact] .stage { margin-top: 12px; }
:root[data-compact] .scale { margin-top: 6px; font-size: 11px; line-height: 14px; }
:root[data-compact] .why { margin-top: 6px; font-size: 13.5px; }
:root[data-compact] .also { font-size: 12px; }
:root[data-compact] .rows { margin-top: 8px; }
:root[data-compact] .row { grid-template-columns: 124px minmax(0, 1fr) 86px; min-height: 37px; padding: 1px 0; }
:root[data-compact] .row-name, :root[data-compact] .row-size { font-size: 15px; line-height: 18px; }
:root[data-compact] .row-note { font-size: 10.5px; line-height: 13px; }
:root[data-compact] .row .tide { height: 24px; }
:root[data-compact] .action { margin-top: 10px; min-height: 40px; padding: 6px 12px; font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
