:root{
  --bg:#fff7fc; --bg-art:none;
  --card:#ffffff; --text:#2b2b2b; --muted:#6b7280;
  --brand:#f472b6; --brand-2:#a78bfa; --ring:rgba(244,114,182,.35);
  --border:#f1e6f2;
}

/* legacy dark toggle still works if used */
:root.dark{
  --bg:#0f1220; --bg-art:none;
  --card:#14172a; --text:#e5e7eb; --muted:#9ca3af;
  --brand:#f472b6; --brand-2:#a78bfa; --ring:rgba(167,139,250,.35);
  --border:#23263a;
}

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

/* FULL-PAGE theme background */
body{
  font-family:ui-sans-serif,system-ui,Segoe UI,Roboto,Apple Color Emoji,Segoe UI Emoji;
  color:var(--text);
  background:var(--bg);
  background-image:var(--bg-art);   /* set per theme in themes.css */
  background-repeat:no-repeat;
  background-size:cover;
  background-attachment:fixed;
}

.container{max-width:1100px;margin:0 auto;padding:16px}
.header{display:flex;align-items:center;justify-content:space-between;padding-top:24px}
h1{font-size:28px;margin:0}.header-actions{display:flex;gap:8px}
.btn{border:1px solid var(--border);background:linear-gradient(#ffffff20,#00000005);color:var(--text);padding:8px 12px;border-radius:10px;cursor:pointer;box-shadow:0 1px 0 0 #00000010 inset,0 1px 2px #00000010}
.btn:hover{outline:2px solid var(--ring)}.btn:active{transform:translateY(1px)}.btn-outline{background:transparent}
.grid{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));padding-bottom:32px}
.card{background:var(--card);border:1px solid var(--border);border-radius:16px;padding:16px;box-shadow:0 2px 8px #00000010}
.link-grid{display:grid;gap:12px;grid-template-columns:repeat(auto-fill,minmax(160px,1fr))}
.link-tile{display:flex;flex-direction:column;gap:6px;padding:12px;border:1px solid var(--border);border-radius:12px;background:#ffffff10}
.link-top{display:flex;justify-content:space-between;align-items:center}
.link-top .fav{cursor:pointer;border:none;background:transparent;font-size:18px}
.link-top .fav[aria-pressed=true]{filter:drop-shadow(0 0 .3rem var(--ring))}
.link-title{font-weight:600}.link-url{color:var(--muted);font-size:12px;word-break:break-all}
.hint{margin-top:8px}.empty{display:grid;place-items:center;min-height:80px;border:1px dashed var(--border);border-radius:12px}
.empty .empty-text{color:var(--muted)}.theater-list{display:flex;flex-direction:column;gap:8px}
.theater-item{display:flex;justify-content:space-between;align-items:center;border:1px solid var(--border);border-radius:12px;padding:10px}
.small-row{display:flex;gap:8px;align-items:center;justify-content:space-between;margin-top:8px}
.checkbox{display:flex;align-items:center;gap:6px;color:var(--muted)}
textarea#journal{width:100%;min-height:120px;border:1px solid var(--border);border-radius:12px;padding:10px;background:transparent;color:var(--text)}
.tiny{color:var(--muted);font-size:12px}
.footer{display:flex;gap:12px;align-items:center;justify-content:space-between;border-top:1px solid var(--border);padding:16px}
.sticker-shelf{display:flex;gap:6px;flex-wrap:wrap}.sticker{font-size:20px}

/* Theater area */
.theater-embed{
  margin-top:10px;border:1px solid var(--border);border-radius:12px;overflow:hidden;height:75vh;
}
.theater-embed iframe{width:100%;height:100%;border:0}

/* Theme select styling */
select#themeSelect {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

/* Make dropdown options readable in all themes */
select#themeSelect option {
  background: var(--card);
  color: var(--text);
}
/* Buttons: make anchors look like real buttons */
a.btn { text-decoration: none; }

/* Primary style + better layout */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;            /* space between emoji and text */
  line-height: 1;
  padding: 10px 14px;
  border-radius: 12px;
}

/* Primary button matches current theme */
.btn-primary {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 0 #00000010 inset, 0 2px 6px #00000020;
  transition: background .2s ease, filter .2s ease;
}
.btn-primary:hover {
  background: var(--brand-2);
  outline: 2px solid var(--ring);
}
.btn-primary:active {
  filter: brightness(0.95);
}

/* Make the “Open Theater” button full width & centered */
.btn-wide { width: 100%; justify-content: center; }

/* If you only want the button in the Theater card to be wide: */
.theater-list + .btn { width: 100%; justify-content: center; }

