* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  color: #222;
  background: #f4f4f5;
}

body {
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 4px;
}

/* ---- Toolbar ---- */
#toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
}
.view-label { font-size: 12px; margin-right: 2px; }
.view-btn {
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
  border: 1px solid #c4c4c8;
  border-radius: 4px;
  background: #fbfbfc;
  cursor: pointer;
}
.view-btn:hover { background: #eef0f3; }
.view-btn:active { background: #e2e5ea; }
.divider { width: 100%; border: none; border-top: 1px solid #ccc; margin: 0; }

/* ---- Body split ---- */
#body {
  flex: 1;
  display: flex;
  gap: 6px;
  min-height: 0;
}

/* ---- Left panel ---- */
#left-panel {
  width: 318px;
  flex: 0 0 318px;
  min-height: 0;
}
.scroll {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}
.group {
  border: 1px solid #c9c9cd;
  border-radius: 5px;
  margin: 0;
  padding: 6px 8px 8px;
}
.group > legend {
  font-size: 12px;
  font-weight: 600;
  padding: 0 4px;
  color: #333;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}
.slider-row .row-label {
  width: 42px;
  font-size: 12px;
  flex: 0 0 42px;
}
.slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
}
.slider-row input[type="number"] {
  width: 74px;
  flex: 0 0 74px;
}
input[type="number"] {
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid #c4c4c8;
  border-radius: 3px;
}

.size-row { display: flex; align-items: center; gap: 8px; }
.size-row label { font-size: 12px; }

.info { font-size: 12px; margin: 1px 0; }

/* ---- View orientation readout (subtle) ---- */
.orientation-readout {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  color: #8a8f98;
  line-height: 1.6;
}
.orientation-readout .ori-key {
  display: inline-block;
  width: 26px;
  color: #b3b7be;
}

/* ---- Faces table ---- */
#faces-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}
#faces-table th, #faces-table td {
  text-align: left;
  padding: 2px 4px;
  border-bottom: 1px solid #e6e6e8;
  vertical-align: top;
  word-break: break-word;
}
#faces-table th { font-weight: 600; background: #f0f0f2; }
#faces-table tbody tr:nth-child(even) { background: #f7f7f9; }

/* ---- Right panel ---- */
#right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
}
#canvas3d {
  flex: 0 0 58%;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
#canvas3d canvas { display: block; cursor: grab; }
#canvas3d canvas:active { cursor: grabbing; }

#profile-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px;
  min-height: 0;
}
.profile-cell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.profile-title {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  height: 14px;
  line-height: 14px;
  overflow: hidden;
  white-space: nowrap;
}
.profile-cell { cursor: zoom-in; }
.profile-cell canvas { flex: 1; display: block; }

/* ---- Lightbox (enlarged view of any panel or the 3D render) ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.62);
  z-index: 1000;
  cursor: zoom-out;
}
.lightbox-overlay.hidden { display: none; }
.lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 10px 48px rgba(0, 0, 0, 0.45);
}
