:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2129;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #58a6ff;
  --ok: #3fb950;
  --ok-tint: rgba(63, 185, 80, 0.08);
  --warn: #d29922;
  --danger: #f85149;
  --danger-tint: rgba(248, 81, 73, 0.12);
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.5 -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    sans-serif;
}

.hidden {
  display: none !important;
}

/* Visually hidden, still announced by screen readers (aria-live region). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.error {
  padding: 8px 16px;
  background: var(--danger-tint);
  color: var(--danger);
  border-bottom: 1px solid var(--danger);
  font-size: 13px;
}

.topbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 {
  font-size: 16px;
  margin: 0 12px 0 0;
  font-weight: 600;
}
.topbar .grow {
  flex: 1;
}

button {
  background: var(--accent);
  color: #0d1117;
  border: 0;
  border-radius: 6px;
  padding: 7px 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    filter 0.12s ease,
    transform 0.06s ease,
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button:hover:not(:disabled) {
  filter: brightness(1.08);
}
button.ghost:hover:not(:disabled) {
  border-color: var(--muted);
}
/* Tactile press — the button dips + darkens while held. */
button:active:not(:disabled) {
  transform: translateY(1px);
  filter: brightness(0.93);
}
button:disabled {
  opacity: 0.55;
  cursor: default;
  filter: none;
}
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* Copy/confirm success — a brief, unmistakable green "Copied!" flash. */
button.copied,
button.copied:hover {
  background: var(--ok);
  border-color: var(--ok);
  color: #0d1117;
  filter: none;
}
.copy-curl {
  margin-top: 12px;
}

input[type='text'],
textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 13px;
}
input[type='text'] {
  min-width: 260px;
}

.ingest {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}
.ingest code {
  background: var(--panel-2);
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--accent);
  user-select: all;
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  flex: 1;
  min-height: 0; /* let the sidebar/main scroll inside the flex row */
}
.sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.main {
  overflow-y: auto;
  padding: 16px;
}

.secrets {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.secrets label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.secrets textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
}
.secrets .row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.note {
  font-size: 11px;
  color: var(--warn);
}

.req-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.1s ease;
}
.req-item:hover {
  background: var(--panel);
}
.req-item:active {
  background: var(--panel-2);
}
.req-item.active {
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
}
.req-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.req-item .line1 {
  display: flex;
  gap: 8px;
  align-items: center;
}
.req-item .when {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.method {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text);
}
.m-GET {
  color: var(--ok);
}
.m-POST {
  color: var(--accent);
}
.m-PUT,
.m-PATCH {
  color: var(--warn);
}
.m-DELETE {
  color: var(--danger);
}

.empty {
  color: var(--muted);
  padding: 24px 16px;
  text-align: center;
}
/* A muted second line under an empty-state message — a gentle "what to do next". */
.empty-hint {
  display: block;
  max-width: 42ch;
  margin: 6px auto 0;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.85;
  line-height: 1.5;
}

/* First-run onboarding hero (shown in #main when no inbox is open). Two columns:
   Watson the detective ferret on the left, the copy on the right. */
.hero {
  max-width: 760px;
  margin: 48px auto;
  padding: 0 16px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 28px;
  text-align: left;
  animation: hero-in 150ms ease-out;
}
/* Watson, the detective-ferret mascot — left column, top-aligned with the copy.
   A soft warm "lamplight" glow (drop-shadow follows his silhouette) lifts him off
   the near-black background so his dark tones don't disappear into it. */
.hero-mascot {
  flex: none;
  width: 185px;
  height: auto;
  filter: drop-shadow(0 0 26px rgba(210, 153, 34, 0.22))
    drop-shadow(0 0 10px rgba(210, 153, 34, 0.18)) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.45));
}
.hero-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}
/* Stack on narrow viewports: Watson on top, centered copy. */
@media (max-width: 620px) {
  .hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .hero-body {
    align-items: center;
  }
  .hero-body .hero-privacy {
    justify-content: center;
  }
}
.hero-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.hero-sub {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
}
.steps {
  width: 100%;
  max-width: 420px;
  margin: 4px 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.step-num {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
}
.step code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent);
  background: var(--panel-2);
  padding: 1px 6px;
  border-radius: 4px;
}
.hero-cta {
  padding: 10px 20px;
  font-size: 14px;
}
.hero-privacy {
  margin: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
  font-size: 12.5px;
  color: var(--muted);
}
.hero-privacy-ok {
  color: var(--ok);
}
@keyframes hero-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .hero {
    animation: none;
  }
  button,
  .req-item {
    transition: none;
  }
  button:active:not(:disabled) {
    transform: none;
  }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 10px;
}

