/* Header, viewport, sidebar, footer. Tokens only - no literal colours.
   Class vocabulary matches Bench-Calculator, so css/patterns.css applies. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font: 400 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  flex: 0 0 auto;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-4);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 20;
}

.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.brand__logo { height: 26px; width: auto; display: block; border-radius: 5px; }
.brand__sep { width: 1px; height: 22px; background: var(--border); }
.brand__tool { font-weight: 600; color: var(--text-dim); white-space: nowrap; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.app-main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  min-height: 0;
}

.viewport {
  display: flex; flex-direction: column; min-width: 0;
  padding: var(--space-4); gap: var(--space-4);
  overflow-y: auto;
}

.viewport__stage {
  display: flex; align-items: center; justify-content: center;
  min-height: 240px;
  padding: var(--space-5) var(--space-4);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.viewport__stage > * { width: 100%; max-width: 900px; }

/* The stage is the one place a drawing lives, so it gets a little breathing
   room and a faint ground that is not the panel colour — a gear drawn in
   outline needs something to sit on. */
.viewport__stage { background: var(--panel); position: relative; }

.sidebar__foot {
  margin-top: auto;
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

.sidebar {
  border-left: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
  display: flex; flex-direction: column;
}

.app-footer {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-faint);
}

.app-footer nav { margin-left: auto; display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* A phone gets the drawing first and the controls under it. */
@media (max-width: 640px) {
  .viewport { padding: var(--space-3); gap: var(--space-3); }
  .viewport__stage { padding: var(--space-3) var(--space-2); min-height: 180px; }
  .app-footer { font-size: 11px; }
}

@media (max-width: 1040px) {
  .app-main { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-left: none; border-top: 1px solid var(--border); }
  .viewport, .sidebar { overflow-y: visible; }
  body { height: auto; }
}
