/* ---------------------------------------------------------------------------
 * style.css — minimal, mobile-first, developer-utility styling.
 * Vertical scroll, CSS Grid for the inspection surface, bottom drawer.
 * No frameworks. Colour is functional, not decorative.
 * ------------------------------------------------------------------------- */

:root {
  --bg: #14161a;
  --panel: #1d2128;
  --panel-2: #242a33;
  --border: #333a45;
  --text: #e6e9ee;
  --muted: #99a2b0;
  --accent: #4f9dff;
  --accent-text: #06223f;
  --danger: #ff6b6b;
  --warn: #ffce6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.45;
}

/* ----- Screen switching ----- */
.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.is-active { display: flex; }

/* ----- Header ----- */
.app-header {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.app-header h1 { font-size: 17px; margin: 0; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 12px; }

/* ----- Input primitives ----- */
.primitive { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.primitive h2 {
  font-size: 13px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tag {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
}
textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ----- Messages ----- */
.messages { padding: 0 16px; }
.messages:not(:empty) { padding: 12px 16px; }
.msg { margin: 2px 0; font-size: 12px; }
.msg.error { color: var(--danger); }
.msg.warn { color: var(--warn); }

/* ----- Footer ----- */
.app-footer {
  margin-top: auto;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  bottom: 0;
}
.btn {
  flex: 1;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }

/* ----- Grid (inspection surface) ----- */
.grid-wrap { flex: 1; overflow: auto; padding: 8px; }
.grid {
  display: grid;
  gap: 1px;
  width: max-content;
  margin: 0 auto;
}
.tile {
  width: 8px;
  height: 8px;
  cursor: pointer;
}
.tile.selected { outline: 2px solid #fff; outline-offset: -1px; z-index: 1; }

/* ----- Drawer ----- */
.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 60dvh;
  overflow: auto;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  transform: translateY(100%);
  transition: transform 0.18s ease;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.drawer.is-open { transform: translateY(0); }
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
}
.btn-close { flex: 0 0 auto; padding: 6px 12px; }
.drawer-body { margin: 0; padding: 12px 16px; }
.drawer-body div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
  border-bottom: 1px dotted var(--border);
}
.drawer-body dt { color: var(--muted); }
.drawer-body dd { margin: 0; text-align: right; word-break: break-word; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-left: 6px; border: 1px solid var(--border); }