/* Compact button grid for Quick Links */
.link-grid {
  /* overwrite from list mode to be a tighter grid */
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

/* Each link is a button-like anchor */
a.link-pill {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 1px 0 0 #00000010 inset, 0 2px 6px #00000014;
}
a.link-pill:hover { outline: 2px solid var(--ring); }

/* Title + description */
.link-pill .t { font-weight: 600; line-height: 1.2; }
.link-pill .d { color: var(--muted); font-size: 12px; line-height: 1.2; }

/* Clamp description to 2 lines so tiles stay short */
.link-pill .d {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Favorite star in the corner */
.link-pill .fav {
  position: absolute;
  top: 6px; right: 6px;
  border: none; background: transparent; cursor: pointer;
  font-size: 18px; line-height: 1;
}
.link-pill .fav[aria-pressed="true"] { filter: drop-shadow(0 0 .3rem var(--ring)); }

/* ==== POLISH PASS (non-destructive) ==== */

/* Use fun font for body + bold for titles */
body { font-family: "Nunito", ui-sans-serif, system-ui, Segoe UI, Roboto, Apple Color Emoji, Segoe UI Emoji; }
h1, h2, .link-title, .movie-title { font-weight: 700; letter-spacing: .2px; }

/* Enter animation for cards */
@keyframes fadeInUp { from {opacity:0; transform: translateY(8px);} to {opacity:1; transform:none;} }
.card { animation: fadeInUp .35s ease both; }

/* Buttons feel clicky & theme-y */
.btn {
  transition: transform .08s ease, outline-color .2s ease, filter .2s ease;
  will-change: transform;
}
.btn:hover { outline: 2px solid var(--ring); }
.btn:active { transform: translateY(1px) scale(0.99); }
a.btn { text-decoration: none; }

/* Primary uses theme colors (already added earlier) */
.btn-primary { background: var(--brand); color:#fff; border:1px solid transparent; }
.btn-primary:hover { background: var(--brand-2); }

/* Link tiles: compact pill buttons */
a.link-pill {
  transition: transform .12s ease, box-shadow .2s ease;
}
a.link-pill:hover { transform: translateY(-2px); }
a.link-pill:active { transform: translateY(0); }

/* Subtle animated background sparkle (uses --bg-art if defined) */
body { background-image: var(--bg-art); }
@media (prefers-reduced-motion:no-preference) {
  .floating { animation: floaty 4s ease-in-out infinite; }
  @keyframes floaty { 0%{transform:translateY(0)} 50%{transform:translateY(-4px)} 100%{transform:translateY(0)} }
}

/* Theater embed a bit more “framed” */
.theater-embed { box-shadow: 0 10px 30px #0000001a; }

/* Stickers: tiny pop when added or clicked */
@keyframes pop { 0%{transform:scale(.6);opacity:0} 100%{transform:scale(1);opacity:1} }
.sticker { animation: pop .18s ease; cursor: default; }
.sticker-shelf .sticker:hover { transform: scale(1.06); }

/* Pet: little happy bounce already toggled via .happy */
@media (prefers-reduced-motion:no-preference) {
  @keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }
  .pet.happy { animation: bounce .6s ease; }
}

/* Theme select matches theme */
select#themeSelect {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
}
select#themeSelect option { background: var(--card); color: var(--text); }

/* Nice scrollbar (Chromium/Edge/Safari) */
*::-webkit-scrollbar{height:10px;width:10px}
*::-webkit-scrollbar-track{background:transparent}
*::-webkit-scrollbar-thumb{background:linear-gradient(180deg,var(--brand),var(--brand-2));border-radius:999px}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Idle warning toast (bottom-right) */
#idleToast {
  position: fixed;
  right: 16px; bottom: 16px;
  max-width: 320px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px #0003;
  padding: 12px 14px;
  display: none;   /* toggled with .show */
  z-index: 9999;
}
#idleToast.show { display: block; }
#idleToast .row { display:flex; align-items:center; justify-content:space-between; gap:8px; }
#idleToast .tiny { color: var(--muted); }
#idleToast .btn { padding:6px 10px; }

/* Simple modal */
.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45);
  display: grid; place-items: center;
  padding: 20px;
}
.modal-card {
  width: min(720px, 96vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 30px #00000033;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.channel-btn {
  display: flex; flex-direction: column; gap: 4px;
  align-items: flex-start; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 12px;
  cursor: pointer;
  text-decoration: none; color: var(--text);
}
.channel-btn:hover { outline: 2px solid var(--ring); }
.channel-btn .t { font-weight: 700; }
.channel-btn .d { font-size: 12px; color: var(--muted); }
/* === Tile Layout (Homepage) === */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.tile {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
  transition: transform .1s ease, box-shadow .15s ease;
  box-shadow: 0 2px 6px #00000014;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px #00000022; }
.tile .emoji { font-size: 22px; }
.tile .title { font-weight: 700; line-height: 1.2; }
.tile .desc { font-size: 12px; opacity: .8; line-height: 1.2; }


/* === Stuffie Buddy (animated) === */
#stuffieBuddy {
  position: fixed;
  left: 16px; bottom: 16px;
  z-index: 9990;
  display: grid; gap: 6px; place-items: center;
  user-select: none;
}

/* Button frame */
.stuffie-btn {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 6px 18px #00000022;
  cursor: pointer;
  transition: transform .12s ease;
  overflow: hidden;
}

/* The emoji gets its own animated span */
.stuffie-emoji {
  font-size: 34px;
  line-height: 1;
  display: inline-block;
  transform-origin: 60% 60%; /* nicer “wave” pivot */
}

/* Subtle idle float (continuous) */
@media (prefers-reduced-motion: no-preference) {
  .stuffie-btn:not(.sleeping) .stuffie-emoji {
    animation: stuffie-float 3.8s ease-in-out infinite;
  }
  @keyframes stuffie-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
  }
}