.kv {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
}
.kv td {
  padding: 3px 8px 3px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.kv td:first-child {
  color: var(--muted);
  white-space: nowrap;
  width: 1%;
}
.kv td:last-child {
  word-break: break-all;
}

pre.body {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
}

.match {
  border-left: 3px solid var(--ok);
  background: var(--ok-tint);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
}
.match .secret {
  color: var(--ok);
  font-weight: 700;
}
.nomatch {
  color: var(--warn);
  font-family: var(--mono);
  font-size: 12.5px;
}
.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin: 0 4px 4px 0;
}

/* Global footer — legal links + a one-line reassurance. Slim, unobtrusive. */
.footer {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-size: 12px;
  color: var(--muted);
}
.footer .brand {
  font-weight: 600;
  color: var(--text);
}
.footer a {
  color: var(--muted);
  text-decoration: none;
}
.footer a:hover {
  color: var(--text);
  text-decoration: underline;
}
.footer a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
.footer .grow {
  flex: 1;
}

/* Standalone legal pages (privacy.html / terms.html). */
.legal {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
.legal h1 {
  font-size: 22px;
  margin: 0 0 4px;
}
.legal .effective {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 24px;
}
.legal h2 {
  font-size: 15px;
  margin: 28px 0 8px;
  color: var(--text);
}
.legal p,
.legal li {
  color: var(--text);
  line-height: 1.6;
}
.legal ul {
  padding-left: 20px;
}
.legal li {
  margin: 4px 0;
}
.legal a {
  color: var(--accent);
}
.legal code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent);
}
.legal .lede {
  color: var(--muted);
}
.topbar h1 a {
  color: inherit;
  text-decoration: none;
}
.legal-back {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}
.legal-back:hover {
  color: var(--text);
}
.legal-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Mobile "back to the request list" control. Hidden on desktop (both panes are
   always visible there); revealed only in the mobile detail view (below). */
.back-to-list {
  display: none;
}

/* ------------------------------------------------------------------------- *
 * Mobile / narrow viewports (<= 640px).
 *
 * The desktop two-pane grid (340px | 1fr) collapses to a SINGLE pane that
 * shows either the request LIST or the request DETAIL — a tabbed
 * master-detail driven by state classes on #layout (set in app.js):
 *   .has-inbox        an inbox is open (otherwise the first-run hero shows)
 *   .show-detail      the detail pane is open (otherwise the list shows)
 * The whole page scrolls as one document (no nested/ trapped scroll areas).
 * Everything above is untouched — desktop keeps both panes side by side.
 * ------------------------------------------------------------------------- */
@media (max-width: 640px) {
  /* One column; let the document scroll instead of each pane individually. */
  .layout {
    grid-template-columns: 1fr;
    flex: 1 0 auto;
    min-height: auto;
  }
  .sidebar {
    border-right: 0;
    overflow-y: visible;
  }
  .main {
    overflow-y: visible;
    min-width: 0;
    padding: 12px;
  }

  /* First run (no inbox): the hero in #main is the whole show — hide the
     empty sidebar placeholder. */
  .layout:not(.has-inbox) .sidebar {
    display: none;
  }
  /* Inbox open: the LIST by default, the DETAIL once a row is opened. */
  .layout.has-inbox:not(.show-detail) .main {
    display: none;
  }
  .layout.has-inbox.show-detail .sidebar {
    display: none;
  }
  .layout.has-inbox.show-detail .back-to-list {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
  }

  /* Topbar packs into tidy rows; the reopen field takes its own full line. */
  .topbar {
    gap: 8px;
  }
  .topbar .grow {
    display: none;
  }
  .topbar input[type='text'] {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }

  /* >=16px fields stop iOS Safari auto-zooming on focus; bigger tap targets. */
  input[type='text'],
  textarea {
    font-size: 16px;
  }
  button {
    min-height: 44px;
  }
  .topbar button,
  .ingest button {
    padding: 10px 14px;
  }

  /* Ingest chip: the URL wraps onto its own full-width line (no page overflow). */
  .ingest {
    flex-wrap: wrap;
    min-width: 0;
  }
  .ingest code {
    flex: 1 1 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-all;
    padding: 10px 12px;
  }

  /* Secrets: the reassurance note drops below the Clear button. */
  .secrets .row {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  /* Detail cards: let long machine strings wrap instead of overflowing. */
  .kv td:first-child {
    white-space: normal;
    overflow-wrap: anywhere;
    width: auto;
  }
  .match,
  .nomatch {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .chip {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  pre.body {
    max-height: 60vh;
  }

  /* Footer + legal: links stay discoverable and comfortably tappable on touch. */
  .footer {
    gap: 16px;
  }
  .footer a {
    padding: 8px 4px;
    text-decoration: underline;
  }
  .legal {
    padding: 24px 16px 40px;
  }
  .legal-back {
    padding: 10px 6px;
    text-decoration: underline;
  }
}

/* Short landscape phones: reclaim vertical space taken by the first-run hero. */
@media (max-height: 520px) {
  .hero {
    margin: 16px auto;
  }
}
