:root {
  --bg: #eef0f2;
  --card: #ffffff;
  --border: #e2e5e8;
  --text: #202122;
  --muted: #6b7075;
  --blue: #006fbf;
  --blue-dark: #0a5ca8;
  --orange: #e8730c;
  --icon: #3a3f44;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.spacer { flex: 1; }
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: none;
  color: var(--icon);
  cursor: pointer;
}
.hamburger { margin-right: auto; }
.icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--orange);
  border: 2px solid var(--card);
}

.avatar-wrap { position: relative; margin-left: 4px; }
.avatar-btn { border: none; background: none; padding: 0; cursor: pointer; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: linear-gradient(135deg, #4b6ea8, #2f4a75);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
}
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Dropdown */
.dropdown {
  position: absolute;
  top: 52px;
  right: 0;
  min-width: 230px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  padding: 12px 0;
  z-index: 50;
}
.dropdown::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 14px;
  width: 16px;
  height: 16px;
  background: var(--card);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.dd-item {
  display: block;
  padding: 9px 20px;
  color: var(--blue);
  text-decoration: none;
  font-size: 17px;
}
.dd-item.focused {
  margin: 0 16px 4px;
  padding: 8px 12px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  text-decoration: underline;
}
.dd-item:not(.focused):active { background: #f0f4f8; }
.dd-divider { height: 1px; background: var(--border); margin: 8px 0; }

/* Content */
.content { padding: 14px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  margin-bottom: 16px;
}

/* Search */
.search-card { padding: 20px 16px; }
.search-box {
  display: flex;
  align-items: center;
  border: 1px solid #cfd4d8;
  border-radius: 4px;
  overflow: hidden;
}
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  padding: 14px 16px;
  font-size: 18px;
  color: var(--text);
}
.search-box input::placeholder { color: #8a9096; }
.search-btn {
  border: none;
  background: var(--blue);
  color: #fff;
  width: 52px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* My Courses */
.courses-card { padding: 20px 16px 12px; }
.card-title { margin: 0 0 16px; font-size: 26px; font-weight: 600; }

.tabstrip {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab-chev {
  flex: 0 0 auto;
  border: none;
  background: none;
  color: var(--icon);
  padding: 6px 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.tabs {
  flex: 1;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  border: none;
  background: none;
  padding: 10px 18px 14px;
  font-size: 19px;
  color: #55595e;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
}
.tab.active { color: var(--text); font-weight: 500; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 3px;
  background: var(--blue);
  border-radius: 2px;
}

/* Course cards */
.course-list { display: flex; flex-direction: column; gap: 20px; }
.course {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}
.course-banner {
  position: relative;
  aspect-ratio: 16 / 8.2;
  background: #dfe3e7;
  cursor: pointer;
}
.course-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.course-menu {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 40px;
  border: none;
  border-radius: 6px;
  background: rgba(40,40,40,0.55);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.course-body { padding: 14px 16px 16px; }
.course-title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
}
.course-end { margin: 0; font-size: 16px; color: var(--muted); }

.view-all {
  display: block;
  padding: 20px 4px 8px;
  color: var(--blue);
  font-size: 21px;
  text-decoration: none;
}

/* Announcements */
.announce-card { padding: 4px 0; }
.announce-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border: none;
  background: none;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.announce-head .chev { transition: transform 0.2s; color: var(--icon); }
.announce-head[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.announce-body { padding: 0 18px 10px; }
.announce-body[hidden] { display: none; }
.announce-item { padding: 12px 0; border-top: 1px solid var(--border); }
.announce-title { font-size: 18px; color: var(--blue); }
.announce-meta { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* Drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 60;
}
.drawer-overlay[hidden] { display: none; }
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 78%;
  max-width: 320px;
  background: var(--card);
  z-index: 70;
  box-shadow: 2px 0 16px rgba(0,0,0,0.25);
  padding: 8px 0;
}
.drawer[hidden] { display: none; }
.drawer-head { padding: 18px 20px; font-size: 20px; font-weight: 700; border-bottom: 1px solid var(--border); }
.drawer-link { display: block; padding: 15px 20px; color: var(--text); text-decoration: none; font-size: 18px; }
.drawer-link:active { background: #f0f4f8; }

/* Card ... popover */
.popover {
  position: absolute;
  z-index: 55;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  padding: 6px 0;
  min-width: 160px;
}
.popover[hidden] { display: none; }
.pop-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 11px 18px;
  font-size: 17px;
  color: var(--text);
  cursor: pointer;
}
.pop-item:active { background: #f0f4f8; }

/* Image picker modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.picker {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}
.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  font-size: 20px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.picker-close { border: none; background: none; font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer; }
.picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px 18px;
}
.picker-thumb {
  aspect-ratio: 16 / 10;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: #dfe3e7;
}
.picker-thumb.selected { border-color: var(--blue); }
.picker-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload-btn {
  display: block;
  margin: 4px 18px 20px;
  padding: 13px;
  text-align: center;
  background: var(--blue);
  color: #fff;
  border-radius: 6px;
  font-size: 17px;
  cursor: pointer;
}
