:root {
  --bg: #0e1116;
  --bg-soft: #151a21;
  --card: #1a212b;
  --line: #2a3441;
  --text: #e6ebf1;
  --muted: #93a1b1;
  --accent: #3ea6ff;
  --accent-soft: #1d3a55;
  --ok: #3fb970;
  --bad: #e05252;
  --warn: #d9a441;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: 0; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-all; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 12px; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.full { margin-top: 14px; }
.hint { color: var(--muted); font-size: 12.5px; }
.hint.small, .small { font-size: 12px; }
.hint.bad, .bad { color: var(--bad); }
.ok { color: var(--ok); font-size: 13px; }
.err {
  background: rgba(224, 82, 82, 0.1);
  border: 1px solid rgba(224, 82, 82, 0.4);
  color: #ffb4b4;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 13.5px;
}
input, select, textarea {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
textarea { width: 100%; resize: vertical; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
label.chk { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
label.big { font-size: 14px; }
label.dim { opacity: 0.55; }
.btn {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent-soft); border-color: var(--accent); color: #dff0ff; }
.btn.danger { background: rgba(224, 82, 82, 0.15); border-color: rgba(224, 82, 82, 0.5); color: #ffb4b4; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 11px; font-size: 15px; font-weight: 600; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.dim { opacity: 0.55; }

/* ---------- public ---------- */
.pub { max-width: 860px; margin: 0 auto; padding: 22px 16px 40px; }
.pub-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.tag { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.langs { display: flex; gap: 6px; }
.lang-btn {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.lang-btn.on { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.pub-main { display: flex; flex-direction: column; gap: 14px; }
.pub .card { margin: 0; }
.form .row { align-items: flex-end; }
.form .row > label { flex: 1; min-width: 120px; }
.prompt-box { margin: 4px 0 10px; }
.prompt-box .row { margin-top: 6px; }
/* 提示詞上限 10000 字，可見範圍約 1000 字。860px 版面下 CJK 每行約 50 字、
   行高 22.5px，20 行約 450px。窄螢幕不可能顯示 1000 字，改用視窗高度為上限，
   避免輸入框把「開始生成」按鈕整個推出畫面外。 */
.prompt-box textarea { min-height: 450px; max-height: 70vh; line-height: 1.5; }
.prompt-notes { margin: 2px 0 10px; color: var(--muted); font-size: 11.5px; }
.prompt-notes .note-line { margin: 3px 0; line-height: 1.5; }
.prompt-notes .note-line.quota { color: var(--text); font-size: 12.5px; }
.row.actions { align-items: stretch; gap: 10px; }
.row.actions .btn.big { flex: 1; width: auto; }
.row.actions .btn.ghost { white-space: nowrap; }
.ts { margin: 10px 0; }
.preview img { width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.grid figure { margin: 0; position: relative; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-soft); display: block; }
.grid figcaption { margin-top: 6px; }
.mini { font-size: 12.5px; }
.pub-foot { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 30px; }
.pubwall .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.pubwall .wall-item { display: block; line-height: 0; }
.pubwall .wall-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--bg-soft); display: block; }
.pubwall .wall-item:hover img { border-color: var(--accent); }
.pub-foot .foot-brand { margin: 0; opacity: .6; }
.center { text-align: center; }

/* ---------- admin ---------- */
.admin { max-width: 1100px; margin: 0 auto; padding: 18px 16px 40px; }
.admin-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-head nav { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.tab {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  padding: 7px 13px;
  font-size: 13.5px;
  cursor: pointer;
}
.tab.on { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.login-card { max-width: 380px; margin: 10vh auto; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; }
.stat { flex: 1; min-width: 200px; margin: 0; }
.vchart { display: flex; align-items: flex-end; gap: 3px; height: 150px; margin: 4px 0 8px; }
.vbar-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; height: 100%; }
.vbar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; background: var(--bg-soft); border-radius: 3px 3px 0 0; }
.vbar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.vbar.zero { background: transparent; }
.vbar-x { font-size: 10px; color: var(--muted); margin-top: 4px; }
.filters { margin-bottom: 12px; }
.filters input, .filters select { max-width: 180px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 7px 8px; border-bottom: 1px solid rgba(42, 52, 65, 0.5); vertical-align: top; }
.tbl tr.sec td { background: rgba(217, 164, 65, 0.06); }
.tbl tr.sec td:first-child { border-left: 3px solid var(--warn); }
.tbl td.detail { background: var(--bg-soft); }
.promptline { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl td.detail .promptfull { white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; margin: 0 0 8px; }
.gitem { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--card); }
.gitem.nsfw { border-color: rgba(224, 82, 82, 0.55); }
.selbox { position: absolute; top: 12px; left: 12px; z-index: 2; background: rgba(14, 17, 22, 0.75); border-radius: 4px; padding: 2px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cols > div { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 760px) {
  .cols { grid-template-columns: 1fr; }
  .pub-head { flex-direction: column; }
  .prompt-box textarea { min-height: 260px; }
}
