:root {
  --bg: #0f1012;
  --panel: #17181b;
  --panel-2: #1f2125;
  --border: #2a2c31;
  --text: #ececec;
  --muted: #8f939c;
  --accent: #c8ff00;
  --accent-ink: #101300;
  --danger: #ff5c5c;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center;
  padding: 14px 24px; background: rgba(15,16,18,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.brand p { margin: 0; font-size: 12px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background:
  linear-gradient(135deg, var(--accent) 0 50%, #fff 50% 100%); }
.search { position: relative; max-width: 620px; width: 100%; justify-self: center; }
.search input {
  width: 100%; padding: 10px 40px 10px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); outline: none;
}
.search input:focus { border-color: #4a4d55; }
.search .ghost { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 2px 10px; }
.actions { display: flex; gap: 8px; }

button { border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 8px 14px; cursor: pointer; transition: background .15s, border-color .15s; }
button:hover { background: var(--panel-2); border-color: #3a3d45; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.05); }
button.ghost { background: transparent; }
button.link { background: none; border: none; padding: 0; color: var(--muted); text-decoration: underline; }
button.small { padding: 5px 10px; font-size: 12px; }
button.danger { color: var(--danger); }

/* Filters */
.filters { padding: 16px 24px 4px; }
.filters-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 4px 10px; font-size: 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip:hover { border-color: #4a4d55; }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chip .n { color: var(--muted); font-size: 11px; }
.chip.active .n { color: inherit; opacity: .7; }

/* Grid */
main { padding: 16px 24px 40px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: transform .15s, border-color .15s; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); border-color: #4a4d55; }
.card .thumb { aspect-ratio: 16 / 10; background: #0a0a0b; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card .chips .chip { padding: 2px 8px; font-size: 11px; cursor: default; }
.card .industry { font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
footer { padding: 16px 24px 32px; font-size: 12px; border-top: 1px solid var(--border); }

/* Dialogs */
dialog {
  border: 1px solid var(--border); border-radius: 18px; background: var(--panel); color: var(--text);
  padding: 24px; width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
dialog h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: -.01em; }
dialog h3 { font-size: 14px; margin: 18px 0 6px; }
.dialog-close { position: absolute; top: 12px; right: 12px; margin: 0; }
.dialog-close button { width: 32px; height: 32px; padding: 0; border-radius: 50%; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; }
.detail-image { margin: 0; }
.detail-image img { width: 100%; border-radius: 12px; border: 1px solid var(--border); background: #000; }
.detail-image figcaption { font-size: 12px; margin-top: 6px; }
.detail-image a { color: var(--muted); }
.eyebrow { margin: 0; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.meta { margin: 14px 0; display: grid; gap: 8px; }
.meta div { display: grid; grid-template-columns: 96px 1fr; gap: 10px; }
.meta dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
.meta dd { margin: 0; }
.prompt-box { border: 1px solid var(--border); border-radius: 12px; background: var(--bg); padding: 12px 14px; }
.prompt-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: 13px; line-height: 1.55; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }

form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
form label small { font-weight: normal; }
form input, form textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 13px; resize: vertical;
}
form input:focus, form textarea:focus { outline: none; border-color: #4a4d55; }
form input[type=file] { padding: 6px; }

.api-list { display: grid; gap: 10px; margin: 0; }
.api-list div { display: grid; grid-template-columns: 1fr; gap: 2px; }
.api-list dt { font-family: var(--mono); font-size: 12px; }
.api-list dt a { color: var(--accent); text-decoration: none; }
.api-list dd { margin: 0; color: var(--muted); font-size: 12px; }
#api pre { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 12px; border-radius: 10px; border: 1px solid var(--border); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 500; z-index: 20;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 860px) {
  .topbar { grid-template-columns: 1fr; gap: 10px; }
  .search { justify-self: stretch; max-width: none; }
  .detail-layout { grid-template-columns: 1fr; }
  .meta div { grid-template-columns: 1fr; gap: 2px; }
}

/* KI-Vorschläge beim Upload */
.suggest-bar { display: flex; align-items: center; gap: 12px; padding: 8px 10px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); }
.suggest-bar img { width: 72px; height: 44px; object-fit: cover; object-position: top; border-radius: 6px; }
.suggest-bar.loading #suggest-status::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--accent); animation: suggest-pulse 1s ease-in-out infinite; }
@keyframes suggest-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .suggest-bar.loading #suggest-status::before { animation: none; } }
form.suggesting textarea, form.suggesting input:not([type=file]) { opacity: .6; }

/* Reiter */
.tabs { display: flex; gap: 6px; padding: 14px 24px 0; border-bottom: 1px solid var(--border); }
.tab { border: 1px solid transparent; border-bottom: none; border-radius: 10px 10px 0 0; background: transparent; padding: 9px 16px; color: var(--muted); font-weight: 500; }
.tab:hover { background: var(--panel); color: var(--text); border-color: var(--border); }
.tab.active { background: var(--panel); color: var(--text); border-color: var(--border); position: relative; top: 1px; }
.tab .n { font-size: 11px; color: var(--muted); margin-left: 4px; }
.tab.active .n { color: var(--accent); }

/* Formular-Helfer */
.row.compact { margin-top: 4px; margin-bottom: 12px; }
.grow { flex: 1; min-width: 160px; }
.field-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field-label small { font-weight: normal; }
label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; white-space: nowrap; }
label.inline input[type=file] { width: auto; }
dialog.narrow { width: min(760px, calc(100vw - 32px)); }
pre.mono { font-family: var(--mono); font-size: 12px; }

/* Farbpaletten */
.card.palette .swatches { display: flex; height: 132px; background: #0a0a0b; }
.card.palette .swatches span { flex: 1; }
.card .hexes { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.strip { display: flex; height: 72px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); margin: 14px 0 12px; }
.strip span { flex: 1; }
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.swatch { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--bg); transition: transform .12s, border-color .12s; }
.swatch:hover { transform: translateY(-2px); border-color: #4a4d55; }
.swatch .block { height: 78px; display: flex; align-items: flex-end; padding: 8px; font-family: var(--mono); font-size: 12px; }
.swatch .info { padding: 8px 10px; font-size: 12px; }
.swatch .info strong { display: block; font-weight: 600; }
.swatch .info span { color: var(--muted); }
.color-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.color-row { display: grid; grid-template-columns: 22px 44px 110px 1fr 1fr 32px; gap: 6px; align-items: center; }
.color-row .handle { cursor: grab; color: var(--muted); text-align: center; user-select: none; }
.color-row.dragging { opacity: .4; }
.color-row input[type=color] { width: 44px; height: 34px; padding: 2px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; }
.color-row input.hex { font-family: var(--mono); }
.color-row input.hex.invalid { border-color: var(--danger); }
.color-row .remove { width: 32px; height: 32px; padding: 0; border-radius: 50%; }

/* Schriftarten */
.card.font .specimen { height: 150px; padding: 16px 18px; background: var(--panel-2); display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.card.font .specimen .big { font-size: 60px; line-height: 1; letter-spacing: -.01em; }
.card.font .specimen .sample { font-size: 15px; line-height: 1.3; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.specimen-controls { margin-bottom: 8px; }
.specimen-list { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); padding: 10px 14px; margin-bottom: 14px; max-height: 50vh; overflow: auto; }
.specimen-row { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); }
.specimen-row:last-child { border-bottom: none; }
.specimen-row .label { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.specimen-row .text { line-height: 1.15; overflow-wrap: anywhere; }
.file-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.file-row { display: grid; grid-template-columns: 1fr 130px 100px 32px; gap: 6px; align-items: center; }
.file-row .name { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row select { padding: 7px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; }
.file-row .remove { width: 32px; height: 32px; padding: 0; border-radius: 50%; }
.file-list a { color: inherit; }
.file-list .muted { font-family: var(--mono); font-size: 11px; }

@media (max-width: 860px) {
  .tabs { padding: 10px 16px 0; overflow-x: auto; }
  .color-row { grid-template-columns: 22px 44px 100px 1fr 32px; }
  .color-row input.role { grid-column: 2 / -1; }
  .file-row { grid-template-columns: 1fr 32px; }
  .specimen-row { grid-template-columns: 1fr; gap: 2px; }
}

/* Feinschliff Schriftarten-Dialog */
.card.font .specimen .big { white-space: nowrap; overflow: hidden; text-overflow: clip; }
.meta .file-list div { display: block; }
#f-sample { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; }
#f-sample:focus { outline: none; border-color: #4a4d55; }

/* KI-Vorschlagsleiste ohne Bild (Paletten, Schriftarten) */
.suggest-bar.plain { margin: 4px 0 12px; }
.suggest-bar.plain.loading #p-suggest-status::before,
.suggest-bar.plain.loading #f-suggest-status::before,
.suggest-bar.plain.loading #nf-suggest-status::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--accent); animation: suggest-pulse 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .suggest-bar.plain.loading [id$="-suggest-status"]::before { animation: none; } }
