:root{
  --bg:#f4f6f9;
  --card:#ffffff;
  --muted:#6b7280;
  --accent:#1f6feb;
  --accent-2:#0ea5a4;
  --radius:12px;
  --shadow: 0 8px 28px rgba(16,24,40,0.08);
  --glass: rgba(255,255,255,0.6);

  /* Theme-aware UI tokens */
  --text: #0f1724;
  --border-soft: rgba(15,23,36,0.06);
  --border-strong: rgba(16,24,40,0.03);
  --card-header-border: rgba(16,24,40,0.04);
  --btn-ghost-border: rgba(15,23,36,0.06);
  --logo-shadow: 0 6px 16px rgba(31,111,235,0.18);
  --spinner-border: rgba(0,0,0,0.08);

  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

/* Dark theme variables applied when body.dark is present */
body.dark {
  --bg: #0b1020;
  --card: #0f1724;
  --muted: #9aa0a6;
  --accent: #60a5fa;
  --accent-2: #34d399;
  --shadow: 0 10px 30px rgba(2,6,23,0.6);

  /* override UI tokens for dark */
  --text: #e6eef8;
  --border-soft: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.03);
  --card-header-border: rgba(255,255,255,0.03);
  --btn-ghost-border: rgba(255,255,255,0.04);
  --logo-shadow: none;
  --spinner-border: rgba(255,255,255,0.06);

  color: #e6eef8;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  /* use theme-aware background only (removes leftover bright gradient stop) */
  background: linear-gradient(180deg, var(--bg), var(--bg));
  color:var(--text, #0f1724);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  transition:background .25s ease, color .25s ease;
}

/* ensure text color uses appropriate value */
body { --text: #0f1724; }
body.dark { --text: #e6eef8; }

main#app{
  width:100%;
  max-width:880px;
  min-height:calc(100vh - 36px);
  display:flex;
  flex-direction:column;
  gap:14px;
}

/* TOPBAR */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:10px 12px;
  background:transparent;
}

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

.logo-badge{
  width:44px;
  height:44px;
  display:inline-grid;
  place-items:center;
  border-radius:10px;
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  color:white;
  font-weight:800;
  box-shadow:0 6px 16px rgba(31,111,235,0.18);
  font-size:20px;
}

.brand-text{line-height:1}
.brand-name{font-weight:700;font-size:16px}
.brand-sub{font-size:12px;color:var(--muted)}

/* links */
.links{
  display:flex;
  gap:8px;
  align-items:center;
}
.links a{
  display:inline-block;
  text-decoration:none;
  padding:8px 12px;
  border-radius:10px;
  background:transparent;
  color:var(--accent);
  font-weight:600;
  border:1px solid var(--border-soft);
  transition:transform .12s ease, box-shadow .12s ease, background .12s, color .12s;
}
.links a:hover{background:rgba(31,111,235,0.06)}
.links a:active{transform:translateY(1px)}

/* theme toggle */
.theme-toggle{
  display:inline-grid;
  place-items:center;
  width:44px;
  height:36px;
  border-radius:10px;
  background:transparent;
  border:1px solid var(--border-soft);
  cursor:pointer;
  padding:6px;
  transition:background .12s ease, transform .08s ease;
}
.theme-toggle:hover{background:rgba(15,23,36,0.02)}
.theme-toggle .sun{display:block}
.theme-toggle .moon{display:none}

/* when dark: swap icons and adjust border/fg */
body.dark .theme-toggle{
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(255,255,255,0.02);
}
body.dark .theme-toggle .sun{display:none}
body.dark .theme-toggle .moon{display:block}

/* CARD */
.announcements-card{
  /* use card token for full background so dark card color shows consistently */
  background: linear-gradient(180deg, var(--card), var(--card));
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:0;
  flex:1;
  display:flex;
  flex-direction:column;
  min-height:260px;
  overflow:hidden;
  border:1px solid var(--border-strong);
}

body.dark .announcements-card{
  background:linear-gradient(180deg,var(--card), rgba(255,255,255,0.02));
  border:1px solid rgba(255,255,255,0.03);
}

.card-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  border-bottom:1px solid var(--card-header-border);
  background:linear-gradient(90deg, rgba(31,111,235,0.03), rgba(14,165,164,0.01));
}
body.dark .card-header{
  border-bottom-color: rgba(255,255,255,0.03);
  background:linear-gradient(90deg, rgba(96,165,250,0.02), rgba(52,211,153,0.01));
}
.card-header h1{margin:0;font-size:16px;color:var(--text);font-weight:700}
.header-actions{display:flex;gap:8px;align-items:center}

/* container */
.announcements-container{
  overflow:auto;
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:12px;
  min-height:180px;
  animation:fadeIn .28s ease both;
}

/* loading / empty */
.loading{
  color:var(--muted);
  display:flex;
  gap:10px;
  align-items:center;
  font-weight:600;
}
.spinner{
  width:18px;height:18px;border-radius:50%;
  border:2px solid rgba(0,0,0,0.08);
  border-top-color:var(--accent);
  animation:spin 1s linear infinite;
}

/* announces */
.announce-list{display:flex;flex-direction:column;gap:12px}
.announce{
  padding:12px;border-radius:10px;
  /* switch to card variable so entries follow theme */
  background: var(--card);
  border:1px solid var(--border-strong);
  box-shadow:0 6px 18px rgba(16,24,40,0.03);
}
body.dark .announce{
  background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border:1px solid rgba(255,255,255,0.03);
  box-shadow:none;
}
.announce h2{margin:0 0 6px 0;font-size:15px}
.announce p{margin:0 0 6px 0;color:var(--muted)}
.announce ul{margin:0 0 6px 18px;color:var(--muted)}
.meta{font-size:12px;color:#9aa0a6}

/* buttons */
.actions{display:flex;justify-content:flex-end}
.btn{
  appearance:none;
  border:0;
  padding:8px 12px;
  border-radius:10px;
  background:var(--accent);
  color:white;
  font-weight:600;
}
.btn-ghost{
  background:transparent;
  border:1px solid var(--btn-ghost-border);
  color:var(--muted);
  padding:6px 10px;
  border-radius:10px;
  cursor:pointer;
}
.btn-ghost:hover{background:rgba(15,23,36,0.02)}

body.dark .btn-ghost{
  border:1px solid rgba(255,255,255,0.04);
  color:var(--muted);
  background:transparent;
}

/* footer */
.footer{
  text-align:center;
  color:var(--muted);
  font-size:13px;
  padding:6px 0 12px;
}

/* animations */
@keyframes spin{to{transform:rotate(360deg)}}
@keyframes fadeIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
@media (max-width:520px){
  body{padding:12px}
  .links a{padding:8px;font-size:13px}
  .announcements-card{padding:12px}
  .logo-badge{width:40px;height:40px;font-size:18px}
  .theme-toggle{width:40px}
}
