/* PachBae Studi-OS — Detail drawer */

.drawer {
  flex-shrink: 0;
  width: 380px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 1px 0 oklch(0.32 0.008 65 / 0.5) inset,
    0 20px 50px -30px rgba(0,0,0,0.6),
    0 1px 2px rgba(0,0,0,0.3);
  transition: transform 0.28s ease, margin-left 0.28s ease, opacity 0.28s ease;
}
.drawer.drawer--closed {
  transform: translateX(calc(100% + 20px));
  margin-left: -400px; /* 380px width + 20px gap — collapses layout space */
  opacity: 0;
  pointer-events: none;
}
.drawer::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, oklch(0.45 0.012 65 / 0.6), transparent);
  z-index: 4;
  pointer-events: none;
}
html[data-theme="light"] .drawer::before {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
}

/* Scrollable body — everything below the sticky header */
.drawer-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky; top: 0;
  z-index: 2;
}
.drawer-id {
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.drawer-close {
  width: 22px; height: 22px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 12px;
  display: grid; place-items: center;
}
.drawer-close:hover { background: var(--surface-3); color: var(--text-primary); }
.drawer-edit-btn {
  width: 26px; height: 26px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  display: grid; place-items: center;
  transition: background 0.12s, color 0.12s;
  margin-left: auto;
  margin-right: 4px;
}
.drawer-edit-btn:hover { background: color-mix(in oklab, var(--accent) 14%, var(--surface-3)); color: var(--accent); }

.drawer-hero {
  height: 200px;
  margin: 14px 14px 0;
  border-radius: var(--radius);
  border: 1px solid;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow:
    inset 0 0 80px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
/* With a photo: a taller frame that shows all of it. Gear shots are mostly
   portrait phone photos, so a fixed landscape strip cropped most of them. */
.drawer-hero:has(.drawer-hero-photo) {
  height: auto;
  aspect-ratio: 4 / 3;
  max-height: 52vh;
}
.drawer-hero-photo-bg {
  position: absolute;
  inset: -24px;
  width: calc(100% + 48px);
  height: calc(100% + 48px);
  object-fit: cover;
  filter: blur(22px) brightness(0.4) saturate(1.1);
}
.drawer-hero-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
}
.drawer-hero:has(.drawer-hero-photo)::before,
.drawer-hero:has(.drawer-hero-photo)::after,
.drawer-hero:has(.drawer-hero-photo) .drawer-hero-tag { display: none; }
.drawer-hero--editable:has(.drawer-hero-photo) .drawer-hero-tag { display: block; z-index: 2; }
.drawer-hero--editable {
  cursor: pointer;
}
.drawer-hero--editable:hover .drawer-hero-edit-overlay {
  opacity: 1;
}
.drawer-hero-edit-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.18s;
  z-index: 2;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  pointer-events: none;
}
.drawer-hero-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: var(--text-primary);
  font-size: 11px;
  display: grid;
  place-items: center;
  transition: background 0.12s;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.drawer-hero-remove:hover { background: rgba(200, 50, 50, 0.7); }

