/* HushGo admin UI.
 *
 * Dark, dense, and quiet: this is a tool people open to change one value and
 * leave. The single accent (lime) is spent on three things only — the mark, the
 * page-title rule, and the primary action — so that the eye lands on what it
 * can do rather than on decoration.
 *
 * Keys and values are set in monospace throughout. That is functional, not
 * stylistic: an operator comparing AWS_SECRET_ACCESS_KEY against a value in
 * another window needs character-level legibility, and proportional type makes
 * 0/O and 1/l/I ambiguous.
 */

:root {
  --bg:            #0c0f0e;
  --bg-raised:     #141917;
  --bg-hover:      #1a201d;
  --bg-inset:      #090b0a;
  --bg-sidebar:    #0a0d0c;

  --border:        #232a26;
  --border-strong: #333c37;

  --text:          #e7ebe8;
  --text-dim:      #98a29b;
  --text-faint:    #626b66;

  --accent:        #d4f24e;
  --accent-text:   #0c0f0e;
  --accent-soft:   #2b3512;
  --accent-line:   #d4f24e;

  --danger:        #f2776b;
  --danger-soft:   #3a1a17;
  --warn:          #f2c14e;
  --ok:            #6ddf9c;

  --radius:        8px;
  --radius-sm:     5px;
  --radius-lg:     12px;

  --sidebar-w:     232px;
  --topbar-h:      52px;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 25%);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

code, kbd, pre, .mono { font-family: var(--mono); }

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

::placeholder { color: var(--text-faint); }

/* ── Shell ──────────────────────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "topbar topbar" "sidebar main";
  min-height: 100vh;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-spacer { flex: 1; }

.sidebar {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.main {
  grid-area: main;
  padding: 32px 40px 80px;
  min-width: 0;
}

.container { max-width: 1180px; margin: 0 auto; }

/* ── Brand and breadcrumbs ──────────────────────────────────────────────── */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand:hover { background: var(--bg-hover); }

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
}

.crumb:hover { background: var(--bg-hover); color: var(--text); }

.crumb-sep { color: var(--text-faint); user-select: none; }

/* The lime tile that carries the mark. Repeated at three sizes: topbar,
   page title, and project card. */
.tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

.tile svg { width: 13px; height: 13px; }
.tile-lg { width: 34px; height: 34px; border-radius: 8px; }
.tile-lg svg { width: 19px; height: 19px; }
.tile-md { width: 28px; height: 28px; border-radius: 6px; }
.tile-md svg { width: 16px; height: 16px; }

/* ── Sidebar navigation ─────────────────────────────────────────────────── */

.nav-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin-bottom: 8px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.nav-back:hover { color: var(--text-dim); }

/* Without this the icon inherits the SVG's own 24x24 viewBox and renders huge:
   .nav-item's rule does not reach it. */
.nav-back svg { width: 14px; height: 14px; flex: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  border-left: 2px solid transparent;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }

.nav-item[aria-current="page"] {
  background: var(--bg-hover);
  color: var(--text);
  border-left-color: var(--accent);
}

.nav-item svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }

.nav-foot { margin-top: auto; padding-top: 12px; }

/* ── Page heading ───────────────────────────────────────────────────────── */

.page-head { margin-bottom: 26px; }

.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 27px;
  margin-bottom: 8px;
}

/* The rule under the title is the accent's second job. It is drawn on the text
   itself, not the row, so it stops where the words stop. */
.page-title span {
  border-bottom: 2px solid var(--accent-line);
  padding-bottom: 3px;
}

.page-sub {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 70ch;
}

.page-sub a { color: var(--text); border-bottom: 1px solid var(--border-strong); }
.page-sub a:hover { border-bottom-color: var(--accent); }

.page-hint { margin-top: 7px; color: var(--text-faint); font-size: 12.5px; }

/* Inline code sits inside 13-14px prose, so it is stepped down to keep the
   line height from jumping. */
code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  font-size: 0.88em;
  color: var(--text-dim);
}

/* ── Panels ─────────────────────────────────────────────────────────────── */

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  flex-wrap: wrap;
}

.panel-body { padding: 16px; }

/* ── Controls ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 90ms ease, border-color 90ms ease;
}

.btn:hover { background: var(--bg-hover); border-color: var(--text-faint); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-raised));
  border-color: var(--accent);
}

.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-icon { padding: 7px; }
.btn-icon svg { width: 16px; height: 16px; }

.input, .select, textarea.input {
  width: 100%;
  padding: 7px 11px;
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.input-mono { font-family: var(--mono); font-size: 13px; }

.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2398a29b' stroke-width='1.5'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px;
  cursor: pointer;
}

.search {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.search .input { padding-left: 32px; }

.search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}

.field { margin-bottom: 15px; }

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
}

/* A label row, for when the label is joined by a (?) or is not a <label> at
   all (a group of checkboxes has no single control to point at). */
