﻿@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg: #020617;
  --panel: #0a0f1f;
  --panel-2: #0e1526;
  --border: #1e2740;
  --border-strong: #2c3654;
  --text: #eef1fa;
  --text-dim: #8792ab;

  /* Single considered accent (warm amber) instead of the purple+teal
     "AI gradient" combo — that pairing is the single most recognizable
     AI-generated-UI fingerprint, so it's deliberately avoided here. */
  --accent: #e0a458;
  --accent-dim: #b9823f;
  --accent-tint: #f0c98a;

  /* Semantic status colors — functional, not brand identity, so they're
     allowed their own hues (green/red) distinct from --accent. */
  --ok: #3ecf8e;
  --danger: #ef5a6f;

  --radius: 14px;
  --font-head: 'Space Grotesk', 'DM Sans', -apple-system, sans-serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Subtle grain so the flat dark surface doesn't read as a bare vector fill —
   fixed, non-interactive, barely perceptible at normal viewing distance. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body::after {
  content: '';
  position: fixed;
  top: -20%;
  left: 10%;
  width: 60%;
  height: 50%;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at center, rgba(224, 164, 88, 0.06) 0%, transparent 70%);
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 72px;
  position: relative;
  z-index: 1;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px 1px rgba(224, 164, 88, 0.5);
  flex-shrink: 0;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.back-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

h1 {
  font-family: var(--font-head);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
  text-wrap: balance;
}
.subtitle { color: var(--text-dim); font-size: 14px; margin: 0 0 24px; max-width: 620px; line-height: 1.65; }

.health-row { margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}
.health-pill.checking { color: var(--text-dim); }
.health-pill.ok { color: var(--ok); border-color: rgba(62, 207, 142, 0.3); background: rgba(62, 207, 142, 0.07); }
.health-pill.down { color: var(--danger); border-color: rgba(239, 90, 111, 0.32); background: rgba(239, 90, 111, 0.07); }

