/*
 * Conflux Minimal Config UI — "M3" dark theme.
 *
 * Visual system ported from the Conflux M3 design (Claude Design project
 * "Conflux M3 Config UI Design"). Every route is server-rendered (Elysia +
 * htmx + Alpine CSP); this stylesheet is the single visual layer shared by the
 * public pages and the Organization settings app shell.
 *
 * Fonts: the design specifies IBM Plex Sans/Mono. The strict Content Security
 * Policy (style-src/font-src 'self') forbids remote font hosts, so the stacks
 * below name IBM Plex first and fall back to the platform sans/mono. Ship the
 * Plex woff2 files under /assets and add @font-face here to reach pixel parity.
 */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg-app: #0a0e16;
  --bg-sidebar: #080b12;
  --bg-panel: #0e1422;
  --bg-elevated: #131b2b;
  --bg-hover: #1a2334;
  --bg-header: #0c111c;

  /* Borders */
  --border: #232b3b;
  --border-subtle: #1b212e;
  --border-strong: #2a3448;

  /* Text */
  --text: #e6eaf0;
  --text-muted: #9aa4b2;
  --text-faint: #67707e;
  --text-dim: #525c6b;

  /* Accent (cyan) */
  --accent: #4cc9e8;
  --accent-hover: #7edcf2;
  --accent-contrast: #06222b;
  --accent-soft: rgba(76, 201, 232, 0.12);
  --accent-line: rgba(76, 201, 232, 0.4);

  /* Status */
  --success: #57c98b;
  --success-soft: rgba(87, 201, 139, 0.12);
  --success-line: rgba(87, 201, 139, 0.38);
  --warning: #e0b154;
  --warning-soft: rgba(224, 177, 84, 0.12);
  --warning-line: rgba(224, 177, 84, 0.38);
  --danger: #e26d6d;
  --danger-soft: rgba(226, 109, 109, 0.12);
  --danger-line: rgba(226, 109, 109, 0.42);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 24px 60px rgba(2, 5, 12, 0.55);
  --font:
    'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI',
    sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 60;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0.75rem;
  text-decoration: none;
}

/* htmx request indicators (self-contained; strict CSP blocks htmx's own
   injected indicator styles). */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
  color: var(--text-muted);
}

/* -------------------------------------------------------------------------
 * Public / status pages (signed-out landing, org list, setup, errors, denied)
 * ---------------------------------------------------------------------- */

.public-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(
      110% 90% at 50% -10%,
      rgba(76, 201, 232, 0.08),
      transparent 60%
    ),
    var(--bg-app);
}

