/* ==========================================================================
   CALIX — style.css
   Organized: tokens · base · desktop · splash · login · sidebar · mascot ·
              main/chat · library/feed/settings · iOS & Android fixes
   Mobile-first. Desktop overrides live in ONE @media (min-width: 768px) block.
   ========================================================================== */

/* ---------- 1. reset / base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #f0fdfa 0%, #ecfdf5 30%, #f4f6f5 70%, #f0fdfa 100%);
  color: #1a1a1a;
  display: flex; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
}

/* The app shell: a centered 480px phone column on mobile/tablet.
   On desktop it becomes a full-width row (see desktop section). */
.phone {
  width: 100%; max-width: 480px;
  min-height: 100vh; min-height: 100dvh;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  box-shadow: 0 0 40px rgba(47,191,155,.08);
}

#mainCol { display: flex; flex-direction: column; flex: 1; min-width: 0; }


/* ---------- 3. splash ---------- */
#splash {
  position: fixed; inset: 0; z-index: 9999; background: #0a0f0e;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .6s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
#galaxy { position: absolute; inset: 0; width: 100%; height: 100%; }
#splashLogo {
  position: relative; font-size: 54px; font-weight: 800; letter-spacing: -1px;
  color: #fff; opacity: 0; animation: logoIn 1.1s ease .8s forwards;
  text-shadow: 0 0 34px rgba(47,191,155,.9), 0 0 80px rgba(47,191,155,.4);
}
#splashTag {
  position: absolute; bottom: 15%; color: #5eead4; font-size: 13px;
  letter-spacing: 3px; text-transform: uppercase; opacity: 0;
  animation: logoIn 1s ease 1.3s forwards;
}
@keyframes logoIn { to { opacity: 1; } }

/* ---------- 4. login ---------- */
#loginView {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 32px;
  text-align: center;
}
#loginView .logo { font-size: 42px; font-weight: 800; letter-spacing: -1px; margin: 0; }
#loginView .tag { color: #8a8f8d; font-size: 15px; margin: 10px 0 40px; }
.login-btn {
  width: 100%; max-width: 320px; padding: 14px; border-radius: 14px;
  font-size: 16px; font-weight: 600; cursor: pointer; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.g-btn { background: #fff; border: 1.5px solid #e3e7e5; color: #1a1a1a; }
.g-btn:active { background: #f4f6f5; }
.login-note {
  color: #b0b5b3; font-size: 12px; margin-top: 24px; max-width: 280px;
  line-height: 1.5;
}

/* ---------- 5. sidebar ---------- */
#scrim {
  position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
#scrim.show { opacity: 1; pointer-events: auto; }
#sidebar {
  position: absolute; top: 0; left: 0; bottom: 0; width: 270px; z-index: 50;
  background: #fff; transform: translateX(-100%); transition: transform .28s ease;
  display: flex; flex-direction: column; box-shadow: 2px 0 18px rgba(0,0,0,.12);
}
#sidebar.open { transform: translateX(0); }
.side-head { display: flex; align-items: center; gap: 12px; padding: 20px 16px 12px; }
.side-head b { font-size: 20px; letter-spacing: -.5px; }
#newChat {
  margin: 4px 16px 12px; padding: 12px; border-radius: 12px; border: none;
  background: #2fbf9b; color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer;
}
#newChat:active { opacity: .85; }
.side-sec {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px; color: #b0b5b3;
  text-transform: uppercase; padding: 10px 20px 4px;
}
#chatList { overflow-y: auto; max-height: 32vh; padding: 0 8px; }
.chat-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 10px 12px; border-radius: 10px; font-size: 14px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #1a1a1a;
}
.chat-item.active { background: #eefbf7; color: #0d7a5f; font-weight: 600; }
.chat-item:active { background: #eef0ef; }
.side-item {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 16px);
  margin: 1px 8px; text-align: left; background: none; border: none;
  padding: 11px 12px; border-radius: 10px; font-size: 15px; cursor: pointer;
  color: #1a1a1a;
}
.side-item:active, .side-item.active { background: #eefbf7; }
.side-item .ico { font-size: 18px; width: 24px; text-align: center; }
.side-foot { margin-top: auto; padding: 12px 8px calc(16px + env(safe-area-inset-bottom)); }

/* ---------- 6. mascot ---------- */
#mascot {
  width: 72px; height: 72px; flex-shrink: 0;
  animation: mbob 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(47,191,155,.45));
}
@keyframes mbob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
#mascot svg { width: 100%; height: 100%; display: block; overflow: visible; }
#mascot .earL, .hero-mascot .earL { animation: mearL 3.2s ease-in-out infinite; transform-origin: 20px 18px; transform-box: fill-box; }
#mascot .earR, .hero-mascot .earR { animation: mearR 2.7s ease-in-out infinite; transform-origin: 44px 18px; transform-box: fill-box; }
@keyframes mearL { 0%,100% { transform: rotate(0deg); } 30% { transform: rotate(-14deg); } 60% { transform: rotate(8deg); } }
@keyframes mearR { 0%,100% { transform: rotate(0deg); } 40% { transform: rotate(14deg); } 70% { transform: rotate(-8deg); } }
#mascot .pupil, .hero-mascot .pupil { animation: mlook 7s infinite; }
@keyframes mlook { 0%, 45%, 100% { transform: translateX(0); } 55% { transform: translateX(-3px); }
  65% { transform: translateX(3px); } 75% { transform: translateX(0); } }
