/**
 * Alpha Engine / Gallery shell for pkm.engine.cleaner
 * Derived from 02-pkm-alpha-engine/app/globals.css (LFIQ gallery surfaces).
 */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,600&display=swap");

:root {
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Source Serif 4", ui-serif, Georgia, serif;
  --lfiq-surface-high: #1e2338;
  --lfiq-ink-strong: #e4e8f7;
  --lfiq-radius-panel: 18px;
  --lfiq-radius-card: 14px;
  --lfiq-shadow-elevated:
    0 1px 0 rgba(173, 198, 255, 0.04) inset,
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 20px 48px -12px rgba(0, 0, 0, 0.5);
  --lfiq-shadow-card:
    0 1px 0 rgba(173, 198, 255, 0.03) inset,
    0 1px 3px rgba(0, 0, 0, 0.25),
    0 10px 28px -8px rgba(0, 0, 0, 0.35);
}

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

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--lfiq-bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(77, 124, 255, 0.08), transparent 52%),
    linear-gradient(175deg, #0c0f1a 0%, #111421 38%, #141825 100%);
  color: var(--lfiq-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
.ae-font-display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--lfiq-ink-strong);
}

a {
  color: var(--lfiq-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--lfiq-primary-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

code {
  font-size: 0.9em;
  color: var(--lfiq-text);
}

.ae-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.ae-topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0 1.35rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(173, 198, 255, 0.1);
}

.ae-topnav-brand {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--lfiq-ink-strong);
}

.ae-topnav-title {
  line-height: 1.2;
}

.ae-topnav-by {
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--lfiq-text-secondary);
}

a.ae-topnav-brand {
  text-decoration: none;
  color: inherit;
}

a.ae-topnav-brand:hover {
  color: var(--lfiq-primary);
  text-decoration: none;
}

.ae-topnav-current {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--lfiq-text-secondary);
}

.ae-hero-panel {
  position: relative;
  padding: 2rem 2rem 2.15rem;
  margin-bottom: 2.75rem;
  background: linear-gradient(180deg, #141825 0%, #1a1f30 100%);
  border: 1px solid rgba(173, 198, 255, 0.1);
  border-radius: var(--lfiq-radius-panel);
  box-shadow: var(--lfiq-shadow-elevated);
  overflow: hidden;
}

.ae-hero-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--lfiq-primary) 0%,
    #6b93ff 42%,
    rgba(77, 124, 255, 0.2) 100%
  );
}

.ae-hero-panel .ae-header {
  margin-bottom: 0;
}

.ae-header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.85rem, 4vw, 2.35rem);
  font-weight: 600;
  line-height: 1.15;
}

.ae-gallery-kicker {
  margin: 0 0 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--lfiq-primary);
}

.ae-gallery-lede {
  max-width: 62ch;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--lfiq-text);
}

#pml-status-line {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  color: var(--lfiq-text-secondary);
  border: 1px solid color-mix(in srgb, var(--lfiq-border) 100%, transparent);
  border-radius: var(--lfiq-radius);
  background: rgba(30, 35, 56, 0.85);
}

.ae-hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 0.85rem;
  margin: 1.65rem 0 0;
}

.ae-hero-stat {
  padding: 1rem 1.15rem;
  background: var(--lfiq-surface-muted);
  border: 1px solid var(--lfiq-border);
  border-radius: 12px;
}

.ae-hero-stat dt {
  margin: 0 0 0.3rem;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--lfiq-text-secondary);
}

.ae-hero-stat dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--lfiq-primary);
  line-height: 1.2;
  word-break: break-word;
}

.ae-gallery-section {
  margin-bottom: 2rem;
  padding: 1.75rem 1.85rem 2rem;
  background: var(--lfiq-surface);
  border: 1px solid var(--lfiq-border);
  border-radius: var(--lfiq-radius-panel);
  box-shadow: var(--lfiq-shadow-card);
}

.ae-section-head {
  margin-bottom: 1.35rem;
}

