/* ==========================================================================
   layout.css — reset and the application shell

   The shell is a real instrument layout: a fixed settings rail on the left, a
   scrolling work area, and the communication log pinned as its own pane at the
   bottom with independent scroll. The log is a pane, never a sticky overlay —
   sticky made it float over the sensor rows.

   On narrow screens the whole thing becomes one ordinary scrolling column and
   the rail moves BELOW the work area, because on a phone the readings are the
   point and the settings are set once.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--text);
  font: var(--text-md) / var(--leading-normal) var(--font-sans);
  font-feature-settings: 'cv05' 1;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

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

svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --- shell -------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100dvh;
}

.app__sidebar {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-5) var(--space-4) var(--space-6);
  background: var(--surface);
  border-right: var(--hairline) solid var(--border);
}

.app__main {
  display: grid;
  /* The log pane is a fixed-height dock; the work area takes all the slack. */
  grid-template-rows: minmax(0, 1fr) var(--log-pane-height);
  min-width: 0;
  min-height: 0;
}

/* The scrolling work area. Everything except the log lives here. */
.app__work {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-5) var(--space-6);
}

/* The log pane: fixed height, own scroll, always visible. */
.app__logpane {
  min-height: 0;
  border-top: var(--hairline) solid var(--border);
  background: var(--surface);
}

.mount {
  min-width: 0;
}

/* --- narrow screens ----------------------------------------------------- */

@media (max-width: 900px) {
  .app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100dvh;
  }

  /* Readings first. The rail is setup you touch once, so it goes last. */
  .app__main {
    display: contents;
  }

  .app__work {
    order: 1;
    overflow: visible;
    padding: var(--space-4);
    gap: var(--space-4);
  }

  .app__logpane {
    order: 2;
    border-top: var(--hairline) solid var(--border);
    border-bottom: var(--hairline) solid var(--border);
  }

  .app__sidebar {
    order: 3;
    overflow: visible;
    border-right: 0;
    border-top: var(--hairline) solid var(--border);
    padding: var(--space-4);
  }
}

@media (max-width: 560px) {
  .app__work {
    padding: var(--space-3);
  }
}

/* --- motion ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
