:root {
  --bg: #0b0b10;
  --bg-elev: #13131c;
  --bg-card: #191926;
  --bg-soft: #222234;
  --border: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(226, 184, 102, 0.35);
  --text: #f3f1eb;
  --muted: #9a96a8;
  --gold: #e2b866;
  --gold-strong: #f5d388;
  --crimson: #d94b6a;
  --emerald: #38c172;
  --sky: #55a7ff;
  --radius: 14px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --top-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.55; min-height: 100vh; overflow-x: hidden;
}

.hidden { display: none !important; }
.blur-nsfw img { filter: blur(18px); transition: filter 0.2s; }
.blur-nsfw img:active { filter: blur(0); }

/* --- Top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: rgba(11, 11, 16, 0.9);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #272033, #17141f); border: 1px solid var(--border-gold);
  color: var(--gold); font-family: Georgia, serif; font-weight: 700; font-size: 13px;
}
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: 0.3px; }
.brand-sub { font-size: 11px; color: var(--muted); display: block; line-height: 1.1; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* --- Buttons --- */
button, .btn {
  font: inherit; color: var(--text); background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.08s ease, background 0.15s, border-color 0.15s;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-gold {
  background: linear-gradient(135deg, #d7a64d, #a97524);
  border-color: rgba(255, 224, 150, 0.4); color: #120e07; font-weight: 700;
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger { background: rgba(217, 75, 106, 0.18); border-color: rgba(217, 75, 106, 0.45); color: #ff8aa4; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 7px 9px; }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 10px; position: relative; }
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 99px; background: var(--crimson); color: #fff;
  font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
}

/* --- Main container & bottom nav --- */
.app-main {
  max-width: 980px; margin: 0 auto; padding: 14px 14px calc(var(--nav-h) + 28px);
}
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45; height: var(--nav-h);
  background: rgba(14, 14, 21, 0.94); backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(6, 1fr);
}
.nav-item {
  background: none; border: none; border-radius: 0; color: var(--muted);
  flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 2px; position: relative;
}
.nav-item .nav-ico { font-size: 18px; line-height: 1.1; }
.nav-item.active { color: var(--gold); }
.nav-item.active::after {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 2px;
  background: var(--gold); border-radius: 0 0 3px 3px;
}

/* --- Cards & Inputs --- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card-gold { border-color: var(--border-gold); }
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.9px; color: var(--gold); margin: 14px 0 8px; font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.space-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font: inherit; font-size: 14px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--border-gold); }
textarea { resize: vertical; min-height: 76px; }
label.field-label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }

/* --- Login screen --- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at top, #1f172b 0%, #0b0b10 65%);
}
.login-box { width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo h1 { margin: 8px 0 2px; font-family: Georgia, serif; color: var(--gold); letter-spacing: 1px; }

/* --- Scene view --- */
.scene-meta {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center;
}
.pill {
  font-size: 12px; padding: 4px 10px; border-radius: 99px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  display: inline-flex; align-items: center; gap: 5px;
}
.pill-gold { border-color: var(--border-gold); color: var(--gold-strong); }
.pill-crimson { border-color: rgba(217,75,106,0.45); color: #ff9ab0; background: rgba(217,75,106,0.12); }

.present-strip {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none;
}
.present-chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 99px;
  padding: 4px 10px 4px 4px; font-size: 12px; cursor: pointer;
}
.present-chip img, .avatar {
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--bg-soft);
}
.avatar-lg { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; background: var(--bg-soft); }

.scene-gallery {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-bottom: 12px;
}
.scene-photo {
  position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: #0e0e14; cursor: pointer; aspect-ratio: 2 / 3;
  max-height: 480px;
}
.scene-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene-photo-cap {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.82)); font-size: 12.5px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}