.public-page-main {
  width: min(40rem, 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  padding: 2rem;
  box-shadow: var(--shadow);
  position: relative;
  animation: fadeIn 0.35s ease both;
}

.public-page-main > h1 {
  margin-top: 0;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* Brand lockup + footer tag drawn by public_page.ts. */
.public-brand {
  display: flex;
  margin-bottom: 1.25rem;
}

.public-brand-lockup {
  display: block;
  height: 30px;
  width: auto;
}

.public-footer-tag {
  margin: 1.5rem 0 0;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.public-error-reference {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.public-error-reference code {
  color: var(--text-faint);
}

.public-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0;
  margin-top: 1.5rem;
}

/* Organization cards on the signed-in home page. */
.organization-card-list {
  display: grid;
  gap: 0.75rem;
}

.organization-card {
  display: grid;
  gap: 0.65rem;
}

.organization-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.organization-card-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}

.organization-card-login,
.organization-card-meta {
  margin: 0;
  color: var(--text-muted);
}

.organization-card-login {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-faint);
}

/* -------------------------------------------------------------------------
 * Feedback / notices
 * ---------------------------------------------------------------------- */

.feedback {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 0.85rem 1rem;
  color: var(--text);
}

.feedback > p {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
}

.feedback-success,
.notice-success {
  border-color: var(--success-line);
  background: var(--success-soft);
}

.feedback-error {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.notice-info {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
}

/* -------------------------------------------------------------------------
 * Buttons + badges (shared visual primitives)
 * ---------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Status pills carry a leading dot in the tint of their state. */
.badge-success::before,
.badge-warning::before,
.badge-danger::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}

.badge-success {
  border-color: var(--success-line);
  color: var(--success);
  background: var(--success-soft);
}

.badge-warning {
  border-color: var(--warning-line);
  color: var(--warning);
  background: var(--warning-soft);
}

.badge-danger {
  border-color: var(--danger-line);
  color: var(--danger);
  background: var(--danger-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    color 0.14s ease;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-line);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

.btn-danger {
  border-color: var(--danger-line);
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-danger:hover {
  background: rgba(226, 109, 109, 0.18);
  border-color: var(--danger);
}

/* Panels */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  padding: 1.1rem 1.2rem;
}

.panel-muted {
  color: var(--text-muted);
}

/* -------------------------------------------------------------------------
 * App shell — fixed sidebar + main column
 * ---------------------------------------------------------------------- */

.app-shell {
  min-height: 100vh;
  display: block;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 15.5rem;
  flex-direction: column;
  gap: 1.35rem;
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-sidebar);
  padding: 1.35rem 1rem;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 650;
  letter-spacing: 0.01em;
}

.app-brand:hover {
  color: var(--text);
  text-decoration: none;
}

.app-brand-mark {
  display: block;
  width: 1.9rem;
  height: 1.9rem;
  flex: none;
}

.app-brand-wordmark {
  display: grid;
  gap: 0.05rem;
  line-height: 1.1;
}

.app-brand-name {
  font-size: 0.95rem;
  font-weight: 650;
}

.app-brand-tag {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.app-sidebar-switcher .org-switcher,
.app-sidebar-switcher .org-switcher-summary {
  width: 100%;
}

.app-navigation {
  min-width: 0;
}

.app-nav-toggle {
  display: none;
}

.app-nav {
  border: 0;
  background: transparent;
  padding: 0;
}

.app-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}

.app-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
}

.app-nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.app-nav-link[aria-current='page'] {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
}

.app-nav-link-icon {
  display: inline-grid;
  width: 1rem;
  place-items: center;
  color: var(--text-faint);
}

.app-nav-link[aria-current='page'] .app-nav-link-icon {
  color: var(--accent);
}

.app-main {
  min-height: 100vh;
  margin-left: 15.5rem;
  padding: 0;
}

.app-main-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.5rem clamp(1.5rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-header);
}

.app-main-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.app-main-subtitle {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
}

.app-main > *:not(.app-main-header) {
  max-width: 78rem;
}

.app-main > .settings-dashboard,
.app-main > .app-main-body,
.app-main > section,
.app-main > p {
  padding-left: clamp(1.5rem, 4vw, 3rem);
  padding-right: clamp(1.5rem, 4vw, 3rem);
}

.settings-dashboard {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

/* -------------------------------------------------------------------------
 * Organization switcher
 * ---------------------------------------------------------------------- */

.org-switcher {
  position: relative;
}

.org-switcher-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 12rem;
  max-width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  user-select: none;
}

.org-switcher-summary::-webkit-details-marker {
  display: none;
}

.org-switcher-summary:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.org-switcher[open] .org-switcher-summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line);
}

.org-switcher-label {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
  flex: 1;
}

.org-switcher-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-switcher-meta {
  color: var(--text-faint);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.org-switcher-chevron {
  color: var(--text-faint);
  font-size: 0.7rem;
}

.org-switcher-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 0.4rem);
  width: min(22rem, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  padding: 0.6rem;
  z-index: 30;
}

.org-switcher-section {
  margin: 0.15rem 0 0.5rem;
}

.org-switcher-section-title {
  margin: 0.35rem 0.45rem 0.35rem;
  color: var(--text-dim);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.org-switcher-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}

