:root {
  --navy: #101827;
  --navy-soft: #1b2a3d;
  --blue: #d8792f;
  --red: #a3161c;
  --ink: #18232d;
  --muted: #5e6a73;
  --line: rgba(16, 24, 39, 0.12);
  --paper: rgba(255,255,255,0.92);
  --wash: #eef0f2;
  --gold: #d9a65f;
  --shadow: rgba(16,24,39,0.16);
  --panel-surface: rgba(15, 22, 31, 0.72);
  --panel-line: rgba(255,255,255,0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(10, 14, 20, 0.88), rgba(20, 28, 38, 0.9)),
    radial-gradient(circle at top left, rgba(216, 121, 47, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(117, 157, 196, 0.18), transparent 32%),
    linear-gradient(135deg, #0b1016 0%, #111b28 38%, #1b2a3a 100%);
  color: var(--ink);
  font: 15px/1.55 system-ui,-apple-system,"Segoe UI",sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255,255,255,0.025), rgba(255,255,255,0.015)),
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,0.025),
      rgba(255,255,255,0.025) 1px,
      transparent 1px,
      transparent 5px
    );
  pointer-events: none;
}

img { max-width: 100%; display: block; }

button, input, select, textarea {
  font: inherit;
}

.site-shell {
  min-height: 100vh;
  position: relative;
}

.site-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.12));
  pointer-events: none;
}

.app-header {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 24px 18px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-home-link {
  color: inherit;
  text-decoration: none;
}

.brand-home-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 6px;
  border-radius: 4px;
}

.brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(135deg, var(--gold), #f8d09c 30%, #9d5b1f 100%);
  color: var(--navy);
  box-shadow: 0 14px 28px rgba(0,0,0,0.2), inset 0 0 0 2px rgba(255,255,255,0.35);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.save-confirmation {
  position: fixed;
  z-index: 1000;
  right: 24px;
  bottom: 24px;
  padding: 12px 18px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: #17232c;
  color: #fff;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
  font-weight: 800;
}

.save-confirmation[hidden] {
  display: none;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.app-header h1 {
  margin: 0;
  color: #f4f6f8;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 0.6rem 0 0;
  color: rgba(228,232,236,0.82);
}

.header-actions,
.dialog-actions,
.action-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.header-actions[hidden] {
  display: none;
}

.button {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), #b15e1f);
  color: #fff;
  padding: 10px 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(184, 95, 34, 0.22);
  transition: box-shadow 0.15s ease, filter 0.15s ease;
}

.button:hover {
  filter: brightness(1.04);
  box-shadow: 0 14px 28px rgba(184, 95, 34, 0.25);
}

.button.secondary {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.2);
  color: #f7f9fb;
  box-shadow: none;
}

.banner-links {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  padding: 0 24px 14px;
  flex-wrap: wrap;
}

.banner-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.07);
  color: #fcfdff;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(6px);
}

.banner-link:hover {
  background: rgba(255,255,255,0.12);
}

.banner-link::after {
  content: "▾";
  font-size: 10px;
  opacity: 0.8;
}

.tabs {
  background: rgba(11,19,29,0.9);
  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 3px;
  padding: 0 max(24px, calc((100% - 1280px) / 2));
  overflow: auto;
}

.tabs .banner-links {
  max-width: none;
  margin: 0;
  padding: 0;
  gap: 3px;
  flex-wrap: nowrap;
  align-items: stretch;
}

.tabs .banner-link {
  border: 0;
  border-radius: 0;
  padding: 14px 18px;
  background: transparent;
  font: inherit;
  white-space: nowrap;
}

.tabs .banner-link::after {
  content: none;
}

.tabs .banner-link:hover {
  background: rgba(255,255,255,0.92);
  color: var(--navy);
}