.ae-section-title {
  margin: 0 0 0.45rem;
  font-size: clamp(1.2rem, 2.5vw, 1.45rem);
  font-weight: 600;
  line-height: 1.25;
}

.ae-section-lede {
  margin: 0 0 0.5rem;
  color: var(--lfiq-text-secondary);
  max-width: 70ch;
  font-size: 0.95rem;
}

.ae-topnav-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(173, 198, 255, 0.12);
}

.ae-topnav-tabs button {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  color: var(--lfiq-text-secondary);
  background: none;
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.ae-topnav-tabs button:hover {
  color: var(--lfiq-text);
  background: rgba(173, 198, 255, 0.06);
}

.ae-topnav-tabs button[aria-selected="true"] {
  color: var(--lfiq-primary);
  background: rgba(173, 198, 255, 0.08);
}

.ae-topnav-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0.5rem;
  right: 0.5rem;
  height: 2px;
  background: var(--lfiq-primary);
  border-radius: 2px 2px 0 0;
}

.pec-panel[hidden] {
  display: none !important;
}

.ae-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.35rem;
  background: linear-gradient(180deg, rgba(22, 28, 42, 0.94) 0%, rgba(16, 21, 33, 0.94) 100%);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: var(--lfiq-radius-card);
  box-shadow: var(--lfiq-shadow-card);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.ae-card:hover {
  border-color: rgba(20, 184, 166, 0.42);
  box-shadow:
    0 1px 0 rgba(148, 163, 184, 0.07) inset,
    0 4px 16px rgba(20, 184, 166, 0.1),
    0 16px 40px -12px rgba(0, 0, 0, 0.35);
  transform: translateY(-1px);
}

.ae-card h3,
.ae-card h4 {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-sans);
}

.pec-grid-3 {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .pec-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pec-muted {
  color: var(--lfiq-text-secondary);
  font-size: 0.875rem;
}

.pec-text-warn {
  color: var(--lfiq-warning);
}

.pec-field {
  margin-bottom: 1rem;
}

.pec-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--lfiq-text-secondary);
  margin-bottom: 0.35rem;
}

.pec-input,
.pec-select {
  width: 100%;
  max-width: 36rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--lfiq-border);
  border-radius: var(--lfiq-radius);
  background: var(--lfiq-surface-muted);
  font: inherit;
  color: var(--lfiq-text);
}

.pec-input:focus,
.pec-select:focus {
  outline: 2px solid var(--lfiq-primary-muted);
  border-color: var(--lfiq-primary);
}

.pec-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.pec-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  background: linear-gradient(135deg, var(--pkm-primary-container) 0%, var(--pkm-primary) 100%);
  color: #fff !important;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(77, 124, 255, 0.45);
  cursor: pointer;
  font: inherit;
  margin-top: 0.5rem;
}

.pec-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  background: var(--lfiq-surface-high);
  color: var(--lfiq-text);
  border: 1px solid var(--lfiq-border);
  border-radius: var(--lfiq-radius);
  cursor: pointer;
  font: inherit;
}

.pec-file-label {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px dashed rgba(173, 198, 255, 0.35);
  border-radius: var(--lfiq-radius);
  background: rgba(30, 35, 56, 0.5);
  cursor: pointer;
  font-size: 0.875rem;
}

.pec-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.pec-activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 18rem;
  overflow-y: auto;
}

.pec-activity-list li {
  border-bottom: 1px solid rgba(173, 198, 255, 0.12);
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
}

/* Workflow diagram: shape language — circles = sources, rounded rects = steps, chamfered = outputs */
.pec-flow-diagram {
  margin: 1.5rem 0 2rem;
  padding: 1.25rem 1rem 1.5rem;
  border-radius: var(--lfiq-radius-panel);
  border: 1px solid rgba(173, 198, 255, 0.1);
  background: linear-gradient(165deg, rgba(18, 22, 34, 0.92) 0%, rgba(14, 17, 28, 0.96) 100%);
}