.org-switcher-item a {
  display: grid;
  gap: 0.1rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.org-switcher-item a:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.org-switcher-item[data-current='true'] a {
  background: var(--accent-soft);
}

.org-switcher-item-name {
  font-weight: 600;
}

.org-switcher-item-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.org-switcher-empty {
  margin: 0.25rem 0.55rem 0.5rem;
  color: var(--text-faint);
  font-size: 0.8rem;
}

.org-switcher-actions {
  display: grid;
  gap: 0.15rem;
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

.org-switcher-action {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
}

.org-switcher-action:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

/* -------------------------------------------------------------------------
 * Settings dashboard
 * ---------------------------------------------------------------------- */

.settings-dashboard {
  display: grid;
  gap: 1.1rem;
}

.org-header {
  display: grid;
  gap: 0.6rem;
}

.org-header-name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 650;
}

.org-header-meta {
  margin: 0;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.org-header-meta strong {
  color: var(--text);
  font-weight: 600;
}

.org-header-badges {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.settings-section {
  scroll-margin-top: 1.5rem;
}

.settings-section-title {
  margin: 1.75rem 0 0.85rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 0.9rem;
}

.status-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  padding: 1.1rem 1.2rem;
  display: grid;
  gap: 0.5rem;
  align-content: start;
}

.status-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.status-card-title {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-family: var(--mono);
}

.status-card-value {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.status-card-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.status-card-feedback {
  min-height: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.status-card-action-disabled {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.8rem;
}

.settings-notices {
  display: grid;
  gap: 0.65rem;
}

.notice {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 0.85rem 1rem;
  color: var(--text-muted);
}

.notice-warning {
  border-color: var(--warning-line);
  background: var(--warning-soft);
  color: var(--text);
}

.notice-muted {
  color: var(--text-muted);
}

.notice-action {
  margin-left: 0.35rem;
  font-weight: 600;
}

/* Default gate config summary */
.config-summary {
  display: grid;
  gap: 0.85rem;
}

.config-summary-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.config-summary-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}

.config-summary-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.config-summary-list {
  margin: 0;
  display: grid;
  gap: 0;
}

.config-summary-row {
  display: grid;
  grid-template-columns: minmax(10rem, 15rem) minmax(0, 1fr);
  gap: 0.5rem 1.25rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border-subtle);
}

.config-summary-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.config-summary-row dt {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: var(--mono);
}

.config-summary-row dd {
  margin: 0;
  color: var(--text);
  font-weight: 500;
}

.config-summary-help,
.config-summary-empty,
.config-summary-editing-disabled {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* -------------------------------------------------------------------------
 * Repository table
 * ---------------------------------------------------------------------- */

.repository-table-panel {
  display: grid;
  gap: 0.85rem;
}

.repository-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.repository-table-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}

.repository-table-empty {
  margin: 0;
  color: var(--text-muted);
}

.repository-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.repository-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.repository-table th,
.repository-table td {
  text-align: left;
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.repository-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-header);
  color: var(--text-dim);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  font-family: var(--mono);
}

.repository-table tbody tr:last-child td {
  border-bottom: 0;
}

.repository-table tbody tr:hover {
  background: rgba(26, 35, 52, 0.55);
}

.repository-table td[data-col='name'] strong {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
}

.repository-table td[data-col='policy'] {
  font-family: var(--mono);
  color: var(--text-muted);
}

.repo-allowlist {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.repo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.repo-actions-readonly {
  color: var(--text-faint);
  font-size: 0.78rem;
}

/* -------------------------------------------------------------------------
 * Developer details
 * ---------------------------------------------------------------------- */

.developer-details details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  padding: 0.9rem 1.1rem;
}

.developer-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
}

.developer-details summary:hover {
  color: var(--text);
}

.developer-details-list {
  display: grid;
  gap: 0.55rem;
  margin: 0.95rem 0 0;
}

.developer-details-list > div {
  display: grid;
  grid-template-columns: minmax(9rem, 13rem) 1fr;
  gap: 0.85rem;
}

.developer-details-list dt {
  color: var(--text-dim);
  font-weight: 600;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.developer-details-list dd {
  margin: 0;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-word;
}

/* -------------------------------------------------------------------------
 * Config drawer (organization default + repo override edits)
 * ---------------------------------------------------------------------- */

#config-drawer-root:empty {
  display: none;
}

.config-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  justify-content: end;
  background: rgba(4, 6, 10, 0.62);
  animation: fadeIn 0.2s ease both;
}

