/* English With Mar — styles. Colours are at the top (:root). */
:root {
  --bg: #ffffff;
  --header: #33449e;
  --header-2: #26337c;
  --navy: #1b2140;
  --surface: #ffffff;
  --surface-soft: #f4f5f9;
  --border-soft: #e3e5ee;
  --border-blue: #33449e;
  --pill: #33449e;
  --pill-hover: #26337c;
  --pill-text: #ffffff;
  --muted: #6b7086;
  --danger: #c14a3d;
  --danger-soft: #fbe6e2;
  --ok: #2f8a58;
  --ok-soft: #e3f5ea;
  --shadow: 0 2px 10px rgba(27,33,64,0.07);
  --radius: 14px;
  --font-display: Arial, Helvetica, sans-serif;
  --font-body: Arial, Helvetica, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--navy); font-family: var(--font-body); min-height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
.header {
  background: linear-gradient(180deg, var(--header), var(--header-2));
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 16px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.header h1 { font-family: var(--font-display); color: #ffffff; font-size: 1.5rem; margin: 0; font-weight: 800; }
.header-icons { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.hicon { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0.92; color: #fff; }
.hicon svg { width: 20px; height: 20px; }
.hicon:hover { opacity: 1; }
.avatar { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; object-fit: cover; }
.page { max-width: 1100px; margin: 0 auto; padding: 26px 20px 60px; position: relative; }
.page.narrow { max-width: 480px; }

.login-page { min-height: calc(100vh - 74px); position: relative; overflow: hidden; padding: 40px 20px 60px; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.deco { position: absolute; pointer-events: none; }
.blob-wrap { display: flex; justify-content: center; margin-top: 10px; position: relative; z-index: 2; }
.blob { width: min(340px, 90vw); position: relative; }
.blob-inner { padding: 70px 24px 40px; text-align: center; position: relative; z-index: 1; }
.blob-inner p { font-weight: 600; color: var(--muted); font-size: 0.9rem; margin: 0 0 22px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; border-radius: 11px; padding: 12px 18px; font-family: var(--font-body); font-weight: 700; font-style: italic; letter-spacing: 0.01em; font-size: 0.9rem; cursor: pointer; background: var(--pill); color: var(--pill-text); box-shadow: var(--shadow); transition: transform 0.08s ease, background 0.15s ease; width: 100%; }
.btn:hover { background: var(--pill-hover); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--header); box-shadow: none; text-decoration: underline; padding: 6px; width: auto; }
.btn.outline { background: var(--surface); color: var(--header); border: 2px solid var(--header); box-shadow: none; }
.btn.google { background: #fff; color: #3c4043; }
.btn.google:hover { background: #f6f6f6; }
.btn.google svg { width: 20px; height: 20px; }
.err { color: var(--danger); font-size: 0.78rem; font-weight: 600; min-height: 1.1em; margin: 10px 0 0; text-align: center; }

.home-grid { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 26px; }
@media (max-width: 880px) { .home-grid { grid-template-columns: 1fr; } }
.section-title { font-family: var(--font-display); font-style: italic; font-weight: 800; font-size: 1.3rem; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.section-title .title-icon { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: var(--header); color: #fff; flex-shrink: 0; }
.section-title .title-icon svg { width: 18px; height: 18px; }
.notif-box, .todo-box { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 16px; min-height: 160px; padding: 18px; box-shadow: var(--shadow); }
.empty-note { color: var(--muted); font-style: italic; font-weight: 600; text-align: center; margin-top: 30px; font-size: 0.9rem; }
.notice-item { padding: 10px 0; border-bottom: 1px solid var(--surface-soft); font-size: 0.88rem; }
.notice-item:last-child { border-bottom: none; }
.notice-date { color: var(--muted); font-size: 0.72rem; display: block; margin-top: 2px; }

.pill-btn { display: flex; align-items: center; justify-content: flex-start; gap: 16px; background: linear-gradient(135deg, var(--header), var(--header-2)); color: var(--pill-text); border-radius: 14px; padding: 14px 22px; margin-bottom: 14px; cursor: pointer; box-shadow: 0 4px 14px rgba(27,33,64,0.18); font-family: var(--font-body); font-weight: 800; font-style: italic; font-size: 1.05rem; transition: transform 0.1s ease, box-shadow 0.1s ease; border: none; width: 100%; text-align: left; }
.pill-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(60,70,180,0.32); }
.pill-btn:active { transform: scale(0.99) translateY(0); }
.pill-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.28); }
.pill-icon svg { width: 24px; height: 24px; }

.cal-title { font-family: var(--font-display); font-style: italic; font-weight: 800; font-size: 1.3rem; margin: 0; }
.profile-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--surface-soft); font-size: 0.92rem; }
.profile-label { color: var(--header); font-weight: 700; }
.profile-value { text-align: right; }
.toggle { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #d5d8e6; transition: 0.2s; border-radius: 34px; }
.toggle-slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: #fff; transition: 0.2s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle input:checked + .toggle-slider { background-color: var(--header); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-weight: 700; font-size: 0.95rem; }
.settings-row-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.cal-page-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 720px) { .cal-page-grid { grid-template-columns: 1fr; } }
.cal-title-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 10px; }
.cal-nav { background: none; border: none; font-size: 1.2rem; color: var(--header); cursor: pointer; padding: 4px 10px; }
table.cal-big td { padding: 14px 4px; font-size: 0.95rem; cursor: pointer; }
table.cal-big td:not(:empty):hover { background: var(--surface-soft); }
table.cal-big td.selected-day { outline: 2px solid var(--header); outline-offset: -2px; background: #e7ebfa; }
.selected-date-label { font-style: italic; font-size: 1rem; color: var(--muted); margin-bottom: 10px; }
.cal-day-list { margin: 0; padding-left: 20px; }
.cal-day-list li { margin-bottom: 8px; font-size: 0.92rem; }
table.cal td.selected-day { outline: 2px solid var(--header); outline-offset: -2px; background: #e7ebfa; }
table.cal-mini td:not(:empty) { cursor: pointer; }
table.cal-mini td:not(:empty):hover { background: var(--surface-soft); }
.mini-cal-head { display: flex; align-items: center; justify-content: space-between; }
.mini-cal-head .cal-month { margin: 4px 0 10px; }
.home-day-detail { margin-top: 12px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px; font-size: 0.88rem; }
.home-day-detail .selected-date-label { font-size: 0.85rem; margin-bottom: 6px; }
.item-actions { display: inline-flex; gap: 6px; margin-left: 8px; vertical-align: middle; }
.mini-btn { background: none; border: 1.5px solid var(--header); color: var(--header); border-radius: 8px; padding: 2px 9px; font-size: 0.72rem; font-weight: 700; cursor: pointer; font-family: var(--font-body); }
.mini-btn:hover { background: #e7ebfa; }
.mini-btn.danger { border-color: var(--danger); color: var(--danger); }
.mini-btn.danger:hover { background: #fdecec; }
.edit-box { margin: 8px 0 14px; padding: 12px; border: 1.5px dashed var(--header); border-radius: 10px; background: #f7f8fe; }
.edit-box .btn { width: auto; margin-top: 10px; margin-right: 6px; }
.posted-notice { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--surface-soft); font-size: 0.9rem; }
.posted-notice:last-child { border-bottom: none; }
.class-note-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); font-size: 0.9rem; }
.cal-month { font-weight: 700; font-style: italic; margin: 4px 0 10px; display: flex; align-items: center; gap: 6px; }
.cal-month svg { width: 16px; height: 16px; }
table.cal { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
table.cal th { background: var(--header); color: #fff; font-size: 0.7rem; padding: 6px 0; font-weight: 700; }
table.cal td { text-align: center; padding: 8px 2px; font-size: 0.8rem; border: 1px solid var(--border-soft); position: relative; }
table.cal td.has-task { background: #e7ebfa; font-weight: 800; }
table.cal td.today { outline: 2px solid var(--header); outline-offset: -2px; border-radius: 4px; }

.top-bar-simple { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 8px; }
.back-link { font-weight: 700; color: var(--header); cursor: pointer; background: none; border: none; font-family: var(--font-body); font-size: 0.95rem; }

.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card h2 { font-family: var(--font-display); font-size: 1.05rem; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.card h2 svg { width: 18px; height: 18px; }
.skills-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 480px) { .skills-grid { grid-template-columns: repeat(3, 1fr); } }
.skill-card { background: var(--pill); color: #fff; border-radius: 16px; padding: 20px 10px; text-align: center; cursor: pointer; box-shadow: var(--shadow); transition: transform 0.08s ease; }
.skill-card:active { transform: scale(0.97); }
.skill-card svg { width: 30px; height: 30px; margin-bottom: 6px; }
.skill-card .name { font-weight: 800; font-style: italic; font-size: 0.95rem; }
.skill-card .status { font-size: 0.72rem; opacity: 0.9; margin-top: 4px; font-weight: 600; }

.task-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--surface-soft); }
.task-row:last-child { border-bottom: none; }
.task-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--header); flex-shrink: 0; }
.task-info { flex: 1; }
.task-title { font-weight: 700; font-size: 0.95rem; }
.task-meta { font-size: 0.78rem; color: var(--muted); }
.badge { font-size: 0.7rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--surface-soft); color: var(--header); white-space: nowrap; }
.badge.overdue { background: var(--danger-soft); color: var(--danger); }
.badge.done { background: var(--ok-soft); color: var(--ok); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 8px; }
@media (min-width: 480px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-box { background: var(--surface-soft); border-radius: 14px; padding: 14px; text-align: center; }
.stat-num { font-size: 1.5rem; font-weight: 800; color: var(--header); font-family: var(--font-display); }
.stat-label { font-size: 0.72rem; color: var(--muted); font-weight: 700; }

label.form-label { font-size: 0.85rem; font-weight: 700; color: var(--muted); display: block; margin-top: 12px; }
input[type="text"], input[type="password"], input[type="date"], textarea, select { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--surface-soft); background: var(--surface-soft); color: var(--navy); font-size: 1rem; margin-top: 6px; font-family: var(--font-body); }
textarea { resize: vertical; min-height: 70px; }
.loading { text-align: center; padding: 60px 0; color: var(--muted); font-weight: 700; }
table.stats-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.stats-table th, table.stats-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--surface-soft); }
table.stats-table th { color: var(--muted); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; }
.q-block { margin-bottom: 22px; }
.q-text { font-weight: 700; margin-bottom: 10px; }
.opt { display: block; padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--surface-soft); margin-bottom: 8px; cursor: pointer; font-size: 0.92rem; background: var(--surface-soft); font-weight: 600; }
.opt.selected { border-color: var(--header); background: #e7ebfa; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.incorrect { border-color: var(--danger); background: var(--danger-soft); }

.chat-window { display: flex; flex-direction: column; height: 420px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 6px 4px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; padding: 9px 13px; border-radius: 14px; font-size: 0.88rem; }
.msg.mine { align-self: flex-end; background: var(--pill); color: #fff; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: var(--surface-soft); border-bottom-left-radius: 4px; }
.msg .who { font-size: 0.68rem; font-weight: 800; opacity: 0.75; display: block; margin-bottom: 2px; }
.msg .when { font-size: 0.62rem; opacity: 0.65; display: block; margin-top: 3px; }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-input-row input { margin-top: 0; }
.chat-input-row button { width: auto; }
.group-pick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.group-chip { padding: 6px 14px; border-radius: 999px; background: var(--surface-soft); font-weight: 700; font-size: 0.82rem; cursor: pointer; border: 2px solid transparent; }
.group-chip.active { border-color: var(--header); background: #e7ebfa; }

/* ---------- teacher portal (phase 1) ---------- */
.group-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 20px; -webkit-overflow-scrolling: touch; }
.gtab { flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 999px; border: 2px solid var(--cs, var(--header)); background: var(--csoft, #eef0fa); color: var(--navy); font-family: var(--font-body); font-weight: 700; font-size: 0.88rem; cursor: pointer; transition: transform 0.08s ease; }
.gtab:hover { transform: translateY(-1px); }
.gtab.active { background: var(--c, var(--header)); }
.gtab-home.active { color: #fff; }
.gdot { width: 10px; height: 10px; border-radius: 50%; background: var(--cs); flex-shrink: 0; }
.gsum-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .gsum-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .gsum-grid { grid-template-columns: 1fr; } }
.gsum { border-radius: 14px; overflow: hidden; border: 1.5px solid var(--cs); background: var(--csoft); cursor: pointer; box-shadow: var(--shadow); transition: transform 0.1s ease; }
.gsum:hover { transform: translateY(-2px); }
.gsum-top { background: var(--c); padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; }
.gsum-name { font-weight: 800; font-size: 1.02rem; }
.gsum-arrow { font-weight: 800; color: var(--cs); }
.gsum-body { padding: 10px 14px 12px; }
.gsum-row { display: flex; justify-content: space-between; gap: 8px; font-size: 0.82rem; padding: 3px 0; }
.gsum-row span { color: var(--muted); }
.dash-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .dash-two { grid-template-columns: 1fr; } }
.link-card { border: 2px dashed var(--header); }
.link-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--surface-soft); flex-wrap: wrap; }
.link-row:last-child { border-bottom: none; }
.link-info { flex: 1; min-width: 160px; }
.link-select { width: auto; min-width: 160px; margin-top: 0; padding: 8px 10px; font-size: 0.9rem; }
.link-btn { padding: 7px 14px; font-size: 0.82rem; }
.avatar-ph { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-soft); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.avatar-ph svg { width: 16px; height: 16px; }
.table-scroll { overflow-x: auto; }
.portal-banner { background: var(--c); border: 2px solid var(--cs); border-radius: 16px; padding: 18px 22px; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.portal-name { font-weight: 800; font-size: 1.5rem; }
.portal-meta { font-size: 0.88rem; margin-top: 4px; }
.portal-next { background: rgba(255,255,255,0.7); border-radius: 12px; padding: 8px 14px; text-align: right; }
.portal-next span { display: block; font-size: 0.72rem; color: var(--muted); font-weight: 700; }
.roster-row { cursor: pointer; }
.roster-row:hover td { background: var(--csoft); }
.add-row { display: flex; gap: 8px; margin-top: 14px; }
.add-row input { margin-top: 0; }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.portal-tile { background: var(--surface); border: 1px solid var(--border-soft); border-top: 5px solid var(--cs); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.portal-tile.clickable { cursor: pointer; }
.portal-tile.clickable:hover { background: var(--csoft); }
.tile-head { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1rem; }
.tile-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--c); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tile-icon svg { width: 17px; height: 17px; }
.badge.soon { background: var(--csoft); color: var(--navy); border: 1px solid var(--cs); }
.modal-back { position: fixed; inset: 0; background: rgba(27,33,64,0.35); display: flex; align-items: flex-start; justify-content: center; padding: calc(40px + env(safe-area-inset-top, 0px)) 14px 30px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 16px; border-top: 6px solid var(--cs); width: min(520px, 100%); padding: 20px; box-shadow: 0 12px 40px rgba(27,33,64,0.25); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.ficha-account { display: flex; align-items: center; gap: 12px; background: var(--csoft); border-radius: 12px; padding: 10px 12px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
