/* LuminaSync, accès à distance : feuille de style de la page du téléphone.
   Couleurs, espacements, rayons et tailles de texte : uniquement les jetons de theme.css
   (générés depuis app/ui/theme.slint). Les mesures propres au téléphone en sont dérivées ici. */

:root {
  --touch: calc(var(--e4) * 2 + var(--e3));
  --e5: calc(var(--e4) + var(--e2));
  --e6: calc(var(--e4) * 2);
  --topbar: calc(var(--touch) + var(--e2));
  --tabbar: calc(var(--touch) + var(--e3));
  --content-max: calc(var(--e4) * 40);
  --icon: calc(var(--e4) + var(--e1) + var(--e1) / 2);
  --icon-small: var(--e4);
  --line: var(--border-width) solid var(--border);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  --ease: var(--t-dur) ease-out;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-left: env(safe-area-inset-left, 0);
  --safe-right: env(safe-area-inset-right, 0);
  --tint: color-mix(in srgb, var(--acc) calc(var(--settings-active-alpha) * 100%), transparent);
  --hover: color-mix(in srgb, var(--txt) calc(var(--settings-hover-alpha) * 100%), transparent);
  --vvh: 100dvh;
}

[hidden] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body { overflow: hidden; }

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--acc); }

:focus-visible { outline: var(--focus-ring) solid var(--acc); outline-offset: var(--border-width); }

.app {
  display: flex;
  flex-direction: column;
  height: var(--vvh);
  max-height: 100dvh;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* ---- Screen: top bar, scrolling content, tab bar ---- */

.screen { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: var(--e2);
  min-height: calc(var(--topbar) + var(--safe-top));
  padding: var(--safe-top) var(--e2) 0;
  background: var(--panel);
  border-bottom: var(--line);
  flex: none;
}

.topbar h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .side { display: flex; align-items: center; min-width: var(--touch); }
.topbar .side.end { justify-content: flex-end; }

.topbar .subtitle { display: block; font-size: var(--text-small); font-weight: 400; color: var(--gray); }

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--e4) var(--e4) calc(var(--e6) + var(--safe-bottom));
}

.content > * { max-width: var(--content-max); margin-left: auto; margin-right: auto; }

.screen.with-tabs .content { padding-bottom: var(--e6); }

.tabbar {
  display: flex;
  flex: none;
  background: var(--panel);
  border-top: var(--line);
  padding-bottom: var(--safe-bottom);
}

.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--e1);
  min-height: var(--tabbar);
  border: 0;
  background: none;
  color: var(--gray);
  font-size: var(--text-small);
  position: relative;
  cursor: pointer;
}

.tabbar button[aria-selected="true"] { color: var(--acc); }

.tabbar .badge { position: absolute; top: var(--e1); left: calc(50% + var(--e2)); }

/* ---- Buttons ---- */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--soft);
  cursor: pointer;
  transition: background var(--ease);
}

.icon-btn:active { background: var(--hover); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--e2);
  min-height: var(--touch);
  padding: 0 var(--e4);
  border: var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--txt);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ease), opacity var(--ease), transform var(--ease);
  -webkit-user-select: none;
  user-select: none;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.btn.danger { background: none; border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: none; border-color: transparent; color: var(--acc); }
.btn.small { min-height: var(--button-height); padding: 0 var(--e3); font-size: var(--text-body); }
.btn.block { display: flex; width: 100%; }

.btn-row { display: flex; gap: var(--e2); flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; white-space: nowrap; }
.spaced { margin-top: var(--e3); }

/* ---- Cards and lists ---- */

.section-title {
  margin: var(--e5) var(--e1) var(--e2);
  font-size: var(--text-small);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray);
}

.section-title:first-child { margin-top: 0; }

.card {
  background: var(--panel);
  border: var(--line);
  border-radius: var(--radius-large);
  padding: var(--e4);
}

.card + .card { margin-top: var(--e3); }

.card h2 { margin: 0 0 var(--e1); font-size: var(--text-base); font-weight: 600; }