.config-drawer-panel {
  width: min(30rem, 100vw);
  height: 100%;
  overflow: auto;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.35rem 2rem;
  display: grid;
  gap: 0.95rem;
  align-content: start;
  animation: drawerIn 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.config-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.config-drawer-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 650;
}

.config-drawer-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--mono);
}

.config-drawer-secondary {
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-subtle);
}

/* -------------------------------------------------------------------------
 * Config form
 * ---------------------------------------------------------------------- */

.config-form {
  display: grid;
  gap: 1rem;
}

.config-form-field {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.config-form-field legend {
  padding: 0;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.config-form-field label:not(.config-checkbox) {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.config-form-help,
.config-form-notice {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.config-form-notice {
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  color: var(--text);
}

.config-form-error {
  border: 1px solid var(--danger-line);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  color: var(--danger);
}

.config-field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.78rem;
}

.config-form-audit {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.76rem;
  font-family: var(--mono);
}

.config-checkbox-grid {
  display: grid;
  gap: 0.4rem;
}

.config-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.85rem;
}

.config-checkbox input {
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.config-textarea,
.config-form-field select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  padding: 0.55rem 0.7rem;
}

.config-textarea:focus,
.config-form-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line);
}

.config-form-field select:disabled {
  color: var(--text-muted);
  opacity: 0.85;
}

.config-textarea {
  font-family: var(--mono);
  font-size: 0.82rem;
  resize: vertical;
}

.config-input-error {
  border-color: var(--danger-line);
  box-shadow: 0 0 0 1px var(--danger-line);
}

.config-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.35rem;
}

.config-mutation-success {
  border: 1px solid var(--success-line);
  background: var(--success-soft);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  color: var(--text);
}

/* -------------------------------------------------------------------------
 * Animations
 * ---------------------------------------------------------------------- */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drawerIn {
  from {
    transform: translateX(24px);
    opacity: 0.4;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .public-page-main,
  .config-drawer,
  .config-drawer-panel {
    animation: none;
  }
}

/* -------------------------------------------------------------------------
 * Responsive — collapse the sidebar to an icon rail, then a top bar
 * ---------------------------------------------------------------------- */

@media (max-width: 960px) {
  .app-sidebar {
    width: 4.5rem;
    align-items: center;
    padding: 1rem 0.6rem;
  }

  .app-brand-wordmark,
  .app-nav-link-label,
  .app-brand-tag,
  .app-sidebar-switcher .org-switcher-label,
  .app-sidebar-switcher .org-switcher-chevron {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .app-sidebar-switcher .org-switcher-summary {
    min-width: 0;
    justify-content: center;
    padding: 0.55rem;
  }

  .app-sidebar-switcher .org-switcher-summary::before {
    content: '⌄';
    color: var(--text-muted);
  }

  .org-switcher-menu {
    left: 0;
    right: auto;
  }

  .app-nav-link {
    justify-content: center;
    padding: 0.7rem;
  }

  .app-main {
    margin-left: 4.5rem;
  }

  .status-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 0.65rem;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.65rem 0.8rem;
  }

  .app-sidebar-switcher {
    margin-left: auto;
  }

  .app-navigation {
    order: 3;
  }

  .app-nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    padding: 0.45rem 0.55rem;
  }

  .app-nav-toggle > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .app-navigation .app-nav {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0.8rem;
    width: min(17rem, calc(100vw - 1.6rem));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    box-shadow: var(--shadow);
    padding: 0.5rem;
    z-index: 30;
  }

  .app-navigation .app-nav-link {
    justify-content: flex-start;
  }

  .app-navigation .app-nav-link-label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }

  /* Before Alpine starts, keep the native links visible. Once it enhances the
     shell, x-bind adds this class and the toggle controls the compact menu. */
  .app-navigation .app-nav-collapsed {
    display: none;
  }

  .app-main {
    min-height: auto;
    margin-left: 0;
  }

  .app-main-header {
    padding: 1.1rem 1.1rem;
  }

  .app-main > .settings-dashboard,
  .app-main > .app-main-body,
  .app-main > section,
  .app-main > p {
    padding-left: 1.1rem;
    padding-right: 1.1rem;
  }

  .config-summary-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .developer-details-list > div {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}