.tab {
  border: 0;
  background: transparent;
  color: rgba(230,236,240,0.8);
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab.active,
.tab:hover {
  background: rgba(255,255,255,0.92);
  color: var(--navy);
}

.workspace {
  max-width: 1280px;
  margin: 26px auto 64px;
  padding: 0 24px;
}

.view { display: none; }
.view.active { display: block; }

html[data-initial-view] .view.active { display: none; }
html[data-initial-view="dashboard"] #view-dashboard,
html[data-initial-view="build-sheet"] #view-build-sheet,
html[data-initial-view="walkthroughs"] #view-walkthroughs,
html[data-initial-view="oem-procedures"] #view-oem-procedures,
html[data-initial-view="walkthrough-detail"] #view-walkthrough-detail,
html[data-initial-view="docs"] #view-docs,
html[data-initial-view="gallery"] #view-gallery,
html[data-initial-view="admin"] #view-admin,
html[data-initial-view="admin-access"] #view-admin-access {
  display: block;
}

.hero-card {
  background: linear-gradient(120deg, rgba(17,26,36,0.94), rgba(29,52,74,0.86));
  color: #f0f5f8;
  padding: 30px 30px 26px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 22px;
  border: 1px solid var(--panel-line);
  box-shadow: 0 24px 48px rgba(11,17,24,0.2);
  position: relative;
  overflow: hidden;
}

.hero-card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.28;
  mix-blend-mode: screen;
}

.hero-card > div,
.hero-card > .status {
  position: relative;
  z-index: 1;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(216,121,47,0.08), transparent);
  pointer-events: none;
}

.hero-card h2 {
  margin: 0.25rem 0 0.75rem;
  font-size: clamp(22px, 3vw, 38px);
  letter-spacing: -0.03em;
}

.hero-card p {
  max-width: 760px;
  margin: 0;
  color: rgba(240,245,248,0.8);
}

