:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1f2630;
  --border: #2a3340;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --success: #3fb950;
  --local: #d29922;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

header {
  margin-bottom: 32px;
}
header h1 {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 600;
}
header p {
  margin: 0;
  color: var(--text-dim);
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--text-dim);
  font-size: 14px;
}
.back-link:hover {
  color: var(--accent);
}

/* App cards on the landing page */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.app-card {
  position: relative; /* anchor for the archive eartag */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.app-card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  padding-right: 30px; /* keep long titles clear of the corner eartag */
}
.app-card .meta {
  color: var(--text-dim);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  margin: 0;
  word-break: break-all;
}
.app-card .description {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-style: italic;
}
.app-card .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}
.app-card .badge.ci {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
}
.app-card .badge.local {
  background: rgba(210, 153, 34, 0.15);
  color: var(--local);
}
.app-card .badge.archived {
  background: rgba(139, 148, 158, 0.15);
  color: var(--text-dim);
  vertical-align: middle;
}
/* Archived app cards are always rendered (so "Show archived" can reveal them)
 * but shown muted. Mirrors the .hidden-row opacity treatment on the builds
 * table. Lift the dimming a little on hover so the Unarchive eartag is usable. */
.app-card.archived {
  opacity: 0.55;
}
.app-card.archived:hover {
  opacity: 0.85;
}
/* Archive control as a top-right corner "eartag": red ✕ to archive, muted ↺ to
 * unarchive. Absolutely positioned so long titles wrap clear of it (h2 has a
 * matching padding-right). Only rendered for signed-in users. */
.archive-eartag {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.archive-eartag.archive {
  color: #f85149;
}
.archive-eartag.archive:hover {
  border-color: #f85149;
  color: #f85149;
  background: rgba(248, 81, 73, 0.12);
}
.archive-eartag.unarchive {
  color: var(--text-dim);
}
.archive-eartag.unarchive:hover {
  border-color: var(--accent);
  color: var(--accent);
}
/* Top-left "ear tag" nav buttons (→ Branches / Builds tabs of app.html). In
 * normal flow at the card top so the title wraps below them; the archive eartag
 * stays pinned top-right over the empty right side of this row. */
.nav-eartags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
  padding-right: 30px; /* clear the absolute archive eartag */
}
.nav-eartag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
}
.nav-eartag:hover {
  border-color: var(--accent);
  color: var(--accent);
}
/* "Manage" side button attached to the Play Tag split row (styled as the right
 * cap via .qr-icon-btn); just keep the label on one line. */
.play-tag-manage {
  white-space: nowrap;
}
/* Branches-tab per-branch play links + auto-build checkbox cell. */
.branch-play {
  white-space: nowrap;
  font-size: 13px;
}
.branch-play a {
  color: var(--accent);
  text-decoration: none;
}
.branch-play a:hover {
  text-decoration: underline;
}
.autobuild-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.autobuild-cell input[disabled] {
  cursor: not-allowed;
}
/* Type-to-confirm input in the archive/unarchive confirmation popup. */
.confirm-input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.confirm-input:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
a.badge {
  text-decoration: none;
}
a.badge:hover {
  text-decoration: none;
  filter: brightness(1.2);
}
.app-card .actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-top: auto;
}
.app-card .actions .btn {
  text-align: center;
}
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}
.btn.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}
.btn.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #000;
}
/* Yellow "Play Most Recent" variant — reuses the gold LOCAL token. Two-class
 * specificity beats the single-class `.btn:hover` blue rule (same as btn-primary). */
.btn.btn-yellow {
  background: var(--local);
  border-color: var(--local);
  color: #000;
}
.btn.btn-yellow:hover {
  background: #e3b341;
  border-color: #e3b341;
  color: #000;
}
/* `.btn` sets `display: inline-block`, which beats the UA `[hidden]` rule.
 * This brings hidden buttons (e.g. Cancel / Save before Edit is clicked)
 * back to `display: none`. */
.btn[hidden] {
  display: none;
}

/* Builds table on the per-app page */
.builds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.builds-table th,
.builds-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.builds-table th {
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface);
  position: sticky;
  top: 0;
}
.builds-table tr:hover td {
  background: var(--surface-2);
}
.builds-table .source {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
}
.builds-table .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.builds-table .badge.local {
  background: rgba(210, 153, 34, 0.15);
  color: var(--local);
}
.builds-table .badge.ci {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
}
.builds-table .description {
  color: var(--text-dim);
  max-width: 320px;
}