.muted { color: var(--gray); }
.small { font-size: var(--text-body); }
.tiny { font-size: var(--text-small); }

.list {
  background: var(--panel);
  border: var(--line);
  border-radius: var(--radius-large);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--e3);
  width: 100%;
  min-height: calc(var(--touch) + var(--e2));
  padding: var(--e2) var(--e4);
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
}

.row + .row { border-top: var(--line); }
button.row { cursor: pointer; }
button.row:active { background: var(--hover); }

.row .grow { flex: 1; min-width: 0; }
.row .title { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { display: block; font-size: var(--text-body); color: var(--gray); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { color: var(--faint); flex: none; }
.row .lead { color: var(--soft); flex: none; display: inline-flex; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--e3);
  padding: var(--e6) var(--e4);
  text-align: center;
  color: var(--gray);
}

.empty .empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--empty-icon);
  height: var(--empty-icon);
  border-radius: 50%;
  background: var(--card);
  color: var(--soft);
}

/* ---- States ---- */

.dot { width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--faint); flex: none; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.wait { background: var(--waiting); }
.dot.err { background: var(--danger); }
.dot.acc { background: var(--acc); }

.status-line { display: inline-flex; align-items: center; gap: var(--e2); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: calc(var(--e4) + var(--e1));
  height: calc(var(--e4) + var(--e1));
  padding: 0 var(--e1);
  border-radius: calc(var(--e4) + var(--e1));
  background: var(--waiting);
  color: var(--on-waiting);
  font-size: var(--text-small);
  font-weight: 700;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--e1);
  padding: 0 var(--e2);
  min-height: calc(var(--e4) + var(--e2));
  border-radius: var(--radius-small);
  background: var(--card);
  color: var(--soft);
  font-size: var(--text-small);
}

.chip.wait { background: var(--waiting); color: var(--on-waiting); }
.chip.ok { color: var(--ok-text); }

.progress {
  height: var(--e1);
  border-radius: var(--e1);
  background: var(--card);
  overflow: hidden;
  margin-top: var(--e2);
}

.progress > span { display: block; height: 100%; background: var(--acc); transition: width var(--ease); }

.banner {
  display: flex;
  align-items: center;
  gap: var(--e3);
  padding: var(--e3) var(--e4);
  background: var(--acc-dark);
  border-bottom: var(--border-width) solid var(--acc-border);
  color: var(--txt);
  font-size: var(--text-body);
  flex: none;
}

.banner .grow { flex: 1; }
.banner.warn { background: var(--card); border-color: var(--waiting); }

.agent { display: inline-block; width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--agent-term); }
.agent[data-ia="claude"] { background: var(--agent-claude); }
.agent[data-ia="codex"] { background: var(--agent-codex); }
.agent[data-ia="antigravity"], .agent[data-ia="agy"], .agent[data-ia="gemini"] { background: var(--agent-agy); }
.agent[data-ia="opencode"] { background: var(--agent-opencode); }

/* ---- Forms ---- */

.field { display: block; margin-top: var(--e3); }
.field:first-child { margin-top: 0; }
.field > span { display: block; margin-bottom: var(--e1); font-size: var(--text-body); color: var(--soft); }

input[type="text"], input:not([type]), textarea, select {
  width: 100%;
  min-height: var(--touch);
  padding: var(--e2) var(--e3);
  border: var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--txt);
  font-size: var(--text-base);
  transition: border-color var(--ease);
}

textarea { resize: vertical; min-height: calc(var(--touch) * 2); line-height: 1.4; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--acc); }
input::placeholder, textarea::placeholder { color: var(--faint); }

.code-input {
  font-family: var(--mono);
  font-size: var(--text-xl);
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.segmented {
  display: flex;
  gap: var(--e1);
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--e1);
}