/* .161 硬體監控橫幅 --------------------------------------------------- */
.monitor-bar {
  margin-bottom: 20px;
  padding: 14px 16px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.monitor-bar.is-down { border-color: rgba(239, 90, 111, 0.32); }
.monitor-metrics {
  display: grid;
  /* 格數會隨 .161 上的磁碟數量增減,所以用 auto-fit 讓它自己排,
     不要寫死欄數。 */
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 10px 18px;
}
.monitor-metric { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.monitor-label {
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}
.monitor-value {
  font-family: var(--font-mono);
  font-size: 17px;
  line-height: 1.15;
  color: var(--text);
  /* 數字每 10 秒就換一次,等寬字距才不會讓整排欄位左右跳動。 */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.monitor-meter {
  height: 3px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-top: 2px;
}
.monitor-meter > span {
  display: block;
  height: 100%;
  background: var(--accent);
  /* 輪詢間隔是 10 秒,補間讓數值變化看起來是移動而不是瞬移。 */
  transition: width 0.6s ease;
}
.monitor-metric.is-warm .monitor-meter > span { background: var(--accent-tint); }
.monitor-metric.is-hot .monitor-value { color: var(--danger); }
.monitor-metric.is-hot .monitor-meter > span { background: var(--danger); }
.monitor-detail {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.monitor-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.monitor-host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monitor-stamp { flex: none; }
.monitor-error { font-size: 12px; color: var(--danger); font-family: var(--font-mono); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 14px;
}

.card-section + .card-section { margin-top: 32px; }
.section-heading {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.card-tile {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 84px 18px 20px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
}
.card-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(224, 164, 88, 0.4);
  background: #101830;
  box-shadow: 0 14px 32px -18px rgba(224, 164, 88, 0.35);
}
.card-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(224, 164, 88, 0.1);
  border: 1px solid rgba(224, 164, 88, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.card-tile:hover .card-icon {
  background: rgba(224, 164, 88, 0.18);
  border-color: rgba(224, 164, 88, 0.5);
  transform: scale(1.05);
}
.card-icon-svg { width: 26px; height: 26px; }
.card-tile .cat {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--accent-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  margin-bottom: 10px;
  border: 1px solid rgba(224, 164, 88, 0.22);
  border-radius: 999px;
  background: rgba(224, 164, 88, 0.07);
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.card-tile:hover .cat {
  color: var(--accent);
  border-color: rgba(224, 164, 88, 0.4);
  background: rgba(224, 164, 88, 0.12);
}
.card-tile h3 { font-family: var(--font-head); margin: 0 0 7px; font-size: 16px; font-weight: 600; letter-spacing: -0.005em; }
.card-tile p { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.55; }

.panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--text);
  letter-spacing: -0.002em;
}
.field .help {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.5;
}
.field input[type=text],
.field input[type=number],
.field textarea,
.field select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224, 164, 88, 0.15);
}
.field textarea { resize: vertical; min-height: 84px; }

.row { display: flex; gap: 12px; }
.row > .field { flex: 1; }

.seed-row { display: flex; gap: 8px; }
.seed-row input { flex: 1; }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn {
  appearance: none;
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s, background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  font-family: var(--font-body);
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent);
  color: #1a1206;
  box-shadow: 0 6px 18px -8px rgba(224, 164, 88, 0.5);
}
.btn-primary:hover { background: var(--accent-tint); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-small { padding: 7px 11px; font-size: 12px; }

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 11px;
  padding: 22px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(224, 164, 88, 0.06); }
.dropzone img { max-width: 100%; max-height: 220px; border-radius: 8px; margin-top: 12px; }

.status-panel { display: none; }
.status-panel.show { display: block; }

.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.status-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}
.status-pill.pending { background: #161d33; color: var(--text-dim); }
.status-pill.running { background: rgba(224, 164, 88, 0.14); color: var(--accent-tint); }
.status-pill.done { background: rgba(62, 207, 142, 0.14); color: var(--ok); }
.status-pill.error { background: rgba(239, 90, 111, 0.14); color: var(--danger); }
.status-pill.cancelled { background: #161d33; color: var(--text-dim); }

.spinner {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(224, 164, 88, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-track {
  height: 5px;
  border-radius: 999px;
  background: #131a2e;
  overflow: hidden;
  margin-bottom: 14px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
  width: 0%;
}
.progress-fill.indeterminate {
  width: 40% !important;
  animation: indeterminate 1.3s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.result-media {
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #010208;
  position: relative;
}
.result-media img, .result-media video { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #010208; }
.result-media .result-audio { width: 100%; display: block; padding: 34px 12px 12px; box-sizing: border-box; }
.result-media .result-text {
  margin: 0;
  padding: 34px 12px 12px;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  user-select: text;
}
.result-media .result-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(4px);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.result-grid:has(> :only-child) { grid-template-columns: 1fr; }
.result-grid:has(> :only-child) .result-media img,
.result-grid:has(> :only-child) .result-media video { max-height: 560px; }

.error-box {
  background: rgba(239, 90, 111, 0.07);
  border: 1px solid rgba(239, 90, 111, 0.3);
  color: #ffb0ba;
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 12.5px;
  margin-top: 14px;
  white-space: pre-wrap;
}

.empty-note { color: var(--text-dim); font-size: 13px; padding: 40px 0; text-align: center; }

.segmented {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  margin-bottom: 20px;
}
.segmented button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s, color 0.15s;
}
.segmented button.active {
  background: var(--accent);
  color: #1a1206;
}

.batch-hint {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.5;
}
.batch-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.style-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.llm-expand-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 15px;
}
.llm-expand-box .field { margin-bottom: 0; }

.footer-note {
  margin-top: 36px;
  color: #414a68;
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---- 畫廊(gallery.html) ---------------------------------------------- */
.gallery-layout {
  display: grid;
  grid-template-columns: minmax(210px, 280px) 1fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 860px) { .gallery-layout { grid-template-columns: 1fr; } }

.gallery-sidebar { padding: 18px; position: sticky; top: 18px; max-height: calc(100vh - 40px); overflow-y: auto; }
.folder-list { display: flex; flex-direction: column; gap: 6px; }
.folder-item {
  display: flex; flex-direction: column; gap: 3px; width: 100%;
  padding: 9px 11px; text-align: left; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-family: inherit;
}
.folder-item:hover { border-color: var(--border-strong); }
.folder-item.active { border-color: var(--accent); background: rgba(224, 164, 88, 0.09); }
.folder-name { font-size: 13px; font-weight: 500; word-break: break-all; }
.folder-meta { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }

.gallery-header { margin-bottom: 14px; }
.gallery-path { margin: 4px 0 0; font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); word-break: break-all; }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.gallery-item {
  margin: 0; background: var(--panel); border: 1px solid var(--border);
  border-radius: 11px; overflow: hidden;
}
.gallery-item img { width: 100%; display: block; cursor: zoom-in; background: #010208; }
.gallery-item video { width: 100%; display: block; background: #010208; }
.gallery-item audio { width: 100%; display: block; padding: 10px; box-sizing: border-box; }
.gallery-item .gallery-text {
  margin: 0; padding: 10px; font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; max-height: 16rem; overflow-y: auto; user-select: text;
}
.gallery-item .gallery-other { padding: 22px 10px; text-align: center; color: var(--text-dim); font-size: 12px; }
.gallery-item figcaption {
  padding: 7px 9px; font-size: 11.5px; color: var(--text-dim);
  border-top: 1px solid var(--border); word-break: break-all;
}
.gallery-item .gallery-sub { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 10.5px; opacity: 0.8; }

.lightbox {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(2, 6, 23, 0.92); z-index: 50; cursor: zoom-out; padding: 24px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* ---- 常用(釘選)圓形按鈕 ---------------------------------------------- */
/* 跟卡片右上角的 .card-icon 同一套語言(圓角方塊 vs 正圓),對齊在它正下方:
   .card-icon 是 48px @ right:16px(中心距右緣 40px),按鈕 32px @ right:24px
   也是中心距右緣 40px,所以兩者垂直對齊。 */
.pin-btn {
  position: absolute;
  top: 72px;
  right: 24px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease,
              transform 0.18s ease, box-shadow 0.18s ease;
}
.pin-btn svg { width: 15px; height: 15px; transition: fill 0.18s ease; }

.card-tile:hover .pin-btn {
  border-color: var(--border-strong);
  color: var(--text);
}
.pin-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(224, 164, 88, 0.14);
  transform: scale(1.08);
}
.pin-btn:active { transform: scale(0.94); }
.pin-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(224, 164, 88, 0.28);
}

/* 已釘選:實心金色,一眼就看得出狀態不同 */
.pin-btn.on,
.card-tile:hover .pin-btn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 0 1px rgba(224, 164, 88, 0.35), 0 6px 14px -6px rgba(224, 164, 88, 0.7);
}
.pin-btn.on svg { fill: var(--bg); }
.pin-btn.on:hover { background: var(--accent-tint); border-color: var(--accent-tint); }

/* ---- 使用說明圖示(2026-09-30)------------------------------------------ */
/* 疊在 .pin-btn 正下方,同一顆 32px 圓、同一個右緣對齊,只是換一個垂直位置,
   兩顆按鈕看起來是同一組語言,不是兩套不同設計。 */
.guide-btn {
  position: absolute;
  top: 112px;
  right: 24px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease,
              transform 0.18s ease;
}
.guide-btn svg { width: 14px; height: 14px; }
.card-tile:hover .guide-btn { border-color: var(--border-strong); color: var(--text); }
.guide-btn:hover { border-color: var(--text-dim); color: var(--text); background: rgba(255, 255, 255, 0.1); transform: scale(1.08); }
.guide-btn:active { transform: scale(0.94); }
.guide-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(224, 164, 88, 0.28); }

/* 手機版跟 .pin-btn 一起放大到 44px 觸控熱區,位置對應往下挪。 */
@media (max-width: 720px) {
  .guide-btn { width: 44px; height: 44px; top: 118px; right: 18px; }
}

.card-tile.pinned {
  border-color: rgba(224, 164, 88, 0.38);
  background: linear-gradient(180deg, rgba(224, 164, 88, 0.05), transparent 60%), var(--panel-2);
}

/* 首頁上方的操作提示 */
.pin-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 10px;
  background: rgba(224, 164, 88, 0.05);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}
.pin-hint strong { color: var(--accent); font-weight: 600; }
.pin-demo {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--bg);
}
.pin-demo svg { width: 14px; height: 14px; fill: var(--bg); }

/* mask field (card.html renderField/wireMask): brush toolbar + paintable
   preview of whatever the field's source_field image currently holds. */
.mask-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.mask-toolbar input[type="range"] { flex: 1 1 140px; min-width: 90px; }
.mask-toolbar .mask-size-label,
.mask-toolbar .mask-size { font-size: 12px; color: var(--text-dim); }
.mask-toolbar .mask-size { min-width: 46px; }
.mask-canvas {
  display: block;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: crosshair;
  /* Without this a drag paints nothing and scrolls the page on touch. */
  touch-action: none;
}
.mask-status { margin-top: 8px; }

/* ============================================================
   三欄工作區(首頁 / 畫廊):左=目錄與卡片,中=內容,右=常用/畫廊/設定
   ============================================================ */

/* The single-column pages keep .wrap's 1080px measure; the three-column shell
   needs room for two rails plus a readable grid between them. */
.wrap-wide { max-width: 1680px; }

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
}

