/* knit-studio: dark, flat, dense. */
:root {
  --bg: #1e1e1e; --bg2: #262626; --bg3: #2b2b2b; --bg4: #3c3c3c;
  --fg: #e0e0e0; --fg-dim: #9d9d9d; --acc: #007acc; --acc-hi: #0098ff;
  --err: #f48771; --ok: #89d185; --warn: #e0a040;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); color: var(--fg);
  font: 13px/1.45 "Segoe UI", system-ui, sans-serif;
}
header {
  display: flex; align-items: center; gap: 16px; padding: 6px 12px;
  background: var(--bg3); border-bottom: 1px solid #000; flex: 0 0 auto;
}
.brand { font-weight: 700; letter-spacing: 0.3px; white-space: nowrap; }
#tabs { display: flex; gap: 4px; }
.tab {
  background: none; border: none; color: var(--fg-dim); font: inherit; font-weight: 600;
  padding: 6px 14px; cursor: pointer; border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--fg); background: var(--bg4); }
.tab.active { color: #fff; background: var(--acc); }
.spacer { flex: 1; }
.status { color: var(--ok); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.err { color: var(--err); }

main { flex: 1; display: flex; min-height: 0; }
.hidden { display: none !important; }

.panel {
  width: 190px; flex: 0 0 auto; overflow-y: auto; padding: 10px;
  background: var(--bg3); border-right: 1px solid #000;
}
#side { width: 260px; border-right: none; border-left: 1px solid #000; }
.group { margin-bottom: 14px; border-bottom: 1px solid #3a3a3a; padding-bottom: 10px; }
.group:last-child { border-bottom: none; }
.group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--fg-dim); margin-bottom: 6px; }

label { display: block; margin: 5px 0 2px; color: var(--fg-dim); font-size: 12px; }
input, select, textarea, button {
  width: 100%; padding: 6px 8px; margin: 1px 0 5px; background: var(--bg4);
  color: var(--fg); border: 1px solid #555; border-radius: 4px; font: inherit;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 1px solid var(--acc); }
input[type="checkbox"] { width: auto; margin-right: 6px; }
.checkrow { display: flex; align-items: center; color: var(--fg); }
.row2 { display: flex; gap: 6px; }
.row2 label { flex: 1; }
kbd { background: #222; border: 1px solid #555; border-radius: 3px; padding: 0 4px; font-size: 10px; }

button { cursor: pointer; background: var(--bg4); font-weight: 600; }
button:hover { filter: brightness(1.25); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
button.primary:hover { background: var(--acc-hi); }
.btn-col button { display: block; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.btn-grid button { margin: 0; font-size: 12px; padding: 6px 4px; }
.btn-grid button.active { background: var(--acc); border-color: var(--acc-hi); color: #fff; }

.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.palette button {
  margin: 0; padding: 2px; height: 34px; display: flex; align-items: center; justify-content: center;
}
.palette button.active { outline: 2px solid var(--acc); }
.palette canvas { width: 24px; height: 24px; background: #ddd; border-radius: 2px; }
.hint { color: var(--fg-dim); font-size: 11.5px; margin: 4px 0; }
.hint.big { text-align: center; margin-top: 15vh; font-size: 14px; }

.stage { flex: 1; position: relative; min-width: 0; background: #262626; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; display: block; }
.zoombar { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 4px; }
.zoombar button, .zoombar span {
  width: auto; margin: 0; padding: 4px 12px; background: rgba(43,43,43,0.9);
}
.zoombar span { border: 1px solid #555; border-radius: 4px; }

.panel-wide { flex: 1; min-width: 0; overflow-y: auto; padding: 14px 18px; }
.libbar { display: flex; gap: 8px; margin-bottom: 14px; }
.libbar input { flex: 1; margin: 0; }
.libbar button { width: auto; margin: 0; padding: 6px 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.card {
  background: var(--bg3); border: 1px solid #3a3a3a; border-radius: 8px;
  overflow: hidden; display: flex; flex-direction: column;
}
.card:hover { border-color: var(--acc); }
.card .thumb {
  height: 130px; background: #2e2e2e center/contain no-repeat; image-rendering: pixelated;
  border-bottom: 1px solid #3a3a3a;
}
.card .body { padding: 8px 10px; flex: 1; }
.card .name { font-weight: 700; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { color: var(--fg-dim); font-size: 11.5px; }
.card .tags { margin-top: 4px; }
.chip {
  display: inline-block; background: var(--bg4); border-radius: 10px; padding: 0 8px;
  font-size: 10.5px; margin: 1px 3px 1px 0; color: var(--fg);
}
.card .acts { display: flex; border-top: 1px solid #3a3a3a; }
.card .acts button {
  flex: 1; margin: 0; border: none; border-right: 1px solid #3a3a3a; border-radius: 0;
  background: none; padding: 7px 0; font-size: 12px; color: var(--fg-dim);
}
.card .acts button:last-child { border-right: none; }
.card .acts button:hover { background: var(--bg4); color: var(--fg); }
.card .acts button.danger:hover { color: var(--err); }

.conv-grid { display: flex; gap: 20px; align-items: flex-start; }
.conv-form { width: 320px; flex: 0 0 auto; }
.conv-form h3 { margin: 0 0 4px; }
.btn-row { display: flex; gap: 8px; }
.conv-preview {
  flex: 1; min-width: 0; background: #2e2e2e; border: 1px solid #3a3a3a; border-radius: 8px;
  padding: 12px; text-align: center; min-height: 300px;
}
#convCv { max-width: 100%; height: auto; image-rendering: pixelated; background: #262626; border-radius: 4px; }
