/* Left sidebar, control panel, and shared detail/sidebar primitives. */

#panel {
  min-width: 300px;
  min-height: 0;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
}

.brand-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 4px 6px 12px 6px;
  border-bottom: 1px solid rgba(var(--ink-rgb), 0.05);
}

/* The appearance switch (app/ui/theme.js): one icon button, "Light theme", pressed while light is on.
   It shows the sun while dark is on and the moon while light is on. */
/* The phone's top bar: the open section's name and the menu button (phones only, styles/responsive.css). */
.fm-mobile-section,
.fm-menu-toggle { display: none; }

.fm-mobile-section {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--text-main);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fm-menu-toggle {
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--input-line);
  border-radius: 12px;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
}

.fm-menu-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.fm-theme-toggle {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.fm-theme-toggle[hidden] {
  display: none;
}

.fm-theme-toggle:hover,
.fm-theme-toggle:focus-visible {
  color: var(--text-main);
  border-color: var(--border-strong);
  outline: none;
}

.fm-theme-toggle:focus-visible {
  box-shadow: var(--focus-ring);
}

.fm-theme-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fm-theme-toggle[aria-pressed="true"] .fm-theme-sun,
.fm-theme-toggle[aria-pressed="false"] .fm-theme-moon {
  display: none;
}

/* In the logo's row the switch sits at the end, just before Sign out. */
.brand-row .fm-theme-toggle {
  margin-left: auto;
}

.brand-row .fm-theme-toggle:not([hidden]) + .fm-account-session {
  margin-left: 0;
}

/* Aleph sign-in session: a quiet Sign out at the end of the logo's row (the Aleph ID in its tooltip). */
.fm-account-session {
  flex: 0 0 auto;
  margin-left: auto;
  display: flex;
  align-items: center;
}

.fm-account-session.hidden {
  display: none;
}

.fm-account-signout {
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.65;
  cursor: pointer;
  transition: opacity 120ms ease, color 120ms ease;
}

.fm-account-signout:hover,
.fm-account-signout:focus-visible {
  color: var(--text-main);
  opacity: 1;
  outline: none;
}

.fm-account-signout:focus-visible {
  box-shadow: var(--focus-ring);
}

.fm-account-signout:disabled {
  opacity: 0.55;
  cursor: progress;
}

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 24px rgba(var(--brand-blue-rgb), 0.12));
  flex: 0 0 auto;
}

.brand-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  min-height: 56px;
}

.panel-top {
  display: block;
  padding: 0 6px;
}

.brand-kicker:empty {
  display: none;
}

.brand-kicker {
  margin: 0 0 6px;
  color: var(--brand-blue-soft);
  font-size: 10px;
}

.brand-wordmark {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.30em;
  line-height: 1;
  color: var(--text-main);
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-blue-soft);
  font-size: 11px;
}

.lede {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.52;
  max-width: 33ch;
}

.lede:empty {
  display: none;
}

.ghost-btn {
  border: 1px solid var(--input-line);
  border-radius: 12px;
  background: transparent;
  color: var(--text-main);
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.17s ease, border-color 0.17s ease, background 0.17s ease;
}

.ghost-btn:hover {
  transform: translateY(-1px);
  border-color: var(--brand-blue);
  background: var(--tint-brand);
}

/* The brandbook's one primary action per view (a form's submit): the brand gradient, lifting 1px on hover. */
.primary-btn {
  border: 1px solid var(--brand-blue);
  border-radius: 12px;
  background: linear-gradient(120deg, var(--brand-blue), var(--brand-blue-soft));
  color: var(--text-on-accent);
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.17s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.ghost-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}


.ghost-btn.danger {
  border-color: color-mix(in srgb, var(--state-failed) 45%, transparent);
  color: var(--state-failed);
}

.ghost-btn.danger:hover {
  background: color-mix(in srgb, var(--state-failed) 10%, transparent);
  border-color: var(--state-failed);
}

