:root {
  --cream: #fbf5ec;
  --green: #123a31;
  --green-2: #1f5a47;
  --gold: #a2702f;
  --rust: #9a4312;
  --ink: #2b3a35;
  --glass: rgba(255, 250, 242, .78);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Cairo', system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 80% at 50% 10%, #fff8ee 0%, #f3e3c8 55%, #d9b98a 100%);
  overflow: hidden;
}
body[dir="ltr"] { direction: ltr; }

#avatar { position: fixed; inset: 0; }

/* --- Noura video character --- */
#noura { position: fixed; inset: 0; display: flex; justify-content: center; align-items: flex-end; background: #f3eadb; }
#noura[hidden] { display: none; }
#noura img, #noura video {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  height: 100%; max-width: none; object-fit: contain; opacity: 0; transition: opacity .25s;
}
#noura[data-state="idle"] #nouraIdle { opacity: 1; }
#noura[data-state="talk"] #nouraTalk { opacity: 1; }
#noura[data-state="clip"] #nouraClip { opacity: 1; }
@keyframes breathe { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.012); } }

/* --- start overlay --- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 16px;
  background: rgba(251, 245, 236, .72); backdrop-filter: blur(8px);
}
.overlay[hidden] { display: none; }
.card {
  width: min(420px, 100%); text-align: center;
  background: #fff; border-radius: 22px; padding: 28px 22px;
  box-shadow: 0 20px 60px rgba(18, 58, 49, .18);
}
.kicker { color: var(--gold); font-weight: 700; font-size: 13px; letter-spacing: .04em; }
h1 { color: var(--green); font-size: 34px; font-weight: 800; margin-top: 6px; }
.sub { color: #6b756f; margin-bottom: 18px; }
.langs { display: grid; gap: 10px; }
.langs button {
  font: inherit; font-size: 20px; font-weight: 700; padding: 14px;
  border-radius: 14px; border: 0; cursor: pointer;
  background: var(--green); color: #fff;
}
.langs button:first-child { background: var(--gold); }
.langs button:disabled { opacity: .5; cursor: wait; }
.muted { color: #8a918c; font-size: 13px; margin-top: 12px; }

/* --- top bar --- */
#top {
  position: fixed; top: 0; inset-inline: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 16px 8px;
}
.name { font-weight: 800; font-size: 22px; color: var(--green); display: flex; gap: 8px; align-items: baseline; }
.name small { font-size: 11px; font-weight: 600; color: var(--gold); background: var(--glass); padding: 2px 8px; border-radius: 99px; }
.ghost { background: var(--glass); border: 0; border-radius: 99px; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }

/* --- subtitle bubble --- */
#bubble {
  position: fixed; z-index: 5; inset-inline: 16px; bottom: 190px;
  margin-inline: auto; max-width: 560px;
  background: var(--glass); backdrop-filter: blur(10px);
  border-radius: 16px; padding: 12px 16px;
  font-size: 17px; line-height: 1.6; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
#bubble.thinking { color: var(--gold); }
#bubble .you { display: block; font-size: 13px; font-weight: 600; color: #7a847e; margin-bottom: 4px; }

/* --- topics --- */
#topics {
  position: fixed; z-index: 5; inset-inline: 0; bottom: 96px;
  display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px;
  scrollbar-width: none;
}
#topics::-webkit-scrollbar { display: none; }
#topics button {
  flex: 0 0 auto; font: inherit; font-weight: 700; font-size: 14px;
  border: 0; border-radius: 99px; padding: 8px 14px; cursor: pointer;
  background: var(--glass); color: var(--green); backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
}
#topics button.active { background: var(--green); color: #fff; }

/* --- controls --- */
#controls {
  position: fixed; z-index: 5; inset-inline: 0; bottom: 0;
  display: flex; gap: 10px; align-items: center;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
}
#askForm { flex: 1; display: flex; background: #fff; border-radius: 99px; padding: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.08); }
#askInput { flex: 1; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 10px 14px; background: transparent; min-width: 0; }
#sendBtn { border: 0; background: var(--green); color: #fff; border-radius: 99px; width: 42px; font-size: 16px; cursor: pointer; }
body[dir="rtl"] #sendBtn { transform: scaleX(-1); }
#micBtn {
  flex: 0 0 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--green); color: #fff;
  box-shadow: 0 0 0 6px rgba(31, 90, 71, .18), 0 10px 24px rgba(18, 58, 49, .3);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#micBtn.rec { background: var(--rust); box-shadow: 0 0 0 10px rgba(154, 67, 18, .25); animation: pulse 1s infinite; }
#micBtn:disabled { opacity: .4; }
@keyframes pulse { 50% { box-shadow: 0 0 0 16px rgba(154, 67, 18, .12); } }

/* --- debug --- */
#dev {
  position: fixed; z-index: 6; top: 56px; inset-inline-end: 12px; width: min(360px, calc(100% - 24px));
  max-height: 45vh; overflow: auto; direction: ltr;
  background: rgba(18, 30, 26, .88); color: #d6f0e4; border-radius: 12px; padding: 10px 12px; font-size: 11px;
}
#dev h3 { font-size: 12px; margin-bottom: 6px; }
#dev pre { white-space: pre-wrap; font-family: ui-monospace, monospace; }

/* --- cover (wall artwork) --- */
.cover { position: fixed; inset: 0; z-index: 20; background: #f6ecdc; overflow: hidden; }
.cover[hidden] { display: none; }
.cover-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 100%; animation: coverIn 1.6s ease-out both; }
@keyframes coverIn { from { transform: scale(1.06); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cover-title { position: absolute; top: max(28px, env(safe-area-inset-top)); inset-inline: 16px; text-align: center; animation: fadeUp 1.2s .4s ease-out both; }
.cover-kicker { font-size: 11px; font-weight: 700; color: #2a78bd; margin-bottom: 8px; }
.cover-title h1 { font-size: clamp(38px, 11vw, 64px); line-height: 1.08; font-weight: 800; margin: 0; text-shadow: 0 2px 16px rgba(255,248,236,.9); }
.cover-title h1 .g { color: var(--green); }
.cover-title h1 .au { color: var(--gold); }
.cover-title p { font-size: 19px; font-weight: 600; color: #3a4a44; margin-top: 6px; text-shadow: 0 1px 10px rgba(255,248,236,.9); }
.cover-actions { position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); inset-inline: 16px; text-align: center; animation: fadeUp 1.2s .9s ease-out both; }
.cta { font: inherit; font-size: 22px; font-weight: 800; color: #fff; background: var(--green); border: 0; border-radius: 99px; padding: 14px 40px; cursor: pointer; box-shadow: 0 10px 30px rgba(18,58,49,.35), 0 0 0 6px rgba(255,255,255,.35); }
.cta:disabled { opacity: .5; }
.cover-langs { margin-top: 12px; display: flex; gap: 8px; justify-content: center; align-items: center; color: #fff; }
.cover-langs button { font: inherit; font-size: 14px; font-weight: 700; color: #fff; background: rgba(18,58,49,.55); border: 0; border-radius: 99px; padding: 6px 14px; cursor: pointer; backdrop-filter: blur(6px); }
.cover .muted { color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.4); }
@keyframes fadeUp { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
body.intro #top, body.intro #topics, body.intro #controls, body.intro #bubble { opacity: 0; pointer-events: none; }
#top, #topics, #controls, #bubble { transition: opacity .6s; }
.cover { transition: opacity .7s; }
.cover.leaving { opacity: 0; pointer-events: none; }
