:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #151c33;
  --line: #2b365c;
  --text: #edf2ff;
  --sub: #9db0ff;
  --muted: #94a3c7;
  --accent: #78a6ff;
  --ok: #57d38c;
  --warn: #ffcf5a;
  --danger: #ff6b81;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background: linear-gradient(180deg,#0a0f1c,#10182e); color: var(--text); }
.container { max-width: 960px; margin: 0 auto; padding: 40px 20px 80px; }
h1 { margin-bottom: 6px; }
.sub { color: var(--sub); margin-top: 0; }
.card { background: rgba(21,28,51,.95); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-top: 20px; }
label { display: block; margin: 12px 0 8px; color: var(--sub); }
textarea, pre, input, select { width: 100%; background: #0d1427; color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
textarea, pre { min-height: 160px; overflow: auto; }
input, select { min-height: 48px; }
button { margin: 12px 0; background: var(--accent); color: #081122; border: none; padding: 12px 18px; border-radius: 10px; font-weight: 700; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.secondary { background: #243152; color: var(--text); }
button.small { padding: 8px 12px; font-size: 12px; }
.row, .section-head, .history-actions, .answer-head, .history-head, .action-row, .history-item-head, .history-models, .history-buttons { display: flex; gap: 12px; }
.row .col { flex: 1; }
.section-head, .answer-head, .history-head, .history-item-head { align-items: center; justify-content: space-between; }
.action-row, .history-actions, .history-models, .history-buttons { flex-wrap: wrap; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.template-card { text-align: left; min-height: 92px; background: #0d1427; color: var(--text); border: 1px solid var(--line); }
.template-card strong { display: block; margin-bottom: 8px; }
.template-card span { color: var(--sub); font-size: 13px; line-height: 1.5; }
.answer-panel { margin-top: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #0d1427; }
.answer-box, .history-text { white-space: pre-wrap; line-height: 1.7; }
.answer-box { min-height: 80px; }
.meta-tag, .badge { display: inline-block; padding: 6px 10px; border-radius: 999px; font-size: 12px; background: rgba(120,166,255,.15); color: var(--accent); }
.meta-tag.ok, .badge.ok { background: rgba(87,211,140,.14); color: var(--ok); }
.meta-tag.warn, .badge.warn { background: rgba(255,207,90,.14); color: var(--warn); }
.meta-tag.danger { background: rgba(255,107,129,.14); color: var(--danger); }
.raw-panel { margin-top: 16px; }
.raw-panel summary { cursor: pointer; color: var(--sub); }
.history-actions input { width: 100px; }
.history-box { display: grid; gap: 14px; }
.history-item { border: 1px solid var(--line); border-radius: 14px; background: #0d1427; padding: 14px; }
.history-time, .history-models, .history-label { color: var(--sub); }
.history-label { font-size: 13px; margin: 10px 0 6px; }
@media (max-width: 720px) {
  .row, .section-head, .history-actions, .answer-head, .history-head, .action-row, .history-item-head { flex-direction: column; align-items: flex-start; }
  .history-actions input { width: 100%; }
}

.template-manage { display: grid; gap: 10px; grid-column: 1 / -1; }
.template-custom { display: flex; flex-direction: column; justify-content: space-between; }

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.dashboard-card { border: 1px solid var(--line); border-radius: 14px; background: #0d1427; padding: 14px; display: grid; gap: 8px; }
.dashboard-card h3 { margin: 0 0 6px; }

.result-summary { margin-top: 12px; }
.result-card { border: 1px solid var(--line); border-radius: 14px; background: #0d1427; padding: 14px; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

.asset-detail-box { margin-top: 12px; }

#historySearch { min-width: 240px; }
#historyFallbackFilter { min-width: 120px; }


.checkbox-line { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.template-meta { color: var(--muted); font-size: 12px; }
#templateSearch, #historySearch { min-width: 240px; }
#templateCategoryFilter, #templateFavoriteFilter, #historyFallbackFilter { min-width: 120px; }

#assetSearch, #assetSourceFilter { min-width: 180px; }

#historyTagFilter { min-width: 120px; }

.mini-row { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mini-empty { color: var(--muted); }
#assetTagFilter, #workbenchTagFilter { min-width: 120px; }


.hero-card { overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.quick-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.quick-nav a { color: var(--text); text-decoration: none; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: #0d1427; }
.hero-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric-card { border: 1px solid var(--line); border-radius: 14px; background: #0d1427; padding: 14px; display: grid; gap: 6px; }
.metric-card strong { font-size: 24px; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }


@media (max-width: 960px) {
  .container { max-width: 100%; padding: 20px 14px 48px; }
  .card { padding: 16px; border-radius: 14px; }
  .dashboard-grid, .template-grid, .result-grid { grid-template-columns: 1fr; }
  .inline-actions, .history-head, .action-row, .history-buttons, .history-models { display: grid; grid-template-columns: 1fr; }
  #templateSearch, #historySearch, #assetSearch, #assetSourceFilter, #assetTagFilter, #historyTagFilter, #historyFallbackFilter, #templateCategoryFilter, #templateFavoriteFilter, #workbenchTagFilter { min-width: 0; width: 100%; }
}

@media (min-width: 1280px) {
  .container { max-width: 1280px; }
  .dashboard-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .template-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .history-box { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