.pec-flow-diagram-main {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .pec-flow-diagram-main {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
  }
}

.pec-flow-stage {
  flex: 1;
  min-width: 0;
}

.pec-flow-stage--classifier {
  flex: 1.15;
  display: flex;
  flex-direction: column;
  min-width: min(100%, 22rem);
}

.pec-flow-col-title {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--lfiq-text-secondary);
  margin-bottom: 0.65rem;
}

.pec-flow-col-title--outputs {
  text-align: left;
  margin: 0.35rem 0 0.65rem;
}

.pec-flow-source-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .pec-flow-source-stack {
    gap: 0.85rem;
  }
}

/* Brand pill on every node */
.pec-flow-brand {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  z-index: 2;
  padding: 0.12rem 0.38rem;
  border-radius: 6px;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(228, 232, 247, 0.95);
  background: linear-gradient(135deg, rgba(77, 124, 255, 0.55), rgba(64, 196, 170, 0.35));
  border: 1px solid rgba(173, 198, 255, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* Connection ports (node graph sockets) */
.pec-flow-port {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #2a3148, #141825);
  border: 2px solid rgba(173, 198, 255, 0.55);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 1px 3px rgba(0, 0, 0, 0.45);
  z-index: 3;
}

.pec-flow-port--in {
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.pec-flow-port--out {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.pec-flow-port--out-bottom {
  right: auto;
  left: 50%;
  top: auto;
  bottom: -6px;
  transform: translateX(-50%);
}

/* Source = circle */
.pec-flow-node--source {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
}

.pec-flow-source-ring {
  position: relative;
  width: 5.5rem;
  height: 5.5rem;
  flex-shrink: 0;
}

.pec-flow-node-shape {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(173, 198, 255, 0.38);
  background: radial-gradient(circle at 35% 30%, rgba(48, 58, 88, 0.95), rgba(22, 26, 40, 0.98));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 12px 28px -8px rgba(0, 0, 0, 0.55);
}

.pec-flow-node--source .pec-flow-brand {
  right: -0.15rem;
  top: -0.15rem;
}

.pec-flow-node--source .pec-flow-port--out {
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
}

.pec-flow-node--source .pec-flow-node-body {
  margin-top: 0.6rem;
  max-width: 14rem;
}

.pec-flow-node-body strong {
  display: block;
  font-size: 0.8125rem;
  margin-bottom: 0.2rem;
  color: var(--lfiq-ink-strong);
}

.pec-flow-node-body > span {
  display: block;
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--lfiq-text-secondary);
}

/* Step = rounded rectangle (processing) */
.pec-flow-node--step {
  position: relative;
  border-radius: 14px;
  border: 1px solid var(--lfiq-border);
  background: rgba(26, 31, 48, 0.9);
  padding: 0.85rem 1.1rem 0.85rem 1.25rem;
  margin: 0;
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

.pec-flow-node--step .pec-flow-brand {
  top: 0.4rem;
  right: 0.5rem;
}

.pec-flow-node--step-primary {
  border-color: rgba(77, 124, 255, 0.42);
  background: linear-gradient(160deg, rgba(36, 44, 72, 0.95), rgba(22, 26, 40, 0.98));
}

.pec-flow-node--step-tertiary {
  border-color: rgba(64, 196, 170, 0.38);
  background: linear-gradient(165deg, rgba(28, 42, 44, 0.95), rgba(18, 22, 34, 0.98));
}

/* Output = chamfered “bucket” (distinct from steps) */
.pec-flow-node--output {
  position: relative;
  padding: 1rem 1.1rem 0.85rem;
  margin: 0;
  border: 1px solid rgba(173, 198, 255, 0.22);
  background: rgba(20, 24, 37, 0.92);
  clip-path: polygon(0 10px, 10px 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
  box-shadow: 0 10px 32px -14px rgba(0, 0, 0, 0.55);
}

.pec-flow-node--output .pec-flow-brand {
  top: 0.55rem;
  right: 0.55rem;
}

.pec-flow-node--output .pec-flow-port--in {
  left: 50%;
  top: -6px;
  transform: translateX(-50%);
}

.pec-flow-node--output-safe {
  border-color: rgba(82, 196, 120, 0.45);
  background: linear-gradient(175deg, rgba(24, 42, 34, 0.55), rgba(18, 22, 34, 0.96));
}

.pec-flow-node--output-risk {
  border-color: rgba(255, 107, 107, 0.42);
  background: linear-gradient(175deg, rgba(48, 28, 32, 0.45), rgba(22, 18, 24, 0.96));
}

.pec-flow-output-list {
  margin: 0.5rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.6875rem;
  line-height: 1.45;
}

/* Horizontal connectors between main stages */
.pec-flow-connector--h {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  flex-shrink: 0;
  position: relative;
}

@media (min-width: 1024px) {
  .pec-flow-connector--h {
    width: 2.75rem;
    min-height: auto;
    align-self: center;
    padding-top: 1.75rem;
  }

  .pec-flow-connector--h::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    margin-top: 0.875rem;
    background: linear-gradient(90deg, transparent, rgba(173, 198, 255, 0.35), rgba(173, 198, 255, 0.5));
    border-radius: 1px;
  }

  .pec-flow-connector--h::after {
    content: "";
    position: absolute;
    right: 2px;
    top: 50%;
    margin-top: 0.65rem;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid rgba(173, 198, 255, 0.55);
  }
}

.pec-flow-connector-label {
  font-size: 0.5625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--lfiq-text-secondary);
  position: relative;
  z-index: 1;
}

@media (min-width: 1024px) {
  .pec-flow-connector-label {
    position: absolute;
    top: 0.25rem;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
  }
}

/* Fork: classifier → two outputs */
.pec-flow-fork {
  width: 100%;
  margin: 0.25rem 0 0.1rem;
  color: rgba(173, 198, 255, 0.45);
}

.pec-flow-fork-svg {
  display: block;
  width: 100%;
  height: 3.25rem;
}

.pec-flow-fork-path {
  stroke: currentColor;
}

.pec-flow-outputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 0.25rem;
}

@media (min-width: 768px) {
  .pec-flow-outputs {
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: stretch;
  }
}

.pec-grid-2 {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .pec-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.pec-border-risk {
  border-color: rgba(255, 107, 107, 0.35) !important;
}

.ae-gallery-footer {
  margin-top: 2.5rem;
  padding: 1.25rem 1.35rem;
  border-radius: var(--lfiq-radius-card);
  border: 1px dashed rgba(173, 198, 255, 0.12);
  background: rgba(20, 24, 37, 0.6);
  font-size: 0.8125rem;
  color: var(--lfiq-text-secondary);
}

.ae-gallery-footer p {
  margin: 0;
  max-width: 75ch;
}

/* Cloud storage tab */
.pec-cloud-card h3,
.pec-cloud-card h4 {
  margin-top: 0;
}

.pec-cloud-config {
  margin: 0.75rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(173, 198, 255, 0.12);
  background: rgba(10, 12, 20, 0.65);
  font-size: 0.75rem;
  line-height: 1.45;
  overflow: auto;
  max-height: 220px;
  color: var(--lfiq-text-secondary);
}

.pec-cloud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.pec-cloud-live {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
  font-size: 0.8125rem;
}

.pec-cloud-live li {
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(173, 198, 255, 0.06);
}

.pec-cloud-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.pec-cloud-thumb {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(173, 198, 255, 0.1);
  background: rgba(10, 12, 20, 0.5);
}

.pec-cloud-thumb img {
  display: block;
  width: 100%;
  height: 100px;
  object-fit: cover;
}

.pec-cloud-thumb-caption {
  font-size: 0.625rem;
  padding: 0.35rem 0.4rem;
  color: var(--lfiq-text-secondary);
  word-break: break-all;
  max-height: 3.2em;
  overflow: hidden;
}