.hero-card .eyebrow { color: #f3c078; }

.status {
  background: rgba(120,187,136,0.14);
  color: #d6f7dd;
  border: 1px solid rgba(142,211,159,0.35);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.stat-grid article,
.panel,
.record,
.source-card,
.page-editor,
.doc-entry {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 18px 30px rgba(11,17,24,0.04);
  backdrop-filter: blur(4px);
}

.stat-grid strong {
  display: block;
  font-size: clamp(20px, 2vw, 30px);
  color: var(--navy);
}

.stat-grid span {
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.project-panel dt,
.project-panel dd {
  align-self: center;
  line-height: 1.55;
  letter-spacing: normal;
}

.project-panel dt {
  color: var(--dashboard-profile-label-color, #727d84);
  font-size: var(--dashboard-profile-label-size, 12px);
  font-style: var(--dashboard-profile-label-style, normal);
  font-weight: var(--dashboard-profile-label-weight, 800);
  text-transform: none;
}

.project-panel dd {
  color: var(--dashboard-profile-value-color, #3c464d);
  font-size: var(--dashboard-profile-value-size, 12px);
  font-style: var(--dashboard-profile-value-style, normal);
  font-weight: var(--dashboard-profile-value-weight, 400);
}

.panel.project-panel h3 {
  color: var(--dashboard-profile-heading-color, var(--navy));
  font-size: var(--dashboard-profile-heading-size, 15px);
  font-style: var(--dashboard-profile-heading-style, normal);
  font-weight: var(--dashboard-profile-heading-weight, 700);
  letter-spacing: normal;
  text-transform: none;
}

.dashboard-grid .dashboard-quick-actions-card h3 {
  color: var(--dashboard-quick-heading-color, #313a41);
  font-size: var(--dashboard-quick-heading-size, 12px);
  font-style: var(--dashboard-quick-heading-style, normal);
  font-weight: var(--dashboard-quick-heading-weight, 700);
  letter-spacing: normal;
  text-transform: none;
}

.dashboard-quick-actions-card .action-list .button {
  font-size: var(--dashboard-quick-button-size, 11px);
  font-style: var(--dashboard-quick-button-style, normal);
  font-weight: var(--dashboard-quick-button-weight, 800);
  letter-spacing: normal;
  text-transform: none;
}

.dashboard-quick-actions-card .action-list .button:not(.secondary) {
  color: var(--dashboard-quick-button-color, #ffffff);
}

.dashboard-quick-actions-card .action-list .button.secondary {
  color: var(--dashboard-quick-secondary-button-color, #343d44);
}

.dashboard-quick-actions-card #dashboard-link-manifesto {
  background: var(--dashboard-quick-manifesto-background, #a4443b);
}

.dashboard-quick-actions-card #dashboard-link-projects {
  background: var(--dashboard-quick-projects-background, #f8f9f9);
}

.dashboard-quick-actions-card #dashboard-link-docs {
  background: var(--dashboard-quick-docs-background, #f8f9f9);
}

.panel h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: var(--navy);
}

.panel {
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(10, 16, 21, 0.08);
}

dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 16px;
  margin: 0;
}

dt {
  font-weight: 800;
  color: var(--muted);
}

dd {
  margin: 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  color: #f5f7f9;
  font-size: clamp(28px, 3vw, 38px);
  letter-spacing: -0.04em;
}

.section-heading p:not(.eyebrow) {
  margin: 0.4rem 0 0;
  color: rgba(236,240,243,0.8);
}

.page-hero-image {
  height: clamp(260px, 38vw, 420px);
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  background: linear-gradient(120deg, #172637, #33465a);
  box-shadow: 0 20px 38px rgba(0,0,0,0.18);
}

.page-hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(var(--page-image-zoom, 1));
  transform-origin: var(--page-image-origin, center center);
  transition: opacity 500ms ease, transform 180ms ease;
}

.admin-page-hero-image {
  height: clamp(220px, 28vw, 320px);
  margin-top: 18px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.toolbar input,
.toolbar select,
label input,
label textarea,
label select {
  border: 1px solid rgba(16, 24, 39, 0.14);
  border-radius: 8px;
  background: rgba(255,255,255,0.9);
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(15, 19, 24, 0.04);
}

label input:focus,
label textarea:focus,
label select:focus,
.toolbar input:focus,
.toolbar select:focus {
  outline: 2px solid rgba(216, 121, 47, 0.14);
  border-color: rgba(216, 121, 47, 0.46);
}

label {
  display: grid;
  gap: 5px;
  font-weight: 700;
  color: var(--navy);
}

.toolbar input { flex: 1; }

.record-list,
.source-list,
.doc-manager,
.selection-list,
.link-list {
  display: grid;
  gap: 12px;
}

.record {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  transition: box-shadow 0.15s ease;
}

.record:hover {
  box-shadow: 0 18px 28px rgba(11,17,24,0.08);
}

.record h3 {
  margin: 0;
  color: var(--navy);
  font-size: 1.06rem;
}

.record p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.record-meta {
  margin-top: 0.55rem;
  font-size: 12px;
  color: var(--muted);
}

.record-actions {
  display: flex;
  gap: 6px;
  align-items: start;
  flex-wrap: wrap;
}

.record-actions button,
.doc-entry button,
.link-item button,
.selection-item button {
  border: 1px solid var(--line);
  background: rgba(17,27,38,0.02);
  color: var(--navy);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 700;
}

.record-actions button:hover,
.doc-entry button:hover,
.link-item button:hover,
.selection-item button:hover {
  background: rgba(216,121,47,0.05);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  background: rgba(216,121,47,0.1);
  color: #8d4f17;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.record-hidden { opacity: 0.55; }
.record-actions .move { font-weight: 900; }

.source-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.source-card h3 {
  margin: 0 0 5px;
  color: var(--navy);
  font-size: 1rem;
}

.source-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.source-card a,
.mini-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.admin-landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.admin-landing-group-heading {
  grid-column: 1 / -1;
  margin: 12px 0 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  color: rgba(245,247,249,0.82);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.admin-landing-card {
  display: flex;
  min-height: 190px;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255,255,255,0.96), rgba(239,242,244,0.92));
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(0,0,0,0.12);
  transition: box-shadow 0.16s ease, border-color 0.16s ease;
}

.admin-landing-card:hover,
.admin-landing-card:focus-visible {
  border-color: rgba(216,121,47,0.5);
  box-shadow: 0 22px 34px rgba(0,0,0,0.18);
}

.admin-card-kicker {
  color: #9a571f;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.admin-landing-card strong {
  color: var(--navy);
  font-size: 1.2rem;
  line-height: 1.2;
}

.admin-landing-card > span:not(.admin-card-kicker) {
  color: var(--muted);
  font-size: 13px;
}

.admin-landing-card i {
  margin-top: auto;
  color: #9a571f;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.admin-editor-view {
  max-width: 1000px;
  margin: 0 auto;
}

#view-admin-records,
#view-admin-walkthroughs,
#view-admin-oem,
#view-admin-docs,
#view-admin-gallery {
  width: 100%;
  max-width: none;
}

#view-admin-profile {
  width: 100%;
  max-width: none;
  margin: 0;
}

.admin-editor-heading {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 20px;
  margin-bottom: 20px;
}

.admin-editor-heading > .button {
  margin-top: 4px;
}

.admin-editor-heading h2 {
  margin: 0;
  color: #f5f7f9;
  font-size: clamp(28px, 3vw, 38px);
  letter-spacing: -0.04em;
}

.admin-editor-heading p:not(.eyebrow) {
  margin: 0.4rem 0 0;
  color: rgba(236,240,243,0.8);
}

.admin-editor-form {
  max-width: 760px;
}

#view-admin-docs .admin-editor-form,
#view-admin-gallery .admin-editor-form,
#view-admin-profile .admin-editor-form {
  width: 100%;
  max-width: none;
}

.admin-settings-group {
  margin-top: 14px;
  padding: 0;
  overflow: hidden;
}

.admin-settings-group > summary {
  padding: 18px 20px;
  color: var(--navy);
  font-weight: 850;
  cursor: pointer;
}

.admin-settings-group > summary::marker {
  color: #9a571f;
}

.admin-settings-group > p,
.admin-settings-group > form {
  margin: 0 20px 18px;
}

.admin-settings-group > form {
  display: grid;
  gap: 12px;
}

.admin-gallery-sources {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.admin-gallery-sources article {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.68);
}

.admin-gallery-sources h3,
.admin-gallery-sources p {
  margin: 0;
}

.admin-gallery-sources h3 {
  color: var(--navy);
  font-size: 15px;
}

.admin-gallery-sources p {
  color: var(--muted);
  font-size: 13px;
}

.admin-gallery-sources .button {
  margin-top: auto;
}

.admin-record-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-record-toolbar h3 {
  margin: 0;
  color: var(--navy);
}

.doc-entry label {
  font-size: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.page-editor,
.doc-entry,
.link-item,
.selection-item {
  display: grid;
  gap: 10px;
}

.tiny-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-label input { width: auto; }

.page-content-preview {
  display: grid;
  gap: 10px;
}

.page-content-preview-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(16, 24, 39, 0.14);
  border-radius: 12px;
  background: rgba(13, 21, 29, 0.04);
  padding: 12px;
}

.page-content-preview-card strong {
  color: var(--navy);
  font-size: 1rem;
}

.page-content-preview-image {
  height: 180px;
  overflow: hidden;
  border-radius: 8px;
  background: #172637;
}

.page-content-preview-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(var(--page-image-zoom, 1));
  transform-origin: var(--page-image-origin, center center);
  transition: transform 180ms ease;
}

.page-content-preview-empty {
  display: grid;
  min-height: 120px;
  place-items: center;
  border: 1px dashed rgba(16,24,39,0.2);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(16,24,39,0.025);
  font-size: 13px;
}

.page-content-preview-card span {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
}

.page-content-preview-card p {
  margin: 0;
  color: var(--muted);
}

dialog {
  border: 0;
  border-radius: 14px;
  width: min(640px, calc(100% - 30px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  box-shadow: 0 30px 90px rgba(0,0,0,0.28);
  background: #f8f9fb;
  border: 1px solid rgba(16,24,39,0.08);
}

dialog::backdrop {
  background: rgba(10, 16, 21, 0.72);
}

#record-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialog-heading h2 { margin: 0; color: var(--navy); }

.icon-button {
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--navy);
}

@media (max-width: 760px) {
  .app-header {
    display: block;
  }

  .header-actions {
    margin-top: 16px;
  }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid,
  .admin-grid { grid-template-columns: 1fr; }
  .hero-card {
    display: block;
  }

  .record {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
  }

  .section-heading {
    display: block;
  }

  .admin-editor-heading {
    grid-template-columns: 1fr;
  }

  .admin-record-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
