/* Coque de l'application : barre du haut, rail de navigation, vue, télémétrie, écran de démarrage, palette. */

.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: var(--top-h) minmax(0, 1fr) var(--foot-h);
  grid-template-areas: "top top" "rail view" "foot foot";
  background: var(--bg);
  opacity: 0;
  transition: opacity 0.6s var(--ease);
}
.app.ready {
  opacity: 1;
}

/* --- Barre du haut --- */
.topbar {
  grid-area: top;
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 0 0 20px;
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
html[data-os="mac"] .topbar {
  padding-left: 86px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  min-width: 0;
}
.brand-mark {
  width: 30px;
  height: 23px;
  color: var(--fg);
  transition: transform 0.5s var(--spring);
}
.brand:hover .brand-mark {
  transform: skewX(-8deg);
}
.brand-sep {
  width: 1px;
  height: 18px;
  background: var(--line-2);
}
.brand-page {
  font-size: var(--t-13);
  font-weight: 560;
  font-stretch: 108%;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-spacer {
  flex: 1;
  height: 100%;
}
.cmdk-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(440px, 38vw);
  height: 34px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--fg-3);
  font-size: var(--t-13);
  transition: border-color 0.25s var(--ease), color 0.25s var(--ease), background 0.25s var(--ease);
}
.cmdk-trigger:hover {
  border-color: var(--line-3);
  color: var(--fg-2);
  background: var(--haze);
}
.cmdk-trigger .grow {
  text-align: left;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding-right: 14px;
}
html[data-os="windows"] .top-actions {
  padding-right: 4px;
}
.jarvis-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 6px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  font-size: var(--t-13);
  font-weight: 560;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.jarvis-chip canvas {
  width: 26px;
  height: 26px;
}
.jarvis-chip:hover {
  background: var(--inv-bg);
  color: var(--inv-fg);
  border-color: var(--inv-bg);
}
.winctl {
  display: none;
  height: 100%;
}
html[data-os="windows"] .winctl,
html[data-os="linux"] .winctl {
  display: flex;
}
.winctl button {
  width: 46px;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--fg-2);
  transition: background 0.15s, color 0.15s;
}
.winctl button:hover {
  background: var(--haze-2);
  color: var(--fg);
}
.winctl button.close:hover {
  background: var(--inv-bg);
  color: var(--inv-fg);
}
.winctl svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  stroke-width: 1.2;
  fill: none;
}

/* --- Rail de navigation --- */
.rail {
  grid-area: rail;
  position: relative;
  z-index: 25;
}
.rail-inner {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 2px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition: width 0.42s var(--ease-out), box-shadow 0.42s var(--ease-out);
}
.rail.open .rail-inner,
.rail.pinned .rail-inner {
  width: var(--rail-open);
}
.rail.open:not(.pinned) .rail-inner {
  box-shadow: 30px 0 60px rgba(0, 0, 0, 0.45);
}
:root[data-theme="light"] .rail.open:not(.pinned) .rail-inner {
  box-shadow: 30px 0 60px rgba(0, 0, 0, 0.08);
}
.app.rail-pinned {
  grid-template-columns: var(--rail-open) minmax(0, 1fr);
}
.rail-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-sep {
  height: 1px;
  margin: 10px 6px;
  background: var(--line);
  flex: none;
}
.rail-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 44px;
  padding: 0 0 0 12px;
  border-radius: 12px;
  color: var(--fg-2);
  white-space: nowrap;
  z-index: 1;
  transition: color 0.3s var(--ease);
}
.rail-item .ico {
  width: 20px;
  height: 20px;
}
.rail-item:hover {
  color: var(--fg);
}
.rail-item:hover::before {
  opacity: 1;
}
.rail-item::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--haze-2);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  z-index: -1;
}
.rail-item.active {
  color: var(--inv-fg);
}
.rail-item.active::before {
  opacity: 0;
}
.rail-label {
  font-size: var(--t-13);
  font-weight: 560;
  font-stretch: 106%;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.3s var(--ease), transform 0.4s var(--ease-out);
}
.rail.open .rail-label,
.rail.pinned .rail-label {
  opacity: 1;
  transform: none;
}
.rail.open .rail-item:nth-child(2) .rail-label { transition-delay: 0.02s; }
.rail.open .rail-item:nth-child(3) .rail-label { transition-delay: 0.04s; }
.rail.open .rail-item:nth-child(4) .rail-label { transition-delay: 0.06s; }
.rail.open .rail-item:nth-child(5) .rail-label { transition-delay: 0.08s; }
.rail-lens {
  position: absolute;
  left: 12px;
  top: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--inv-bg);
  z-index: 0;
  pointer-events: none;
  transition: transform 0.55s var(--spring), width 0.42s var(--ease-out), opacity 0.3s;
}
.rail.open .rail-lens,
.rail.pinned .rail-lens {
  width: calc(var(--rail-open) - 24px);
}
.rail-bottom {
  margin-top: auto;
}
.rail-badge {
  position: absolute;
  left: 34px;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 2px var(--bg);
}

