:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --fg: #1d1d1b;
  --muted: #6b6a66;
  --line: #e3e1dc;
  --accent: #2f5bd3;
  --accent-fg: #ffffff;
  --ok: #1f7a4d;
  --busy: #a06400;
  --err: #b3261e;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --card: #1f1f1d;
    --fg: #ecebe7;
    --muted: #9c9a94;
    --line: #34332f;
    --accent: #7c9cff;
    --accent-fg: #0d0d0c;
    --ok: #5fcf95;
    --busy: #e0a84a;
    --err: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}
a { color: var(--accent); }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card);
}
.top nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.top nav form { margin: 0; }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); letter-spacing: .02em; }
.who { color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--err); }
.ok { color: var(--ok); }
.busy { color: var(--busy); }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { font: inherit; cursor: pointer; }
button.primary {
  background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 8px;
  padding: 10px 16px; font-weight: 600;
}
button.primary:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
button.link.danger { color: var(--err); }

.login { max-width: 360px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0; }
.login p { margin: 0; }

.layout { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } }

.gen { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 16px; }
@media (max-width: 800px) { .gen { position: static; } }
.gen p { margin: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
details .row + .row { margin-top: 10px; }
.gpu { padding: 8px 10px; border-radius: 8px; background: var(--bg); }

.jobs { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.job header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.job .prompt { margin: 8px 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.job .note { margin: 0 0 8px; overflow-wrap: anywhere; }
.job .actions { display: flex; gap: 16px; margin-top: 8px; font-size: 13px; }
.empty { text-align: center; padding: 48px 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.grid figure { margin: 0; }
.grid img {
  display: block; width: 100%; height: auto; border-radius: 8px; background: var(--bg);
}
.grid figcaption { font-size: 12px; margin-top: 2px; }
.placeholder {
  aspect-ratio: 1; border-radius: 8px;
  background: linear-gradient(90deg, var(--bg) 0%, var(--line) 50%, var(--bg) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .placeholder { animation: none; } }

.badge {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line);
}
.badge.done, .badge.ready { color: var(--ok); }
.badge.running, .badge.queued, .badge.downloading { color: var(--busy); }
.badge.failed { color: var(--err); }

.admin { display: flex; flex-direction: column; gap: 16px; max-width: 1100px; margin: 0 auto; }
.admin h2 { margin: 0 0 8px; font-size: 17px; }
.add { display: flex; gap: 8px; margin: 12px 0 8px; }
.add input { flex: 1; min-width: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
code { font-size: 13px; }
