:root {
  --bg: #111111;
  --panel: #1c1c1c;
  --accent: #FFD400;
  --text: #f5f5f5;
  --muted: #999;
  --danger: #ff4d4f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh; /* hauteur réellement visible sur mobile (sans la barre d'adresse) */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

.install-banner {
  flex-shrink: 0;
  background: var(--accent);
  color: #111;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  font-size: 0.85rem;
  font-weight: bold;
}
.install-banner button {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
  background: #111;
  color: var(--accent);
}
.install-banner .btn-dismiss {
  background: transparent;
  color: #111;
  font-weight: normal;
  padding: 6px 8px;
}

.ios-help {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.ios-help-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 24px;
  max-width: 320px;
  text-align: left;
}
.ios-help-card ol { padding-left: 20px; line-height: 1.6; }
.ios-help-card button { width: 100%; margin-top: 12px; }

#view-auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  gap: 12px;
  padding: 24px;
  overflow-y: auto;
}

#view-auth h1 { color: var(--accent); font-size: 2.5rem; margin-bottom: 24px; }

input, button, textarea {
  font-size: 1rem;
  padding: 12px;
  border-radius: 10px;
  border: none;
  outline: none;
}

input {
  width: 100%;
  max-width: 320px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid #333;
}

button {
  background: var(--accent);
  color: #111;
  font-weight: bold;
  cursor: pointer;
}

button.secondary { background: var(--panel); color: var(--text); border: 1px solid #333; }
button.link { background: none; color: var(--accent); padding: 4px; }

#app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tabs {
  display: flex;
  justify-content: space-around;
  background: var(--panel);
  border-top: 1px solid #333;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  order: 2;
}

.tabs button {
  background: none;
  color: var(--muted);
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tabs button.active { color: var(--accent); }
.tabs button .icon { font-size: 1.4rem; }

.screen {
  flex: 1;
  overflow-y: auto;
  order: 1;
  position: relative;
}

/* Caméra */
#screen-camera { display: flex; flex-direction: column; background: #000; }
#camera-video { flex: 1; width: 100%; object-fit: cover; background: #000; transform: scaleX(-1); }
#camera-preview { flex: 1; width: 100%; object-fit: contain; background: #000; }
.camera-controls {
  position: absolute;
  bottom: 20px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 24px;
}
#shutter-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--accent);
}
#shutter-btn.recording { background: var(--danger); }

.send-panel {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; flex-direction: column;
  padding: 16px; gap: 12px; overflow-y: auto;
}
.friend-check {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; background: var(--panel); border-radius: 10px;
}

/* Listes */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid #262626;
}
.list-item .meta { display: flex; flex-direction: column; }
.list-item .username { font-weight: bold; }
.list-item .sub { color: var(--muted); font-size: 0.85rem; }
.list-item .actions { display: flex; gap: 8px; }
.list-item .actions button { padding: 6px 12px; font-size: 0.85rem; }

.section-title {
  padding: 12px 16px 4px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Stories bar */
.stories-bar {
  display: flex; gap: 12px;
  padding: 12px; overflow-x: auto;
  border-bottom: 1px solid #262626;
}
.story-avatar {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 64px;
}
.story-avatar .circle {
  width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 1.2rem;
  background: var(--panel);
}
.story-avatar .circle.viewed { border-color: #444; }
.story-avatar span { font-size: 0.7rem; color: var(--muted); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Viewer plein écran (snap/story) */
#viewer {
  position: fixed; inset: 0; background: #000;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
#viewer img, #viewer video { max-width: 100%; max-height: 100%; }
#viewer .close-btn {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px;
  background: rgba(0,0,0,0.5); color: #fff; border-radius: 50%;
  width: 36px; height: 36px; font-size: 1.2rem;
}
#viewer .timer-bar {
  position: absolute; top: 0; left: 0; height: 4px; background: var(--accent);
  transition: width linear;
}

/* Appel audio/vidéo */
.call-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
}
.call-card { text-align: center; }
.call-avatar {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--panel); border: 3px solid var(--accent);
  margin: 0 auto 16px;
}
.call-status { color: var(--muted); margin-bottom: 20px; }
.call-actions { display: flex; gap: 16px; justify-content: center; }
button.danger { background: var(--danger); color: #fff; }

.call-active {
  position: fixed; inset: 0; z-index: 80;
  background: #000;
}
#call-remote-video {
  width: 100%; height: 100%; object-fit: cover;
}
#call-local-video {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px;
  width: 100px; height: 140px; object-fit: cover;
  border-radius: 12px; border: 2px solid var(--accent);
  transform: scaleX(-1);
}
.call-camoff {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; background: #111;
}
.call-controls {
  position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); left: 0; right: 0;
  display: flex; justify-content: center; gap: 20px;
}
.call-controls button {
  width: 56px; height: 56px; border-radius: 50%;
  font-size: 1.4rem;
  background: rgba(255,255,255,0.15); color: #fff;
}
.call-controls button.off { background: var(--danger); }
.call-controls button.danger { background: var(--danger); }

/* Chat */
.chat-thread { display: flex; flex-direction: column; height: 100%; }
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 75%; padding: 10px 14px; border-radius: 14px; background: var(--panel); align-self: flex-start; }
.bubble.mine { background: var(--accent); color: #111; align-self: flex-end; }
.bubble.snap { cursor: pointer; font-weight: bold; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #262626; }
.chat-input input { flex: 1; }

.empty-state { padding: 40px 16px; text-align: center; color: var(--muted); }

.add-friend-bar { display: flex; gap: 8px; padding: 12px; }
.add-friend-bar input { flex: 1; }
