/*
 * /lab, the Studio shell.
 *
 * REDESIGN_SPEC sections 2 to 4. The tokens are unchanged from the public page
 * (Studio's zinc greys plus blue, and the lab's dark values already matched them
 * one for one). What is new is the shell: a top bar, a 240 px schema sidebar on
 * the left, shared edges between panels instead of a column of floating cards,
 * and Studio's radii and 14 px gutter.
 *
 * The binding mobile rules are LAB_SPEC section 4, from the mobile report:
 * stacked and never split-pane, editor 6 to 10 lines with an expand control, an
 * explicit Run button that stays put, a real scrollable table rather than cards,
 * a rendered-row cap stated in the UI, schema in a drawer, and results collapsed
 * while the soft keyboard is open. Below 900 the sidebar is `display: contents`,
 * so the protocol chips and the engineering lines order to the end of the one
 * column while the schema itself moves to the bottom sheet.
 */

:root {
  --bg: #0a0a0b;
  --panel: #111113;
  --raised: #1a1a1e;
  --line: #27272a;
  --line-active: #3f3f46;
  --text: #fafafa;
  --sub: #a1a1aa;
  --muted: #71717a;
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --red: #ef4444;
  --green: #22c55e;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/*
 * `[hidden]` beats any author `display` on the same element. The UA rule loses
 * to every author rule, and the sheet and the CodeMirror host are both
 * hidden-and-styled. One rule here rather than a copy per element.
 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border-radius: 6px;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

/* Panels and labels ------------------------------------------------------- */

.panel-title,
.aside-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sub);
}

/* The old `.eyebrow` is kept as an alias so nothing that used it breaks. */
.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.primary {
  background: var(--blue);
  border: 1px solid var(--blue);
  color: #fff;
  font-weight: 500;
  padding: 10px 16px;
  min-height: 44px;
}
.primary:hover:not(:disabled) {
  background: var(--blue-hover);
}
.primary:disabled {
  opacity: 0.55;
  cursor: default;
}

.ghost {
  background: var(--raised);
  border: 1px solid var(--line-active);
  color: var(--sub);
  padding: 8px 12px;
  min-height: 40px;
}
.ghost:hover:not(:disabled) {
  color: var(--text);
}
.ghost:disabled {
  opacity: 0.55;
  cursor: default;
}
.ghost.small {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

.message {
  margin: 8px 0 0;
  font-size: 13px;
}
.message.error {
  color: var(--red);
}
.message.inline {
  flex: 1 1 100%;
  margin: 0;
}
.message.inline:empty {
  display: none;
}

/* Top bar ----------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.brand .mark {
  flex: none;
}
.brand h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill {
  flex: none;
  font-size: 11px;
  font-weight: 400;
  color: var(--sub);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 999px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.loadline {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
}
.loadline b {
  color: var(--text);
  font-weight: 600;
}

.verified {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}
.verified-wallet {
  font-weight: 600;
  font-size: 13px;
}
.verified-address {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--sub);
}
#switch-wallet {
  margin-left: 4px;
}

/* Shell ------------------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: calc(100vh - 52px);
}

.sidebar {
  width: 240px;
  min-height: 0;
  overflow: auto;
  padding: 12px 8px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.aside-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 10px;
}
.icon-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--sub);
  width: 26px;
  height: 26px;
  min-height: 0;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}
.icon-button:hover {
  background: var(--raised);
  color: var(--text);
}

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
  color: var(--muted);
}
.search-icon {
  font-size: 12px;
  line-height: 1;
}
.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}
.search input::placeholder {
  color: var(--muted);
}

/* Schema tree ------------------------------------------------------------- */

.tree {
  margin-top: 10px;
}
.tree-empty {
  margin: 8px 6px;
  font-size: 12px;
  color: var(--muted);
}
.tree details {
  border: 0;
}
.tree summary {
  list-style: none;
}
.tree summary::-webkit-details-marker {
  display: none;
}
.table-node {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 30px;
  padding: 0 6px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text);
  text-align: left;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.table-node:hover {
  background: var(--raised);
}
.table-node .chev {
  flex: none;
  width: 12px;
  color: var(--muted);
  font-size: 9px;
  transition: transform 0.12s ease;
}
.tree details[open] .table-node .chev {
  transform: rotate(90deg);
}
.table-node .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-node .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
}
.tree-columns {
  padding-left: 21px;
}
.tree-column {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 4px 6px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--sub);
  text-align: left;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.tree-column:hover {
  background: var(--raised);
}
.tree-column em {
  font-style: normal;
  color: var(--muted);
  font-size: 10px;
}
.tree-filtered-out {
  display: none;
}