.empty, .error {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px 24px;
  text-align: center;
  color: var(--text-dim);
}
.error {
  border-color: rgba(248, 81, 73, 0.4);
  color: #f85149;
}

/* Toolbar above the builds table */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.search-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  min-width: 240px;
}
.search-input:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.tag-filter-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
}
.tag-filter-select:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.filter-empty {
  margin-top: 12px;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.toggle input {
  cursor: pointer;
}
.auth-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.auth-status a {
  color: var(--text-dim);
  text-decoration: underline;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot-on { background: var(--success); }
.dot-off { background: var(--text-dim); }

/* Hidden rows (when "Show hidden" is on) */
.builds-table tr.hidden-row td {
  opacity: 0.45;
}
.builds-table tr.pending td {
  opacity: 0.6;
}

/* Smaller button for table actions */
.btn.btn-icon {
  padding: 4px 10px;
  font-size: 13px;
}

/* Sign-in modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
  max-width: 460px;
  width: calc(100% - 32px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.modal-content h3 {
  margin: 0 0 12px;
  font-size: 18px;
}
.modal-content p {
  margin: 8px 0;
  font-size: 14px;
  color: var(--text);
}
.modal-content p.hint {
  color: var(--text-dim);
  font-size: 13px;
}
.modal-content code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}
.user-code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 28px !important;
  font-weight: 600;
  letter-spacing: 4px;
  text-align: center;
  margin: 16px 0 !important;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 6px;
  user-select: all;
}

/* Wraps a user-code (or viewer-gate-code) paragraph with a Copy button.
   The code itself stays centered in the modal; the Copy button is anchored
   to the right edge so it doesn't push the code off-center. */
.user-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
  position: relative;
}
.user-code-row .user-code,
.user-code-row .viewer-gate-code {
  margin: 0 !important;
  flex: 0 0 auto;
}
.copy-code-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.copy-code-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.user-code-row .copy-code-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.error-text {
  color: #f85149 !important;
}

/* Play-with-config modal */
.play-config-content {
  position: relative;
  max-width: 560px;
  width: calc(100% - 32px);
}
.play-config-content h3 {
  margin: 0 0 4px;
  font-size: 18px;
}
.play-config-content > .meta {
  margin: 0 0 16px;
  font-size: 12px;
  word-break: break-all;
}
.play-config-close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: transparent;
  color: var(--text-dim);
  border: 0;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.play-config-close:hover {
  color: var(--text);
  background: var(--surface-2);
}
.play-config-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 12px;
}
.play-config-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.play-config-field label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.play-config-field .play-config-key {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--accent);
}
.play-config-field .play-config-label {
  font-weight: 500;
}
.play-config-field .play-config-range {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}
.play-config-field input[type="text"],
.play-config-field input[type="number"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
}
.play-config-field input[type="text"]:focus,
.play-config-field input[type="number"]:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.play-config-field input[type="color"] {
  width: 56px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 2px;
}
.play-config-field .hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

/* v2-only: grouped sections, presets row, puzzle authoring textarea */

.play-config-presets-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.play-config-presets-label {
  font-size: 12px;
  color: var(--text-dim);
}
.play-config-presets-row select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  flex: 1 1 180px;
  min-width: 160px;
}
.btn.btn-sm {
  font-size: 12px;
  padding: 5px 10px;
}

.play-config-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 12px;
}
.play-config-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.play-config-section[open] {
  background: var(--surface-2, var(--surface));
}
.play-config-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.play-config-section > summary::-webkit-details-marker {
  display: none;
}
.play-config-section > summary::before {
  content: "▸";
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 120ms;
}
.play-config-section[open] > summary::before {
  transform: rotate(90deg);
}
.play-config-section-title {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
  color: var(--accent);
}
.play-config-section .play-config-section-body {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* Authoring section — collapsible like the other v2 sections. The summary
   carries the Edit/Cancel/Save buttons; we flex them to the right of the
   title. */
#play-config-section-authoring > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}
.play-config-authoring-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
#play-config-puzzle-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  resize: vertical;
  min-height: 120px;
}
#play-config-puzzle-textarea:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
#play-config-puzzle-textarea[readonly] {
  opacity: 0.85;
  cursor: default;
}
.play-config-puzzle-gui {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.play-config-puzzle-gui:empty {
  display: none;
}
.play-config-puzzle-gui.gui-disabled {
  pointer-events: none;
  opacity: 0.4;
}
/* Inline editor styles — small inputs, compact rows, repeating-row blocks. */
.pe-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.pe-row > label {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pe-row input[type="text"],
.pe-row input[type="number"],
.pe-row select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 6px;
  font-size: 12px;
  font-family: inherit;
}
.pe-row input.pe-narrow { width: 60px; }
.pe-row input.pe-mid { width: 110px; }
.pe-row input.pe-wide { width: 220px; }
.pe-list-row {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  background: var(--bg);
}
.pe-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin: 6px 0 2px;
}
.pe-add-btn {
  align-self: flex-start;
  font-size: 12px;
}
.pe-board-grid {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  min-height: 60px;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  resize: vertical;
}

