/* Space Project — a dark, starry, kid-friendly theme */
:root {
  --bg: #0b1026;
  --bg-2: #131a3a;
  --card: #1a2350;
  --card-2: #20296a;
  --ink: #eef1ff;
  --muted: #9aa6d6;
  --accent: #ffcf5c;      /* sun yellow */
  --accent-2: #6ee7ff;    /* sky blue */
  --danger: #ff6b6b;
  --ok: #57e08a;
  --line: #33407e;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 700px at 70% -10%, #23306e 0%, var(--bg) 55%) fixed;
  min-height: 100vh;
}

/* Twinkling starfield */
.stars {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 40% 70%, #fff, transparent),
    radial-gradient(1px 1px at 65% 20%, #fff, transparent),
    radial-gradient(2px 2px at 80% 50%, #fff, transparent),
    radial-gradient(1px 1px at 10% 80%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 90% 85%, #fff, transparent),
    radial-gradient(1px 1px at 55% 90%, #fff, transparent);
  opacity: 0.5;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.25; } to { opacity: 0.7; } }
@media (prefers-reduced-motion: reduce) { .stars { animation: none; } }

/* Header */
.site-header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.9rem 1.4rem;
  background: rgba(12, 17, 46, 0.85);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(6px);
}
.brand { font-size: 1.25rem; font-weight: 800; color: var(--ink); text-decoration: none; }
.brand-rocket { filter: drop-shadow(0 0 6px var(--accent)); }
.main-nav { display: flex; gap: 1rem; margin-left: 1rem; flex-wrap: wrap; }
.main-nav a { color: var(--muted); text-decoration: none; font-weight: 600; padding: 0.2rem 0; }
.main-nav a:hover { color: var(--accent-2); }
.main-nav a.cta { color: var(--bg); background: var(--accent); padding: 0.35rem 0.7rem; border-radius: 999px; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.who { color: var(--muted); font-size: 0.9rem; }
.role-badge { font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 700; }
.role-editor { background: rgba(87,224,138,0.18); color: var(--ok); border: 1px solid var(--ok); }
.role-viewer { background: rgba(110,231,255,0.15); color: var(--accent-2); border: 1px solid var(--accent-2); }
.logout-form { margin: 0; }
.linkish { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; text-decoration: underline; }

/* Layout */
.content { max-width: 980px; margin: 1.6rem auto; padding: 0 1.2rem; }
.site-footer { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: 0.85rem; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Cards */
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem 1.6rem; margin-bottom: 1.4rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
h1 { margin-top: 0.2rem; }

/* Hero + stats */
.hero h1 { font-size: 2rem; }
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1rem 0; }
.stat { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 1.2rem; text-align: center; min-width: 96px; }
.stat-num { display: block; font-size: 1.8rem; font-weight: 800; color: var(--accent); }
.stat-label { color: var(--muted); font-size: 0.8rem; }
.quick-links, .form-actions, .edit-bar { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.6rem; }
.recent-list { list-style: none; padding: 0; }
.recent-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.recent-list a { color: var(--accent-2); text-decoration: none; font-weight: 600; }

/* Buttons */
.btn {
  display: inline-block; cursor: pointer; text-decoration: none;
  background: var(--card-2); color: var(--ink); border: 1px solid var(--line);
  padding: 0.5rem 0.95rem; border-radius: 999px; font-weight: 700; font-size: 0.95rem;
}
.btn:hover { border-color: var(--accent-2); }
.btn.cta { background: var(--accent); color: #241a00; border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.nav { min-width: 90px; }
.btn.small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Messages */
.messages { list-style: none; max-width: 980px; margin: 1rem auto 0; padding: 0 1.2rem; }
.msg { padding: 0.6rem 0.9rem; border-radius: 10px; margin-bottom: 0.5rem; }
.msg.success { background: rgba(87,224,138,0.15); border: 1px solid var(--ok); }
.msg.error { background: rgba(255,107,107,0.15); border: 1px solid var(--danger); }

/* Forms */
.form label { display: block; margin: 0.9rem 0 0.3rem; font-weight: 600; }
input[type="text"], input[type="url"], input[type="date"], input[type="password"],
input[type="file"], textarea, .form input, .auth-card input {
  width: 100%; padding: 0.6rem 0.7rem; border-radius: 10px;
  border: 1px solid var(--line); background: #0e1436; color: var(--ink); font: inherit;
}
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 1.2rem 0; padding: 1rem; }
legend { padding: 0 0.5rem; color: var(--muted); }
.link-row { display: grid; grid-template-columns: 1.4fr 1fr 1.4fr auto; gap: 0.5rem; margin-bottom: 0.5rem; }
.link-row input { width: 100%; }
.del-link { white-space: nowrap; align-self: center; color: var(--muted); }
.thumb-grid { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.thumb { width: 130px; text-align: center; }
.thumb img { width: 130px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* Mission Control — live feeds landing page */
.feed-hero { display: flex; gap: 1.2rem; align-items: center; text-decoration: none; color: var(--ink); overflow: hidden; }
.feed-hero img { width: 46%; max-width: 360px; max-height: 240px; object-fit: cover; border-radius: 12px; }
.feed-hero-text { flex: 1; min-width: 0; }
.feed-hero h2 { margin: 0.35rem 0; }
.feed-hero:hover { border-color: var(--accent-2); }
@media (max-width: 640px) { .feed-hero { flex-direction: column; } .feed-hero img { width: 100%; max-width: none; } }

.feed-section h2 { margin-top: 0; }
.feed-list { list-style: none; padding: 0; margin: 0; }
.feed-item { display: flex; gap: 0.9rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; padding-bottom: 0; }
.feed-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; border: 1px solid var(--line); }
.feed-item-body { flex: 1; min-width: 0; }
.feed-title { color: var(--ink); font-weight: 700; text-decoration: none; }
.feed-title:hover { color: var(--accent-2); }
.feed-meta { font-size: 0.78rem; color: var(--muted); margin: 0.15rem 0; }
.feed-badge { display: inline-block; background: var(--card-2); border: 1px solid var(--line); color: var(--accent-2); border-radius: 999px; padding: 0.05rem 0.5rem; font-size: 0.72rem; font-weight: 700; }
.feed-summary { margin: 0.25rem 0 0; font-size: 0.9rem; }
.feed-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.8rem; }
.feed-pic { display: block; text-decoration: none; color: var(--ink); background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.feed-pic img { width: 100%; height: 110px; object-fit: cover; display: block; }
.feed-pic-noimg { display: flex; align-items: center; justify-content: center; height: 110px; font-size: 2rem; background: var(--bg-2); }
.feed-pic-title { display: block; padding: 0.5rem 0.6rem; font-size: 0.82rem; font-weight: 600; }
.feed-pic:hover { border-color: var(--accent-2); }
.feed-more { display: inline-block; margin-top: 0.7rem; color: var(--accent-2); text-decoration: none; font-weight: 700; font-size: 0.9rem; }
.feed-more:hover { text-decoration: underline; }

/* Public pages + news detail */
.public-header { justify-content: space-between; }
.news-detail h1 { margin: 0.4rem 0 1rem; }
.news-detail-img { width: 100%; max-height: 520px; object-fit: contain; background: #0a0f28; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 1rem; }
.news-detail-summary { font-size: 1.02rem; line-height: 1.7; }
.about-list { list-style: none; padding: 0; margin: 0.5rem 0; }
.about-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.about-list li:last-child { border-bottom: 0; }

/* Auth */
.auth-card { max-width: 380px; margin: 3rem auto; }

/* Calendar */
.calendar-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.calendar-head h1 { margin: 0; }
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th { color: var(--muted); font-size: 0.8rem; padding: 0.4rem; text-align: left; }
.calendar td {
  border: 1px solid var(--line); vertical-align: top; height: 92px; padding: 0.3rem;
  background: rgba(26,35,80,0.5); border-radius: 6px;
}
.calendar td.empty { background: transparent; border-color: transparent; }
.calendar td.today { outline: 2px solid var(--accent); }
.daynum { font-size: 0.8rem; color: var(--muted); }
.cal-activity {
  display: block; margin-top: 0.2rem; font-size: 0.78rem; padding: 0.15rem 0.35rem;
  background: var(--accent-2); color: #041018; border-radius: 6px; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Slideshow + detail */
.slide-date { color: var(--accent); font-weight: 700; letter-spacing: 0.02em; }
.slide { background: linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem; box-shadow: 0 10px 30px rgba(0,0,0,0.35); }
.slide-images { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.slide-images figure { margin: 0; max-width: 320px; }
.slide-images img { border-radius: 10px; border: 1px solid var(--line); }
.slide-images figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }
.notes { line-height: 1.6; }
.notes a { color: var(--accent-2); }
.slide-links ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.slide-links a { color: var(--accent-2); }
.slide-controls { display: flex; align-items: center; justify-content: center; gap: 1.2rem; margin: 1.2rem 0 0.4rem; }
.counter { color: var(--muted); font-weight: 700; }

/* Interactive HTML embeds */
.embeds { display:flex; flex-direction:column; gap:1.2rem; margin:1.2rem 0; }
.embed-wrap { margin:0; }
.embed-cap { display:flex; align-items:center; justify-content:space-between; gap:.6rem; margin-bottom:.4rem; font-weight:700; color:var(--ink); }
.embed-cap a { color:var(--accent-2); text-decoration:none; font-weight:600; font-size:.85rem; }
.embed-frame { width:100%; min-height:240px; border:1px solid var(--line); border-radius:12px; background:#0b1026; display:block; }
.embed-list { list-style:none; padding:0; }
.embed-list li { display:flex; align-items:center; gap:.8rem; padding:.35rem 0; border-bottom:1px solid var(--line); }

/* Image safety net — nothing overflows its container */
img { max-width: 100%; height: auto; }

/* Activity image gallery: small previews above a scaled main image */
.gallery { margin: 1.2rem 0; }
.gallery-thumbs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .7rem; }
.gthumb { padding: 0; width: 64px; height: 64px; border: 2px solid var(--line); border-radius: 8px; background: #0e1436; overflow: hidden; cursor: pointer; }
.gthumb:hover { border-color: var(--accent-2); }
.gthumb.active { border-color: var(--accent); }
.gthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-main { margin: 0; }
.gallery-main img { max-width: 100%; max-height: min(60vh, 520px); width: auto; border-radius: 12px; border: 1px solid var(--line); display: block; }
.gallery-main figcaption { color: var(--muted); font-size: .85rem; margin-top: .4rem; }

/* Rendered guide/instruction documents */
.doc { line-height:1.7; }
.doc > *:first-child { margin-top:0; }
.doc h1, .doc h2, .doc h3, .doc h4 { line-height:1.3; margin:1.5rem 0 .5rem; }
.doc h1 { font-size:1.8rem; }
.doc h2 { font-size:1.4rem; border-bottom:1px solid var(--line); padding-bottom:.3rem; }
.doc h3 { font-size:1.15rem; color:var(--accent); }
.doc p, .doc li { color:var(--ink); }
.doc a { color:var(--accent-2); }
.doc ul, .doc ol { padding-left:1.4rem; }
.doc li { margin:.25rem 0; }
.doc blockquote { margin:1rem 0; padding:.5rem 1rem; border-left:3px solid var(--accent); background:var(--card-2); border-radius:0 8px 8px 0; color:var(--muted); }
.doc hr { border:none; border-top:1px solid var(--line); margin:1.6rem 0; }
.doc code { font-family:"Cascadia Code", Consolas, monospace; background:#0e1436; padding:.12rem .4rem; border-radius:5px; font-size:.9em; }
.doc pre { background:#0b1026; border:1px solid var(--line); border-radius:10px; padding:1rem; overflow-x:auto; }
.doc pre code { background:none; padding:0; }
.doc table { border-collapse:collapse; width:100%; margin:1rem 0; display:block; overflow-x:auto; }
.doc th, .doc td { border:1px solid var(--line); padding:.5rem .7rem; text-align:left; vertical-align:top; }
.doc th { background:var(--card-2); }

/* Fun Facts */
.ff-hero { display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; margin-bottom:1.2rem; }
.ff-hero h1 { margin:0 0 .2rem; }
.funfacts-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:1rem; }
.ff-card {
  display:flex; flex-direction:column; gap:.35rem; text-decoration:none; color:var(--ink);
  background:linear-gradient(180deg, var(--card) 0%, var(--bg-2) 100%);
  border:1px solid var(--line); border-radius:16px; padding:1.3rem 1.2rem;
  transition:border-color .15s, transform .1s, box-shadow .15s;
}
.ff-card:hover { border-color:var(--accent-2); transform:translateY(-3px); box-shadow:0 12px 28px rgba(0,0,0,.4); }
.ff-emoji { font-size:2.4rem; line-height:1; }
.ff-title { font-weight:800; font-size:1.15rem; }
.ff-desc { color:var(--muted); font-size:.9rem; }
.ff-go { margin-top:auto; color:var(--accent-2); font-weight:700; font-size:.9rem; padding-top:.5rem; }
.ff-detail-head { display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; margin-bottom:.6rem; }
.form-two { display:grid; grid-template-columns:1fr 1fr; gap:1rem; }
@media (max-width:520px){ .form-two{ grid-template-columns:1fr; } }

/* Links table */
.links-table { width: 100%; border-collapse: collapse; }
.links-table th, .links-table td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.links-table th { color: var(--muted); font-size: 0.85rem; }
.links-table a { color: var(--accent-2); }

@media (max-width: 640px) {
  .link-row { grid-template-columns: 1fr; }
  .calendar td { height: 70px; }
  .user-box { width: 100%; margin-left: 0; }
}