/* Protocol chips ---------------------------------------------------------- */

.protocols {
  margin-bottom: 14px;
}
.protocols .aside-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 4px 8px;
}
.grain {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--muted);
}
.protocol-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.protocol-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  border: 1px solid var(--line-active);
  background: var(--raised);
  color: var(--text);
}
.protocol-chip .icon {
  flex: none;
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
}
.protocol-chip .icon svg {
  width: 16px;
  height: 16px;
  display: block;
}
.protocol-chip .icon img {
  width: 16px;
  height: 16px;
  display: block;
  border-radius: 50%;
}
.protocol-chip .icon .letter {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--line-active);
  color: var(--sub);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.protocol-chip .count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--sub);
}
.protocol-chip[data-bucket="venue"] {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}
.protocol-chip[data-bucket="venue"] .count {
  color: var(--muted);
}
.protocol-chip[data-bucket="venue"] .icon .letter {
  background: var(--line);
  color: var(--muted);
}
.protocol-chip .via {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.legend {
  margin: 8px 4px 0;
  font-size: 12px;
  color: var(--muted);
}
.fellthrough {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Engineering ------------------------------------------------------------- */

.engineering {
  margin-top: 6px;
  padding: 0 4px;
}
.engineering summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 0;
  list-style: none;
}
.engineering summary::-webkit-details-marker {
  display: none;
}
.engineering summary::before {
  content: "\25B8  ";
}
.engineering[open] summary::before {
  content: "\25BE  ";
}
.diagnostics {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* Editor area ------------------------------------------------------------- */

.editor-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.loadscreen {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px 14px;
  overflow: auto;
}
.load-card {
  width: 100%;
  max-width: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}
.load-card .panel-title {
  margin-bottom: 12px;
}

.address-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#address {
  flex: 1 1 200px;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line-active);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  padding: 10px 12px;
  min-height: 44px;
}
#address:focus {
  border-color: var(--blue);
}
#address::placeholder {
  color: var(--muted);
  font-family: var(--sans);
}
#address[data-verified] {
  border-color: var(--green);
}

.connect {
  margin-top: 10px;
}
.connect-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.connect-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.connect-button img {
  border-radius: 4px;
}
.connect-other {
  margin-top: 8px;
}
.connect-other summary {
  cursor: pointer;
  color: var(--sub);
  font-size: 13px;
  padding: 13px 0;
}
.connect-other .connect-row {
  margin-top: 4px;
}
.connect-install {
  margin-top: 8px;
}
.connect-install a {
  color: var(--blue);
}
#connect-status {
  color: var(--green);
}

.steps {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--sub);
}
.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.steps .dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-active);
}
.steps li[data-state="active"] .dot {
  background: var(--blue);
}
.steps li[data-state="done"] .dot {
  background: var(--green);
}
.steps li[data-state="failed"] .dot {
  background: var(--red);
}
.steps li[data-state="done"] {
  color: var(--muted);
}
.steps .step-time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

/* Workbench --------------------------------------------------------------- */

.workbench {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.exercise {
  flex: none;
  margin: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
  /* A strip, not a panel: at 1440x900 an open question card was taking 213 px
     and squeezing the results to 2 rows. It still scrolls when the prompt is
     long (Architect, reviewing 826e0e2). */
  max-height: 22vh;
}
.exercise summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 0;
}
.exercise-title {
  font-weight: 600;
}
.exercise-verdict {
  font-size: 13px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.exercise-verdict[data-state='pass'] {
  color: var(--green);
}
.exercise-verdict[data-state='fail'] {
  color: var(--red);
}
.exercise-verdict[data-state='unavailable'] {
  color: var(--sub);
}
.exercise-prompt {
  margin: 10px 0 0;
}
.exercise-note,
.exercise-diff {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--sub);
}
.exercise-diff {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}
.exercise code {
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 1px 4px;
  border-radius: 4px;
  background: #1c1c1f;
}
.exercise-shape {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--sub);
}
.exercise-plain {
  color: var(--text);
}
.exercise-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.exercise-progress {
  font-size: 12px;
  color: var(--muted);
}
.exercise-all {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
}
.demo-wallet-link {
  display: inline-block;
  margin: 0 16px 16px;
  color: var(--text);
  font-size: 13px;
  text-decoration: underline;
}