/* Rails scroll independently so a long card list never pushes the main column
   down, and stay put while the middle scrolls. */
.rail {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.rail::-webkit-scrollbar { width: 8px; }
.rail::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.rail::-webkit-scrollbar-track { background: transparent; }

.rail-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  margin-bottom: 14px;
}
.rail-block:last-child { margin-bottom: 0; }

.rail-title {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rail-search {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
}
.rail-search:focus { outline: none; border-color: var(--accent-dim); }

/* Category nav ------------------------------------------------ */
.cat-nav { display: flex; flex-direction: column; gap: 2px; }
.cat-nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.cat-nav button:hover { background: var(--panel-2); color: var(--text); }
.cat-nav button.active { background: var(--panel-2); color: var(--accent-tint); }
.cat-nav .n {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 7px;
  flex: none;
}
.cat-nav button.active .n { color: var(--accent); border-color: var(--accent-dim); }

/* Flat card list in the left rail ----------------------------- */
.rail-cards { display: flex; flex-direction: column; gap: 1px; }
.rail-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
}
.rail-card:hover { background: var(--panel-2); color: var(--text); }
.rail-card .star { color: var(--accent); flex: none; opacity: 0; }
.rail-card.pinned .star { opacity: 1; }
.rail-card span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rail-empty {
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 6px 2px;
  line-height: 1.6;
}

