:root {
  --navy:#071329; --gold:#e7bd65; --lightgold:#ffe4a0;
  --cyan:#48d9e8; --white:#f7f9ff; --muted:#aab7ca;
  --border:rgba(231,189,101,.25);
}
* {box-sizing:border-box;margin:0;padding:0}
body {
  min-height:100vh;color:var(--white);
  background:radial-gradient(ellipse at top,#1b3558,var(--navy) 65%);
  font-family:Arial,sans-serif;
}
button,input {font:inherit}
button {cursor:pointer}
.topbar {
  min-height:78px;padding:12px 5%;display:flex;
  align-items:center;justify-content:space-between;
  border-bottom:1px solid var(--border);
}
.brand {display:flex;align-items:center;gap:12px;letter-spacing:2px}
.brand b {display:block;font-size:14px}
.brand small {display:block;color:var(--gold);letter-spacing:5px;margin-top:5px}
.logo {
  width:48px;height:48px;border:2px solid var(--gold);
  border-radius:14px;display:grid;place-items:center;
  color:var(--lightgold);font-weight:bold;
}
#menuButton {
  color:var(--gold);background:transparent;
  border:1px solid var(--border);border-radius:10px;
  padding:10px 14px;font-size:20px;
}
.screen {display:none;min-height:65vh;padding:35px 18px}
.screen.active {display:block;animation:appear .3s ease}
@keyframes appear {
  from {opacity:0;transform:translateY(10px)}
  to {opacity:1;transform:translateY(0)}
}
.hero {max-width:850px;margin:auto;padding:55px 8px;text-align:center}
.badge {
  display:inline-block;border:1px solid var(--border);
  border-radius:30px;padding:12px 16px;
  color:var(--lightgold);font-size:11px;letter-spacing:1px;
}
.book {
  width:125px;height:125px;display:grid;place-items:center;
  margin:40px auto;font-size:60px;border:1px solid var(--border);
  border-radius:30px;background:#10213c;
}
h1,h2 {font-family:Georgia,serif}
.hero h1 {font-size:clamp(30px,6vw,52px);line-height:1.3}
.hero h1 span,.dash-title span {color:var(--gold)}
.hero h3 {margin:25px 0;color:var(--lightgold);line-height:1.6}
.hero p {max-width:600px;margin:0 auto 30px;color:var(--muted);line-height:1.8}
.primary {
  min-height:52px;padding:0 26px;border:0;border-radius:12px;
  color:#172039;font-weight:bold;
  background:linear-gradient(110deg,#c7953d,#ffe4a0,#d5a64e);
}
.primary:active {transform:scale(.98)}
.full {width:100%;margin-top:22px}
.motto {margin-top:42px;color:var(--muted);letter-spacing:3px;font-weight:bold;font-size:12px}
.features {max-width:950px;margin:auto;padding:30px 5px 55px;border-top:1px solid var(--border);text-align:center}
.features h2 {color:var(--lightgold);margin-bottom:24px}
.feature-grid {display:grid;grid-template-columns:repeat(3,1fr);gap:15px}
.feature-grid article {
  padding:25px 15px;background:#10213c;
  border:1px solid var(--border);border-radius:18px;font-size:30px;
}
.feature-grid h3 {color:var(--gold);margin:12px;font-size:19px}
.feature-grid p {color:var(--muted);font-size:13px;line-height:1.6}
.panel {
  max-width:450px;margin:15px auto;padding:30px 24px;
  background:linear-gradient(145deg,#142b4b,#0c1b33);
  border:1px solid var(--border);border-radius:22px;
}
.symbol {
  width:60px;height:60px;margin:0 auto 18px;display:grid;
  place-items:center;border-radius:18px;background:#26344a;font-size:27px;
}
.eyebrow {color:var(--cyan);text-align:center;font-size:11px;letter-spacing:2px;font-weight:bold}
.panel h2 {text-align:center;color:var(--lightgold);margin:12px 0;font-size:27px}
.muted {color:var(--muted);text-align:center;font-size:13px;line-height:1.7;margin-bottom:22px}
label {display:block;margin:15px 0 7px;color:var(--lightgold);font-size:13px}
input {
  width:100%;height:48px;padding:0 13px;background:#071329;
  color:white;border:1px solid #34435b;border-radius:9px;outline:none;
}
input:focus {border-color:var(--cyan)}
input::placeholder {color:#77869e}
.role {
  width:100%;display:flex;align-items:center;gap:14px;
  margin:13px 0;padding:16px;color:white;background:#10213c;
  border:1px solid var(--border);border-radius:13px;text-align:left;
}
.role span {flex:1}
.role b,.role small {display:block}
.role b {color:var(--lightgold)}
.role small {color:var(--muted);margin-top:6px;font-size:11px}
.bottom {margin-top:22px;text-align:center;color:var(--muted);font-size:12px}
.link {border:0;background:none;color:var(--cyan);font-weight:bold}
.forgot {display:block;margin:12px 0 0 auto}
.back {display:block;margin:22px auto 0;background:none;border:0;color:var(--gold)}
.dashboard {max-width:1000px;margin:auto}
.dash-title {font-size:clamp(28px,5vw,40px);margin:17px 0 25px;line-height:1.35}
.profile {
  display:flex;align-items:center;gap:15px;padding:20px;margin-bottom:35px;
  background:#142b4b;border:1px solid var(--border);border-radius:16px;
}
.avatar {
  width:58px;height:58px;display:grid;place-items:center;
  border-radius:50%;background:#293d58;font-size:27px;
}
.profile b {color:var(--lightgold)}
.profile p {color:var(--muted);font-size:12px;margin:5px 0;overflow-wrap:anywhere}
.profile small {color:var(--cyan)}
.dashboard h2 {color:var(--gold);margin-bottom:8px}
.left {text-align:left}
.dash-grid {display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-top:20px}
.dash-card {
  min-height:145px;padding:18px 12px;display:flex;flex-direction:column;
  align-items:flex-start;justify-content:center;gap:10px;text-align:left;
  color:white;background:#142b4b;border:1px solid var(--border);border-radius:15px;
}
.dash-card:active {border-color:var(--cyan)}
.dash-card b {color:var(--lightgold);font-size:14px}
.dash-card small {color:var(--muted);font-size:11px}
.tip {
  display:flex;gap:12px;padding:18px;margin-top:25px;
  background:#102b40;border:1px solid #24505a;border-radius:13px;
  color:var(--cyan);line-height:1.6;
}
.tip span {color:var(--muted);font-size:13px}
.tip b {color:var(--cyan)}
.logout {
  display:block;margin:25px auto;padding:12px 30px;background:transparent;
  color:#ffb8b8;border:1px solid #9b5555;border-radius:10px;
}
footer {padding:30px 15px;text-align:center;border-top:1px solid var(--border)}
footer b {color:var(--gold);font-size:24px}
footer p {margin:8px}
footer small {display:block;color:var(--muted);margin:6px;font-size:11px}
#toast {
  position:fixed;bottom:25px;left:50%;z-index:5;
  transform:translate(-50%,20px);opacity:0;pointer-events:none;
  padding:13px 20px;background:#183454;border:1px solid var(--border);
  border-radius:12px;color:white;font-size:13px;
  transition:.25s;width:max-content;max-width:90%;
}
#toast.show {opacity:1;transform:translate(-50%,0)}
@media(max-width:650px) {
  .feature-grid {grid-template-columns:1fr}
  .dash-grid {grid-template-columns:repeat(2,1fr);gap:10px}
  .dash-card {min-height:135px;padding:14px 10px}
  .hero {padding:35px 8px}
  .panel {padding:27px 19px}
}
@media(max-width:360px) {
  .dash-grid {grid-template-columns:1fr}
}

/* PHASE 2 - EDUCATION SELECTION */
select {
  width:100%;
  min-height:48px;
  padding:0 12px;
  margin-bottom:8px;
  color:white;
  background:#071329;
  border:1px solid #34435b;
  border-radius:9px;
  outline:none;
}
select:focus {border-color:var(--cyan)}
select option {background:#071329;color:white}
.education-panel {max-width:500px}
.education-panel [hidden] {display:none !important}
.education-panel .primary {margin-top:25px}
.education-panel .back {cursor:pointer}

/* PHASE 3 - MY SUBJECTS */
.subject-grid {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
  margin-top:25px;
}
.subject-card {
  min-height:145px;
  padding:18px;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  justify-content:center;
  gap:12px;
  color:white;
  text-align:left;
  background:linear-gradient(145deg,#173556,#10213c);
  border:1px solid var(--border);
  border-radius:16px;
}
.subject-card:active {border-color:var(--cyan)}
.subject-card b {color:var(--lightgold);font-size:15px}
.subject-card small {color:var(--cyan);font-size:11px}
.subject-number {
  color:var(--gold);
  font-size:12px;
  font-weight:bold;
  letter-spacing:2px;
}
.subject-detail {max-width:550px}
.chapter-heading {
  margin:25px 0 12px;
  color:var(--gold);
  font-weight:bold;
}
.chapter-placeholder {
  padding:20px;
  color:var(--muted);
  background:#071329;
  border:1px solid var(--border);
  border-radius:12px;
  line-height:1.8;
  font-size:13px;
}
@media(max-width:650px) {
  .subject-grid {grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .subject-card {min-height:125px;padding:14px}
}
@media(max-width:360px) {
  .subject-grid {grid-template-columns:1fr}
}

/* PHASE 3 - LANGUAGE SWITCH */
.language-switch {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0;
}
.language-switch span {
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}
.language-btn {
  padding: 10px 18px;
  color: white;
  background: #10213c;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
}
.language-btn.active {
  color: #071329;
  background: var(--gold);
  border-color: var(--gold);
  font-weight: bold;
}

/* =====================================
   SGA DESIGN POLISH - MOBILE FIRST
   Existing design and colours preserved
===================================== */

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

img {
  max-width: 100%;
  height: auto;
}

/* Better text rendering */
h1, h2, h3, p, small, b {
  overflow-wrap: break-word;
}

button, .role, .dash-card, .subject-card {
  transition: transform .2s ease, border-color .2s ease,
              background .2s ease, box-shadow .2s ease;
}

/* Header improvement */
.topbar {
  position: relative;
  z-index: 20;
  gap: 12px;
}

.brand {
  min-width: 0;
}

.brand b {
  font-size: clamp(12px, 3vw, 17px);
}

#menuButton {
  flex-shrink: 0;
  min-width: 48px;
  min-height: 48px;
}

/* Homepage heading overflow fix */
.hero {
  width: 100%;
  max-width: 850px;
}

.hero h1 {
  max-width: 100%;
  font-size: clamp(29px, 7vw, 52px);
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.hero h3 {
  max-width: 100%;
  font-size: clamp(16px, 4.5vw, 23px);
  overflow-wrap: anywhere;
}

.hero p {
  max-width: 600px;
  padding: 0 5px;
}

/* Premium buttons */
.primary {
  box-shadow: 0 5px 16px rgba(231,189,101,.13);
}

.primary:hover {
  box-shadow: 0 8px 22px rgba(231,189,101,.23);
  transform: translateY(-2px);
}

.primary:focus-visible,
.role:focus-visible,
.dash-card:focus-visible,
.subject-card:focus-visible,
#menuButton:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

/* Cards */
.panel,
.profile,
.dash-card,
.subject-card,
.feature-grid article {
  box-shadow: 0 7px 22px rgba(0,0,0,.10);
}

.role {
  min-height: 82px;
  gap: 16px;
}

.role:hover,
.dash-card:hover,
.subject-card:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
}

/* Dashboard */
.dashboard {
  width: 100%;
}

.dash-title {
  overflow-wrap: anywhere;
}

.profile {
  min-width: 0;
}

.profile > div:last-child {
  min-width: 0;
}

/* Textbook floating button safety */
#allTextbooksButton,
.all-textbooks-button,
.floating-textbooks,
.textbook-floating-button {
  max-width: calc(100vw - 28px);
  z-index: 10;
}

footer {
  padding-bottom: 55px;
}

/* Tablet */
@media (min-width: 651px) {
  .screen {
    padding: 45px 5%;
  }

  .dash-grid {
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 18px;
  }

  .dash-card {
    min-height: 160px;
    padding: 22px;
  }

  .role {
    padding: 20px;
  }
}

/* Mobile */
@media (max-width: 650px) {
  .topbar {
    min-height: 72px;
    padding: 10px 4%;
  }

  .logo {
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }

  .brand {
    gap: 9px;
    letter-spacing: 1.5px;
  }

  .brand small {
    letter-spacing: 4px;
  }

  .screen {
    min-height: 60vh;
    padding: 25px 14px;
  }

  .hero {
    padding: 35px 4px 42px;
  }

  .book {
    width: 105px;
    height: 105px;
    margin: 30px auto;
    font-size: 52px;
  }

  .badge {
    max-width: 100%;
    font-size: 10px;
    line-height: 1.6;
  }

  .features {
    padding: 28px 0 45px;
  }

  .feature-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 11px;
  }

  .feature-grid article {
    min-width: 0;
    padding: 20px 10px;
    font-size: 25px;
  }

  .feature-grid h3 {
    font-size: 16px;
    margin: 10px 0;
  }

  .feature-grid p {
    font-size: 12px;
  }

  .panel {
    margin: 12px auto;
    padding: 25px 17px;
    border-radius: 20px;
  }

  .dash-title {
    font-size: clamp(26px, 7vw, 38px);
    line-height: 1.25;
  }

  .profile {
    padding: 16px;
    margin-bottom: 28px;
    gap: 12px;
  }

  .avatar {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
  }

  .dash-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 11px;
  }

  .dash-card {
    min-width: 0;
    min-height: 132px;
    padding: 15px 12px;
    border-radius: 15px;
  }

  .dash-card b {
    font-size: 14px;
    line-height: 1.4;
  }

  .dash-card small {
    font-size: 11px;
    line-height: 1.5;
  }

  .tip {
    padding: 15px;
    margin-top: 22px;
  }

  .subject-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }

  .logout {
    min-height: 46px;
  }

  #toast {
    bottom: 18px;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .brand b {
    font-size: 11px;
  }

  .brand small {
    font-size: 10px;
    letter-spacing: 3px;
  }

  .dash-grid,
  .subject-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 8px;
  }

  .dash-card {
    min-height: 125px;
    padding: 12px 9px;
  }

  .feature-grid {
    gap: 8px;
  }

  .role {
    padding: 14px 11px;
  }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
