/* ── Apparition — Design system ── */

:root {
  --ink: #12191f;
  --ink2: #1a232b;
  --line: #28333d;
  --paper: #f3ead8;
  --paper-line: #e5d8bd;
  --paper-ink: #2a2016;
  --glow: #e0975a;
  --sub: #4e8c82;
  --muted: #8a97a0;
  --muted-2: #5f6d76;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: radial-gradient(120% 60% at 50% 0%, rgba(224,151,90,.10), transparent 55%), var(--ink);
  color: #dfe6ea;
  font-family: "Inter", system-ui, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
}

.meta { font-family: "Courier Prime", monospace; }


/* ═══════════════════════════════════
   LOGIN OVERLAY
   ═══════════════════════════════════ */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(ellipse at 50% 30%, rgba(224,151,90,.08), transparent 60%), var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 20px;
}

.login-overlay.hidden { display: none; }

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 14px 3px rgba(224,151,90,.6);
}

.login-brand .name {
  font-family: "Courier Prime", monospace;
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 300px;
}

.login-box input {
  width: 100%;
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #e7edf1;
  padding: 13px 16px;
  font-family: "Courier Prime", monospace;
  font-size: 15px;
  text-align: center;
  letter-spacing: .08em;
}

.login-box input:focus {
  outline: 2px solid var(--glow);
  outline-offset: 1px;
  border-color: transparent;
}

.login-box input::placeholder {
  color: var(--muted-2);
  letter-spacing: .06em;
}

.login-box button {
  width: 100%;
  background: var(--glow);
  color: #241405;
  border: 0;
  border-radius: 10px;
  padding: 13px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: .15s;
}

.login-box button:hover { filter: brightness(1.06); }

.login-error {
  font-family: "Courier Prime", monospace;
  font-size: 11px;
  color: #e06a5a;
  min-height: 16px;
}


/* ═══════════════════════════════════
   TOPBAR
   ═══════════════════════════════════ */

.topbar {
  width: 100%;
  max-width: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px calc(14px + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 12px 2px rgba(224,151,90,.6);
}

.brand .name {
  font-family: "Courier Prime", monospace;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}


/* ═══════════════════════════════════
   PHONE / APPARITION CARD
   ═══════════════════════════════════ */

.screen {
  width: 100%;
  max-width: 460px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 40px;
}

.phone {
  position: relative;
  width: 100%;
  margin-top: -52px;
  height: 100dvh;
  max-height: 920px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f6eede, var(--paper));
  color: var(--paper-ink);
  overflow: hidden;
}

@media (min-width: 520px) {
  .phone {
    border-radius: 26px;
    box-shadow: 0 40px 90px -30px rgba(0,0,0,.8),
                0 0 120px -40px rgba(224,151,90,.4);
    margin-top: 8px;
    height: min(86dvh, 880px);
  }
}

/* Preview mode (admin) */
.phone.preview {
  height: auto;
  max-height: none;
  border-radius: 20px;
  box-shadow: 0 30px 70px -30px rgba(0,0,0,.7);
  margin: 6px 0 22px;
}
.phone.preview .media { aspect-ratio: 4/3; height: auto; }
.phone.preview .paperfill { min-height: 280px; }


/* ── Date label ── */

.note-date {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  text-align: center;
  z-index: 5;
  font-family: "Courier Prime", monospace;
  font-size: 11px;
  letter-spacing: .14em;
  color: rgba(42,32,22,.5);
  text-transform: lowercase;
}


/* ── Media (photo / video) ── */

.media {
  width: 100%;
  flex: 1;
  min-height: 0;
  background: #0d1216;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.media .scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 45%;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  pointer-events: none;
}


/* ── Audio layout ── */

.audio {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: radial-gradient(90% 70% at 50% 35%, rgba(224,151,90,.16), transparent 70%);
}

.playbtn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 2px solid var(--glow);
  background: rgba(224,151,90,.10);
  color: var(--glow);
  font-size: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .15s;
}

.playbtn:hover { background: rgba(224,151,90,.2); }

.bars {
  display: flex;
  gap: 4px;
  height: 26px;
  align-items: center;
}

.bars span {
  width: 3px;
  background: var(--sub);
  border-radius: 2px;
  height: 8px;
}

.bars.on span { animation: eq 1s ease-in-out infinite; }
.bars span:nth-child(2) { animation-delay: .15s; }
.bars span:nth-child(3) { animation-delay: .3s; }
.bars span:nth-child(4) { animation-delay: .45s; }
.bars span:nth-child(5) { animation-delay: .2s; }

@keyframes eq {
  0%, 100% { height: 8px; }
  50% { height: 24px; }
}


/* ── Footer (signature + text) ── */