/* Click “wave” animation */
@keyframes stuffie-wave {
  0%   { transform: rotate(0deg); }
  25%  { transform: rotate(16deg); }
  50%  { transform: rotate(-16deg) scale(1.02); }
  75%  { transform: rotate(12deg); }
  100% { transform: rotate(0deg); }
}
.stuffie-btn.wave .stuffie-emoji {
  animation: stuffie-wave .7s ease both;
}

/* Periodic bounce to show it’s alive */
@keyframes idle-bounce {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-6px); }
}
.stuffie-btn.idle {
  animation: idle-bounce .9s ease;
}

/* Speech bubble */
.stuffie-bubble {
  font-size: 12px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 10px;
  box-shadow: 0 6px 18px #00000018;
  max-width: 200px;
}

/* Nap mode visuals */
.stuffie-btn.sleeping {
  filter: saturate(.7) brightness(.95);
}
.stuffie-btn.sleeping .stuffie-emoji {
  animation: stuffie-sleep 5s ease-in-out infinite !important;
  opacity: .9;
}
@keyframes stuffie-sleep {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(1px) scale(0.98); } /* gentle “breathing” */
}

/* Tiny Zzz badge shown during nap */
.stuffie-zzz {
  position: absolute;
  top: -6px; right: -2px;
  font-size: 12px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 6px;
  box-shadow: 0 4px 10px #00000018;
  display: none;
}
.stuffie-btn.sleeping + .stuffie-zzz { display: inline-block; }

/* Picker modal */
#stuffieModal .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.stuffie-option {
  display: grid; gap: 6px; place-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
}
.stuffie-option:hover { outline: 2px solid var(--ring); }
.stuffie-option .e { font-size: 28px; }
.stuffie-option .n { font-size: 12px; color: var(--muted); }

/* Nap toggle row in bubble */
.stuffie-actions {
  display: flex; gap: 6px; margin-top: 6px;
}
.stuffie-actions .btn {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
}

/* === Star Jar === */
.star-progress { display:grid; gap:8px; margin-top:8px; }
.star-progress .bar {
  position: relative;
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.star-progress .bar .fill {
  position: absolute; inset: 0 0 0 auto; /* left to right */
  width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px;
  transition: width .3s ease;
}
.stars {
  font-size: 20px;
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
}

/* === Affirmations Drawer === */
.aff-drawer {
  position: fixed;
  right: 16px; bottom: 16px;
  z-index: 9995;
  display: grid; gap: 8px;
  justify-items: end;
}
.aff-toggle { /* uses .btn styles already */ }

.aff-panel {
  width: min(320px, 92vw);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 30px #0000002a;
  padding: 12px;
  transform: translateY(8px);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}
.aff-panel.show {
  transform: translateY(0);
  opacity: 1;
}
.aff-text {
  font-size: 14px;
  line-height: 1.4;
}
.aff-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 10px;
}

/* What's New toast */
#newsToast {
  position: fixed;
  right: 16px; bottom: 16px;
  max-width: 320px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px #0003;
  padding: 12px 14px;
  display: none;
  z-index: 9999;
}
#newsToast.show { display: block; }
#newsToast .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#newsToast .tiny { color: var(--muted); }
#newsToast .btn { padding: 6px 10px; }
/* === Ambient Mixer === */
.mix-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
}
.mix-left .mix-name { font-weight: 700; }
.mix-right { display: flex; gap: 8px; align-items: center; }
.mix-right input[type="range"] {
  width: min(340px, 60vw);
}
.mix-val { min-width: 44px; text-align: right; }
.mix-sep {
  border: 0; border-top: 1px dashed var(--border);
  margin: 10px 0;
}


/* Theater fills the screen when fullscreen */
.theater-embed:fullscreen,
.theater-embed:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  margin: 0;
}

/* Status board */
.status-item{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 2px 6px #00000014;
  margin: 10px 0;
}
.status-head{
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.status-head .mood{ font-size: 18px; }
.status-head .name{ font-weight: 700; }
.status-head .time{ margin-left: auto; color: var(--muted); }
.status-text{
  white-space: pre-wrap; line-height: 1.35; margin-bottom: 8px;
}
.status-actions{ display: flex; gap: 8px; }
/* Mood select styling (matches theme) */
#mood {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  line-height: 1.4;
  padding: 8px 12px;       /* same feel as .btn */
  appearance: none;        /* cleaner on some browsers */
}

/* Ensure options are readable in all themes */
select option,
#mood option {
  background: var(--card);
  color: var(--text);
}
.reply-item { padding:8px 0; }
.reply-item + .reply-item { border-top:1px dashed var(--border); }
.reply-head { display:flex; gap:8px; align-items:center; }
.reply-text { white-space:pre-wrap; word-break:break-word; margin-top:2px; }

/* Hide the buddy only on the breathing page */
body[data-page="breathe"] #stuffieBuddy {
  display: none;
}