/* ============================================================================
   penguina.css — the shared house style for the whole penguina.io fleet.
   Single source of truth: /crate/apps/_shared/penguina.css, bind-mounted
   read-only into each app's public/ and served at /penguina.css.
   Light by default, dark via prefers-color-scheme. Monochrome, system font,
   720px column. Tokens match the original scout/store/drop inline styles.
   ============================================================================ */

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --fg-soft: #3f3f46;
  --muted: #71717a;
  --line: #e4e4e7;
  --line-soft: #f4f4f5;
  --row-hover: #f9fafb;
  --row-active: #f3f4f6;
  --row-details-bg: #f9fafb;

  --btn-bg: #18181b;
  --btn-fg: #fafafa;
  --btn-bg-hover: #27272a;
  --btn-secondary-bg: transparent;
  --btn-secondary-fg: var(--fg);
  --btn-secondary-border: var(--line);
  --btn-secondary-hover: var(--row-hover);

  --field-bg: #fafaf9;

  --dot: #d4d4d8;          /* neutral/idle status dot */
  --dot-active: #18181b;
  --ok: #15803d;           /* up / success */
  --danger: #c2410c;       /* down / destructive */

  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 720px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #fafafa;
    --fg-soft: #d4d4d8;
    --muted: #71717a;
    --line: #1c1c1f;
    --line-soft: #141416;
    --row-hover: #131316;
    --row-active: #181819;
    --row-details-bg: #0f0f11;

    --btn-bg: #fafafa;
    --btn-fg: #0a0a0a;
    --btn-bg-hover: #e4e4e7;

    --field-bg: #18181b;

    --dot: #3f3f46;
    --dot-active: #fafafa;
    --ok: #4ade80;
    --danger: #fb923c;
  }
}

/* ---- reset + base ---- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--fg);
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---- layout: header / main / footer (720px column) ---- */
header {
  width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding: 32px 24px 8px;
  padding-top: calc(32px + env(safe-area-inset-top));
}
header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0; color: var(--fg); }
header .sub, .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

main { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 16px 24px 48px; flex: 1 0 auto; }

footer {
  width: 100%; max-width: var(--maxw); margin: 24px auto 0; padding: 16px 24px;
  font-size: 11px; color: var(--muted); border-top: 1px solid var(--line-soft); flex-shrink: 0;
}
footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
footer a:hover { color: var(--fg); }

/* ---- small helpers ---- */
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }
.spread { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
[hidden] { display: none !important; }
.empty { padding: 64px 0; text-align: center; color: var(--muted); font-size: 14px; }

/* group heading (small caps label above a list/grid) */
.group { margin-top: 26px; }
.group > h2 {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 10px;
}

/* ---- tabs ---- */
.tabs { display: flex; gap: 20px; margin-top: 18px; border-bottom: 1px solid var(--line-soft); }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px; padding: 8px 0; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--muted); cursor: pointer; transition: color .12s ease;
}
.tab:hover { color: var(--fg-soft); }
.tab.active { color: var(--fg); border-bottom-color: var(--fg); }

/* ---- buttons ---- */
.btn {
  appearance: none; background: var(--btn-bg); color: var(--btn-fg); border: none;
  border-radius: var(--radius-sm); padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; transition: background-color .12s ease, transform .08s ease;
}
.btn:hover { background: var(--btn-bg-hover); }
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-fg); border: 1px solid var(--btn-secondary-border); }
.btn-secondary:hover { background: var(--btn-secondary-hover); }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ---- form controls ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--fg-soft); }
input[type=text], input[type=email], input[type=password], input[type=number],
input:not([type]), select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--fg);
  background: var(--field-bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; outline: none;
  transition: border-color .15s ease, background .15s ease;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--fg); background: var(--bg); }

/* monospace output block (logs / JSON) */
.out {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  color: var(--muted); background: var(--row-hover);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 12px;
}

/* ---- pills / badges ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  color: var(--muted); border: 1px solid var(--line); background: transparent;
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.pill.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ---- generic list + row ---- */
.list { padding-top: 4px; }
.row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center;
  padding: 14px 16px; border-radius: var(--radius); margin: 1px 0; transition: background-color .12s ease;
}
.row + .row { border-top: 1px solid var(--line-soft); }
.row:hover { background: var(--row-hover); border-top-color: transparent; }
.row:hover + .row { border-top-color: transparent; }
.row .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; color: var(--fg); }
.row .meta { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---- status dot (used by tiles + inline status) ---- */
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); flex: none; }
.dot.up { background: var(--ok); }
.dot.down { background: var(--danger); }
.dot.unknown { background: var(--dot); }

