/* ==========================================================
   Student portal + staff console (black and gold, like the site)
   ========================================================== */
:root {
  color-scheme: dark;
  --bg: #0a0a0c;
  --bg-alt: #111114;
  --surface: #16161a;
  --surface-2: #1d1d22;
  --line: #2a2a31;
  --line-soft: #202026;
  --text: #f6f3ec;
  --muted: #a9a59b;
  --gold: #f2b71e;
  --gold-hi: #ffe68a;
  --gold-grad: linear-gradient(180deg, #ffe68a 0%, #f2b71e 48%, #c48a0a 100%);
  --good: #4fd18b;
  --warn: #f2b71e;
  --low: #ff8f6b;
  --danger: #ff6b5b;
  --info: #6ea8ff;
  --display: "Archivo", "Arial Black", system-ui, sans-serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); font-size: .92rem; }
.fine { color: var(--muted); font-size: .82rem; }
.error { color: var(--danger); font-weight: 600; min-height: 1.2em; font-size: .92rem; }
.empty, .loading { color: var(--muted); padding: 18px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.notice { background: rgba(242,183,30,.08); border: 1px solid rgba(242,183,30,.4); color: var(--gold-hi); padding: 14px 16px; border-radius: var(--radius); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 700 .95rem/1 var(--sans); padding: .8em 1.2em; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; transition: transform .15s, border-color .2s, background .2s; }
.btn:hover { transform: translateY(-1px); }
.btn-gold { background: var(--gold-grad); color: #1a1204; }
.btn-ghost { background: var(--surface); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-danger { background: transparent; border-color: rgba(255,107,91,.5); color: var(--danger); }
.btn-sm { padding: .6em .9em; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: progress; transform: none; }
input, select, textarea { width: 100%; font: 400 1rem var(--sans); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .7em .85em; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f2b71e' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
label { display: block; font-weight: 600; font-size: .88rem; margin: 10px 0 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 700; padding: .4em .8em; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--gold-hi); text-decoration: none; }
.chip.waiting { color: var(--muted); }

/* ---------- sign in / sign up ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(60% 50% at 50% 25%, rgba(242,183,30,.13), transparent 70%), var(--bg); }
.gate-card { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: clamp(24px, 5vw, 38px); text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.gate-card > img { margin: 0 auto 14px; }
.gate-card h1 { font-size: 1.8rem; }
.tabs { display: flex; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin: 22px 0 6px; }
.tab { flex: 1; font: 700 .95rem var(--sans); color: var(--muted); background: none; border: 0; border-radius: 999px; padding: .7em; cursor: pointer; }
.tab.is-active { background: var(--gold-grad); color: #1a1204; }
.gate-form { text-align: left; margin-top: 10px; }
.gate-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gate-form .btn { margin-top: 16px; }
.gate-form .fine { margin-top: 12px; text-align: center; }
.gate-done h2 { margin: 18px 0 8px; font-size: 1.4rem; }
.gate-done .btn { margin-top: 18px; }
.back { display: inline-block; margin-top: 20px; color: var(--muted); font-size: .88rem; }
@media (max-width: 520px) { .gate-form .row { grid-template-columns: 1fr; gap: 0; } }

/* ---------- app shell ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; background: rgba(10,10,12,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-family: var(--display); font-size: 1.05rem; }
.brand small { color: var(--gold); font-size: .8rem; font-weight: 600; }
.tabbar { display: flex; gap: 4px; padding: 10px 20px 0; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
.navtab { font: 700 .95rem var(--sans); color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: .7em 1em; cursor: pointer; white-space: nowrap; }
.navtab.is-active { color: var(--text); border-bottom-color: var(--gold); }
.view { max-width: 980px; margin: 0 auto; padding: 24px 20px 72px; display: flex; flex-direction: column; gap: 22px; }
.hello { font-size: clamp(1.7rem, 5vw, 2.4rem); }
.sub { margin-top: -12px; }
.back-link { align-self: flex-start; background: none; border: 0; color: var(--gold); font: 600 .95rem var(--sans); cursor: pointer; padding: 0; }

/* ---------- blocks and cards ---------- */
.block { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.row-card h3 { margin-bottom: 2px; }
.link-card { text-decoration: none; transition: border-color .2s; }
.link-card:hover { border-color: var(--gold); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile strong { font-family: var(--display); font-size: 1.9rem; line-height: 1; }
.tile span { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
@media (max-width: 760px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- homework / exam cards ---------- */
.work { display: flex; flex-direction: column; gap: 12px; }
.work header h3 { margin-bottom: 2px; }
.instructions { white-space: pre-wrap; color: var(--text); font-size: .95rem; }
.work .chip { align-self: flex-start; }
.status { font-size: .9rem; font-weight: 600; }
.status.waiting { color: var(--warn); }
.submit { display: flex; flex-direction: column; gap: 10px; border-top: 1px dashed var(--line); padding-top: 12px; }
.filepick { display: flex; align-items: center; gap: 12px; margin: 0; background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.filepick span { font-weight: 600; font-size: .92rem; }
.filepick input { padding: 0; border: 0; background: none; font-size: .85rem; }
.submit-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mark { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.score { display: flex; align-items: baseline; gap: 10px; }
.score strong { font-family: var(--display); font-size: 1.5rem; }
.percent { font-weight: 700; font-size: .9rem; padding: .2em .6em; border-radius: 999px; }
.percent.good { color: var(--good); background: rgba(79,209,139,.12); }
.percent.ok { color: var(--warn); background: rgba(242,183,30,.12); }
.percent.low { color: var(--low); background: rgba(255,143,107,.12); }
.feedback { white-space: pre-wrap; font-size: .95rem; }

/* ---------- marks list ---------- */
.marks { display: flex; flex-direction: column; gap: 10px; }
.mark-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.mark-main { display: flex; flex-direction: column; gap: 4px; }
.mark-score { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; white-space: nowrap; }
.mark-score strong { font-family: var(--display); font-size: 1.2rem; }

/* ---------- chart ---------- */
.chart { position: relative; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis { fill: var(--muted); font: 11px var(--sans); }
.chart-svg .area { fill: rgba(242,183,30,.10); }
.chart-svg .line { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { fill: var(--gold); stroke: var(--surface); stroke-width: 2; }
.chart-svg .hit { fill: transparent; cursor: pointer; }
.chart-svg .point-label { fill: var(--gold-hi); font: 700 12px var(--sans); }
.chart-tip { position: absolute; transform: translate(-50%, -140%); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; pointer-events: none; display: flex; flex-direction: column; font-size: .82rem; box-shadow: 0 8px 24px rgba(0,0,0,.5); white-space: nowrap; }
.chart-tip strong { font-family: var(--display); font-size: 1rem; color: var(--gold-hi); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line); padding: 11px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.45); font-weight: 600; max-width: calc(100% - 32px); }
.toast.good { border-color: rgba(79,209,139,.5); color: var(--good); }
.toast.bad { border-color: rgba(255,107,91,.5); color: var(--danger); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- bell ---------- */
.bell { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); cursor: pointer; }
.bell:hover { border-color: var(--gold); }
.bell .ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bell .badge { position: absolute; top: -6px; right: -6px; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--gold-grad); color: #1a1204; font: 700 .75rem var(--sans); }
.note.unread { border-left: 3px solid var(--gold); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- settings ---------- */
.switches { display: flex; flex-direction: column; gap: 4px; }
.switch-row { display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--gold); flex: none; }
.switch-row span { display: flex; flex-direction: column; }
.switch-row small { color: var(--muted); font-size: .85rem; }
.fee-head, .fee-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; align-items: center; }
.fee-head { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.fee-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
hr { border: 0; border-top: 1px dashed var(--line); margin: 16px 0; }

/* ---------- attendance ---------- */
.att-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.att-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.att-btn { font: 600 .85rem var(--sans); padding: .45em .8em; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--muted); cursor: pointer; }
.att-btn.is-on { background: var(--gold-grad); border-color: transparent; color: #1a1204; }
.checkin-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.checkin-code { font-family: var(--display); font-size: 2rem; letter-spacing: .2em; color: var(--gold-hi); margin: 0; }
.checkin-row { display: flex; gap: 10px; align-items: center; }
.code-input { font-family: var(--display); font-size: 1.3rem; letter-spacing: .25em; text-align: center; max-width: 180px; }
.chip.att-present { color: var(--good); } .chip.att-late { color: var(--warn); }
.chip.att-absent { color: var(--low); } .chip.att-excused, .chip.att-none { color: var(--muted); }

/* ---------- profile ---------- */
.avatar { border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); background: var(--surface-2); }
.avatar-text { display: grid; place-items: center; font-family: var(--display); font-weight: 800; color: var(--gold-hi); }
.profile-card { display: flex; align-items: center; gap: 18px; }

/* ---------- AI checker ---------- */
.question { display: flex; flex-direction: column; gap: 6px; }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.method { white-space: pre-wrap; font-size: .95rem; line-height: 1.6; }
.bubble { padding: 12px 14px; }
.bubble.from-me { background: var(--surface-2); margin-left: 24px; }
.bubble.from-ai { border-left: 3px solid var(--gold); }