.segmented button {
  flex: 1;
  min-height: var(--button-height);
  border: 0;
  border-radius: var(--radius-small);
  background: none;
  color: var(--soft);
  font-size: var(--text-body);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.segmented button[aria-pressed="true"] { background: var(--panel); color: var(--txt); box-shadow: 0 var(--border-width) var(--e1) var(--shadow); }

.switch {
  position: relative;
  flex: none;
  width: calc(var(--touch) + var(--e2));
  height: calc(var(--e4) * 2 - var(--e1));
  border: 0;
  border-radius: var(--e4);
  background: var(--border-light);
  cursor: pointer;
  transition: background var(--ease);
}

.switch::after {
  content: '';
  position: absolute;
  top: calc(var(--e1) / 2);
  left: calc(var(--e1) / 2);
  width: calc(var(--e4) * 2 - var(--e1) * 2);
  height: calc(var(--e4) * 2 - var(--e1) * 2);
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 var(--border-width) var(--e1) var(--shadow);
  transition: transform var(--ease);
}

.switch[aria-checked="true"] { background: var(--acc); }
.switch[aria-checked="true"]::after { transform: translateX(calc(var(--touch) + var(--e2) - var(--e4) * 2 + var(--e1))); }

.choice-list .row { cursor: pointer; }
.choice-list .row[aria-checked="true"] .check { visibility: visible; }
.choice-list .check { visibility: hidden; color: var(--acc); }

.swatch {
  width: calc(var(--e4) + var(--e2));
  height: calc(var(--e4) + var(--e2));
  border-radius: 50%;
  border: var(--line);
  flex: none;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.swatch::after { content: ''; position: absolute; inset: 50% 0 0 50%; background: var(--acc); }

/* ---- Home ---- */

.brand { display: flex; align-items: center; gap: var(--e3); margin: var(--e2) 0 var(--e5); }
.brand img { width: var(--touch); height: var(--touch); border-radius: var(--radius); }
.brand h2 { margin: 0; font-size: var(--text-xl); font-weight: 700; }

/* ---- Pairing ---- */

.hero { text-align: center; padding: var(--e5) 0 var(--e4); }
.hero h2 { margin: var(--e3) 0 var(--e2); font-size: var(--text-xl); }
.hero p { margin: 0; color: var(--soft); }
.hero img { width: calc(var(--touch) * 2); height: calc(var(--touch) * 2); border-radius: var(--radius-large); }

.verification {
  margin: var(--e5) 0;
  font-family: var(--mono);
  font-size: calc(var(--text-xl) * 2);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--acc);
}

.spinner {
  width: var(--e5);
  height: var(--e5);
  border: var(--stripe) solid var(--border-light);
  border-top-color: var(--acc);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.or { display: flex; align-items: center; gap: var(--e3); margin: var(--e5) 0; color: var(--faint); font-size: var(--text-body); }
.or::before, .or::after { content: ''; flex: 1; border-top: var(--line); }

.scanner {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--scanner-bg);
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.scanner video { flex: 1; min-height: 0; width: 100%; object-fit: cover; }

.scanner .frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64vmin;
  height: 64vmin;
  transform: translate(-50%, -50%);
  border: var(--stripe) solid var(--acc);
  border-radius: var(--radius-large);
  box-shadow: 0 0 0 100vmax var(--shadow);
  pointer-events: none;
}

.scanner .bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--e3);
  padding: var(--e4) var(--e4) calc(var(--e5) + var(--safe-bottom));
  color: var(--scanner-text);
  text-align: center;
}

/* ---- Install guide ---- */

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }

.steps li {
  display: flex;
  gap: var(--e3);
  align-items: flex-start;
  padding: var(--e3) 0;
  counter-increment: step;
}

.steps li + li { border-top: var(--line); }

.steps li::before {
  content: counter(step);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--e5);
  height: var(--e5);
  border-radius: 50%;
  background: var(--acc-dark);
  border: var(--border-width) solid var(--acc-border);
  color: var(--acc);
  font-size: var(--text-body);
  font-weight: 700;
}

.steps .inline-icon { display: inline-flex; vertical-align: middle; color: var(--acc); }

