/* tiksi - materials library view and material pickers.
   Uses the console design tokens (--panel, --line, --accent, --mono ...) from console.css. */

/* ---------- layout ---------- */
.mv { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.mv-head {
  padding: 16px 22px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
}
.mv-title-row { display: flex; align-items: baseline; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.mv-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mv-tools .sp { flex: 1; }
.mv-search { width: 240px; }
.mv-chips { display: flex; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; }
.mv-chip-btn {
  background: var(--panel-2); color: var(--dim); border: 0; border-right: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; padding: 6px 11px; cursor: pointer;
}
.mv-chip-btn:last-child { border-right: 0; }
.mv-chip-btn:hover { color: var(--ink); }
.mv-chip-btn.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.mv-body { flex: 1; display: grid; grid-template-columns: 1fr auto; min-height: 0; }
.mv-grid-scroll { overflow-y: auto; padding: 18px 22px 60px; }
.mv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 14px; }

.mv-empty { grid-column: 1 / -1; padding: 40px 0; max-width: 460px; color: var(--dim); font-size: 13px; line-height: 1.6; }

/* ---------- sample chips ---------- */
.mv-card {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  box-shadow: 0 1px 0 #ffffff08 inset, 0 6px 18px -10px #000000cc;
}
.mv-card:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: 0 1px 0 #ffffff0c inset, 0 14px 28px -14px #000000ee; }
.mv-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px -6px var(--accent-soft), 0 14px 28px -14px #000000ee; }
.mv-chip {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--panel-3);
}
.mv-chip img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mv-chip::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 1px #ffffff0e, inset 0 -18px 24px -18px #00000088;
}
.mv-hole {
  position: absolute; top: 8px; left: 8px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); box-shadow: inset 0 1px 2px #000, 0 1px 0 #ffffff22; opacity: 0.85;
}
.mv-card-body { padding: 8px 10px 9px; border-top: 1px solid var(--line); }
.mv-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.mv-kind { color: var(--dim); }
.mv-use { color: var(--cyan); }
.mv-custom { color: var(--accent); }

/* ---------- editor ---------- */
.mv-editor {
  width: 440px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.mv-editor[hidden] { display: none; }
.mv-ed-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.mv-ed-name {
  flex: 1; min-width: 0;
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  color: var(--ink); font-family: var(--sans); font-size: 17px; font-weight: 600; padding: 4px 6px;
}
.mv-ed-name:hover { border-color: var(--line-2); }
.mv-ed-name:focus { outline: none; border-color: var(--accent); background: var(--panel-2); }
.mv-ed-badges { display: flex; align-items: center; gap: 8px; }
.mv-close {
  background: transparent; border: 1px solid var(--line-2); color: var(--dim); border-radius: 4px;
  width: 26px; height: 26px; cursor: pointer; font-size: 16px; line-height: 1;
}
.mv-close:hover { color: var(--ink); border-color: var(--accent); }

.mv-editor > * { flex: none; }
.mv-preview {
  position: relative; margin: 0 16px; border-radius: 8px; overflow: hidden;
  background: #10151a; border: 1px solid var(--line-2);
  box-shadow: inset 0 0 40px #00000088;
}
.mv-preview canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.mv-preview canvas:active { cursor: grabbing; }
.mv-preview-hint {
  position: absolute; left: 10px; bottom: 8px; pointer-events: none;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; color: var(--faint);
  background: #0c1013aa; padding: 3px 7px; border-radius: 3px;
}

.mv-notice {
  margin: 12px 16px 0; padding: 8px 10px; border-radius: 6px;
  background: #e0525218; border: 1px solid var(--red); color: var(--ink); font-size: 12px; line-height: 1.5;
}
.mv-fields { padding: 14px 16px 6px; }
.mv-fields .field label .faint { text-transform: none; letter-spacing: 0; }
.mv-color { display: flex; gap: 6px; align-items: center; }
.mv-color input[type="color"] {
  width: 34px; height: 30px; padding: 0; border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--panel-2); cursor: pointer;
}
.mv-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.mv-color input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 2px; }
.mv-color input[type="text"] { flex: 1; min-width: 0; text-transform: lowercase; }
.mv-hint { font-family: var(--mono); font-size: 10px; color: var(--faint); line-height: 1.55; margin: -2px 0 12px; }
.mv-hint b { color: var(--dim); font-weight: 600; }

.mv-range label { display: flex; justify-content: space-between; }
.mv-val { color: var(--accent); font-weight: 600; letter-spacing: 0; }
.mv-range input[type="range"] { width: 100%; accent-color: var(--accent); margin: 2px 0 0; }

.mv-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.mv-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.mv-photo {
  width: 58px; height: 58px; padding: 0; border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel-2);
}
.mv-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mv-photo:hover { border-color: var(--accent); }
.mv-photo.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.mv-photo-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--dim); font-size: 18px; line-height: 1; border-style: dashed;
}
.mv-photo-add span { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em; }
.mv-photo-add:disabled { opacity: 0.5; cursor: wait; }
.mv-uses { display: flex; flex-wrap: wrap; gap: 5px; }

.mv-actions {
  display: flex; gap: 8px; align-items: center; padding: 12px 16px 16px; margin-top: auto;
  border-top: 1px solid var(--line); background: var(--panel);
  position: sticky; bottom: 0;
}
.mv-actions .sp { flex: 1; }
.mv-actions .btn:disabled { opacity: 0.45; cursor: default; }

/* ---------- material picker (select + swatch strip), used by inspectors ---------- */
.mat-picker select { width: 100%; }
.mat-picker-strip { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mat-pick {
  width: 26px; height: 26px; padding: 0; border-radius: 4px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel-2);
  box-shadow: inset 0 0 0 1px #ffffff10;
}
.mat-pick img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mat-pick:hover { border-color: var(--accent); }
.mat-pick.active { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 1100px) {
  .mv-editor { width: 380px; }
  .mv-grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
}