/* Right rail: favourites -------------------------------------- */
.fav-list { display: flex; flex-direction: column; gap: 2px; }
.fav-row { display: flex; align-items: center; gap: 4px; }
.fav-row a {
  flex: 1;
  min-width: 0;
  padding: 6px 9px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fav-row a:hover { background: var(--panel-2); }
.fav-row button {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.fav-row button:hover { background: var(--panel-2); color: var(--danger); }

.rail-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  width: 100%;
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
}
.rail-link:hover { border-color: var(--accent-dim); color: var(--accent-tint); }
.rail-link + .rail-link { margin-top: 8px; }

/* Settings modal ---------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .78);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  z-index: 60;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }

.modal {
  width: 100%;
  max-width: 620px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 24px 26px 26px;
}
.modal h2 {
  font-family: var(--font-head);
  font-size: 19px;
  margin: 0 0 4px;
}
.modal .modal-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 20px; line-height: 1.6; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.modal-note {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.65;
  margin: -8px 0 18px;
}
.settings-msg {
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
  display: none;
}
.settings-msg.ok { display: block; background: rgba(62, 207, 142, .1); border: 1px solid var(--ok); color: var(--ok); }
.settings-msg.bad { display: block; background: rgba(239, 90, 111, .1); border: 1px solid var(--danger); color: var(--danger); }

/* The gallery keeps its own folder sidebar as the left rail, so its old
   two-column grid is redundant inside the shell. */
.app-shell .gallery-layout { display: block; }

/* 中型螢幕 (961px ~ 1320px,如 1080p 筆電 125%/150% 縮放):維持三欄,微調欄寬與間距,右側欄不折行 */
@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr) 250px;
    gap: 14px;
  }
}

/* 平板 / 窄視窗 (< 960px):右側欄才收折到下方橫向排列 */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 200px minmax(0, 1fr); }
  .app-shell .rail-right { grid-column: 1 / -1; position: static; max-height: none; }
  .app-shell .rail-right .rail-block { display: inline-block; vertical-align: top; width: 32%; margin-right: 1%; }
}

/* 手機螢幕 (< 720px):單欄垂直堆疊 */
@media (max-width: 720px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-shell .rail { position: static; max-height: none; }
  .app-shell .rail-right .rail-block { display: block; width: auto; margin-right: 0; }
}

