/* Page du téléphone (étape 214) : mêmes couleurs que Jaris sur le PC (jetons --hud-* de src/index.css). */
:root {
  --bg: #01040a;
  --panel: #061019;
  --raised: rgba(12, 28, 44, 0.75);
  --text: #e6f7ff;
  --soft: #a9cfe8;
  --faint: #4f7391;
  --accent: #3ddcff;
  --accent-rgb: 61, 220, 255;
  --line: rgba(61, 220, 255, 0.22);
  --danger: #ff4d68;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  background: radial-gradient(ellipse at 50% 0%, rgba(var(--accent-rgb), 0.12), transparent 60%), var(--bg);
}

[hidden] {
  display: none !important;
}

.button {
  border: 1px solid rgba(var(--accent-rgb), 0.6);
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 12px;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.5;
}

.error {
  color: var(--danger);
  margin: 0;
}

/* Orbe : le vrai logo de Jaris (anneau irrégulier), qui respire ; plus vite pendant que Jaris travaille. */
.orb {
  width: 38px;
  height: 38px;
  flex: none;
  filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.45));
  animation: breathe 3.2s ease-in-out infinite;
}

.orb--big {
  width: 150px;
  height: 150px;
}

.orb--busy {
  animation: spin 2.4s linear infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.93);
    opacity: 0.85;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .orb--busy {
    animation: none;
  }
}

/* Appairage */
.pair {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
}

.pair h1 {
  margin: 8px 0 0;
  font-size: 30px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.pair__lead {
  margin: 0;
  font-size: 18px;
}

.pair__hint {
  margin: 0;
  color: var(--soft);
  max-width: 340px;
}

.pair__form {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}

.pair__code::placeholder {
  color: var(--faint);
}

.pair__code {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 20px;
  letter-spacing: 0.15em;
  text-align: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

/* Application : barre du haut, onglet affiché, barre d'onglets en bas (comme une appli de téléphone). */
.app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(1, 4, 10, 0.85);
}

.topbar__title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar__name {
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar__status {
  color: var(--soft);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(1, 4, 10, 0.95);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  border: none;
  background: none;
  color: var(--faint);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tabbar__item--active {
  color: var(--accent);
}

.tabbar__item--active svg {
  filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.6));
}

.messages {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.message {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message--user {
  align-self: flex-end;
  background: rgba(var(--accent-rgb), 0.2);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-bottom-right-radius: 5px;
}

.message--assistant {
  align-self: flex-start;
  background: var(--raised);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.message--pending {
  color: var(--soft);
  font-style: italic;
}

.message--error {
  border-color: rgba(255, 77, 104, 0.6);
  color: #ffb8c2;
}

.message img {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  margin-top: 8px;
}

.empty {
  margin: auto;
  color: var(--faint);
  text-align: center;
  padding: 0 24px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(1, 4, 10, 0.92);
}

.composer__input {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 140px;
  font: inherit;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.composer__input:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.6);
}

.composer__send {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
}

.composer__send:disabled {
  opacity: 0.4;
}

.link {
  border: none;
  background: none;
  color: var(--soft);
  font: inherit;
  padding: 10px;
  min-height: 44px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--soft);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.chip--active {
  border-color: rgba(var(--accent-rgb), 0.7);
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--text);
}

.button--primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* Vocal : l'orbe au centre, comme l'Agent vocal du PC. */
.voice {
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px 20px 16px;
  text-align: center;
  overflow-y: auto;
}

.voice__orb {
  --level: 0;
  position: relative;
  width: 190px;
  height: 190px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.14), transparent 68%);
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.voice__orb img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 14px rgba(var(--accent-rgb), 0.5));
  animation: breathe 3.2s ease-in-out infinite;
}

/* Écoute : un halo qui suit le volume de la voix. */
.voice__orb::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), 0);
  transform: scale(calc(1 + var(--level) * 0.12));
  transition:
    transform 0.1s linear,
    border-color 0.2s;
  pointer-events: none;
}

.voice__orb--listening::after {
  border-color: rgba(var(--accent-rgb), 0.75);
}

.voice__orb--working img {
  animation: spin 2.4s linear infinite;
}

.voice__orb--speaking img {
  animation: breathe 0.9s ease-in-out infinite;
  filter: drop-shadow(0 0 22px rgba(var(--accent-rgb), 0.85));
}

.voice__state {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.voice__help {
  margin: -6px 0 0;
  max-width: 320px;
  color: var(--soft);
  font-size: 14px;
}

.voice__last {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--raised);
  text-align: left;
}

.voice__line {
  margin: 0;
  display: flex;
  flex-direction: column;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.voice__who {
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.voice__image {
  max-width: 100%;
  border-radius: 10px;
}

/* Image et Vidéo : décrire en haut, la galerie en dessous. */
.studio {
  overflow-y: auto;
  padding: 16px 14px 20px;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.studio__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.studio__prompt {
  width: 100%;
  resize: none;
  font: inherit;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.studio__prompt:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.6);
}

.studio__prompt::placeholder {
  color: var(--faint);
}

.studio__label {
  color: var(--soft);
  font-size: 13px;
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.studio__title {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft);
}

.studio__more {
  align-self: center;
}

.notice {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--soft);
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 8px 14px;
  border-radius: 14px;
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.08);
}

.progress__spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(var(--accent-rgb), 0.25);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.progress__text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
}

.gallery {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.gallery__empty {
  grid-column: 1 / -1;
  color: var(--faint);
  text-align: center;
  padding: 18px 10px;
}

.tile {
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: left;
  overflow: hidden;
  cursor: pointer;
}

.tile__frame {
  position: relative;
  display: block;
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 40%, rgba(var(--accent-rgb), 0.16), transparent 70%), #02070d;
}

.tile--video .tile__frame {
  aspect-ratio: 16 / 10;
}

.tile__frame img,
.tile__frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile__play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: rgba(1, 4, 10, 0.65);
  border: 1px solid rgba(var(--accent-rgb), 0.6);
  z-index: 1;
}

.tile__play::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 11px;
  border-style: solid;
  border-width: 9px 0 9px 14px;
  border-color: transparent transparent transparent var(--text);
}

.tile__caption {
  display: flex;
  flex-direction: column;
  padding: 7px 10px 9px;
  min-width: 0;
}

.tile__label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile__date {
  color: var(--faint);
  font-size: 12px;
}

/* Visionneuse plein écran */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
  background: rgba(1, 4, 10, 0.97);
}

.viewer__bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.viewer__title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer__close {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.viewer__media {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer__media img,
.viewer__media video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
}

.viewer__loading {
  color: var(--soft);
}

.viewer__note {
  margin: 0;
  color: var(--soft);
  text-align: center;
}

.viewer__save {
  text-align: center;
  text-decoration: none;
}