/* Bool fields render as checkboxes — inline with label */
.play-config-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Action-pending modal (mark stable, tag, hide, delete-tag) */
.action-modal-content {
  position: relative;
  text-align: center;
  padding-top: 32px;
}
.action-modal-close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: transparent;
  color: var(--text-dim);
  border: 0;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.action-modal-close:hover {
  color: var(--text);
  background: var(--surface-2);
}
.action-modal-text {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}
.action-modal-spinner-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.action-modal-counter {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}
.action-modal-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: dropzone-spin 0.8s linear infinite;
}
@keyframes dropzone-spin {
  to { transform: rotate(360deg); }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover {
  color: var(--text);
  text-decoration: none;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Stable checkbox column in build rows */
.stable-cell {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.stable-cell input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}
.stable-cell input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}
.stable-cell-na {
  color: var(--text-dim);
  font-size: 13px;
}

/* Custom tag dropdown widget in build rows */
.tag-dropdown {
  position: relative;
  display: inline-block;
}
.tag-dropdown.pending { opacity: 0.6; }
.tag-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  min-width: 110px;
  justify-content: space-between;
}
.tag-toggle:hover {
  border-color: var(--accent);
}
.tag-toggle-caret {
  font-size: 10px;
  color: var(--text-dim);
}
.tag-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.tag-dropdown.open .tag-menu { display: block; }
.tag-menu-item {
  display: block;
  box-sizing: border-box;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}
.tag-menu-item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.tag-menu-item.current { color: var(--success); }
.tag-menu-clear {
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
.tag-menu-search-wrap {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.tag-menu-search {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
}
.tag-menu-search:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.tag-menu-no-match {
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}
.tag-menu-recents {
  /* Show ~3 rows; scroll for more. Each row is ~32px tall. */
  max-height: 96px;
  overflow-y: auto;
}
.tag-menu-empty {
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}
.tag-menu-add {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.tag-menu-add-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--accent);
  border: 0;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.tag-menu-add-btn:hover { background: var(--surface); }
.tag-menu-add-form {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
}
/* Custom display values silently override the HTML `hidden` attribute, so
   force `display: none` whenever `hidden` is set. */
.tag-menu-add-form[hidden] {
  display: none;
}
.tag-menu-add-input {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
}
.tag-menu-add-input:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.tag-menu-add-confirm {
  background: var(--accent);
  color: #000;
  border: 0;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.tag-menu-add-error {
  margin: 0;
  padding: 0 12px 8px;
  color: #f85149;
  font-size: 12px;
}

/* Manage Tags tab */
.manage-tags-list .tag-name {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-weight: 500;
  color: var(--accent);
}
.manage-tags-delete:hover {
  border-color: #f85149;
  color: #f85149;
}

/* Play-Tag dropdown on the landing card */
.play-tag-wrapper {
  position: relative;
}
.play-tag-toggle {
  width: 100%;
  text-align: center;
}
.play-tag-wrapper .tag-menu {
  display: none;
  left: 0;
  right: 0;
  min-width: 0;
}
.play-tag-wrapper.open .tag-menu { display: block; }
/* Landing-card play-tag list scrolls inside its own container so the search
   input stays pinned at the top of the dropdown. */
.play-tag-wrapper .tag-menu-recents {
  max-height: 220px;
}

/* Tag banner above the builds table */
.tag-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-dim);
}
.tag-banner strong {
  color: var(--text);
  font-weight: 500;
  margin-right: 6px;
}
.tag-banner a {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}

/* Branch links in branches table */
.branch-link {
  font-weight: 500;
}
.branch-heading {
  margin: 8px 0 16px;
  font-size: 20px;
  font-weight: 600;
}

/* Landing page header — h1 on the left, GitHub status + buttons on the right */
.landing-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.landing-header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.meta-link {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: underline;
}
.meta-link:hover { color: var(--accent); }

/* View-access gate (overlay shown until the visitor authenticates) */
.viewer-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-gate-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}
.viewer-gate-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 32px 28px;
  width: calc(100% - 32px);
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.viewer-gate-title {
  margin: 0 0 6px;
  font-size: 22px;
}
.viewer-gate-sub {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 14px;
}
.viewer-gate-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.viewer-gate-divider {
  position: relative;
  text-align: center;
  margin: 18px 0;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.viewer-gate-divider::before,
.viewer-gate-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 18px);
  border-top: 1px solid var(--border);
}
.viewer-gate-divider::before { left: 0; }
.viewer-gate-divider::after { right: 0; }
.viewer-gate-divider span { background: var(--surface); padding: 0 8px; }
.viewer-gate-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}
.viewer-gate-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
.viewer-gate-input:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.viewer-gate-btn {
  width: 100%;
  text-align: center;
}
.viewer-gate-btn-secondary {
  width: 100%;
  text-align: center;
}
.viewer-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.viewer-gate-hint {
  margin: 0 0 8px;
  color: var(--text-dim);
  font-size: 13px;
}
.viewer-gate-code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 4px;
  text-align: center;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 6px;
  margin: 8px 0;
  user-select: all;
}
.viewer-gate-error {
  margin: 12px 0 0;
  color: #f85149;
  font-size: 13px;
}

