/* Light theme (default): 100% white bg, 100% black text, yellow accent. */
:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #5a5a54;
  --accent: #ffff00;        /* yellow, kept in both themes */
  --code-bg: #f2f2ef;
  --border: #d0d0c8;
  --error: #c0392b;
  --pw-color: #aaa;   /* masked PASSWORD text (light) */
}
/* Dark theme: 100% black bg, 100% white text. Applied when the OS is dark and
   the user hasn't forced light, or when the user explicitly picks dark. The two
   selectors carry identical values (data-theme is set by the head script). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --fg: #ffffff;
    --muted: #9a9a94;
    --code-bg: #161615;
    --border: #333330;
    --error: #ff6b5e;
    --pw-color: #666;   /* masked PASSWORD text (dark) */
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #9a9a94;
  --code-bg: #161615;
  --border: #333330;
  --error: #ff6b5e;
  --pw-color: #666;   /* masked PASSWORD text (dark) */
}

* { box-sizing: border-box; }
::selection { background: var(--accent); color: #000; }
::-moz-selection { background: var(--accent); color: #000; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 ui-monospace, "SF Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  /* the web terminal drops in from the top and pushes the page down by its height */
  padding-top: var(--webterm-height, 0);
}
main { max-width: 80rem; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* links: dark text, yellow underline — readable and yellow in both themes */
a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
a:hover { background: var(--accent); color: #000; text-decoration: none; }

header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem;
}
.brand {
  font-weight: 700; font-size: 1.05rem; color: var(--fg); text-decoration: none;
}
.brand:hover { background: none; color: var(--fg); }
/* yellow highlight for the accented word (".new", "ClickHouse") */
.accent { background: var(--accent); color: #000; padding: 0 0.15em; }
nav { display: flex; gap: 0.9rem; align-items: baseline; }
.header-right { display: flex; align-items: center; gap: 1rem; }
.ghstar {
  display: inline-flex; align-items: center; gap: 0.35rem;
  color: var(--fg); text-decoration: none; font-size: 0.85rem; white-space: nowrap;
}
.ghstar svg { display: block; }
.theme-toggle {
  display: inline-flex; align-items: center;
  background: none; border: none; padding: 0.1rem 0.2rem; cursor: pointer;
  color: var(--fg); line-height: 1;
}
.theme-toggle svg { display: block; }
.theme-toggle:hover { background: var(--accent); color: #000; }

h1 { font-size: 1.7rem; line-height: 1.25; margin: 1.2rem 0 0.6rem; font-weight: 700; }
h2 { font-size: 1.35rem; margin: 2.4rem 0 0.6rem; }
h3 { font-size: 0.9rem; margin: 1.4rem 0 0.3rem; font-weight: 700; }
.lead { color: var(--muted); font-size: 1rem; margin: 0.2rem 0 1.2rem; }
.fine { color: var(--muted); font-size: 0.8rem; }
.error { color: var(--error); font-size: 0.9rem; }
.hidden { display: none; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 2.5rem; }
@media (max-width: 48rem) { .cols { grid-template-columns: 1fr; } }
.cols ul { padding-left: 1.1rem; margin: 0.4rem 0; }
.cols li { margin: 0.25rem 0; font-size: 0.9rem; }

code, pre, .mono, .pw { font-family: inherit; font-size: 0.9em; }
/* password value: plain mono (no code chip bg/padding) so it left-aligns with
   the host/user/database values above it */
.pw { cursor: pointer; user-select: none; background: none; padding: 0; }
code { background: var(--code-bg); padding: 0.1em 0.35em; }
pre {
  background: var(--code-bg); border: 1px solid var(--border);
  padding: 0.7rem 0.9rem; overflow-x: auto;
}
pre code { background: none; padding: 0; }

/* each snippet is wrapped so the copy button can sit at the top right */
.snippet { position: relative; }
.copybtn {
  position: absolute; top: 0; right: 0;
  font: inherit; font-size: 0.78rem; line-height: 1;
  padding: 0.35rem 0.6rem; cursor: pointer;
  background: var(--code-bg); color: var(--muted);
  border: 1px solid var(--border);
}
.copybtn:hover { background: var(--accent); color: #000; }

/* SQL comments in snippets */
.cmt { color: var(--muted); }

/* clickable PASSWORD fragment in snippets: masked look (theme bg + muted
   color) until clicked — white/#aaa in light, black/#666 in dark. */
.pwslot {
  background: var(--bg); color: var(--pw-color); padding: 0 0.15em;
  cursor: pointer; user-select: none;
}

.button, button.primary, a.button {
  display: inline-block; cursor: pointer; text-decoration: none;
  border: none; border-radius: 0; padding: 0.65rem 1.2rem;
  font-size: 1rem; font-weight: 700;
}
.primary { background: var(--accent); color: #000; }
/* hover inverts to the theme's fg/bg: white-on-black in light, black-on-white in dark */
.primary:hover { background: var(--fg); color: var(--bg); }
.primary:disabled { opacity: 0.5; cursor: wait; }
button.linky {
  background: none; border: none; padding: 0; cursor: pointer; color: var(--fg);
  text-decoration: underline; text-decoration-color: var(--accent);
  text-decoration-thickness: 2px; text-underline-offset: 3px; font-size: 0.85rem;
}
button.linky:hover { background: var(--accent); color: #000; text-decoration: none; }
form.inline { display: inline; }

.devlogin input {
  font: inherit; padding: 0.6rem 0.8rem; border-radius: 0;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  margin-right: 0.5rem;
}

table.kv { border-collapse: collapse; width: 100%; }
table.kv td { padding: 0.35rem 0.6rem 0.35rem 0; vertical-align: baseline; }
table.kv td:first-child { color: var(--muted); width: 7rem; font-size: 0.85rem; }

footer { margin-top: 4rem; border-top: 1px solid var(--border); padding-top: 1rem; }

kbd {
  font-family: inherit; font-size: 0.85em;
  background: var(--code-bg); border: 1px solid var(--border); padding: 0 0.3em;
}

/* Quake-style web terminal: drops down from the top, no animation, no header.
   Black background so there is no white flash before the terminal paints.
   Height is controlled inline by JS (remembered across toggles). */
#webterm-panel {
  position: fixed; left: 0; right: 0; top: 0; height: 0;
  background: #000; border-bottom: 2px solid var(--accent);
  overflow: hidden; z-index: 1000;
}
#webterm-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }
/* grab strip over the bottom border to resize */
#webterm-resizer { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; cursor: row-resize; z-index: 2; }
#webterm-drag-overlay { position: fixed; inset: 0; z-index: 1001; cursor: row-resize; }