#mascot .eye, .hero-mascot .eye { animation: mblink 4.5s infinite; transform-origin: center; transform-box: fill-box; }
@keyframes mblink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.08); } }
#mascot .armL { animation: mtypeL .5s ease-in-out infinite; transform-origin: 14px 48px; transform-box: fill-box; }
#mascot .armR { animation: mtypeR .5s ease-in-out infinite; transform-origin: 50px 48px; transform-box: fill-box; }
@keyframes mtypeL { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-4px) rotate(-8deg); } }
@keyframes mtypeR { 0%,100% { transform: translateY(-4px) rotate(8deg); } 50% { transform: translateY(0) rotate(0deg); } }
#mascot .mouth, .hero-mascot .smile { animation: msmile 6s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes msmile { 0%, 88%, 100% { transform: scale(1,1); } 92% { transform: scale(1.4,1.6); } 96% { transform: scale(1,1); } }
#mascot.laughing { animation: mlaugh .4s ease-in-out 6; }
@keyframes mlaugh { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-5px) rotate(3deg); } }
#mascot .sparkle, .hero-mascot .sparkle { animation: mtwinkle 2s infinite ease-in-out; transform-origin: center; transform-box: fill-box; }
#mascot .sparkle.s2 { animation-delay: .7s; }
#mascot .sparkle.s3 { animation-delay: 1.3s; }
@keyframes mtwinkle { 0%,100% { opacity: .3; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.15); } }

/* ---------- 7. main / chat ---------- */
#appView { display: none; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
header { padding: 20px 16px 10px; display: flex; align-items: center; gap: 12px; }
#menuBtn {
  background: none; border: none; font-size: 24px; cursor: pointer;
  color: #1a1a1a; padding: 6px; line-height: 1;
}
header h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.5px; flex: 1; }
#avatar {
  width: 38px; height: 38px; border-radius: 50%; background: #eefbf7;
  color: #2fbf9b; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0; cursor: pointer;
}
#avatarWrap { position: relative; }
#avatarMenu {
  display: none; position: absolute; top: 46px; right: 0;
  background: #fff; border: 1px solid #e3e7e5; border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.12); overflow: hidden; z-index: 50;
  min-width: 170px;
}
#avatarMenu.show { display: block; }
.menu-credits {
  padding: 12px 16px; font-size: 14px; font-weight: 700; color: #0d7a5f;
  border-bottom: 1px solid #f0f2f1; background: #fbfdfc; white-space: nowrap;
}
#avatarMenu button {
  display: block; width: 100%; padding: 12px 16px; border: none;
  background: none; text-align: left; font-size: 14px; cursor: pointer;
  color: #1f2937;
}
#avatarMenu button:hover { background: #f0faf7; }
#avatarMenu button + button { border-top: 1px solid #f0f2f1; }
#miniMascot {
  width: 34px; height: 34px; flex-shrink: 0;
  animation: mbob 3s ease-in-out infinite;
  filter: drop-shadow(0 2px 6px rgba(47,191,155,.4));
}
#miniMascot.working { animation: mwork .7s ease-in-out infinite; }
@keyframes mwork { 0%,100% { transform: translateY(0) rotate(-6deg) scale(1); }
  50% { transform: translateY(-4px) rotate(6deg) scale(1.08); } }
#miniMascot .m-blush { top: 15px; width: 5px; height: 3px; }
#miniMascot .m-blush.l { left: 4px; } #miniMascot .m-blush.r { right: 4px; }

.view { display: none; flex-direction: column; flex: 1; min-height: 0; }
.view.on { display: flex; }
#out {
  flex: 1; overflow-y: auto; min-height: 0; padding: 10px 18px; display: flex;
  flex-direction: column; gap: 12px;
  -webkit-overflow-scrolling: touch;
}
/* message cards must keep their natural height: #out is a fixed-height flex
   column, so without flex-shrink:0 the bubbles squash vertically instead of
   overflowing + scrolling (regression from the viewport-locked layout) */
