* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}

/* THEMES */

body.light {
  --bg: #f4f6f8;
  --text: #000;
  --card: #fff;
  --top: #1e293b;
  --side: #0f172a;
}

body.dark {
  --bg: #0b1220;
  --text: #fff;
  --card: #111827;
  --top: #020617;
  --side: #020617;
}

body {
  background: var(--bg);
  color: var(--text);
}

/* TOP BAR */

.topbar {
  height: 60px;
  background: var(--top);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
}

.left {
  display: flex;
  align-items: center;
}

#menuBtn,
#themeBtn {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
}

/* LAYOUT */

.container {
  display: flex;
  height: calc(100vh - 60px);
}

/* SIDEBAR */

.sidebar {
  width: 220px;
  background: var(--side);
  padding-top: 20px;
  transition: width .3s ease;
}

.sidebar.closed {
  width: 0;
  overflow: hidden;
}

.sidebar a {
  display: block;
  color: white;
  padding: 12px 20px;
  text-decoration: none;
}

.sidebar a:hover {
  background: #334155;
}

.sidebar a.active {
  background: #475569;
  font-weight: bold;
}

/* CONTENT */

.content {
  flex: 1;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;      /* horizontal center */
  justify-content: center; /* vertical center */
}


/* FLASHCARDS */

.flashcard-container {
  perspective: 1000px;
  margin-top: 20px;
}

.flashcard {
  width: 420px;
  height: 260px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .5s;
  cursor: pointer;
  font-size: 24px;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard .front,
.flashcard .back {
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backface-visibility: hidden;
  text-align: center;
}

.flashcard .back {
  transform: rotateY(180deg);
}

/* CONTROLS + INPUT */

.controls {
  margin-top: 20px;
}

.controls button,
button {
  padding: 14px 22px;
  margin: 10px 5px 0 0;
  font-size: 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

input {
  font-size: 18px;
  padding: 14px;
  margin: 8px 8px 0 0;
  width: 250px;
}

.progress {
  margin-top: 10px;
  font-size: 18px;
}

/* CALENDAR */

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 20px;
  max-width: 600px;
}

.day {
  background: var(--card);
  padding: 12px;
  text-align: center;
  border-radius: 6px;
  cursor: pointer;
}

.day:hover {
  background: #64748b;
  color: white;
}

#events {
  margin-top: 20px;
}

.event {
  background: var(--card);
  padding: 10px;
  margin-top: 8px;
  border-radius: 6px;
}

#month {
  font-size: 22px;
  margin-top: 10px;
}

/* ======================
   FLASHCARD LIBRARY
====================== */

.create-set {
  margin-top: 20px;
}

.library-grid {
  margin-top: 25px;
  display: grid;
  grid-template-columns: repeat(auto-fill, 220px);
  gap: 20px;
}

.set-card {
  background: var(--card);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 3px 8px rgba(0,0,0,.2);
}

.set-title {
  font-size: 18px;
  margin-bottom: 10px;
}

.set-buttons button {
  margin-right: 5px;
  margin-top: 8px;
}

/* ======================
   AI CHAT PAGE
====================== */

/* Override .content layout for AI page */
#content.ai-page {
  justify-content: flex-start;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.ai-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid rgba(128,128,128,.15);
  flex-shrink: 0;
}

.ai-topbar label {
  font-size: 14px;
  opacity: .6;
  white-space: nowrap;
}<aside class="sidebar" id="sidebar">
    <a href="index.html">Home</a>
    <a href="library.html">Your Library</a>
    <a href="settings.html">Settings</a>
    <a href="contact.html">Contact</a>
  </aside>

.ai-topbar select {
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(128,128,128,.3);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  width: 200px;
}
<aside class="sidebar" id="sidebar">
    <a href="index.html">Home</a>
    <a href="library.html">Your Library</a>
    <a href="settings.html">Settings</a>
    <a href="contact.html">Contact</a>
  </aside>
.refresh-btn {
  padding: 6px 12px !important;
  font-size: 13px !important;
  border-radius: 6px !important;
  background: rgba(128,128,128,.15) !important;
  color: var(--text) !important;
}

.refresh-btn:hover { background: rgba(128,128,128,.28) !important; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  transition: background .3s;
}

.status-dot.online { background: #22c55e; }

/* Chat window */

.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-window::-webkit-scrollbar { width: 6px; }
.chat-window::-webkit-scrollbar-thumb {
  background: rgba(128,128,128,.25);
  border-radius: 3px;
}

/* Messages */

.msg {
  display: flex;
  gap: 10px;
  max-width: 780px;
  animation: fadeUp .25s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.user      { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg.user .avatar      { background: #3b82f6; }
.msg.assistant .avatar { background: #6366f1; }

.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.6;
  max-width: calc(100% - 50px);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: #3b82f6;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.assistant .bubble {
  background: var(--card);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

/* Typing indicator */

.typing .bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(128,128,128,.5);
  animation: bounce 1.2s infinite ease-in-out;
}

.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }

@keyframes bounce {
  0%,80%,100% { transform: translateY(0); }
  40%          { transform: translateY(-6px); }
}

/* Chat input bar */

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px;
  background: var(--card);
  border-top: 1px solid rgba(128,128,128,.15);
  flex-shrink: 0;
}

#chatInput {
  flex: 1;
  resize: none;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(128,128,128,.25);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  max-height: 140px;
  overflow-y: auto;
  line-height: 1.5;
  outline: none;
  transition: border-color .2s;
  margin: 0;
  width: auto;
}

#chatInput:focus { border-color: #3b82f6; }

#sendBtn {
  width: 46px !important;
  height: 46px !important;
  border-radius: 10px !important;
  background: #3b82f6 !important;
  color: #fff !important;
  font-size: 20px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0 !important;
  margin: 0 !important;
  transition: background .2s, transform .1s;
}

#sendBtn:hover  { background: #2563eb !important; }
#sendBtn:active { transform: scale(.95); }
#sendBtn:disabled { background: rgba(128,128,128,.3) !important; cursor: default; }

/* Empty state */

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: .4;
  user-select: none;
}

.empty-state .icon { font-size: 48px; }
.empty-state p     { font-size: 16px; }

/* Toast */

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #ef4444;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  animation: fadeUp .2s ease;
}