.workbench-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.workbench-top .panel-title {
  font-size: 11px;
  color: var(--muted);
}
.starter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.starter-chips button {
  min-height: 30px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--sub);
  font-size: 12px;
}
.starter-chips button:hover:not(:disabled) {
  background: var(--raised);
  border-color: var(--line-active);
  color: var(--text);
}
.starter-chips button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Editor ------------------------------------------------------------------ */

.editor {
  flex: 0 0 var(--editor-height, 40%);
  min-height: 150px;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
}
.cm-host {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.cm-host .cm-editor {
  height: 100%;
}
.cm-host .cm-scroller {
  overflow: auto;
}
#sql {
  flex: 1;
  width: 100%;
  background: var(--bg);
  border: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.45;
  padding: 10px 12px;
  resize: none;
}
#sql:focus {
  outline: none;
}
.expand {
  align-self: flex-start;
  margin: 0 14px 10px;
  font-size: 13px;
  min-height: 36px;
  padding: 6px 10px;
}
/* Desktop resizes the editor with the drag handle; Expand is the phone control. */
@media (min-width: 900px) {
  .expand {
    display: none;
  }
}

.resize-handle {
  flex: none;
  height: 4px;
  background: var(--line);
  cursor: row-resize;
  transition: background 0.15s;
}
.resize-handle:hover,
.resize-handle.active {
  background: var(--blue);
}
.editor.editor-tall {
  flex-basis: 75%;
}

/* Run bar ----------------------------------------------------------------- */

.runbar {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px;
  color: var(--sub);
}
.run {
  min-width: 72px;
}
/* The spec's run bar is 46 px; a 44 px primary plus 8 px padding was 61. */
.runbar .run {
  min-height: 30px;
  padding: 6px 16px;
}
.run-meta {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.run-status {
  color: var(--muted);
}
.rowcount {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--sub);
}
#schema-open {
  display: none;
}

/* Results ----------------------------------------------------------------- */

.results {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.results-head {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.results-head .panel-title {
  font-size: 11px;
  color: var(--muted);
}
/* The coverage path rides in the load line, so it inherits that line's size:
   no larger, no colour of its own, mono only to set it apart as a value. */
.loadline .coverage-path {
  font-family: var(--mono);
  color: var(--muted);
}
.grid-shell {
  position: relative;
  flex: 1;
  min-height: 0;
}
.table-wrap {
  height: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 13px;
}
.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  color: var(--sub);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  padding: 7px 14px;
}
.table-wrap thead .col-name {
  display: block;
  font-weight: 600;
  font-size: 12px;
  color: var(--sub);
}
.table-wrap thead .col-type {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}
.table-wrap tbody td {
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  padding: 6px 14px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 330px;
  cursor: pointer;
}
.table-wrap tbody tr:hover {
  background: var(--raised);
}
.table-wrap tbody tr:last-child td {
  border-bottom: none;
}
.table-wrap td.numeric {
  text-align: right;
}
.table-wrap td.null {
  color: var(--muted);
  font-style: italic;
}
.placeholder {
  margin: 0;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}
.grid-shell .fade {
  position: absolute;
  top: 0;
  right: 1px;
  bottom: 1px;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to right, rgb(10 10 11 / 0%), rgb(10 10 11 / 88%));
}
.colhint {
  flex: none;
  margin: 6px 14px 0;
  font-size: 12px;
  color: var(--muted);
}
.more {
  flex: none;
  margin: 8px 14px 12px;
}
.keyboard-note {
  flex: none;
  margin: 10px 14px;
  font-size: 12px;
  color: var(--muted);
}

body.keyboard-open .results {
  display: none;
}

/* Sheet ------------------------------------------------------------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgb(0 0 0 / 55%);
}
.sheet {
  position: fixed;
  z-index: 9;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--line-active);
  border-radius: 12px 12px 0 0;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.sheet-body {
  overflow: auto;
  padding: 12px 14px 20px;
}
.sheet details {
  border-bottom: 1px solid var(--line);
}
.sheet details:last-child {
  border-bottom: none;
}
.sheet summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
  list-style: none;
}
.sheet summary::-webkit-details-marker {
  display: none;
}
.sheet .caret {
  color: var(--muted);
  font-size: 10px;
  transition: transform 0.12s ease;
}
.sheet details[open] .caret {
  transform: rotate(90deg);
}
.sheet .table-rows {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
.sheet .columns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 2px 12px;
}
.sheet .column {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  min-height: 34px;
}
.sheet .column em {
  font-style: normal;
  color: var(--muted);
  font-size: 11px;
}
.sheet .table-note {
  margin: 0 2px 12px;
  font-size: 12px;
  color: var(--muted);
}
.sheet .cell-column {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}
.sheet .cell-value {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
}
.sheet .cell-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--blue);
  font-size: 13px;
}

/* Sidebar collapsed (desktop) -------------------------------------------- */

