/* ─────────────────────────────────────────────────────────────────────────────
   Dataset tab — gallery, capture modal, camera + 1 mm ruler
   Inherits design tokens from style.css (--accent #bf5af2, radii, fonts)
───────────────────────────────────────────────────────────────────────────── */

.ds-page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 64px;
  animation: ds-fade-in 0.4s ease;
}
@keyframes ds-fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.ds-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.ds-title {
  font-size: 30px; font-weight: 700; letter-spacing: -0.6px; color: var(--text-primary);
}
.ds-subtitle { font-size: 15px; color: var(--text-tertiary); margin-top: 2px; }
.ds-header-actions { display: flex; gap: 10px; }

/* ── Stats ── */
.ds-stats { display: flex; gap: 12px; margin-bottom: 24px; }
.ds-stat {
  background: var(--bg-tertiary); border: 1px solid var(--separator);
  border-radius: var(--radius-md); padding: 14px 22px; min-width: 110px;
}
.ds-stat-val { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.ds-stat-lbl { font-size: 13px; color: var(--text-tertiary); margin-top: 1px; }

/* ── Gallery ── */
.ds-gallery {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.ds-loading { grid-column: 1 / -1; display: flex; justify-content: center; padding: 60px 0; }

.ds-card {
  background: var(--bg-primary); border: 1px solid var(--separator);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); transition: transform 0.2s, box-shadow 0.2s;
}
.ds-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0,0,0,0.12); }

.ds-card-shots { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--separator); }
.ds-card-shot { position: relative; aspect-ratio: 1; background: #000; overflow: hidden; }
.ds-card-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ds-card-shot-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--text-quaternary); font-size: 13px; font-weight: 600;
  background: var(--bg-tertiary); aspect-ratio: 1;
}
.ds-card-shot-empty span { font-size: 11px; font-weight: 500; color: var(--accent-red); }
.ds-card-shot-angle {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(6px);
  color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px;
}
.ds-card-chips {
  position: absolute; bottom: 8px; left: 8px; right: 8px;
  display: flex; gap: 4px; flex-wrap: wrap;
}
.ds-chip {
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); color: #fff;
  font-size: 11px; font-weight: 600; font-family: var(--font-mono);
  padding: 3px 7px; border-radius: 6px;
}
.ds-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
}
.ds-card-date { font-size: 13px; color: var(--text-tertiary); font-family: var(--font-mono); }
.ds-card-del {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; color: var(--text-quaternary); transition: all 0.15s;
}
.ds-card-del:hover { background: rgba(255,69,58,0.12); color: var(--accent-red); }

/* ── Empty state ── */
.ds-empty {
  grid-column: 1 / -1; text-align: center; padding: 70px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.ds-empty-icon {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-dim); color: var(--accent); margin-bottom: 6px;
}
.ds-empty-title { font-size: 18px; font-weight: 700; }
.ds-empty-sub { font-size: 14px; color: var(--text-tertiary); max-width: 320px; }

/* ── Capture modal ── */
.ds-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity 0.2s;
}
.ds-modal-overlay.show { opacity: 1; }
.ds-modal {
  background: var(--bg-primary); border-radius: var(--radius-xl);
  width: 100%; max-width: 720px; max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(0,0,0,0.35);
  transform: scale(0.96); transition: transform 0.2s;
}
.ds-modal-overlay.show .ds-modal { transform: scale(1); }
.ds-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--separator);
}
.ds-modal-title { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; }
.ds-modal-close {
  width: 34px; height: 34px; border: none; border-radius: 50%; cursor: pointer;
  background: var(--bg-tertiary); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.ds-modal-close:hover { background: var(--bg-elevated); }
.ds-modal-body { padding: 22px 24px; overflow-y: auto; }
.ds-modal-foot {
  display: flex; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--separator);
}
.ds-modal-foot .btn { flex: 1; }

.ds-angle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 560px) { .ds-angle-grid { grid-template-columns: 1fr; } }

.ds-angle {
  border: 1px solid var(--separator); border-radius: var(--radius-lg); padding: 14px;
  background: var(--bg-secondary);
}
.ds-angle-head { font-size: 14px; font-weight: 700; margin-bottom: 10px; letter-spacing: -0.2px; }