#out > * { flex-shrink: 0; }
.welcome { text-align: center; padding: 40px 30px; color: #8a8f8d; }

/* ---------- welcome hero ---------- */
.welcome-hero {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 48px 24px 24px;
  transition: opacity .45s ease, transform .45s ease; max-width: 560px; margin: 0 auto;
}
.welcome-hero.fade { opacity: 0; transform: translateY(-18px) scale(.97); pointer-events: none; }
.hero-mascot {
  width: 96px; height: 96px; margin-bottom: 18px;
  animation: mbob 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 24px rgba(47,191,155,.35));
}
.hero-mascot svg { width: 100%; height: 100%; }
.hero-greet {
  font-size: 30px; font-weight: 700; letter-spacing: -.5px; color: #0f2e28;
  margin-bottom: 6px;
}
.hero-greet .name { color: #0d9488; }
.hero-sub { font-size: 15px; color: #6b8f86; }
.welcome .big { font-size: 20px; color: #1a1a1a; font-weight: 700; margin-bottom: 8px; }
.welcome p { font-size: 14px; line-height: 1.7; margin: 6px 0; }

/* ---------- chat cards: Claude-style minimal ---------- */
/* assistant replies are plain typography on the background — no bubbles.
   user messages are a small subtle pill, right aligned. */
.oc {
  background: none; border: none; border-radius: 0; overflow: visible;
  width: 100%; max-width: 780px; margin-left: auto; margin-right: auto;
  padding: 6px 0;
}
.oc .body {
  padding: 6px 2px; font-size: 15px; line-height: 1.65; color: #1c1e1d;
  white-space: pre-wrap; word-wrap: break-word;
}
/* user: quiet pill, right aligned inside the column */
.oc.me { display: flex; justify-content: flex-end; }
.oc.me .body {
  background: #edf0ef; border-radius: 20px; padding: 9px 17px;
  width: fit-content; max-width: 88%; color: #1c1e1d;
}
/* rich-reply markdown */
.oc .body strong { font-weight: 700; }
.oc .body em { font-style: italic; }
.oc .body .mdh { font-weight: 700; font-size: 16px; margin: 6px 0 4px; }
.oc .body ul, .oc .body ol { margin: 6px 0 6px 20px; padding: 0; }
.oc .body li { margin: 3px 0; }
.oc .body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; background: rgba(127,140,135,.15); padding: 1px 5px; border-radius: 4px; }
.oc .media { border-radius: 14px; overflow: hidden; position: relative; }
.oc img, .oc video {
  width: 100%; display: block; background: #f4f6f5;
}
.oc video { aspect-ratio: 16/9; object-fit: cover; }
.oc img { height: auto; }
.typing { color: #8a8f8d; font-style: italic; }
.oc.err .body { color: #a33; }

/* quiet action row under each assistant reply */
.msg-actions {
  display: flex; gap: 2px; padding: 4px 0 6px; margin-left: -7px;
  opacity: 0; transition: opacity .18s ease;
}
.oc:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: .8; } }
.msg-actions button {
  border: none; background: none; cursor: pointer; padding: 7px;
  color: #9aa0a6; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center;
  transition: color .15s ease, background .15s ease, transform .15s ease;
}
.msg-actions button:hover { color: #1c1e1d; background: #f1f4f3; }
.msg-actions button:active { transform: scale(.92); }
.msg-actions button.on { color: #0d9488; }
.msg-actions button.on[data-act="dislike"] { color: #d97706; }
.msg-actions svg { width: 17px; height: 17px; display: block; }

/* ---------- video tier picker ---------- */
#tiers { display: none; gap: 8px; padding: 10px 18px 4px; }
#tiers.show { display: flex; }
.tier {
  flex: 1; text-align: center; border: 1.5px solid #e3e7e5; border-radius: 12px;
  padding: 9px; font-size: 13.5px; cursor: pointer; background: #fff;
}
.tier b { display: block; font-size: 14px; }
.tier span { color: #8a8f8d; font-size: 11.5px; }
.tier.active { border-color: #2fbf9b; background: #eefbf7; }

/* ---------- composer: one clean unified box ---------- */
.bar {
  position: relative;
  display: flex; align-items: center; gap: 2px;
  width: calc(100% - 28px); max-width: 780px;
  margin: 0 auto calc(22px + env(safe-area-inset-bottom));
  background: #fff; border: 1.5px solid #e3e7e5; border-radius: 28px;
  padding: 6px 6px 6px 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.07);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.bar:focus-within { border-color: #2fbf9b; box-shadow: 0 4px 24px rgba(47,191,155,.14); }
#inp {
  flex: 1; border: none; background: transparent; box-shadow: none;
  border-radius: 0; padding: 11px 8px;
  font-size: 15px; outline: none; min-width: 0; color: #1c1e1d;
}
#inp:focus { border: none; }
#inp::placeholder { color: #9aa0a6; }
/* quiet icon buttons inside the composer */
#attach, #mic {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: none; color: #6b7280; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
#attach:hover, #mic:hover { background: #f1f4f3; color: #1c1e1d; }
#attach:active, #mic:active { transform: scale(.9); }
#attach svg, #mic svg { width: 20px; height: 20px; display: block; }
#mic.live { background: #fee2e2; color: #ef4444; animation: micpulse 1s infinite; }
#send {
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: #2fbf9b; color: #fff; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
#send:hover { background: #28a988; }
#send:active { transform: scale(.9); }
#send:disabled { opacity: .45; }
#send svg { width: 18px; height: 18px; display: block; }
#attachMenu {
  display: none; position: absolute; bottom: calc(100% + 10px); left: 10px;
  background: #fff; border: 1px solid #e3e7e5; border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.12); overflow: hidden; z-index: 50;
  min-width: 160px;
}
#attachMenu.show { display: block; }
#attachMenu button {
  display: block; width: 100%; padding: 12px 16px; border: none;
  background: none; text-align: left; font-size: 14px; cursor: pointer;
  color: #1f2937;
}
#attachMenu button:hover { background: #f0faf7; }
#attachMenu button + button { border-top: 1px solid #f0f2f1; }
@keyframes micpulse { 50% { transform: scale(1.12); } }


/* ---------- honest inline system note (not a model message) ---------- */
.sys-note {
  margin: 8px auto; max-width: 92%; text-align: center;
  font-size: 13px; color: #6b7280; background: #f4f6f5;
  border: 1px solid #e3e7e5; border-radius: 999px;
  padding: 8px 16px; line-height: 1.4;
}

/* ---------- placeholder views ---------- */
.soon {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 40px 20px; color: #6b7280;
}
.soon .ico { font-size: 48px; margin-bottom: 16px; }
.soon b { font-size: 18px; color: #1a1a1a; margin-bottom: 8px; }
.soon p { font-size: 14px; line-height: 1.6; max-width: 260px; }

/* ---------- library & feed ---------- */
.ideas-wrap { flex: 1; overflow-y: auto; padding: 20px 16px 32px; -webkit-overflow-scrolling: touch; }
.ideas-head { margin: 4px 4px 14px; }
.ideas-head b { font-size: 22px; letter-spacing: -.5px; }
.ideas-head p { color: #8a8f8d; font-size: 13px; margin: 4px 0 0; }
.ideas-cats { display: flex; gap: 8px; overflow-x: auto; padding: 2px 4px 12px; -webkit-overflow-scrolling: touch; }
.idea-cat {
  flex-shrink: 0; padding: 7px 14px; border-radius: 20px; border: 1.5px solid #e3e7e5;
  background: #fff; font-size: 13px; font-weight: 600; color: #6b7280; cursor: pointer;
}
.idea-cat.on { background: #0d9488; border-color: #0d9488; color: #fff; }
.ideas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.idea-card {
  background: #fff; border: 1px solid rgba(47,191,155,.14); border-radius: 16px;
  padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 2px 12px rgba(47,191,155,.06); transition: transform .15s ease, box-shadow .15s ease;
}
.idea-card:active { transform: scale(.97); box-shadow: 0 1px 6px rgba(47,191,155,.1); }
.idea-top { display: flex; align-items: center; justify-content: space-between; }
.idea-icon { font-size: 26px; }
.idea-cat-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: #0d9488; background: rgba(47,191,155,.1); padding: 3px 8px; border-radius: 10px;
}
.idea-title { font-size: 15px; letter-spacing: -.2px; }
.idea-desc { font-size: 12.5px; color: #6b7280; line-height: 1.45; margin: 0; flex: 1; }
.idea-go { font-size: 13px; font-weight: 700; color: #0d9488; margin-top: 4px; }

/* ---------- goals ---------- */
.goals-wrap { flex: 1; overflow-y: auto; padding: 20px 16px 32px; -webkit-overflow-scrolling: touch; }
.goals-head { margin: 4px 4px 14px; }
.goals-head b { font-size: 22px; letter-spacing: -.5px; }
.goals-head p { color: #8a8f8d; font-size: 13px; margin: 4px 0 0; }
.goal-add { display: flex; gap: 8px; margin-bottom: 16px; }
.goal-add input {
  border: 1.5px solid #e3e7e5; border-radius: 12px; padding: 10px 12px;
  font-size: 14px; outline: none; background: #fff;
}
.goal-add input:focus { border-color: #2fbf9b; }
#goalTitle { flex: 1; min-width: 0; }
#goalDate { width: 132px; flex-shrink: 0; color: #6b7280; }
#goalAddBtn {
  flex-shrink: 0; padding: 10px 18px; border-radius: 12px; border: none;
  background: #0d9488; color: #fff; font-size: 14px; font-weight: 700; cursor: pointer;
}
#goalAddBtn:active { opacity: .85; }
.goal-card {
  background: #fff; border: 1px solid rgba(47,191,155,.14); border-radius: 16px;
  padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 12px rgba(47,191,155,.06);
}
.goal-card.done { opacity: .65; }
.goal-card.done .goal-text b { text-decoration: line-through; }
.goal-main { display: flex; align-items: flex-start; gap: 10px; }
.goal-check {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #d1d5db; background: #fff; color: transparent;
  font-size: 14px; font-weight: 800; cursor: pointer; line-height: 1;
}
.goal-check.on { background: #22c55e; border-color: #22c55e; color: #fff; }
.goal-text { flex: 1; min-width: 0; }
.goal-text b { font-size: 15px; }
.goal-text p { font-size: 13px; color: #6b7280; margin: 4px 0 0; line-height: 1.45; }
.goal-date { font-size: 12px; color: #0d9488; font-weight: 600; }
.goal-status { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 10px;
  border-radius: 999px; border: 1px solid #2a3548; color: #8a8f8d; margin-left: 8px;
  vertical-align: middle; }
.goal-status.done { border-color: #0d9488; color: #0d9488; background: rgba(13,148,136,.08); }
.goal-del {
  flex-shrink: 0; background: none; border: none; font-size: 20px;
  color: #d1d5db; cursor: pointer; padding: 0 4px; line-height: 1;
}
.goal-del:active { color: #ef4444; }
.goal-prog { margin-top: 10px; }
.goal-bar { height: 8px; background: #f0f4f3; border-radius: 4px; overflow: hidden; }
.goal-fill { height: 100%; background: linear-gradient(90deg, #2fbf9b, #0d9488); border-radius: 4px; transition: width .3s ease; }
.goal-pct-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.goal-pct-row span { font-size: 12px; font-weight: 700; color: #6b7280; min-width: 36px; text-align: center; }
.goal-pct-row button {
  width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid #e3e7e5;
  background: #fff; font-size: 15px; font-weight: 700; color: #0d9488; cursor: pointer; line-height: 1;
}
.goal-pct-row button:active { background: #f0faf7; }
.lib-wrap { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.lib-item {
  background: #fff; border-radius: 12px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.lib-media img, .lib-media video { width: 100%; height: 150px; object-fit: cover; display: block; }
.lib-media .lib-file { display: flex; align-items: center; justify-content: center;
  width: 100%; height: 150px; font-size: 44px; text-decoration: none;
  background: linear-gradient(135deg, #f0fdfa, #ecfdf5); }
.lib-media .lib-file.lib-preview span { font-size: 15px; font-weight: 600; color: #0e1512; opacity: .75; }
.lib-prompt {
  padding: 8px 10px; font-size: 12px; color: #4b5563;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.feed-wrap {
  flex: 1; overflow-y: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 16px; -webkit-overflow-scrolling: touch;
}
.feed-item {
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.feed-meta { padding: 10px 14px 0; font-size: 12px; color: #9ca3af; }
.feed-media img, .feed-media video {
  width: 100%; max-height: 320px;
  object-fit: contain; display: block; background: #000;
}
.feed-prompt { padding: 10px 14px 14px; font-size: 14px; color: #374151; font-style: italic; }

/* ---------- code blocks ---------- */
.codeblock {
  margin: 12px 0; border-radius: 12px; overflow: hidden;
  background: #f6f8f7; border: 1px solid #e3e7e5;
}
.codehead {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 14px; background: #eef1f0; font-size: 12px; color: #6b7280;
  font-weight: 500;
}
.codehead button {
  background: #fff; color: #374151; border: 1px solid #d1d5db; border-radius: 8px;
  padding: 4px 12px; font-size: 12px; cursor: pointer; font-weight: 500;
  transition: background .15s ease;
}
.codehead button:hover { background: #f3f4f6; }
.codehead button:active { transform: scale(0.96); }
.codeblock pre { margin: 0; padding: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.codeblock code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13.5px; color: #1c1e1d; white-space: pre; line-height: 1.6;
}

/* ---------- typing dots ---------- */
.tdots { display: inline-flex; gap: 5px; padding: 6px 2px; }
.tdots span {
  width: 8px; height: 8px; border-radius: 50%; background: #9ca3af;
  animation: tbounce 1.2s infinite ease-in-out;
}
.tdots span:nth-child(2) { animation-delay: 0.15s; }
.tdots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tbounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; } }

/* ---------- settings ---------- */
.set-wrap { flex: 1; overflow-y: auto; padding: 8px 18px 30px; -webkit-overflow-scrolling: touch; }
.set-group { margin-bottom: 22px; }
.set-group > b {
  display: block; font-size: 13px; letter-spacing: 1px;
  text-transform: uppercase; color: #8a8f8d; margin-bottom: 10px;
}
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; border: 1.5px solid #eef0ef; border-radius: 14px;
  margin-bottom: 8px; font-size: 15px; background: #fff;
}
.set-row .sub { display: block; font-size: 12.5px; color: #8a8f8d; margin-top: 3px; }
.seg { display: flex; border: 1.5px solid #e3e7e5; border-radius: 12px; overflow: hidden; }
.seg button {
  flex: 1; border: none; background: #fff; padding: 10px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer; color: #8a8f8d;
}
.seg button.on { background: #2fbf9b; color: #fff; }
#logoutBtn {
  width: 100%; padding: 13px; border-radius: 14px; border: 1.5px solid #f3c1c1;
  background: #fff; color: #c0392b; font-size: 15px; font-weight: 600;
  cursor: pointer;
}

/* ==========================================================================
   8. iOS & Android fixes — phone-browser quirks live here, away from the
   main layout, so the two never fight.
   ========================================================================== */
@media (max-width: 767px) {
  /* iOS Safari zooms the page when an input is under 16px — keep it at 16 */
  #inp { font-size: 16px; }

  /* notch / home-bar safe areas */
  header { padding-top: calc(20px + env(safe-area-inset-top)); }
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* long-press callout off on tappable controls */
  button, #avatar { -webkit-touch-callout: none; }
}

/* touch devices: kill the sticky hover states, keep :active feedback */
@media (hover: none) {
  #avatarMenu button:hover, #attachMenu button:hover { background: none; }
  #avatarMenu button:active, #attachMenu button:active { background: #f0faf7; }
}

/* small landscape phones: keep the composer usable */
@media (max-height: 430px) and (orientation: landscape) {
  .welcome-hero { padding-top: 20px; }
  #chatList { max-height: 24vh; }
}

/* ---------- website preview (browser-chrome style) ---------- */
.preview-wrap {
  border: 1px solid #e8eceb; border-radius: 12px; overflow: hidden;
  background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}
/* side panel is desktop-only: hidden by default, shown via .split on desktop */
#previewSide { display: none !important; }
.preview-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid #f0f2f1;
  background: #f4f6f5;
}
.pvseg { display: inline-flex; background: #e9edec; border-radius: 10px; padding: 3px; gap: 2px; flex-shrink: 0; }
.pvseg-btn { border: none; background: transparent; padding: 6px 10px; border-radius: 7px; cursor: pointer; color: #8a8f8d; display: inline-flex; align-items: center; justify-content: center; min-width: 38px; min-height: 32px; -webkit-tap-highlight-color: transparent; }
.pvseg-btn.on { background: #fff; color: #1a1a1a; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.pvseg-btn svg { display: block; }
.preview-actions { display: flex; gap: 2px; align-items: center; flex-shrink: 0; margin-left: auto; }
.preview-actions button, .preview-actions a {
  border: none; background: transparent; padding: 8px; border-radius: 8px;
  cursor: pointer; color: #5a5e5c; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; min-height: 38px; -webkit-tap-highlight-color: transparent;
}
.preview-actions button:active, .preview-actions a:active { background: #e2e8e6; }
.preview-actions svg { display: block; }
.preview-frame-holder { height: 420px; background: #101314; padding: 10px; display: flex; }
.preview-frame-holder iframe {
  flex: 1; width: 100%; border: none; display: block; background: #fff;
  border-radius: 8px; min-height: 0;
}
.preview-frame-holder.mobile {
  justify-content: center; padding: 12px 0;
}
.preview-frame-holder.mobile iframe {
  width: 375px; max-width: calc(100% - 24px); height: 100%;
  border: 7px solid #1a1a1a; border-radius: 24px; flex: none;
}
/* fullscreen preview overlay */
.preview-fullscreen {
  position: fixed; inset: 0; z-index: 9000; background: #fff;
  display: flex; flex-direction: column;
}
.preview-fullscreen .pvfs-bar {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid #eef0ef;
  background: #f4f6f5; flex-shrink: 0;
}
.pvfs-close {
  border: none; background: transparent; cursor: pointer; color: #5a5e5c;
  padding: 8px 12px; border-radius: 8px; min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pvfs-close:active { background: #e2e8e6; }
.preview-fullscreen iframe {
  flex: 1; width: 100%; border: none; background: #fff; min-height: 0;
}

/* ---------- tier badge on generated media ---------- */
.media { position: relative; }
.tier-tag {
  position: absolute; top: 8px; right: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  padding: 4px 10px; border-radius: 20px; color: #fff;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.tier-tag.pro { background: rgba(47, 191, 155, 0.85); }
.tier-tag.free { background: rgba(90, 94, 92, 0.75); }

/* ---------- desktop layout (min-width: 768px). LAST in file so these
   overrides beat the mobile-first base rules above. Keep the 768px
   breakpoint in sync with openSide() in app.js. ---------- */
@media (min-width: 768px) {
  body { justify-content: flex-start; }
  body.sb-hidden #sidebar { display: none !important; }

  .phone {
    max-width: none; flex-direction: row;
    background: transparent;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none;
  }

  /* appView must be a ROW on desktop so the sidebar is a left rail,
     not a top strip (its children are #sidebar + #mainCol) */
  #appView { flex: 1; flex-direction: row; }
  #loginView { flex: 1; } /* keeps the login screen centered on desktop */

  #sidebar {
    position: relative; transform: none;
    width: 280px; flex-shrink: 0;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(47,191,155,.12);
    box-shadow: none;
  }
  #sidebar.open { transform: none; }
  #scrim { display: none; }

  #mainCol {
    flex: 1; display: flex; flex-direction: column; min-width: 0;
    min-height: 100vh; min-height: 100dvh;
  }

  #menuBtn { display: block; }
  .welcome-hero { max-width: 640px; }
  #out { max-width: 760px; margin: 0 auto; width: 100%; }
  .bar { max-width: 760px; margin: 0 auto; width: 100%; }

  .hero-mascot { width: 120px; height: 120px; }
  .hero-greet { font-size: 36px; }

  /* ---------- side-by-side preview (desktop only) ---------- */
  #previewSide { display: none; }
  #view-chat.split {
    display: grid;
    grid-template-columns: minmax(340px, 42%) 1fr;
    grid-template-rows: 1fr auto auto;
    gap: 0; height: 100%;
    min-height: 0;
  }
  #view-chat.split #out {
    grid-column: 1; grid-row: 1;
    max-width: none; margin: 0; width: auto;
    border-right: 1px solid #eef0ef;
    overflow-y: auto; min-height: 0;
  }
  #view-chat.split #tiers { grid-column: 1; grid-row: 2; max-width: none; margin: 0; }
  #view-chat.split .bar { grid-column: 1; grid-row: 3; max-width: none; margin: 0; }
  #view-chat.split #previewSide {
    display: flex !important; flex-direction: column;
    grid-column: 2; grid-row: 1 / 4;
    background: #fff; min-height: 0; min-width: 0;
    border-left: 1px solid #e8eceb;
  }
  /* hide the inline card's iframe on desktop when side panel is active —
     the side panel IS the preview; the card would just be an empty bar */
  #view-chat.split .preview-wrap { display: none; }
  .pvside-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-bottom: 1px solid #f0f2f1;
    background: #f4f6f5; flex-shrink: 0;
  }
  .pvside-frame-holder { flex: 1; min-height: 0; background: #101314; padding: 12px; display: flex; }
  .pvside-frame-holder iframe {
    flex: 1; width: 100%; border: none; display: block; background: #fff;
    border-radius: 10px; min-height: 0;
  }
  .pvside-frame-holder.mobile {
    justify-content: center; padding: 16px 0;
  }
  .pvside-frame-holder.mobile iframe {
    width: 375px; max-width: calc(100% - 32px); height: 100%;
    border: 8px solid #1a1a1a; border-radius: 28px; flex: none;
  }
  #previewSide .preview-actions button, #previewSide .preview-actions a {
    border: none; background: transparent; padding: 8px; border-radius: 8px;
    cursor: pointer; color: #5a5e5c; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; min-height: 38px;
  }
  #previewSide .preview-actions button:hover, #previewSide .preview-actions a:hover {
    background: #e2e8e6;
  }
  #previewSide .preview-actions svg { display: block; }

  /* ---------- fixed sidebar: lock the app to the viewport so ONLY the
     inner regions scroll. Root cause of the sidebar drifting with the chat:
     the whole flex chain (body > .phone > #appView > #mainCol) was
     min-height-based with no definite height, so long chats stretched the
     page and the BODY scrolled — carrying the sidebar along. With definite
     heights, #out's own overflow-y takes over and the rail never moves.
     Mobile drawer (base rules) untouched. ---------- */
  html, body { height: 100%; }
  body { overflow: hidden; }
  .phone { height: 100vh; height: 100dvh; min-height: 0; }
  #appView { height: 100%; min-height: 0; }
  #sidebar { height: 100%; min-height: 0; }
  #mainCol { height: 100%; min-height: 0; }
  /* chat list gets the leftover sidebar space and scrolls on its own —
     rail (New chat, Explore links) stays pinned. Overrides the vh caps. */
  #chatList { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; }
  /* only #out and #chatList may yield space in the fixed-height chain —
     header, composer, and the sidebar rails must never shrink */
  #mainCol > header { flex-shrink: 0; }
  #view-chat > #tiers, #view-chat > .bar { flex-shrink: 0; }
  #sidebar > .side-head, #sidebar > #newChat, #sidebar > .side-sec,
  #sidebar > .side-item, #sidebar > .side-foot { flex-shrink: 0; }
}

/* ==========================================================================
   9. Plans & billing — matches app light theme (white cards, teal accent)
   ========================================================================== */
header { position: relative; }
.plan-pill {
  position: static; transform: none; flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1.5px solid #e3e7e5; border-radius: 999px;
  padding: 7px 15px; font-size: 13px; font-weight: 700; color: #1a1a1a;
  cursor: pointer; white-space: nowrap; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.plan-pill .chev { font-size: 10px; color: #8a8f8d; }
.plan-pill.pro { border-color: #2fbf9b; color: #0d7a5f; }
.plan-pill:active { background: #f0faf7; }
@media (max-width: 380px) {
  .plan-pill { padding: 6px 11px; font-size: 12px; }
  header h1 { font-size: 19px; }
}

/* bottom sheets — transform-only animation for 60fps */
#sheetScrim {
  position: fixed; inset: 0; background: rgba(10, 20, 18, .45);
  opacity: 0; pointer-events: none; transition: opacity .28s ease;
  z-index: 90;
}
#sheetScrim.show { opacity: 1; pointer-events: auto; }
.bsheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 91;
  max-width: 560px; margin: 0 auto;
  background: #fff; border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 48px rgba(0, 0, 0, .18);
  transform: translateY(105%); transition: transform .34s cubic-bezier(.32,.72,.28,1);
  will-change: transform; max-height: 88vh;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.bsheet.open { transform: translateY(0); }
.sheet-handle {
  width: 40px; height: 4px; border-radius: 3px; background: #e3e7e5;
  margin: 10px auto 4px; flex-shrink: 0;
}
.sheet-body { padding: 10px 20px 26px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-body h2 { font-size: 20px; margin: 6px 0 4px; text-align: center; letter-spacing: -.3px; }
.sheet-hint { font-size: 13px; color: #8a8f8d; text-align: center; margin-bottom: 16px; }
.sheet-center { text-align: center; }
.sheet-later {
  display: block; width: 100%; background: none; border: none;
  color: #8a8f8d; font-size: 14px; padding: 12px; cursor: pointer; font-family: inherit;
}

.plan-card {
  position: relative; border: 1.5px solid #e3e7e5; border-radius: 16px;
  padding: 16px; margin-bottom: 12px; background: #fff;
}
.plan-card.hot { border-color: #2fbf9b; }
.plan-card .tag {
  position: absolute; top: -11px; right: 14px; background: #2fbf9b; color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: .6px;
  padding: 4px 11px; border-radius: 999px;
}
.pc-row { display: flex; justify-content: space-between; align-items: baseline; }
.pc-row b { font-size: 16px; }
.pc-price { font-size: 15px; font-weight: 700; color: #0d7a5f; }
.pc-price.dim { color: #8a8f8d; font-weight: 600; }
.pc-sub { font-weight: 400; color: #8a8f8d; font-size: 12px; }
.pc-list { list-style: none; margin: 8px 0 4px; padding: 0; font-size: 13px; color: #5b625f; line-height: 1.75; }
.pc-list li::before { content: "· "; color: #2fbf9b; font-weight: 700; }

.cta-primary {
  display: block; width: 100%; border: none; border-radius: 12px;
  background: #2fbf9b; color: #fff; font-size: 15px; font-weight: 700;
  padding: 13px; margin-top: 12px; cursor: pointer; font-family: inherit;
}
.cta-primary:active { background: #28a886; }
.cta-ghost {
  display: block; width: 100%; border: 1.5px solid #e3e7e5; border-radius: 12px;
  background: #fff; color: #1a1a1a; font-size: 14px; font-weight: 600;
  padding: 12px; margin-top: 10px; cursor: pointer; font-family: inherit;
}
.cta-ghost:active { background: #f4f6f5; }

/* credits sheet */
.amt-box {
  border: 1.5px solid #e3e7e5; border-radius: 16px; padding: 18px;
  text-align: center; margin-bottom: 12px; background: #fbfdfc;
}
.amt-big { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.amt-eq { font-size: 13px; color: #0d7a5f; margin-top: 4px; font-weight: 600; }
.amt-chips { display: flex; gap: 8px; margin-bottom: 10px; }
.amt-chips button {
  flex: 1; border: 1.5px solid #e3e7e5; background: #fff; border-radius: 10px;
  padding: 10px 4px; font-size: 13px; font-weight: 700; color: #8a8f8d;
  cursor: pointer; font-family: inherit;
}
.amt-chips button.on { border-color: #2fbf9b; color: #0d7a5f; background: #eefbf7; }
.amt-custom-wrap { position: relative; margin-bottom: 4px; }
.amt-dollar {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 16px; color: #8a8f8d; pointer-events: none;
}
.amt-custom {
  width: 100%; border: 1.5px solid #e3e7e5; border-radius: 10px; padding: 11px 14px 11px 30px;
  font-size: 16px; font-family: inherit; box-sizing: border-box;
}
.min-note { font-size: 12.5px; color: #b3261e; text-align: center; margin: 2px 0 4px; min-height: 18px; font-weight: 600; }
.bonus-note { font-size: 12px; color: #0d7a5f; text-align: center; margin: 6px 0 4px; min-height: 17px; }
.info-row { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 8px 0 2px; }
.info-row span { font-size: 12.5px; color: #8a8f8d; }
.info-icon {
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #e3e7e5;
  background: #fff; color: #2fbf9b; font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-family: inherit; padding: 0;
}
.rate-pop {
  display: none; border: 1.5px solid #e3e7e5; border-radius: 14px;
  padding: 14px 16px; margin-top: 10px; background: #fbfdfc;
}
.info-icon.sm { width: 17px; height: 17px; font-size: 10px; vertical-align: 1px; margin-left: 2px; }
.pop-text { font-size: 12.5px; color: #5b625f; line-height: 1.55; text-align: center; margin: 0 0 10px; }
.sm-close { display: block; margin: 0 auto; padding: 7px 22px; font-size: 12px; }
.rate-pop.show { display: block; }
.rate-pop > b { display: block; font-size: 13.5px; margin-bottom: 8px; text-align: center; }
.rrow {
  display: flex; justify-content: space-between; font-size: 12.5px;
  padding: 7px 2px; border-bottom: 1px solid #eef0ef; color: #5b625f;
}
.rrow:last-of-type { border-bottom: none; }
.rrow span:last-child { font-weight: 700; color: #1a1a1a; }

/* pending downgrade notice */
.pend-note { border: 1.5px solid #e3e7e5; border-radius: 12px; padding: 10px 14px;
  font-size: 12.5px; color: #5b625f; background: #fbfdfc; margin-top: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pend-note b { color: #1a1a1a; }
.link-btn { background: none; border: none; color: #0d7a5f; font-weight: 700;
  font-size: 12.5px; cursor: pointer; font-family: inherit; padding: 4px 0;
  white-space: nowrap; }
.cta-primary:disabled, .cta-ghost:disabled { opacity: .45; cursor: default; }
/* billing meters */
.meter-block { margin: 4px 0 6px; }
.meter-label { display: flex; justify-content: space-between; font-size: 12.5px; color: #8a8f8d; margin-bottom: 6px; }
.meter-label b { color: #1a1a1a; }
.meter { height: 7px; background: #eef0ef; border-radius: 99px; overflow: hidden; margin-bottom: 13px; }
.meter > div { height: 100%; background: #2fbf9b; border-radius: 99px; transition: width .4s ease; }
.bill-btns { display: flex; gap: 8px; }
.bill-btns .cta-ghost { margin-top: 0; }
.credit-big { text-align: center; padding: 20px 0 8px; }
.credit-big .n { font-size: 42px; font-weight: 800; color: #0d7a5f; letter-spacing: -.5px; }
.credit-big .t { font-size: 12.5px; color: #8a8f8d; margin-top: 2px; }
.cred-row { display: flex; justify-content: space-between; align-items: center;
  padding: 12px 2px; margin-top: 6px; border-top: 1px solid #eef0ef;
  font-size: 13px; color: #5b625f; }
.cred-row b { color: #1a1a1a; font-size: 15px; }

/* video duration toggle inside the tiers box */
.dur-seg { display: none; gap: 6px; align-items: center; margin-left: auto; }
#tiers.show-dur .dur-seg { display: flex; }
.dur-seg button {
  border: 1.5px solid #e3e7e5; background: #fff; border-radius: 10px;
  padding: 8px 12px; font-size: 12.5px; font-weight: 700; color: #8a8f8d;
  cursor: pointer; font-family: inherit;
}
.dur-seg button.on { border-color: #2fbf9b; color: #0d7a5f; background: #eefbf7; }

/* download button on generated media tiles (tiered: pro clean, basic watermarked)
   Professional treatment: refined glass pill, crisp stroke icon, smooth
   hover/touch feedback — no emoji glyphs. */
.dl-btn { position: absolute; right: 10px; bottom: 10px; width: 36px; height: 36px;
  border-radius: 12px;
  background: rgba(255,255,255,.94); color: #3a3f3d;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; border: 1px solid rgba(0,0,0,.07);
  box-shadow: 0 2px 10px rgba(0,0,0,.12); z-index: 3;
  transition: transform .16s ease, box-shadow .16s ease, color .16s ease; }
.dl-btn svg { width: 16px; height: 16px; display: block; }
.dl-btn:hover { transform: translateY(-1px); color: #0d9488;
  box-shadow: 0 4px 14px rgba(0,0,0,.16); }
.dl-btn:active { transform: scale(.9);
  box-shadow: 0 2px 8px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.15); }
.lib-media { position: relative; }
/* one-line transient note (basic-tier watermark upsell) */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(8px);
  background: rgba(8,10,12,.88); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 9999; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; max-width: 88vw; text-align: center;
  border: 1px solid rgba(255,255,255,.14); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* markdown tables + highlight (renderBodyHTML) */
.mdtable-wrap { overflow-x: auto; margin: 8px 0; }
.mdtable { border-collapse: collapse; width: 100%; font-size: .92em; }
.mdtable th, .mdtable td { border: 1px solid rgba(0,0,0,.16); padding: 6px 10px; text-align: left; vertical-align: top; }
.mdtable thead th { background: rgba(0,0,0,.06); font-weight: 700; }
mark { background: #fff3b0; color: inherit; padding: 0 2px; border-radius: 3px; }

/* PDF file card — minimal, matches the quiet media language */
.pdf-card { position: relative; display: flex; align-items: center; }
.pdf-open { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  padding: 12px 52px 12px 14px; background: #f6f8f7; border: 1px solid #e3e7e5;
  border-radius: 14px; text-decoration: none; color: inherit; }
.pdf-open:hover { border-color: #0d9488; }
.pdf-badge { flex: none; font-size: 10px; font-weight: 800; letter-spacing: .08em;
  color: #fff; background: #b3402e; border-radius: 6px; padding: 4px 7px; }
.pdf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px; font-weight: 600; color: #1b2430; }
.lib-pdf span { font-size: 11px; font-weight: 800; letter-spacing: .06em;
  color: #b3402e; }