.ghost-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.details-shell {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 0 6px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.focus-pill {
  /* Same in both themes: dark ink on the brand fill reads on either ground. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 11px;
  color: #07131a;
  background: rgba(var(--brand-blue-soft-rgb), 0.96);
  min-width: 92px;
}

.focus-pill.focus-pill-static {
  background: rgba(var(--brand-blue-soft-rgb), 0.16);
  color: var(--text-main);
  border: 1px solid rgba(var(--brand-blue-soft-rgb), 0.24);
}

.focus-pill.focus-pill-qr {
  font-family: "JetBrains Mono", monospace;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.focus-pill.is-hidden {
  display: none;
}

.focus-pill.is-good {
  background: rgba(var(--cyan-rgb), 0.16);
  color: color-mix(in srgb, rgb(var(--cyan-rgb)) 35%, var(--text-main));
  border-color: rgba(var(--cyan-rgb), 0.28);
}

.focus-pill.is-warning {
  background: rgba(var(--amber-rgb), 0.16);
  color: color-mix(in srgb, rgb(var(--amber-rgb)) 35%, var(--text-main));
  border-color: rgba(var(--amber-rgb), 0.3);
}

.focus-pill.is-critical {
  background: rgba(var(--alert-rgb), 0.16);
  color: color-mix(in srgb, rgb(var(--alert-rgb)) 35%, var(--text-main));
  border-color: rgba(var(--alert-rgb), 0.32);
}

.details-card {
  min-height: 0;
  overflow: auto;
  border: 1px solid rgba(var(--ink-rgb), 0.06);
  border-radius: 20px;
  background: var(--fill-card);
  padding: 14px 14px 16px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--brand-blue-soft-rgb), 0.56) rgba(var(--ink-rgb), 0.03);
}

.details-card::-webkit-scrollbar {
  width: 12px;
}

.details-card::-webkit-scrollbar-track {
  background: linear-gradient(180deg, rgba(var(--ink-rgb), 0.02), rgba(var(--ink-rgb), 0.04));
  border-left: 1px solid rgba(var(--ink-rgb), 0.04);
  border-radius: 999px;
  margin: 10px 0;
}

.details-card::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 2px solid rgba(var(--surface-rgb), 0.82);
  background: linear-gradient(180deg, rgba(var(--brand-blue-soft-rgb), 0.92), rgba(var(--brand-blue-rgb), 0.78) 48%, rgba(var(--brand-orange-rgb), 0.72));
  box-shadow: 0 0 12px rgba(var(--brand-blue-rgb), 0.18), 0 0 18px rgba(var(--brand-orange-rgb), 0.12);
}

.panel-stat-grid,
.panel-action-grid {
  display: grid;
  gap: 10px;
}

.panel-stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel-action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-action-grid-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-button,
.panel-stat-card,
.panel-record-btn {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-main);
  text-align: left;
  transition: transform 0.17s ease, border-color 0.17s ease, background 0.17s ease;
}

.dashboard-button,
.panel-stat-card-button,
.panel-record-btn {
  cursor: pointer;
}

.dashboard-button:hover,
.panel-stat-card-button:hover,
.panel-record-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--brand-blue-soft-rgb), 0.24);
  background: rgba(var(--ink-rgb), 0.045);
}

.dashboard-button.is-active,
.panel-stat-card-button.is-active,
.dashboard-button[aria-pressed="true"],
.panel-stat-card-button[aria-pressed="true"] {
  border-color: rgba(var(--brand-blue-soft-rgb), 0.48);
  background:
    linear-gradient(135deg, rgba(var(--brand-blue-rgb), 0.18), rgba(var(--ink-rgb), 0.055)),
    rgba(var(--brand-blue-rgb), 0.1);
  box-shadow:
    inset 0 1px 0 rgba(var(--ink-rgb), 0.09),
    0 0 0 1px rgba(var(--brand-blue-soft-rgb), 0.1),
    0 0 22px rgba(var(--brand-blue-rgb), 0.16);
}

.dashboard-button.tone-good {
  border-color: rgba(var(--cyan-rgb), 0.24);
  background: rgba(var(--cyan-rgb), 0.08);
}

.dashboard-button.tone-warning {
  border-color: rgba(var(--amber-rgb), 0.24);
  background: rgba(var(--amber-rgb), 0.08);
}

.dashboard-button.tone-critical {
  border-color: rgba(var(--alert-rgb), 0.28);
  background: rgba(var(--alert-rgb), 0.1);
}

.panel-record-list {
  display: grid;
  gap: 8px;
}

.panel-record-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.panel-inline-note {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(var(--ink-rgb), 0.05);
  background: transparent;
}

.detail-visual {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(var(--ink-rgb), 0.08);
  background: rgba(var(--ink-rgb), 0.03);
  margin-bottom: 12px;
}

.detail-visual img {
  display: block;
  width: 100%;
  height: auto;
}

.detail-tags,
.related-list,
.proof-list,
.nav-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.related-chip,
.nav-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(var(--ink-rgb), 0.08);
  background: rgba(var(--ink-rgb), 0.05);
  color: var(--text-main);
  font-size: 11px;
}

.related-chip,
.nav-chip {
  cursor: pointer;
}

.related-chip:hover,
.nav-chip:hover {
  box-shadow: var(--focus-ring);
}

.nav-chip {
  gap: 7px;
}

.nav-chip-label {
  font-size: 10px;
  color: var(--brand-blue-soft);
  letter-spacing: 0.14em;
}

.detail-copy {
  color: var(--text-muted);
  line-height: 1.52;
  font-size: 14px;
}

.detail-section {
  margin-top: 14px;
}

.detail-section h3 {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--brand-blue-soft);
}

.detail-link-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.detail-link-list li::marker {
  color: var(--brand-blue-soft);
}

.detail-specs {
  display: grid;
  gap: 8px;
}

.detail-spec {
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid rgba(var(--ink-rgb), 0.06);
  background: rgba(var(--ink-rgb), 0.035);
}

.detail-spec-label {
  margin-bottom: 4px;
  color: rgba(var(--brand-blue-soft-rgb), 0.86);
  font: 10px/1.2 "JetBrains Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-spec-value {
  color: var(--text-main);
  line-height: 1.45;
  font-size: 13px;
}

.graph-context {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--fill-card);
  border: 1px solid rgba(var(--ink-rgb), 0.06);
}

.graph-context strong {
  display: block;
  margin-bottom: 6px;
}

.proof-list {
  flex-direction: column;
  margin: 0;
  padding-left: 18px;
}

.proof-list li {
  color: var(--text-main);
  margin-bottom: 8px;
  line-height: 1.45;
}

.doc-link {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font: inherit;
  cursor: pointer;
}

.doc-link:hover {
  color: var(--brand-blue-soft);
}

.doc-link-label {
  font-weight: 700;
}

.doc-link-meta {
  color: var(--text-muted);
  font-weight: 500;
}

#panel-resizer {
  position: relative;
  width: var(--resizer-width);
  cursor: col-resize;
  align-self: stretch;
  z-index: 3;
}

#panel-resizer::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 12px;
  bottom: 12px;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(var(--brand-blue-rgb), 0.04), rgba(var(--brand-blue-rgb), 0.22), rgba(var(--brand-orange-rgb), 0.18), rgba(var(--brand-blue-rgb), 0.22), rgba(var(--brand-blue-rgb), 0.04));
  border-radius: 999px;
  transition: background 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  opacity: 0.8;
}

#panel-resizer:hover::before,
body.resizing #panel-resizer::before {
  background: linear-gradient(180deg, rgba(var(--brand-blue-rgb), 0.12), rgba(var(--brand-blue-rgb), 0.5), rgba(var(--brand-orange-rgb), 0.42), rgba(var(--brand-blue-rgb), 0.5), rgba(var(--brand-blue-rgb), 0.12));
  box-shadow: 0 0 0 1px rgba(var(--brand-blue-rgb), 0.22), 0 0 18px rgba(var(--brand-blue-rgb), 0.2);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .ghost-btn,
  .dashboard-button,
  .panel-stat-card,
  .panel-record-btn,
  .primary-btn { transition: none; }
  .ghost-btn:hover,
  .primary-btn:hover { transform: none; }
}
