:root {
  --sidebar: #343a40;
  --sidebar-active: #2c3136;
  --sidebar-text: #c2c7d0;
  --body: #f4f6f9;
  --line: #dee2e6;
  --text: #212529;
  --muted: #6c757d;
  --primary: #0d6efd;
  --info: #0dcaf0;
  --warning: #ffc107;
  --success: #198754;
  --danger: #dc3545;
  --secondary: #6c757d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--body);
  color: var(--text);
  font-family: "Source Sans 3", Arial, Helvetica, sans-serif;
}

a { color: inherit; }
button { font: inherit; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar);
  color: var(--sidebar-text);
  box-shadow: 0 0 14px rgba(0,0,0,.18);
}

.sidebar-brand {
  height: 58px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  padding: 0 14px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  width: 100%;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f8f9fa;
  color: #343a40;
  font-weight: 700;
}

.brand-text {
  font-size: 20px;
  font-weight: 300;
}

.menu {
  padding: 12px 8px;
}

.menu-section {
  margin-bottom: 4px;
}

.menu-item {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 34px 1fr auto 18px;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--sidebar-text);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  font-size: 18px;
}

.menu-item:hover,
.menu-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.menu-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
}

.menu-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.badge {
  min-width: 30px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #8b949e;
  color: #fff;
  font-weight: 700;
}

.chevron {
  font-size: 24px;
  line-height: 1;
}

.submenu {
  display: none;
  padding: 4px 0 6px 36px;
}

.menu-section.open .submenu {
  display: block;
}

.submenu button {
  width: 100%;
  display: block;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--sidebar-text);
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  font-size: 15px;
}

.submenu button:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.top-link {
  text-decoration: none;
  color: #495057;
  padding: 8px 4px;
}

.top-link:hover {
  color: #0d6efd;
}

.spacer { flex: 1; }

.nav-icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #495057;
  cursor: pointer;
  font-size: 20px;
  display: grid;
  place-items: center;
}

.nav-icon-button:hover {
  background: #f1f3f5;
}

.nav-icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #495057;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #0d6efd;
  color: #fff;
  font-weight: 700;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 8px;
}

.page-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
}

.breadcrumb {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 8px;
  color: #adb5bd;
}

.breadcrumb a {
  color: #0d6efd;
  text-decoration: none;
}

.content {
  padding: 16px 24px 42px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 18px;
}

.skill-panel {
  background: #fff;
  border-radius: 4px;
  border-top: 3px solid var(--primary);
  box-shadow: 0 0 1px rgba(0,0,0,.13), 0 1px 3px rgba(0,0,0,.2);
  padding: 18px;
}

.skill-panel.listening { border-top-color: var(--danger); }
.skill-panel.writing { border-top-color: var(--info); }
.skill-panel.speaking { border-top-color: var(--warning); }

.skill-panel h2 {
  margin: 0 0 12px;
  font-size: 21px;
  font-weight: 600;
}

.section-block {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 1px rgba(0,0,0,.13), 0 1px 3px rgba(0,0,0,.2);
  padding: 18px;
  margin-bottom: 18px;
}

.section-title {
  margin: 0 0 14px;
  font-size: 21px;
  font-weight: 500;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.lesson-button,
.home-action {
  min-height: 54px;
  width: 100%;
  border: 0;
  border-radius: 4px;
  color: #fff;
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}

.lesson-button:hover,
.home-action:hover {
  filter: brightness(.95);
}

.btn-primary { background: var(--primary); }
.btn-info { background: var(--info); color: #052c33; }
.btn-warning { background: var(--warning); color: #332701; }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-secondary { background: var(--secondary); }

.lesson-button small {
  display: block;
  font-weight: 400;
  opacity: .88;
}

.legacy-frame {
  width: 100%;
  height: calc(100vh - 132px);
  border: 0;
  background: #fff;
  box-shadow: 0 0 1px rgba(0,0,0,.13), 0 1px 3px rgba(0,0,0,.2);
}

.mobile-menu {
  display: none;
}

@media (max-width: 1050px) {
  .home-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}

@media (max-width: 760px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu { display: block; }
  .top-link { display: none; }
  .page-header { padding: 14px 16px 4px; }
  .content { padding: 12px 16px 30px; }
  .home-grid { grid-template-columns: 1fr; }
  .button-grid { grid-template-columns: 1fr; }
  .user-pill span:last-child { display: none; }
}
