/* StackVault – minimal, dependency-free styles. */
/* Colors are variables only. Light is the default; dark follows the
   browser/OS setting (prefers-color-scheme). color-scheme makes the
   browser draw form controls and scrollbars to match. */
:root {
  color-scheme: light dark;
  --fg: #1d2127; --muted: #5d6673; --bg: #f6f7f9; --card: #fff; --input: #fff;
  --accent: #2357d9; --on-accent: #fff; --error: #b3261e; --warn: #8a5a00; --border: #d9dde3;
  --ok-bg: #dcefe0; --ok-fg: #1d6b2f; --warn-bg: #fbecc8; --err-bg: #f9dedc; --run-bg: #dbe5fb;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e3e7ed; --muted: #9aa4b2; --bg: #14171c; --card: #1c2027; --input: #12151a;
    --accent: #7ea4ff; --on-accent: #0d1424; --error: #f28b82; --warn: #e8b44c; --border: #343a44;
    --ok-bg: #1f3a27; --ok-fg: #8fd6a2; --warn-bg: #3d3216; --err-bg: #47201d; --run-bg: #1d2b4a;
  }
}
body { margin: 0; }
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 1.2rem; background: var(--card); border-bottom: 1px solid var(--border);
}
header nav { display: flex; gap: 1rem; align-items: center; }
header form { margin: 0; }
.brand { font-weight: 700; color: var(--fg); text-decoration: none; }
main { max-width: 60rem; margin: 1.5rem auto; padding: 0 1.2rem; }
footer { max-width: 60rem; margin: 2rem auto 1rem; padding: 0 1.2rem; }
a { color: var(--accent); }
.card {
  display: grid; gap: .9rem; max-width: 24rem; padding: 1.2rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
}
label { display: grid; gap: .3rem; font-size: .95rem; }
input, textarea { background: var(--input); color: var(--fg); }
input { padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 5px; font: inherit; }
button {
  padding: .45rem .9rem; border: 0; border-radius: 5px; background: var(--accent);
  color: var(--on-accent); font: inherit; cursor: pointer;
}
header button { background: transparent; color: var(--accent); padding: 0; }
.error { color: var(--error); font-weight: 600; }
.warning { color: var(--warn); font-weight: 600; }
.info { color: var(--accent); }
.hint { color: var(--muted); font-size: .9rem; }

/* Tables, badges, sections (stack and user pages). */
h2 { font-size: 1.15rem; margin-top: 1.8rem; }
table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px;
}
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td form { margin: 0; }
tr.missing td { color: var(--muted); }
.badge {
  display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .75rem;
  font-weight: 600; background: var(--border); color: var(--fg); vertical-align: middle;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.muted { color: var(--muted); }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--border); }
form.inline { display: flex; gap: .8rem; align-items: center; }
td.actions form.inline { display: inline-flex; margin-right: .4rem; }
table + form.card { margin-top: 1rem; }
label.check { display: flex; gap: .5rem; align-items: center; }
.card.wide { max-width: none; margin-bottom: 1.2rem; }
code.secret { font-size: 1.1rem; user-select: all; }
@media (max-width: 40rem) {
  table { display: block; overflow-x: auto; }
}

/* Tab bar of the stack pages. */
h1 + nav.tabs { margin-top: -.4rem; }
nav.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: 1.2rem; }
nav.tabs a {
  padding: .5rem .9rem; text-decoration: none; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav.tabs a:hover { color: var(--fg); }
nav.tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
textarea {
  padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 5px;
  font: .9rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical;
}
/* The compose editor: wide, tall, no wrapping (YAML indentation matters). */
textarea.code { width: 100%; box-sizing: border-box; min-height: 60vh; white-space: pre; overflow-x: auto; tab-size: 2; }
fieldset { display: grid; gap: .4rem; margin: 0; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 5px; }
legend { font-size: .95rem; padding: 0 .3rem; }
.card.wide p.hint { margin: -.5rem 0 0; }
.section-head { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin-top: 1.8rem; }
.section-head h2 { margin: 0; }
.section-head form { margin: 0; }
button[disabled] { opacity: .6; cursor: progress; }
form.init { border-color: var(--accent); }
form.init p { margin: 0; }

/* Jobs. */
.badge.err { background: var(--err-bg); color: var(--error); }
.badge.run { background: var(--run-bg); color: var(--accent); }
table.details { width: auto; }
table.details th { width: 10rem; }
/* The job log is a dark terminal in both modes; its colors are fixed. */
.log {
  background: #11151b; color: #d7dde5; border-radius: 8px; padding: .8rem 1rem; overflow-x: auto;
  font: .82rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 70vh; overflow-y: auto;
  border: 1px solid var(--border);
}
.log .line { white-space: pre-wrap; word-break: break-word; }
.log .ts { color: #8792a2; }
.log .lvl { display: inline-block; min-width: 3.2rem; color: #8792a2; }
.log .WARN .lvl { color: #e8b44c; }
.log .ERROR .lvl, .log .ERROR { color: #f28b82; }
.log .attrs { color: #9aa5b4; }
.log .ctr { color: #7cb7ff; }
.log .line[hidden] { display: none; }
fieldset.containers { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; align-items: center; }
fieldset.containers .actions { margin-left: auto; display: flex; gap: .5rem; }
.log-controls { display: flex; gap: 1.2rem; align-items: center; margin: .6rem 0; }
/* Line wrapping off: long lines scroll horizontally (.log has overflow-x). */
.log.nowrap .line { white-space: pre; word-break: normal; }
/* Full screen inside the browser window: only the log and the exit button. */
.log-frame.fullscreen {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  gap: .4rem; padding: .4rem; background: #11151b;
}
.log-frame.fullscreen .log { flex: 1; max-height: none; margin: 0; border-radius: 4px; }
.log-bar { display: flex; align-items: center; gap: .4rem 1rem; }
.log-bar[hidden] { display: none; }
.log-bar .log-exit { margin-left: auto; flex: none; color: #d7dde5; border-color: #3a4350; }
/* The container filter in the full-screen bar: one compact row on the dark
   background; the legend stays for screen readers only. */
.log-bar fieldset.containers { flex: 1; border: none; padding: 0; color: #d7dde5; }
.log-bar fieldset.containers legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.log-bar fieldset.containers .actions { margin-left: 0; }
.log-bar fieldset.containers button.secondary { color: #d7dde5; border-color: #3a4350; }
.log-bar fieldset.containers .hint { color: #9aa4b1; }
body.log-fullscreen { overflow: hidden; }
/* Container shell (xterm.js draws inside). */
.terminal { height: 70vh; padding: .4rem; background: #11151b; border-radius: 8px; border: 1px solid var(--border); }
.term-frame.fullscreen {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  gap: .4rem; padding: .4rem; background: #11151b;
}
.term-frame.fullscreen .terminal { flex: 1; min-height: 0; height: auto; border-color: #3a4350; }
.term-bar { display: flex; align-items: center; gap: 1rem; color: #d7dde5; }
.term-bar[hidden] { display: none; }
.term-bar .term-title { font-weight: 600; }
.term-bar .term-exit { margin-left: auto; color: #d7dde5; border-color: #3a4350; }
body.term-fullscreen { overflow: hidden; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.log:empty { display: none; }