.field-label { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.field-label > label, .field-label > .label { margin-bottom: 0; }

.label { font-size: 12.5px; font-weight: 500; color: var(--text-dim); }

/* A checkbox that is itself the field, rather than a control with a caption. */
.field-label .check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  font-size: 13px;
  cursor: pointer;
}
.field-label .check input { accent-color: var(--accent); cursor: pointer; }

/* The (?) beside a label. The explanation it opens is written out in full in
   the markup, so it stays in the page for search and for screen readers even
   while hidden; only its visibility is in question. */
.hint-btn {
  display: inline-flex;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  line-height: 0;
}
.hint-btn svg { width: 14px; height: 14px; }
.hint-btn:hover, .hint-btn[aria-expanded="true"] { color: var(--text-dim); }

.field-hint { margin-top: 5px; font-size: 12px; color: var(--text-faint); }
.field-hint[hidden] { display: none; }
.field-error { margin-top: 5px; font-size: 12.5px; color: var(--danger); }
.field-warn  { margin-top: 5px; font-size: 12.5px; color: var(--warn); }

/* The parsed shape of a connection string, shown under a revealed value. */
.dsn-breakdown { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.dsn-parts { font-family: var(--mono, ui-monospace, monospace); font-size: 12px; color: var(--text-dim); }

/* Segmented control, as used for My Projects / All Projects. */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.segmented a, .segmented button {
  padding: 5px 13px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.segmented [aria-selected="true"] {
  background: var(--bg-hover);
  color: var(--text);
  font-weight: 500;
}

/* ── Project grid ───────────────────────────────────────────────────────── */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.project-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 148px;
  transition: border-color 110ms ease, background 110ms ease;
}

.project-card:hover { border-color: var(--border-strong); background: var(--bg-hover); }

.project-card-top { display: flex; align-items: flex-start; gap: 11px; }

.project-card-name {
  font-size: 15.5px;
  font-weight: 600;
  border-bottom: 1px solid transparent;
}

.project-card:hover .project-card-name { border-bottom-color: var(--accent); }

.project-card-desc {
  margin-top: 5px;
  color: var(--text-dim);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-desc.is-empty { color: var(--text-faint); font-style: italic; }

.project-card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12.5px;
}

.project-card-foot strong { color: var(--text-dim); font-weight: 600; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

.table { width: 100%; border-collapse: collapse; }

.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-inset);
  white-space: nowrap;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }

.table-actions { text-align: right; white-space: nowrap; }

.cell-key {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 13px;
}

.cell-key svg { width: 14px; height: 14px; color: var(--text-faint); flex: none; }

/* A masked value keeps the row height stable whether or not it is revealed. */
.cell-value {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-value.is-empty { color: var(--text-faint); letter-spacing: 0.06em; font-size: 12px; }

/* ── Small pieces ───────────────────────────────────────────────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 500;
}

.chip-accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent); }
.chip-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.chip-ok     { background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.row   { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }

.empty {
  padding: 52px 24px;
  text-align: center;
  color: var(--text-dim);
}

.empty h3 { margin-bottom: 6px; font-size: 15px; color: var(--text); }
.empty p { margin: 0 auto 18px; max-width: 44ch; font-size: 13.5px; }

/* ── Flash messages ─────────────────────────────────────────────────────── */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  font-size: 13.5px;
}

.flash-error   { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); }
.flash-warn    { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, var(--bg-raised)); }
.flash-success { border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: color-mix(in srgb, var(--ok) 10%, var(--bg-raised)); }
.flash svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ── Sign-in ────────────────────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 26px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-box {
  padding: 26px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-box h1 { font-size: 17px; margin-bottom: 4px; }
.auth-box .page-sub { font-size: 13px; margin-bottom: 20px; }
.auth-box .btn { width: 100%; margin-top: 6px; }

.auth-foot { margin-top: 18px; text-align: center; font-size: 12.5px; color: var(--text-faint); }

/* ── Modal ──────────────────────────────────────────────────────────────── */

/* Native <dialog>: the browser supplies the focus trap, Escape-to-close, and
   inertness of the page behind it, so none of that is reimplemented here. The
   element itself is the clickable backdrop; .modal-inner holds the content, so
   a click on the dialog box never reads as a click outside it. */
dialog.modal {
  width: min(460px, calc(100vw - 40px));
  padding: 0;
  border: none;
  background: none;
  color: var(--text);

  /* The dialog must never exceed the screen, or its footer lands below the
     fold with nothing to scroll. dvh rather than vh: on iOS, vh measures the
     viewport as if the browser chrome were hidden, which overshoots by the
     height of the address bar. */
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
}

dialog.modal::backdrop {
  background: rgb(0 0 0 / 62%);
  backdrop-filter: blur(2px);
}

dialog.modal:not([open]) { display: none; }

/* A column so the body takes the leftover height and scrolls inside it, while
   the head and footer stay put. Without min-height:0 the body refuses to shrink
   below its content and pushes the footer out of view. */
.modal-inner {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-head, .modal-foot { flex: none; }

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 { font-size: 15.5px; }
.modal-body { padding: 18px; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-inset);
}



/* ── Pagination ─────────────────────────────────────────────────────────── */

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
}

