/* ============================================================================
   22. Record detail — the reference "open a record" view
   ----------------------------------------------------------------------------
   Title + "N of N filled", collapsible section panels (Details / Dates /
   Notes), and canonical field cells with live inline editing (the app.js
   PATCH handler). Fields sit in an auto-fit grid, labels above controls.
   ========================================================================== */

.record-detail {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.record-head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--ta-border);
}

.record-back {
  text-decoration: none;
  color: var(--ta-muted);
  font-size: 0.6875rem;
}

.record-back:hover {
  color: var(--ta-accent-ink, var(--ta-accent));
}

.record-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.875rem;
  flex-wrap: wrap;
}

.record-title {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.record-filled {
  font-size: 0.6875rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--ta-surface-2);
  color: var(--ta-muted);
  white-space: nowrap;
}

/* Section panels (collapsible, open by default). */
.record-section {
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-r-lg);
  background: var(--ta-glass-strong);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  overflow: hidden;
}

.record-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  cursor: pointer;
  list-style: none;
  font-weight: 500;
}

.record-section summary::-webkit-details-marker {
  display: none;
}

.record-section[open] summary {
  border-bottom: 1px solid var(--ta-border);
}

.record-section-count {
  font-size: 0.625rem;
}

/* Fields lay out exactly like the create/edit form (`.form-fields`): a
   2-column grid with long-form fields spanning full width. */
.record-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
  padding: 1.25rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.field-group.wide {
  grid-column: 1 / -1;
}

/* The label keeps the create form's `.field-label` face (0.82rem/600,
   sentence case) — no mono uppercase override here. */
.field-group .field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ta-text);
}

/* Captions under an inline control (a field's `hint`) — same 0.78rem
   muted note as the create form. */
.field-group .field-hint {
  font-size: 0.78rem;
  color: var(--ta-faint);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .record-fields {
    grid-template-columns: 1fr;
  }
}

/* A confidence-style slider inside a field group: the range is the
   inline-editable input; give the row breathing room so the readout box
   (6rem from forms.css) doesn't crowd a narrow grid cell. */
.field-group .slider-field {
  min-height: 2.25rem;
}

/* Inline editing controls — flush, hairline, commit on change/blur. */
.field-inline {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-r-sm);
  background: var(--ta-surface);
  color: var(--ta-text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color var(--ta-t) var(--ta-ease);
}

.field-inline:focus {
  outline: none;
  border-color: var(--ta-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ta-accent) 18%, transparent);
}

.field-inline.inline-error {
  border-color: var(--ta-err);
}

.field-inline.bool {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: auto;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.field-inline.bool input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--ta-accent);
}

/* Auto (engine-owned) values read as the create form's `.auto-note`: a
   dashed note box with an "auto" accent badge. */
.field-inline.auto {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px dashed var(--ta-border-strong);
  border-radius: var(--ta-r-sm);
  background: var(--ta-surface-2);
}

.field-auto-note {
  flex: none;
  padding: 0.06rem 0.45rem;
  border-radius: var(--ta-r-sm);
  background: var(--ta-accent-soft);
  color: var(--ta-accent);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Canonical display cells (read-only values). */
.field-cell {
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.field-cell.empty {
  color: var(--ta-faint);
}

.field-cell.data {
  font-family: var(--ta-mono);
  font-variant-numeric: tabular-nums;
}

.field-email {
  color: var(--ta-accent-ink, var(--ta-accent));
  text-decoration: none;
}

.field-bool {
  display: inline-grid;
  place-items: center;
  width: 0.875rem;
  height: 0.875rem;
  border: 1px solid var(--ta-border);
  border-radius: 0.25rem;
  font-size: 0.625rem;
  color: #fff;
  background: var(--ta-surface);
}

.field-bool svg {
  width: 0.625rem;
  height: 0.625rem;
}

.field-bool[data-on="1"] {
  background: var(--ta-accent);
  border-color: var(--ta-accent);
}

.state-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--ta-r-sm);
  background: var(--ta-surface-2);
  color: var(--ta-muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* The table's primary cell doubles as the drill-in link. */
.table-title {
  color: var(--ta-accent-ink, var(--ta-accent));
  text-decoration: none;
  font-weight: 500;
}

/* ---- 22c. Saved-view bar (Table / Board / Calendar) --------------------- */

.view-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: var(--ta-r-lg);
  background: var(--ta-surface-2);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.view-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border-radius: var(--ta-r-sm);
  color: var(--ta-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--ta-t) var(--ta-ease), color var(--ta-t) var(--ta-ease);
}

.view-pill:hover {
  color: var(--ta-text);
}

.view-pill.active {
  background: var(--ta-surface);
  color: var(--ta-text);
  box-shadow: var(--ta-shadow-sm);
}

.view-icon svg {
  width: 1rem;
  height: 1rem;
}