.footer {
  padding: 20px 26px calc(26px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 3;
}

.kind {
  font-family: "Courier Prime", monospace;
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 12px;
}

.msg {
  font-family: "Caveat", cursive;
  font-weight: 600;
  line-height: 1.25;
  color: var(--paper-ink);
  font-size: clamp(26px, 7vw, 38px);
  margin-bottom: 18px;
}

.sign {
  display: flex;
  align-items: center;
  gap: 13px;
}

.seal {
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid currentColor;
}

.seal svg {
  width: 25px;
  height: 25px;
}

.seal.cafe { color: var(--sub); }
.seal.chinois { color: #b26a2f; }

.who {
  font-family: "Caveat", cursive;
  font-size: 25px;
  font-weight: 700;
  color: var(--paper-ink);
}

.who small {
  display: block;
  font-family: "Courier Prime", monospace;
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-top: 1px;
  font-weight: 400;
}


/* ── Text-only (paperfill) ── */

.paperfill {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  padding: 26px 30px 6px;
  position: relative;
}

.paperfill::before {
  content: "";
  position: absolute;
  left: 30px;
  right: 30px;
  top: 0;
  bottom: 0;
  background-image: repeating-linear-gradient(transparent 0 30px, var(--paper-line) 30px 31px);
  opacity: .3;
  pointer-events: none;
}

.paperfill .msg {
  font-size: clamp(30px, 9vw, 46px);
  margin: 0;
  position: relative;
  z-index: 1;
}


/* ── Media overlay text ── */

.onmedia .footer { margin-top: -90px; }
.onmedia .kind { color: rgba(255,255,255,.6); }
.onmedia .msg { color: #fff; }
.onmedia .who { color: #fff; }
.onmedia .who small { color: rgba(255,255,255,.55); }


/* ── Badges (admin preview only) ── */

.badge {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  z-index: 6;
  font-family: "Courier Prime", monospace;
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
}

.badge.pin {
  background: rgba(178,106,47,.22);
  color: #7a4113;
  border: 1px solid rgba(178,106,47,.5);
}

.badge.rand {
  background: rgba(78,140,130,.2);
  color: #245049;
  border: 1px solid rgba(78,140,130,.5);
}


/* ── Reveal animation ── */

.phone { opacity: 0; transform: translateY(12px); }
.phone.in { animation: rise .55s cubic-bezier(.2,.7,.2,1) forwards; }

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .phone, .phone.in { animation: none; opacity: 1; transform: none; }
}


/* ═══════════════════════════════════
   ADMIN / TIROIR
   ═══════════════════════════════════ */

.admin-wrap {
  width: 100%;
  max-width: 460px;
  padding: 0 16px 60px;
}

.dateline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 18px 0 16px;
}

.dateline .d {
  font-family: "Courier Prime", monospace;
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--muted);
}

.stepper {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--ink2);
  color: #cdd6db;
  cursor: pointer;
  font-size: 14px;
  transition: .15s;
}

.stepper:hover {
  border-color: var(--glow);
  color: var(--glow);
}

h2 {
  font-family: "Courier Prime", monospace;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 24px 0 12px;
}

.card {
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-family: "Courier Prime", monospace;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

textarea, input[type=date] {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #e7edf1;
  padding: 10px 12px;
  font-family: "Inter";
  font-size: 14px;
  resize: vertical;
}

textarea:focus, input:focus {
  outline: 2px solid var(--glow);
  outline-offset: 1px;
  border-color: transparent;
}

.seg {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.seg button {
  flex: 1;
  min-width: 70px;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
  font-family: "Courier Prime", monospace;
  font-size: 12px;
  transition: .15s;
}

.seg button.sel {
  border-color: var(--glow);
  color: var(--glow);
  background: rgba(224,151,90,.12);
}

.seg.voice button.sel.cafe {
  border-color: var(--sub);
  color: #7fd3c6;
  background: rgba(78,140,130,.12);
}

.filebox { margin-top: 4px; }
.filebox input[type=file] { display: none; }

.filelabel {
  display: block;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 9px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}

.filelabel:hover {
  border-color: var(--glow);
  color: var(--glow);
}

.filename {
  margin-top: 8px;
  font-family: "Courier Prime", monospace;
  font-size: 11px;
  color: var(--sub);
  word-break: break-all;
}

.addbtn {
  width: 100%;
  margin-top: 6px;
  background: var(--glow);
  color: #241405;
  border: 0;
  border-radius: 10px;
  padding: 13px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: .15s;
}

.addbtn:hover { filter: brightness(1.06); }
.addbtn:disabled { opacity: .5; cursor: not-allowed; }

.bank {
  margin: 20px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--ink2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  color: #c8d1d7;
}

.tag {
  font-family: "Courier Prime", monospace;
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.tag.cafe { background: rgba(78,140,130,.14); color: #6fc2b6; }
.tag.chinois { background: rgba(224,151,90,.14); color: var(--glow); }
.tag.m { background: rgba(120,130,140,.16); color: #a9b4bc; }
.tag.date { background: rgba(178,106,47,.16); color: #c98a52; margin-left: auto; }

.row .txt {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delbtn {
  background: transparent;
  border: 1px solid rgba(224,106,90,.3);
  color: #e06a5a;
  border-radius: 6px;
  padding: 3px 8px;
  font-family: "Courier Prime", monospace;
  font-size: 10px;
  cursor: pointer;
  transition: .15s;
  flex: 0 0 auto;
}

.delbtn:hover {
  background: rgba(224,106,90,.14);
  border-color: #e06a5a;
}


/* ── Empty state ── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 24px;
  text-align: center;
}

.empty-state .icon {
  font-size: 48px;
  opacity: .4;
}

.empty-state p {
  font-family: "Caveat", cursive;
  font-size: 24px;
  color: #8a7c66;
  margin: 0;
}


/* ── Loading spinner ── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--paper-line);
  border-top-color: var(--glow);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }


/* ── Status toast ── */

.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--ink2);
  border: 1px solid var(--line);
  color: #dfe6ea;
  font-family: "Courier Prime", monospace;
  font-size: 12px;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 200;
  opacity: 0;
  transition: transform .3s, opacity .3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* ── Character Watermarks ── */

.char-watermark {
  position: absolute;
  bottom: 120px;
  right: 20px;
  width: 130px;
  height: 130px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  opacity: 0.08; /* Very subtle watermark in the background */
  z-index: 1;
}

/* Slightly more opacity on the paper background to look like a stamp */
.phone:not(.onmedia) .char-watermark {
  opacity: 0.12;
}

.char-watermark.char-cafe {
  background-image: url('/static/images/cafe.png');
}

.char-watermark.char-chinois {
  background-image: url('/static/images/chinois.png');
}

