/* Family Bridge - theme inspire du Codex des Trois Mondes.
   Les etats restent textuels et symboliques, jamais portes par la couleur seule. */

:root {
  --bg: #080c16;
  --bg-soft: #0d1424;
  --panel: #111a2d;
  --panel-2: #16223a;
  --panel-3: #0c1220;
  --text: #edf3ff;
  --muted: #b7c4df;
  --muted-2: #8fa0c0;
  --border: #314565;
  --line-soft: #23334f;
  --accent: #9bd6ff;
  --accent-dark: #69bcec;
  --accent-gold: #ffd87a;
  --accent-green: #a8e6b0;
  --warn: #ffd87a;
  --bad: #ff9aae;
  --ok: #a8e6b0;
  --in-bg: #112a46;
  --in-border: #7fc9ff;
  --out-bg: #26331f;
  --out-border: #f1c96e;
  --shadow: 0 18px 42px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(20, 31, 57, .82), rgba(8, 12, 22, 1) 38rem),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 72px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, transparent 0 30%, rgba(155, 214, 255, .08) 30% 31%, transparent 31% 100%),
    linear-gradient(28deg, transparent 0 58%, rgba(255, 216, 122, .08) 58% 59%, transparent 59% 100%);
  opacity: .75;
}

.spacefield {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: .92;
}

.spacefield-fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 18%, rgba(155, 214, 255, .18), transparent 18rem),
    radial-gradient(circle at 78% 32%, rgba(255, 216, 122, .13), transparent 16rem),
    radial-gradient(circle at 50% 86%, rgba(168, 230, 176, .08), transparent 18rem);
}

h1, h2, h3 {
  margin: 0 0 .75rem;
  line-height: 1.15;
}

h1 {
  font-size: 1.7rem;
  color: #ffffff;
}

h2 {
  font-size: 1.2rem;
  margin-top: 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

code {
  color: #f8dc91;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 6px;
  padding: .12rem .35rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1.5rem;
  background: rgba(8, 16, 27, .88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
}

.brand {
  color: #ffffff;
  font-weight: 800;
  letter-spacing: .02em;
}

.brand::before {
  content: "✦";
  color: var(--accent-gold);
  margin-right: .5rem;
}

.container {
  position: relative;
  z-index: 1;
  width: min(1060px, calc(100% - 2rem));
  margin: 2rem auto;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(17, 26, 45, .9), rgba(22, 34, 58, .86));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.card::after {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(155, 214, 255, .65), transparent);
}

.card-narrow {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.card-narrow h1::before {
  content: "Atlas securise";
  display: block;
  width: max-content;
  max-width: 100%;
  margin-bottom: .55rem;
  color: var(--accent-gold);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.truncate {
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

label {
  display: block;
  margin-bottom: 1rem;
  color: var(--text);
  font-weight: 650;
}

input[type="text"], input[type="password"], textarea, select {
  display: block;
  width: 100%;
  padding: .7rem .8rem;
  margin-top: .3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: rgba(5, 10, 19, .72);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
  border-color: var(--accent);
}

.secret-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(7.5rem, .75fr);
  gap: .75rem;
}

.secret-grid label {
  margin-bottom: 1rem;
}

@media (max-width: 560px) {
  .secret-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: .58rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.btn:hover {
  background: rgba(255, 255, 255, .08);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #07111f;
}

.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #07111f;
}

.btn-ghost {
  background: transparent;
}

.btn-warn {
  background: rgba(255, 216, 122, .13);
  border-color: rgba(255, 216, 122, .55);
  color: #ffe8a6;
}

.alert {
  padding: .8rem 1rem;
  border-radius: 8px;
  background: rgba(255, 154, 174, .14);
  border: 1px solid rgba(255, 154, 174, .52);
  color: #ffd8df;
  margin-bottom: 1rem;
}

.alert-info {
  background: rgba(155, 214, 255, .14);
  border-color: rgba(155, 214, 255, .5);
  color: #d9f0ff;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .13rem .52rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  color: var(--text);
  font-size: .8rem;
  font-weight: 700;
  border: 1px solid var(--border);
}

.tag-in {
  background: rgba(127, 201, 255, .16);
  border-color: var(--in-border);
}

.tag-out {
  background: rgba(255, 216, 122, .15);
  border-color: var(--out-border);
}

.tag-ok::before { content: "✓ "; }
.tag-ok {
  background: rgba(168, 230, 176, .16);
  border-color: rgba(168, 230, 176, .65);
  color: #d7ffdc;
}

.tag-bad::before { content: "✗ "; }
.tag-bad {
  background: rgba(255, 154, 174, .16);
  border-color: rgba(255, 154, 174, .65);
  color: #ffd6de;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}

.table th, .table td {
  padding: .58rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.table th {
  background: rgba(255, 255, 255, .06);
  color: #ffffff;
  font-weight: 750;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .75rem;
  margin-top: 1rem;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: rgba(5, 10, 19, .52);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.stat-val {
  color: #ffffff;
  font-size: 2rem;
  font-weight: 850;
}

.stat-lbl {
  color: var(--muted);
  font-size: .85rem;
}

.nav {
  display: flex;
  gap: .65rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav a {
  color: var(--text);
  padding: .25rem .55rem;
  border-radius: 8px;
  border: 1px solid transparent;
}

.nav a:hover {
  background: rgba(255, 255, 255, .07);
  text-decoration: none;
}

.nav a.active {
  background: rgba(155, 214, 255, .12);
  border-color: rgba(155, 214, 255, .45);
  color: #ffffff;
}

.inline { display: inline; }
.inline-form { display: inline-flex; gap: .3rem; margin: 0; }
.inline-form input { width: auto; margin: 0; }

.actions {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: .8rem;
  min-height: 180px;
  max-height: 60vh;
  overflow-y: auto;
  padding: .85rem;
  background:
    linear-gradient(180deg, rgba(5, 10, 19, .48), rgba(13, 20, 36, .58)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 42px);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1rem 0;
}

.bubble {
  max-width: 80%;
  padding: .68rem .9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
}

.bubble-in {
  align-self: flex-end;
  background: linear-gradient(180deg, rgba(17, 42, 70, .98), rgba(16, 52, 83, .98));
  border-color: var(--in-border);
}

.bubble-out {
  align-self: flex-start;
  background: linear-gradient(180deg, rgba(38, 51, 31, .98), rgba(52, 54, 30, .98));
  border-color: var(--out-border);
}

.bubble-meta {
  display: flex;
  gap: .5rem;
  align-items: center;
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: .3rem;
}

.bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.compose {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.compose textarea { resize: vertical; }

.compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.totp-uri {
  padding: .8rem;
  background: #050a13;
  color: #e7efff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  word-break: break-all;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem;
}

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

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: .85rem 1rem;
  }

  .container {
    width: min(100% - 1rem, 1060px);
    margin: 1rem auto;
  }

  .card {
    padding: 1rem;
  }

  .truncate {
    max-width: 150px;
  }

  .bubble {
    max-width: 95%;
  }

  .compose-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .compose-actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spacefield {
    display: none;
  }

  .spacefield-fallback {
    display: block;
  }
}