.ds-shot-zone {
  position: relative; width: 100%; aspect-ratio: 4/3; border-radius: var(--radius-md);
  border: 2px dashed var(--separator); background: var(--bg-tertiary);
  cursor: pointer; overflow: hidden; padding: 0; transition: border-color 0.15s, background 0.15s;
}
.ds-shot-zone:hover { border-color: var(--accent); background: var(--accent-dim); }
.ds-shot-zone.has-shot { border-style: solid; border-color: var(--accent); }
.ds-shot-zone img { width: 100%; height: 100%; object-fit: cover; }
.ds-shot-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--text-tertiary); font-size: 14px; font-weight: 600;
}
.ds-shot-retake {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); color: #fff;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 20px;
}

.ds-measures { display: flex; gap: 8px; margin-top: 12px; }
.ds-measure { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.ds-measure-input {
  width: 100%; background: var(--bg-tertiary); border: 1.5px solid var(--separator);
  border-radius: var(--radius-sm); padding: 9px 10px; font-family: var(--font);
  font-size: 15px; text-align: center; transition: border-color 0.15s;
  -moz-appearance: textfield;
}
.ds-measure-input::-webkit-outer-spin-button,
.ds-measure-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ds-measure-input:focus { outline: none; border-color: var(--accent); }
.ds-measure label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-align: center; }
.ds-measure label span { color: var(--text-quaternary); font-weight: 500; }

/* ── Camera ── */
.ds-cam {
  position: fixed; inset: 0; z-index: 1100; background: #000;
  display: flex; flex-direction: column;
  opacity: 0; transition: opacity 0.18s;
}
.ds-cam.show { opacity: 1; }
.ds-cam-stage { position: relative; flex: 1; overflow: hidden; }
#ds-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ds-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ds-cam-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.6); backdrop-filter: blur(10px); color: #fff;
  font-size: 13px; padding: 8px 14px; border-radius: 20px; max-width: 90%;
  text-align: center; line-height: 1.35;
}
.ds-cam-hint b { color: var(--accent-hover); }

.ds-cam-controls {
  background: #0a0a0a; padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.ds-cal { display: flex; align-items: center; gap: 12px; }
.ds-cal-label { color: #fff; font-size: 14px; font-weight: 600; width: 44px; }
.ds-cal input[type=range] { flex: 1; accent-color: var(--accent); height: 4px; }
.ds-cal-val {
  color: var(--accent-hover); font-size: 13px; font-weight: 600;
  font-family: var(--font-mono); width: 92px; text-align: right;
}
.ds-cam-note { color: #98989d; font-size: 12.5px; line-height: 1.35; }

.ds-cam-buttons { display: flex; align-items: center; justify-content: space-between; }
.ds-cam-buttons .btn { width: auto; background: #1c1c1e; color: #fff; }
.ds-cam-buttons .btn:hover { background: #2c2c2e; }
.ds-shutter {
  width: 68px; height: 68px; border-radius: 50%; cursor: pointer;
  background: #fff; border: 4px solid rgba(255,255,255,0.35);
  box-shadow: 0 0 0 2px #fff inset; transition: transform 0.1s;
}
.ds-shutter:active { transform: scale(0.92); }

/* ── Mobile ── */
@media (max-width: 640px) {
  .ds-page { padding: 18px 14px 56px; }
  .ds-title { font-size: 24px; }
  .ds-subtitle { font-size: 14px; }
  .ds-header { flex-direction: column; align-items: stretch; gap: 14px; }
  .ds-header-actions { width: 100%; }
  .ds-header-actions .btn { flex: 1; }
  .ds-stats { gap: 10px; }
  .ds-stat { flex: 1; min-width: 0; padding: 12px 14px; text-align: center; }
  .ds-gallery { grid-template-columns: 1fr; gap: 14px; }

  .ds-modal { max-height: 94vh; border-radius: var(--radius-lg); }
  .ds-modal-body { padding: 16px; }
  .ds-modal-head { padding: 16px 18px; }
  .ds-modal-foot { padding: 14px 16px; }
  .ds-angle-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Camera controls sit comfortably on small screens */
  .ds-cam-controls { gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
  .ds-cal-val { width: 78px; font-size: 12px; }
  .ds-shutter { width: 62px; height: 62px; }
}

/* Avoid iOS auto-zoom on focusing number inputs (needs >=16px) */
@media (max-width: 640px) {
  .ds-measure-input { font-size: 16px; }
}