/* 畫廊縮圖大小(設定裡的「畫廊預設縮圖大小」) */
.gallery-grid.size-small  { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.gallery-grid.size-medium { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.gallery-grid.size-large  { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

/* The logo doubles as the home button on every page, so it must not pick up
   default link styling (purple, underlined) from the browser. */
a.brand {
  text-decoration: none;
  color: inherit;
}
a.brand:hover { color: var(--accent-tint); }
a.brand:hover .badge { border-color: var(--accent-dim); color: var(--accent); }

/* dynamic_select with audio_preview: dropdown + ▶ button on one line */
.preview-row { display: flex; gap: 8px; align-items: center; }
.preview-row select { flex: 1 1 auto; min-width: 0; }
.preview-row .btn { flex: 0 0 auto; white-space: nowrap; }

/* 3D mesh outputs (img2mesh_hunyuan3d, instantmesh_3d): no inline preview, so
   both the card result area and the gallery show a download tile. */
.result-media .result-model,
.gallery-item .gallery-model {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 1.8rem 0.8rem;
  text-decoration: none;
  color: var(--muted, #8b8b8b);
  font-size: 0.85rem;
  word-break: break-all;
  text-align: center;
}
.result-media .result-model:hover,
.gallery-item .gallery-model:hover { color: inherit; background: rgba(127, 127, 127, 0.08); }
.result-model-icon, .gallery-model-icon { font-size: 2.2rem; line-height: 1; }

/* Aspect Ratio Presets */
.aspect-preset-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.aspect-preset-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-right: 4px;
}
.aspect-preset-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
}
.aspect-preset-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(224, 164, 88, 0.08);
}
.aspect-preset-btn.active {
  background: rgba(224, 164, 88, 0.18);
  border-color: var(--accent);
  color: var(--accent-tint);
  font-weight: 600;
}


/* Collapsed group for a card's less-used knobs (manifest ui_group:"advanced"),
   e.g. the dozen ratio fields on the wildcard batch cards. */
.adv-group { border: 1px solid var(--border, #2a2f3a); border-radius: 8px; margin: 12px 0; background: rgba(255,255,255,.02); }
.adv-group > summary { cursor: pointer; padding: 10px 12px; font-weight: 600; user-select: none; }
.adv-group > summary:hover { background: rgba(255,255,255,.04); }
.adv-body { padding: 4px 12px 12px; }

/* preview_dir picker: thumbnail grid for a select's options (see card.html
   openPreviewPicker). Sized for the 832x1216 portrait samples the model
   comparison runs produce. */
.preview-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 9000;
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.preview-modal { background: #14161c; border: 1px solid rgba(255,255,255,.12); border-radius: 12px;
  max-width: 1200px; width: 100%; max-height: 88vh; display: flex; flex-direction: column; }
.preview-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.preview-head .btn { margin-left: auto; }
.preview-grid { overflow: auto; padding: 16px; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.preview-cell { cursor: pointer; border: 1px solid rgba(255,255,255,.12); border-radius: 8px;
  overflow: hidden; background: rgba(255,255,255,.03); transition: border-color .12s, transform .12s; }
.preview-cell:hover { border-color: #e0a458; transform: translateY(-2px); }
.preview-cell img { display: block; width: 100%; aspect-ratio: 832 / 1216; object-fit: cover; }
.preview-name { padding: 6px 8px; font-size: 11px; line-height: 1.4; word-break: break-all; opacity: .85; }

/* ---- RWD 補強 (2026-09-24):手機寬度下導覽列換行、長字串不撐寬版面 ---- */
.subtitle, .card-tile p, .card-tile h3 { overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .top-nav { flex-wrap: wrap; gap: 10px; }
  .top-nav > div { flex-wrap: wrap; gap: 8px !important; min-width: 0; }
}

/* ============================================================
   Phase A (2026-09-30):手機殼層共用元件 —— 底部導覽列 + 底部抽屜
   由 app.js 的 wfuiInitMobileTabbar() / wfuiOpenSheet() 注入使用。
   純附加,不影響任何現有桌面版樣式;只在 <=720px 顯示。
   ============================================================ */

/* 底部導覽列:5 個 tab,固定在視窗底部,留 iOS 手勢列安全區。
   只在手機寬度顯示 —— 桌面/平板完全看不到,不佔版位。 */
.mobile-tabbar { display: none; }
@media (max-width: 720px) {
  .mobile-tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 70;
    background: rgba(10, 15, 31, 0.94);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  /* 內容區留出底部導覽列的高度,避免最後一段被蓋住。
     頁面若已經有自己的 padding-bottom,這裡用 !important 疊加最小值。 */
  body.has-mobile-tabbar .wrap,
  body.has-mobile-tabbar .app-container,
  body.has-mobile-tabbar .sd-app {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}
.mobile-tab svg { width: 20px; height: 20px; }
.mobile-tab.active { color: var(--accent); }
.mobile-tab:active { background: rgba(224, 164, 88, 0.1); }

/* 底部抽屜(bottom sheet):從底部滑入,拖曳把手,內部可捲動。
   settings modal 走現有 .modal-backdrop,這裡是給「更多工具」選單、
   畫布工具的素材/設定面板用的手機版容器,共用同一組 class。 */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  z-index: 80;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop.open { display: flex; }
.bottom-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: sheet-in 0.22s ease-out;
}
@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 4px auto 14px;
}
.sheet-close {
  position: sticky;
  top: 0;
  float: right;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
}