.drawer-hero::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: radial-gradient(circle at 50% 50%, color-mix(in oklab, var(--accent) 25%, transparent), transparent 55%);
  pointer-events: none;
  opacity: 0.5;
}
.drawer-hero::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.08), transparent 40%),
    repeating-linear-gradient(180deg, transparent 0 2px, rgba(0,0,0,0.04) 2px 3px),
    linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.5));
  pointer-events: none;
}
.drawer-hero-glyph {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 600;
  color: var(--text-primary);
  background: oklch(0.16 0.005 65 / 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  padding: 6px 22px;
  border-radius: 4px;
  border: 1px solid oklch(0.30 0.01 65 / 0.5);
  letter-spacing: 0.04em;
  position: relative; z-index: 1;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.08);
}
.drawer-hero-tag {
  position: absolute;
  bottom: 12px; left: 14px;
  font-size: 9.5px;
  letter-spacing: 0.10em;
  color: var(--text-muted);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.drawer-hero-tag::before {
  content: ""; width: 4px; height: 4px; border-radius: 50%;
  background: oklch(0.78 0.14 145);
  box-shadow: 0 0 4px oklch(0.78 0.14 145);
}

.drawer-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 18px 14px;
}
.drawer-title-main {
  flex: 1;
  min-width: 0;
}
.drawer-title-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drawer-edit-model-input {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.028em;
  height: auto;
  min-height: 36px;
  padding: 6px 8px;
  line-height: 1.15;
}
.drawer-subcat-edit-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.drawer-subcat-edit-type {
  flex: 1;
  min-width: 140px;
}
.drawer-subcat-edit-year {
  flex: 0 0 auto;
  width: 96px;
}
.drawer-subcat-edit-sep {
  color: var(--text-faint);
  padding-bottom: 9px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  flex-shrink: 0;
}
.drawer-status-edit {
  min-width: 148px;
  width: 100%;
  max-width: min(100%, 280px);
}
.drawer-brand {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.drawer-model {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.028em;
  color: var(--text-primary);
  margin: 4px 0 6px;
  line-height: 1;
  font-feature-settings: "ss01" on;
}
.drawer-subcat {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: -0.005em;
}
.drawer-status { padding-top: 4px; }

.drawer-actions {
  display: flex;
  gap: 6px;
  padding: 0 14px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.drawer-actions .tb-btn { height: 30px; font-size: 12px; flex: 1 1 auto; }
.drawer-actions .tb-btn.ghost { flex: 0 1 auto; }

.drawer-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-section:last-of-type { border-bottom: none; }
.drawer-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.drawer-section-title::before {
  content: "";
  width: 14px; height: 1px;
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent);
}

/* Collapsible QR code section */
.drawer-qr-toggle {
  border: none; background: none; padding: 0; cursor: pointer;
}
.drawer-qr-toggle:hover { color: var(--text-primary); }
.drawer-qr-toggle:not(.open) { margin-bottom: 0; }
.drawer-qr-caret { font-size: 9px; transition: transform 0.12s; }
.drawer-qr-toggle.open .drawer-qr-caret { transform: rotate(90deg); color: var(--accent); }
.item-qr { display: flex; align-items: center; gap: 14px; }
.item-qr-img {
  width: 120px; height: 120px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; overflow: hidden; background: #fff;
}
.item-qr-img svg { width: 100%; height: 100%; display: block; }
.item-qr-meta { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.item-qr-code { font-size: 15px; letter-spacing: 0.08em; color: var(--text-primary); }

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.spec { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.spec-label {
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.spec-value {
  font-size: 12.5px;
  color: var(--text-primary);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spec-grid .spec.spec-span2 {
  grid-column: 1 / -1;
}

.drawer-notes {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  padding: 10px 14px;
  background: var(--bg);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.history { display: flex; flex-direction: column; gap: 4px; }
.history-row {
  display: grid;
  grid-template-columns: 88px 12px 1fr;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  position: relative;
}
.history-row::before {
  content: ""; position: absolute;
  left: 96px; top: 18px; bottom: -2px;
  width: 1px;
  background: var(--border);
}
.history-row:last-child::before { display: none; }
.history-date {
  font-size: 10.5px;
  color: var(--text-muted);
  padding-top: 2px;
}
.history-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  margin-top: 6px;
  margin-left: 3px;
}
.history-row:first-child .history-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
.history-body { font-size: 12px; }
.history-type {
  color: var(--text-primary);
  font-weight: 500;
}
.history-who {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11.5px;
}
.history-note {
  color: var(--text-secondary);
  font-size: 11.5px;
  margin-top: 2px;
}
.history-empty {
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
  padding: 4px 0;
}

.drawer-footnote {
  padding: 12px 16px;
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--surface-2);
  letter-spacing: 0.02em;
}

.drawer-img-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 4px;
}
.drawer-img-preview {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.drawer-inline-input {
  height: 28px;
  padding: 0 8px;
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12.5px;
  transition: border-color 0.15s, background-color 0.15s;
}
.drawer-inline-input:hover  { border-color: var(--border-strong); }
.drawer-inline-input:focus  { border-color: var(--accent); background-color: var(--surface-2); outline: none; }
.drawer-inline-input::placeholder { color: var(--text-faint); }
.drawer-inline-input.mono   { font-family: var(--font-mono); font-size: 11.5px; }
.drawer-inline-textarea     { height: auto; padding: 6px 8px; resize: vertical; }

/* make CustomSelect match inline-input height inside the drawer */
.drawer-inline-input.cs-wrap { display: flex; align-items: center; }

/* ─── Responsive: hide drawer on small viewports ─────────────────────── */
@media (max-width: 1180px) {
  .inv-body { grid-template-columns: 1fr; }
  .drawer {
    position: fixed;
    top: var(--topbar-h);
    right: 0; bottom: 0;
    width: 380px;
    max-height: none;
    max-width: 100vw;
    border-radius: 0;
    border-right: none;
    z-index: 20;
    box-shadow: -16px 0 40px rgba(0,0,0,0.4);
  }
}

@media (max-width: 820px) {
  .inventory { padding: 18px 16px 60px; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat-strip > .stat:nth-child(5) { grid-column: span 2; }
  .page-head { flex-direction: column; gap: 16px; }
  .page-head-r { width: 100%; min-width: 0; }
  .list-header { display: none; }
  .list-row {
    grid-template-columns: 44px 1fr auto;
    grid-template-areas:
      "thumb name status"
      "thumb subcat value";
    gap: 4px 12px;
    padding: 10px 14px;
  }
  .list-row > :nth-child(1) { grid-area: thumb; align-self: center; }
  .list-row > :nth-child(2) { grid-area: name; }
  .list-row > :nth-child(3) { grid-area: subcat; }
  .list-row > :nth-child(4) { display: none; }
  .list-row > :nth-child(5) { display: none; }
  .list-row > :nth-child(6) { grid-area: status; justify-self: end; }
  .list-row > :nth-child(7) { grid-area: value; justify-self: end; }
  .list-row > :nth-child(8) { display: none; }
  .drawer { width: 100%; }
  .room-selector { display: none; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .inv-search-bar { max-width: none; width: 100%; }
  .cat-tabs { overflow-x: auto; }
}