/* Manage Access page rows */
.manage-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 20px;
}
.manage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.manage-value {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
}
.manage-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.manage-add-row .search-input {
  flex: 1;
  min-width: 220px;
}
.manage-save-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.manage-error {
  margin: 8px 0 0;
}
.manage-row [data-action="delete"]:hover {
  border-color: #f85149;
  color: #f85149;
}

/* QR-code buttons + modal (used on landing card and per-app builds table). */
/* Square icon button: ~38px on the landing card, smaller in the table. */
.qr-icon-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  padding: 0 10px;
  height: auto;
  min-width: 38px;
}
.qr-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.qr-icon-btn svg {
  display: block;
}

/* Landing card: pair each Play button with its QR button as one visually
   unified split-button (Play takes the row, QR badge attached to the right). */
.app-card .actions .action-row {
  display: flex;
  gap: 0;
  align-items: stretch;
}
.app-card .actions .action-row > .btn:not(.qr-icon-btn),
.app-card .actions .action-row > .play-tag-wrapper {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 0;
}
.app-card .actions .action-row > .qr-icon-btn {
  flex: 0 0 auto;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  font-size: 12px;
  letter-spacing: 0.5px;
  padding: 0 14px;
}

/* Tag dropdown rows: a flex pair of <link> + <qr button>. The link still
   takes most of the width; the QR icon button sits flush on the right and
   has its own hover treatment. */
.tag-menu-row {
  display: flex;
  align-items: stretch;
  border-bottom: 0;
}
.tag-menu-row .tag-menu-item {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.tag-menu-row .tag-menu-qr {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tag-menu-row .tag-menu-qr:hover {
  background: var(--surface-2);
  color: var(--accent);
}

/* Builds-table Play cell: Play and QR buttons inline, small gap. */
.builds-table .play-cell {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.builds-table .play-cell .qr-icon-btn {
  padding: 4px 8px;
  min-width: 0;
  font-size: 13px;
}

/* QR modal */
.qr-modal-content {
  max-width: 400px;
  width: calc(100% - 32px);
  position: relative;
}
.qr-modal-close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.qr-modal-close:hover { color: var(--text); }
.qr-modal-title {
  margin: 0 0 4px;
  font-size: 18px;
}
.qr-modal-subtitle {
  margin: 0 0 16px !important;
  font-size: 12px;
  word-break: break-all;
}
.qr-modal-svg {
  background: white;
  padding: 16px;
  border-radius: 8px;
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
}
.qr-modal-svg svg {
  display: block;
  width: 256px;
  height: 256px;
  max-width: 100%;
}
.qr-modal-url-row {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.qr-modal-url {
  flex: 1;
  background: var(--surface-2);
  padding: 8px 10px !important;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px !important;
  word-break: break-all;
  overflow-wrap: anywhere;
  color: var(--text-dim);
  user-select: all;
}
.qr-modal-copy {
  flex: 0 0 auto;
  font-size: 12px;
  padding: 4px 12px;
}