/* ── Feedback while htmx is in flight ───────────────────────────────────── */

.htmx-request.btn { opacity: 0.6; pointer-events: none; }
.htmx-indicator { opacity: 0; transition: opacity 140ms ease; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    /* Three areas need three rows. With only two defined, the sidebar strip
       inherited 1fr and claimed a third of the screen. */
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "topbar" "sidebar" "main";
  }

  .sidebar {
    flex-direction: row;
    /* Wrap rather than scroll: a horizontal strip hides whatever does not fit,
       and "Settings" — the only way to rename or delete a project — was the
       item falling off the right edge. */
    flex-wrap: wrap;
    padding: 8px 10px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav-back, .nav-foot { display: none; }
  .nav-item { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
  .nav-item[aria-current="page"] { border-bottom-color: var(--accent); }
  .main { padding: 22px 18px 60px; }
  .page-title { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Dropdown (native <details>) ─────────────────────────────────────────
 * A real dropdown with no JavaScript, which is what the CSP requires. The
 * summary is styled as a button; the panel is absolutely positioned so it
 * overlays the toolbar instead of pushing it apart.
 */

.dropdown { position: relative; }

.dropdown > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary::marker { content: ""; }

.dropdown[open] > summary {
  background: var(--bg-hover);
  border-color: var(--text-faint);
}

.dropdown-caret { display: inline-flex; margin-left: 2px; color: var(--text-faint); }
.dropdown-caret svg { width: 13px; height: 13px; }
.dropdown[open] .dropdown-caret { transform: rotate(180deg); }

.dropdown-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  left: 0;
  min-width: 262px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dropdown-list { max-height: 260px; overflow-y: auto; padding: 5px; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  cursor: pointer;
}

.dropdown-item:hover { background: var(--bg-hover); }

/* A dropdown item that is a choice rather than a link. It hides its checkbox
   and shows a tick on the right, the same way an .env-toggle does — a native
   box inside a styled row reads as a second control sitting in the first. */
.dropdown-check { position: relative; color: var(--text-dim); }

.dropdown-check input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.dropdown-check svg { flex: none; width: 15px; height: 15px; opacity: 0; color: var(--accent); }
.dropdown-check:has(input:checked) { color: var(--text); }
.dropdown-check:has(input:checked) svg { opacity: 1; }

/* The hidden input takes the focus, so the row has to show it. Inset, because
   an outline outside the row would be clipped by the panel. */
.dropdown-check:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Pushed right, and it takes the tick with it. */
.dropdown-slug { margin-left: auto; font-size: 11.5px; }

.dropdown-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-inset);
}

.dropdown-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
}

.dropdown-add:hover { background: var(--bg-hover); color: var(--text); }
.dropdown-add svg { width: 14px; height: 14px; }

/* ── Presence matrix ─────────────────────────────────────────────────────
 * Three states, deliberately distinct: set, set-but-empty, and absent. The
 * middle one is usually a mistake worth spotting, so it gets the warning
 * colour rather than being collapsed into either neighbour.
 */

.table-matrix th.matrix-col,
.table-matrix td.matrix-col { text-align: center; }

.table-matrix th.matrix-col a { color: var(--text-dim); }
.table-matrix th.matrix-col a:hover { color: var(--accent); }
.table-matrix td.matrix-col .cell-value { max-width: 260px; margin: 0 auto; text-align: left; }

.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.mark svg { width: 15px; height: 15px; }
.mark-set { color: var(--ok); }
.mark-empty { color: var(--warn); }
.mark-empty svg { width: 12px; height: 12px; }
.mark-missing { color: var(--text-faint); font-size: 13px; }

/* ── Code snippets and copy buttons ──────────────────────────────────────── */

.snippet { position: relative; }

.snippet pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
}

.snippet pre code {
  padding: 0;
  border: none;
  background: none;
  font-size: inherit;
  color: inherit;
}

.snippet-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0;
  transition: opacity 110ms ease;
}

.snippet:hover .snippet-copy,
.snippet-copy:focus-visible { opacity: 1; }