.scene-prose {
  font-size: 15.5px; line-height: 1.72; color: #f2efe8;
}
.scene-prose p { margin: 0 0 12px; }
.scene-prose p.dialogue { color: #fff6e0; padding-left: 10px; border-left: 2px solid var(--border-gold); }

/* --- Gauges --- */
.gauge-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 11px; padding: 10px 12px;
}
.gauge-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-weight: 700; font-size: 13.5px; }
.gauge-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 11.5px; color: var(--muted); }
.bar-track { height: 5px; background: rgba(255,255,255,0.08); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--gold); }
.bar-fill.desire { background: #e8557c; }
.bar-fill.res { background: #60a5fa; }
.bar-fill.trust { background: #38c172; }
.bar-fill.tension { background: #f59e0b; }
.delta-pos { color: var(--emerald); font-weight: 700; }
.delta-neg { color: var(--crimson); font-weight: 700; }

/* --- Choices & Action box --- */
.choices-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.choice-btn {
  width: 100%; text-align: left; justify-content: flex-start; align-items: flex-start;
  padding: 12px 13px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; line-height: 1.45;
}
.choice-btn:hover:not(:disabled) { border-color: var(--border-gold); background: #201e2e; }
.choice-key {
  flex: 0 0 26px; height: 26px; border-radius: 7px; background: rgba(226,184,102,0.16);
  color: var(--gold); font-weight: 800; display: grid; place-items: center; font-size: 13px; margin-top: 1px;
}
.choice-note { display: block; font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }

.progress-banner {
  background: linear-gradient(90deg, rgba(226,184,102,0.16), rgba(217,75,106,0.14));
  border: 1px solid var(--border-gold); border-radius: 12px; padding: 12px 14px;
  margin-bottom: 12px; display: flex; align-items: center; gap: 10px;
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(226,184,102,0.25);
  border-top-color: var(--gold); animation: spin 0.8s linear infinite; flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Chips (multi-select presets) --- */
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.chip {
  font-size: 12px; padding: 5px 10px; border-radius: 99px; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--muted);
  user-select: none;
}
.chip.active { background: rgba(226,184,102,0.2); border-color: var(--gold); color: var(--gold-strong); font-weight: 600; }

/* --- Sliders --- */
.slider-row { margin: 10px 0; }
.slider-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
input[type="range"] { width: 100%; accent-color: var(--gold); }

/* --- Actor cards --- */
.actor-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: border-color 0.15s;
}
.actor-card:hover { border-color: var(--border-gold); }
.actor-thumb { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--bg-soft); display: block; }
.actor-body { padding: 9px 10px; }
.actor-name { font-weight: 700; font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; }

/* --- SMS --- */
.sms-bubble {
  max-width: 82%; padding: 9px 12px; border-radius: 14px; margin-bottom: 8px; font-size: 14px;
}
.sms-in { background: var(--bg-soft); border-bottom-left-radius: 4px; margin-right: auto; }
.sms-out { background: linear-gradient(135deg, #c99a44, #9c6c20); color: #120e07; font-weight: 500; border-bottom-right-radius: 4px; margin-left: auto; }
.sms-time { font-size: 10.5px; opacity: 0.7; margin-top: 3px; display: block; }

/* --- Modals & Panic --- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.85);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-panel {
  background: var(--bg-card); border: 1px solid var(--border-gold); border-radius: 16px;
  max-width: 720px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 16px;
}
.zoom-img { max-width: 96vw; max-height: 92vh; border-radius: 12px; object-fit: contain; }

.panic-screen {
  position: fixed; inset: 0; z-index: 200; background: #f5f6f8; color: #1f2937;
  padding: 24px; overflow-y: auto; font-family: system-ui, sans-serif;
}
.panic-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; max-width: 640px; margin: 12px auto; }

.toast {
  position: fixed; top: 68px; right: 14px; z-index: 120;
  background: #1f1c2c; border: 1px solid var(--border-gold); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}

details.spoiler {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 8px 0;
}
details.spoiler summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--gold); }
pre.memory-text {
  white-space: pre-wrap; font-family: inherit; font-size: 13px; color: #d7d3e0; margin: 8px 0 0; line-height: 1.55;
}

/* --- Mode Clair (Ivoire & Or) --- */
[data-theme="light"] {
  --bg: #f4f1ea;
  --bg-elev: #fbf9f4;
  --bg-card: #ffffff;
  --bg-soft: #ece6d9;
  --border: rgba(30, 24, 16, 0.11);
  --border-gold: rgba(168, 118, 28, 0.42);
  --text: #1c1922;
  --muted: #666072;
  --gold: #a8761c;
  --gold-strong: #8a5c0d;
}
[data-theme="light"] .topbar,
[data-theme="light"] .bottom-nav { background: rgba(255, 253, 248, 0.94); }
[data-theme="light"] .brand-mark { background: linear-gradient(135deg, #f3e6c8, #e6cf9b); color: #5e3f07; }
[data-theme="light"] .scene-prose { color: #201d26; }
[data-theme="light"] .scene-prose p.dialogue { color: #3a2a0b; background: rgba(168,118,28,0.06); padding: 4px 10px; border-radius: 6px; }
[data-theme="light"] .choice-btn:hover:not(:disabled) { background: #f8f2e4; }
[data-theme="light"] .login-wrap { background: radial-gradient(circle at top, #f3ead6 0%, #ebe5d8 65%); }
[data-theme="light"] .toast { background: #ffffff; color: #1c1922; box-shadow: 0 8px 24px rgba(0,0,0,0.14); }
[data-theme="light"] pre.memory-text { color: #353040; }
[data-theme="light"] .bar-track { background: rgba(0,0,0,0.08); }
[data-theme="light"] .btn-danger { background: rgba(217,75,106,0.12); color: #b62848; }

/* --- Carrousel swipe tactile sur mobile --- */
@media (max-width: 640px) {
  .scene-gallery.swipeable {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px;
    padding-bottom: 6px; scrollbar-width: none;
  }
  .scene-gallery.swipeable::-webkit-scrollbar { display: none; }
  .scene-gallery.swipeable .scene-photo {
    flex: 0 0 86%; scroll-snap-align: center; max-height: 460px;
  }
  .scene-gallery.swipeable.single-photo .scene-photo { flex: 0 0 100%; }
}