/* --- Vue principale --- */
.view {
  grid-area: view;
  position: relative;
  overflow: hidden;
}
.view-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.page {
  position: relative;
  max-width: 1380px;
  margin: 0 auto;
  padding: 40px 48px 72px;
  min-height: 100%;
}
.page.full {
  max-width: none;
  height: 100%;
  padding: 0;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.page-title {
  --stretch: 120%;
  font-size: clamp(34px, 3.8vw, 52px);
  line-height: 1.02;
  font-weight: 660;
  font-stretch: 120%;
  letter-spacing: -0.028em;
}
.page-sub {
  margin-top: 10px;
  font-size: var(--t-16);
  color: var(--fg-2);
  max-width: 62ch;
}

/* --- Télémétrie (pied) --- */
.telemetry {
  grid-area: foot;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 18px;
  border-top: 1px solid var(--line);
  font-size: var(--t-11);
  font-weight: 520;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.telemetry .t-item {
  display: flex;
  align-items: center;
  gap: 7px;
}
.telemetry .t-item b {
  font-weight: 600;
  color: var(--fg-2);
}
.telemetry .t-bar {
  width: 34px;
  height: 3px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.telemetry .t-bar i {
  position: absolute;
  inset: 0;
  background: var(--fg-2);
  transform-origin: left;
  transform: scaleX(var(--v, 0));
  transition: transform 0.9s var(--ease-out);
}
.telemetry .t-spacer {
  flex: 1;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  flex: none;
}
.dot.on {
  background: currentColor;
}
.dot.live {
  animation: zk-pulse 2.4s var(--ease) infinite;
}
.telemetry button {
  color: inherit;
  display: flex;
  align-items: center;
  gap: 7px;
}
.telemetry button:hover {
  color: var(--fg);
}

/* --- Écran de démarrage --- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.7s var(--ease), visibility 0.7s;
}
.splash.gone {
  opacity: 0;
  visibility: hidden;
}
.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.splash svg {
  width: 132px;
  height: 100px;
  color: var(--fg);
}
.splash svg path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: zk-stroke 0.9s var(--ease-io) forwards;
}
.splash svg path:nth-child(2) {
  animation-delay: 0.45s;
}
.splash svg path:nth-child(3) {
  animation-delay: 0.7s;
}
.splash-line {
  width: 180px;
  height: 1px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.splash-line i {
  position: absolute;
  inset: 0;
  background: var(--fg);
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  transition: transform 0.5s var(--ease-out);
}
.splash-text {
  font-size: var(--t-12);
  color: var(--fg-3);
  font-stretch: 112%;
  letter-spacing: 0.02em;
  min-height: 18px;
}

/* --- Palette de commandes --- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: zk-fade 0.25s var(--ease) both;
}
.palette {
  position: fixed;
  z-index: 121;
  top: 13vh;
  left: 50%;
  width: min(680px, calc(100vw - 48px));
  transform: translateX(-50%);
  background: var(--bg);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: zk-pop 0.32s var(--ease-out) both;
}
.palette-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.palette-input input {
  flex: 1;
  border: 0;
  background: none;
  font-size: var(--t-18);
  font-weight: 480;
  font-stretch: 104%;
}
.palette-input input::placeholder {
  color: var(--fg-4);
}
.palette-list {
  max-height: min(56vh, 520px);
  overflow-y: auto;
  padding: 8px;
}
.palette-group {
  padding: 12px 12px 6px;
  font-size: var(--t-11);
  font-weight: 600;
  color: var(--fg-3);
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: left;
  color: var(--fg-2);
  animation: zk-rise 0.35s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.palette-item .p-title {
  flex: 1;
  color: var(--fg);
  font-weight: 520;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-item .p-hint {
  font-size: var(--t-12);
  color: var(--fg-3);
}
.palette-item.sel {
  background: var(--inv-bg);
  color: var(--inv-fg);
}
.palette-item.sel .p-title,
.palette-item.sel .p-hint {
  color: var(--inv-fg);
}
.palette-item mark {
  background: none;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.palette-foot {
  display: flex;
  gap: 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  font-size: var(--t-11);
  color: var(--fg-3);
}
.palette-result {
  padding: 18px 20px;
  font-size: var(--t-30);
  font-weight: 640;
  font-stretch: 116%;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  animation: zk-rise 0.3s var(--ease-out) both;
}
.palette-result small {
  display: block;
  font-size: var(--t-12);
  font-weight: 500;
  color: var(--fg-3);
  letter-spacing: 0;
  font-stretch: 100%;
}
