/* Image Farm panel. Colours are tokens on :root, redefined for dark mode. No external
   fonts or images; nothing here loads from anywhere else. */

:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #1c2127;
  --muted: #5a6470;
  --border: #d6dbe1;
  --accent: #1f56c3;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --danger-text: #ffffff;
  --good: #1d7037;
  --warn: #7a5200;
  --warn-bg: #fff3d1;
  --bad-bg: #fde7e5;
  --bar: #1f56c3;
  --bar-full: #b3261e;
  --bar-track: #e3e7ec;
  --focus: #1f56c3;
  --radius: 8px;
  --gap: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --surface: #1d2126;
    --surface-2: #262b31;
    --text: #e7eaee;
    --muted: #9ba5b1;
    --border: #353c44;
    --accent: #7fa8ff;
    --accent-text: #0e1a33;
    --danger: #ff8a80;
    --danger-text: #2b0a07;
    --good: #7dd492;
    --warn: #f3c969;
    --warn-bg: #3a2f12;
    --bad-bg: #3d1c1a;
    --bar: #7fa8ff;
    --bar-full: #ff8a80;
    --bar-track: #2c3238;
    --focus: #7fa8ff;
  }
}

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

/* Author display rules (such as button's) would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: anywhere;
}

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
h4 { font-size: 0.95rem; margin: 14px 0 6px; }
p { margin: 6px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
img { max-width: 100%; height: auto; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

/* ---------- header and jump links ---------- */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 16px 6px;
}
.top #updated { flex: 1 1 160px; margin: 0; font-size: 0.88rem; }
.top #sign-out-message { flex: 1 1 100%; margin: 0; min-height: 0; }

.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 8px;
  font-size: 0.9rem;
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
  min-width: 0;
}

/* ---------- controls ---------- */

button, .button {
  display: inline-block;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.3;
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  max-width: 100%;
}
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger, .button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.quiet { background: transparent; }
button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  text-align: left;
}
a.button:not([href]) { opacity: 0.5; cursor: default; pointer-events: none; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

label { display: block; font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 3px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  min-width: 0;
}
input[type="file"] { padding: 4px; }
textarea { resize: vertical; }

.stack > * + * { margin-top: 10px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--gap); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap); margin-bottom: 12px; }

.message { min-height: 1.2em; }
.message.bad, .problems li.bad { color: var(--danger); }
.message.good { color: var(--good); }
.notice { border-radius: 6px; padding: 8px 12px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--danger); margin: 8px 0; }
.problems { margin: 6px 0; padding-left: 20px; }
.problems li { margin: 3px 0; }
.problems li.good { color: var(--good); }

/* ---------- tiles ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.tile { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; }
.tile .value { font-size: 1.6rem; font-weight: 600; line-height: 1.2; }
.tile .label { font-size: 0.9rem; }
.tile .sub { font-size: 0.82rem; color: var(--muted); }
.tile.warn { background: var(--warn-bg); color: var(--warn); }
.tile.warn .sub { color: var(--warn); }

/* ---------- tables (stacked on narrow screens) ---------- */

table.rows { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.rows th, table.rows td { text-align: left; vertical-align: top; padding: 7px 8px; border-bottom: 1px solid var(--border); }
table.rows th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
table.rows tr.open td { background: var(--surface-2); }

@media (max-width: 720px) {
  table.rows thead { display: none; }
  table.rows, table.rows tbody, table.rows tr, table.rows td { display: block; width: 100%; }
  table.rows tr { border-bottom: 1px solid var(--border); padding: 6px 0; }
  table.rows td { border: none; padding: 2px 0; }
  table.rows td[data-label]:not([data-label=""])::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-size: 0.85rem;
  }
}

/* ---------- connections ---------- */

.network { border-top: 1px solid var(--border); padding: 12px 0 4px; }
.network:first-child { border-top: none; padding-top: 0; }
.network h3 { margin: 0 0 4px; }
progress.bar {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 12px;
  border: none;
  border-radius: 6px;
  background: var(--bar-track);
  overflow: hidden;
  margin: 4px 0;
}
progress.bar::-webkit-progress-bar { background: var(--bar-track); border-radius: 6px; }
progress.bar::-webkit-progress-value { background: var(--bar); border-radius: 6px; }
progress.bar::-moz-progress-bar { background: var(--bar); border-radius: 6px; }
progress.bar.full::-webkit-progress-value { background: var(--bar-full); }
progress.bar.full::-moz-progress-bar { background: var(--bar-full); }
details { margin: 4px 0; }
summary { cursor: pointer; color: var(--muted); }

/* ---------- job detail and scene grid ---------- */

.detail { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-top: 14px; background: var(--bg); }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.detail-head h3 { margin: 0; }
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.scene { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; margin: 0; font-size: 0.86rem; min-width: 0; }
.scene img { display: block; width: 100%; border-radius: 4px; background: var(--surface-2); }
.scene .placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  padding: 4px;
}
.scene.failed { border-color: var(--danger); }
.scene .error { color: var(--danger); }
.scene p { margin: 4px 0; }

/* ---------- playground, kits, keys ---------- */

.result { margin: 10px 0; }
.result img { border-radius: var(--radius); border: 1px solid var(--border); }
.from-preview img { max-height: 120px; width: auto; border-radius: 4px; }
.kit { border-top: 1px solid var(--border); padding: 10px 0; }
.kit:first-child { border-top: none; }
.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 6px 0; }
.ref { background: var(--surface-2); border-radius: 6px; padding: 6px; font-size: 0.86rem; margin: 0; }
.ref img { display: block; width: 100%; max-height: 140px; object-fit: contain; border-radius: 4px; }
.character-row { border: 1px dashed var(--border); border-radius: 6px; padding: 8px; margin-bottom: 8px; }
.settings .setting { padding: 8px 0; border-top: 1px solid var(--border); }
.settings .setting:first-child { border-top: none; }
.steps li { margin: 4px 0; }
.secret {
  display: block;
  padding: 8px;
  border-radius: 6px;
  background: var(--surface-2);
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
}

/* ---------- dialogs ---------- */

dialog {
  width: min(480px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

/* ---------- sign-in page and the hub's sign-in answers ---------- */

.sign-in-box { max-width: 420px; margin: 12vh auto 0; }
.sign-in-box h1 { margin-bottom: 12px; }
.sign-in-box form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.sign-in-box label { color: var(--text); font-weight: 600; }

/* ---------- who is signed in, and two-step setup ---------- */

.top #who { font-size: 0.88rem; }
#two-step-secret { letter-spacing: 0.08em; }