/* ---- tiles (launcher / dashboard grid) ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(224px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; align-items: center; gap: 13px;
  text-decoration: none; color: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; transition: background-color .12s ease, border-color .12s ease, transform .08s ease;
}
.tile:hover { background: var(--row-hover); border-color: var(--fg-soft); transform: translateY(-1px); }
.tile.is-down { opacity: .55; }
.tile .tile-body { min-width: 0; flex: 1; }
.tile .tile-name { font-weight: 500; font-size: 14.5px; letter-spacing: -0.01em; color: var(--fg); }
.tile .tile-note, .tile .tile-stat {
  font-size: 12.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .tile-note { color: var(--muted); }
.tile .tile-stat { color: var(--fg-soft); }
.tile .dot { position: absolute; top: 13px; right: 13px; }

/* ============================================================================
   Fleet shell — opt-in app chrome derived from Penguina Video.

   Use .pg-bar + .pg-footer instead of styling generic header/footer elements.
   The namespaced contract lets apps migrate independently without disturbing
   nested headers, full-screen players, public product pages, or third-party UIs.
   ============================================================================ */
:root {
  --pg-bar-h: 56px;
  --pg-shell-max: var(--maxw);
  --pg-shell-pad: 24px;
}
.pg-shell--wide { --pg-shell-max: 1040px; --maxw: 1040px; }
.pg-shell--full { --pg-shell-max: none; }

.pg-bar {
  position: sticky; top: 0; z-index: 40;
  width: 100%; max-width: none; margin: 0; padding: 0;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.pg-bar__inner {
  width: 100%; max-width: none; margin: 0;
  min-height: calc(var(--pg-bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--pg-shell-pad) 0;
  display: flex; align-items: center; gap: 14px;
}
.pg-brand {
  display: inline-flex; align-items: center; gap: 9px; min-width: 0;
  color: var(--fg); text-decoration: none; white-space: nowrap;
  font: inherit; background: none; border: 0; padding: 0; cursor: pointer;
}
.pg-brand:hover { color: var(--fg); }
.pg-brand__mark {
  width: 26px; height: 26px; flex: none; display: inline-grid; place-items: center;
}
.pg-brand__name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
  font-size: 16px; font-weight: 650; letter-spacing: -.02em;
}
.pg-brand__app { color: var(--fg); }
.pg-bar__subtitle {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: 12px;
}
.pg-bar__slot {
  min-width: 0; flex: 1 1 auto; margin-left: auto;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}
.pg-bar__actions {
  margin-left: auto; display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; min-width: 0;
}
.pg-user {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-size: 12px;
}
.pg-user b { color: var(--fg-soft); font-weight: 600; }
.pg-search { position: relative; width: min(340px, 42vw); }
.pg-bar__slot.pg-search { flex: 0 1 340px; margin-left: auto; }
.pg-search input,
input.pg-search {
  width: 100%; margin: 0; padding: 9px 12px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--field-bg); font-size: 14px;
}
.pg-search input:focus,
input.pg-search:focus { border-color: var(--fg-soft); background: var(--bg); }
.pg-iconbtn {
  appearance: none; width: 38px; height: 38px; flex: none;
  display: inline-grid; place-items: center; padding: 0;
  color: var(--fg); background: none; border: 0; border-radius: 9px;
  cursor: pointer; transition: background-color .12s ease;
}
.pg-iconbtn:hover { background: var(--row-hover); }
.pg-iconbtn svg { width: 21px; height: 21px; display: block; }
.pg-bar :is(a, button, input, select):focus-visible,
.pg-footer a:focus-visible {
  outline: 2px solid var(--fg); outline-offset: 3px;
}

.pg-subnav {
  width: 100%; max-width: var(--pg-shell-max); margin: 0 auto;
  padding-inline: var(--pg-shell-pad);
}
.pg-subnav.tabs { margin-top: 0; }

.pg-footer {
  width: 100%; max-width: none; margin: auto 0 0; padding: 0;
  color: var(--muted); background: var(--bg);
  border-top: 1px solid var(--line-soft); font-size: 11px;
  flex: 0 0 auto;
}
.pg-footer__inner {
  width: 100%; max-width: none; margin: 0;
  min-height: 48px;
  padding: 13px var(--pg-shell-pad) calc(13px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.pg-footer__meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pg-footer__links { display: inline-flex; align-items: center; gap: 12px; margin-left: auto; }
.pg-footer a { color: var(--muted); text-decoration: none; }
.pg-footer a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
body:has(.pg-footer) { padding-bottom: 0; }

@media (max-width: 640px) {
  :root { --pg-shell-pad: 16px; }
  .pg-bar__inner { gap: 10px; }
  .pg-brand__mark { width: 24px; height: 24px; }
  .pg-brand__name { font-size: 15px; }
  .pg-bar__subtitle { display: none; }
  .pg-bar__slot.pg-search { width: auto; flex: 1 1 auto; }
  .pg-user { max-width: 34vw; }
  .pg-bar__actions .pg-user { display: none; }
  .pg-footer__inner { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-iconbtn { transition: none; }
}