.note {
  margin-top: var(--e4);
  padding: var(--e3) var(--e4);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--soft);
  font-size: var(--text-body);
}

/* ---- PC view ---- */

.project-head { display: flex; align-items: center; gap: var(--e3); }
.project-head .grow { flex: 1; min-width: 0; }
.project-head .name { font-size: var(--text-title); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.kv { display: flex; align-items: center; justify-content: space-between; gap: var(--e3); min-height: var(--touch); }
.kv + .kv { border-top: var(--line); }
.kv select { width: auto; min-width: calc(var(--e4) * 8); }

.notif .when { font-size: var(--text-small); color: var(--faint); flex: none; }

/* ---- Agents, statistiques, capture de Studio ---- */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--e2); margin-top: var(--e3); }
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--e1);
  padding: var(--e3) var(--e2);
  border: var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--txt);
  cursor: pointer;
  text-align: center;
}
.stat .n { font-size: var(--text-xl); font-weight: 700; line-height: 1; }
.stat .l { font-size: var(--text-small); color: var(--gray); }
.stat.alert { border-color: var(--waiting); }
.stat.alert .n { color: var(--waiting-text); }

.agent-card .head { display: flex; align-items: center; gap: var(--e2); }
.agent-card .head .title { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.agent-card .activity { margin: var(--e2) 0 0; overflow-wrap: anywhere; }
.steps-list { list-style: none; margin: var(--e2) 0 0; padding: 0; }
.step { display: flex; gap: var(--e2); padding: var(--e1) 0; font-size: var(--text-body); color: var(--soft); overflow-wrap: anywhere; }
.step .mark { flex: none; width: var(--e4); text-align: center; color: var(--faint); }
.step.fait .mark { color: var(--ok-text); }
.step.en_cours .mark { color: var(--acc); }
.step.bloque .mark { color: var(--waiting-text); }
.step.fait { color: var(--gray); }
.milestone { display: flex; align-items: center; gap: var(--e2); margin: var(--e2) 0 0; color: var(--ok-text); font-size: var(--text-body); }
.row .sub.wrap { white-space: normal; overflow-wrap: anywhere; }
.center { text-align: center; }
.project-head .name, .project-head .small { display: block; }
.field + .card { margin-top: var(--e3); }

.capture { display: block; width: 100%; height: auto; border: var(--line); border-radius: var(--radius); background: var(--card); }

/* ---- Sheets, dialogs, toasts ---- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--shadow);
  animation: fade var(--ease);
}

.sheet {
  width: 100%;
  max-width: var(--content-max);
  max-height: 85dvh;
  overflow-y: auto;
  padding: var(--e4) var(--e4) calc(var(--e4) + var(--safe-bottom));
  background: var(--panel);
  border: var(--line);
  border-bottom: 0;
  border-radius: var(--radius-large) var(--radius-large) 0 0;
  animation: rise var(--ease);
}

.sheet h2 { margin: 0 0 var(--e2); font-size: var(--text-title); }
.sheet p { margin: 0 0 var(--e4); color: var(--soft); }
.sheet .btn-row { margin-top: var(--e4); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(var(--e6)); opacity: 0; } }

.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar) + var(--safe-bottom) + var(--e2));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--e2);
  padding: 0 var(--e4);
  pointer-events: none;
}

.toast {
  max-width: var(--content-max);
  padding: var(--e3) var(--e4);
  border-radius: var(--radius);
  background: var(--card);
  border: var(--border-width) solid var(--border-light);
  box-shadow: 0 var(--e1) var(--e4) var(--shadow);
  color: var(--txt);
  font-size: var(--text-body);
  pointer-events: auto;
  animation: rise var(--ease);
}

.toast.error { border-color: var(--danger); }
.toast.ok { border-color: var(--ok-border); }

svg.icon { width: var(--icon); height: var(--icon); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.icon.small { width: var(--icon-small); height: var(--icon-small); }

.visually-hidden { position: absolute; width: var(--border-width); height: var(--border-width); overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 48em) {
  .content { padding-top: var(--e5); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