.is-copied { color: var(--ok) !important; border-color: var(--ok) !important; }

.copyable { display: inline-flex; align-items: center; gap: 6px; }
.copyable code { font-size: 12.5px; }

/* Collapsible guide sections. */
.guide > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.guide > summary::-webkit-details-marker { display: none; }
.guide > summary::marker { content: ""; }
.guide > summary:hover { background: var(--bg-hover); }
.guide[open] > summary { border-bottom: 1px solid var(--border); }

.prose { margin: 0; padding-left: 18px; color: var(--text-dim); font-size: 13.5px; line-height: 1.7; }
.prose li { margin-bottom: 8px; }
.prose strong { color: var(--text); font-weight: 600; }

/* ── Environment toggles ─────────────────────────────────────────────────
 * A short list of checkboxes drawn as pills on a wrapping line. Every option
 * has to stay visible — seeing production sitting there unticked is what stops
 * a value going to the wrong place — but a boxed column of them costs a third
 * of the create-secret dialog for a choice usually left as it came.
 */
.env-toggles { display: flex; flex-wrap: wrap; gap: 6px; }

.env-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-inset);
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  transition: color 110ms ease, background 110ms ease, border-color 110ms ease;
}

/* The checkbox is the state, not the picture of it. It stays in the form and
   in the tab order; the pill does the drawing, because a native box inside a
   framed control reads as two nested controls rather than one. */
.env-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

/* Space for the tick is reserved rather than revealed: a pill that changed
   width on being ticked would reflow the whole row under the pointer. */
.env-toggle svg { width: 13px; height: 13px; opacity: 0; }

.env-toggle:hover { background: var(--bg-hover); color: var(--text); }

.env-toggle:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-soft);
  color: var(--accent);
}

.env-toggle:has(input:checked) svg { opacity: 1; }

/* The hidden input takes the focus, so the pill has to show it. */
.env-toggle:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.inline-fanout {
  margin-top: 8px;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
}

/* Smaller pills here than in the dialog: this sits inside a table row, where
   the full size would push the row taller than the ones around it. */
.inline-fanout .env-toggle { gap: 5px; padding: 3px 10px; font-size: 12.5px; }
.inline-fanout .env-toggle svg { width: 12px; height: 12px; }

/* ── Mobile ──────────────────────────────────────────────────────────────
 * A wide table used to drag the whole page sideways. On iOS that also shifts
 * modal dialogs off-centre, because the layout viewport moves under them —
 * so containing the scroll is a layout fix and a usability fix at once.
 */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Let the flex/grid parent shrink instead of being pushed wide by the table. */
  min-width: 0;
}

/* Flex children default to min-width:auto and refuse to shrink below their
   content, which is how a long value or a textarea forces a page-wide scroll. */
.row > *, .panel-bar > *, .search { min-width: 0; }

/* Long values, DSNs and commands must wrap rather than widen the page. */
.page-hint, .page-sub { overflow-wrap: anywhere; }
.page-hint code { white-space: normal; overflow-wrap: anywhere; }

@media (max-width: 860px) {
  /* The sidebar becomes a horizontal strip of pills. Without align-items the
     flex row stretches each item to full height, which rendered the current
     page as a tall empty box. */
  .sidebar {
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
  }

  .nav-item {
    flex: none;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-inset);
    font-size: 13px;
  }

  .nav-item[aria-current="page"] {
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    color: var(--accent);
  }

  .main { padding: 18px 14px 60px; }
  .panel-bar { padding: 12px; gap: 8px; }
  .table th, .table td { padding: 10px 11px; }

  /* Nearly full width: the extra 40px of margin is a luxury on a phone. */
  dialog.modal {
    width: calc(100vw - 16px);
    max-width: none;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .modal-inner {
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .modal-body { padding: 14px; }
  .modal-foot { padding: 12px 14px; }
  .modal-foot .btn { flex: 1; }

  /* Comfortable touch targets. */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; }
  .env-toggle { padding: 7px 14px; }

  .cell-value { max-width: 210px; }
  .search { min-width: 140px; }
}

@media (max-width: 460px) {
  .page-title { font-size: 20px; }
  .brand span, .crumb span:not(.tile) { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { padding: 0 10px; }
}

/* Progressive disclosure for narrow screens: labels give way to icons, and
   secondary metadata drops out, but nothing actionable disappears. */
.show-sm { display: none; }

@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .show-sm { display: inline-flex; }
  .show-sm svg { width: 15px; height: 15px; }
  .table-actions .btn { padding: 6px 8px; }
}

/* The title's own controls should not inherit the accent rule under the text. */
.page-title .btn { border-bottom: none; padding: 6px; }
.page-title .btn svg { width: 17px; height: 17px; }