.workspace.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}
.workspace.sidebar-collapsed .sidebar {
  display: none;
}
#sidebar-open {
  display: none;
}
.workspace.sidebar-collapsed #sidebar-open {
  display: inline-grid;
}
#sidebar-open {
  margin-right: 2px;
}

/* Phone ------------------------------------------------------------------- */

@media (max-width: 899px) {
  html,
  body {
    font-size: 15px;
  }

  .topbar {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    padding: 4px 12px;
    gap: 8px;
  }
  .brand h1 {
    font-size: 13px;
  }
  .brand .pill {
    display: none;
  }
  /* The load line is not dropped at 390: it wraps to a full-width row under
     the compact bar so the freshness sentence and the coverage path survive
     (REDESIGN_SPEC section 2). */
  .topbar-right {
    flex: 1 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .loadline {
    display: block;
    order: 2;
    flex: 1 1 100%;
    max-width: none;
    white-space: normal;
    text-align: right;
    padding-bottom: 2px;
  }
  .verified-address {
    display: none;
  }
  /* No signature means no wallet name to identify the load, so the short
     address is the only thing that says which wallet; keep it. */
  .verified.no-name .verified-address {
    display: inline;
  }

  /*
   * The sidebar dissolves into the column: the schema panel is hidden (the
   * sheet carries the schema on a phone) and the protocol and engineering
   * blocks order to the end, per REDESIGN_SPEC section 3.
   */
  .workspace {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 48px);
  }
  .sidebar {
    display: contents;
    width: auto;
    border-right: 0;
    background: none;
    padding: 0 14px;
  }
  .sidebar .schema-panel {
    display: none;
  }
  /* Above the question card on a phone, REDESIGN_SPEC section 3. */
  .protocols {
    order: -1;
    margin: 4px 0 14px;
  }
  .engineering {
    order: 3;
    margin: 0 0 24px;
    padding: 0;
  }
  .editor-area {
    order: 1;
    overflow: visible;
  }

  /* The protocol and engineering blocks share the page gutter on a phone. */
  .loadscreen {
    padding: 20px 14px;
  }
  .load-card {
    padding: 16px 14px;
  }

  .workbench {
    display: block;
  }
  .exercise {
    max-height: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 12px 14px 0;
    padding: 12px;
  }
  .workbench-top {
    border-bottom: 0;
    padding: 12px 14px 8px;
  }
  .editor {
    flex: none;
    margin: 0 14px;
    border: 1px solid var(--line-active);
    border-radius: 6px;
    background: var(--bg);
    overflow: hidden;
  }
  #sql,
  .cm-host {
    min-height: calc(8 * 16px * 1.45 + 20px);
  }
  .editor.editor-tall #sql,
  .editor.editor-tall .cm-host {
    min-height: calc(20 * 16px * 1.45 + 24px);
  }
  /* 16px below 900 so iOS does not zoom on focus. */
  .editor .cm-editor .cm-content,
  .editor .cm-editor .cm-scroller {
    font-size: 16px !important;
  }
  .expand {
    margin: 8px 14px;
  }
  .resize-handle {
    display: none;
  }

  .runbar {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 12px 0 0;
    padding: 8px 14px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--panel);
  }
  #schema-open {
    display: inline-flex;
    margin-left: auto;
  }

  .results {
    margin: 0 14px;
  }
  .results-head {
    padding: 12px 0 8px;
    border-bottom: 0;
  }
  .grid-shell {
    position: relative;
  }
  .table-wrap {
    height: auto;
    max-height: 60vh;
    border: 1px solid var(--line);
    border-radius: 6px;
  }
  .colhint {
    margin: 6px 0 0;
  }
  .more {
    width: 100%;
    margin: 8px 0 0;
  }
  .keyboard-note {
    margin: 10px 0;
  }
}
