/* Alpha Class - flat, phone-first */
:root {
  --blue: #0a6cf0; --sky: #00b4ff; --brand: linear-gradient(135deg, #0a6cf0, #00b4ff);
  --ink: #1d2433; --muted: #6b7280; --line: #e3e8f0; --bg: #f5f7fb; --card: #fff;
  --ok: #12805c; --okbg: #e6f6ef; --warn: #a15c00; --warnbg: #fff4e0; --bad: #c62828; --badbg: #fdecec;
  --field: #fff; --soft: #eef1f6; --thead: #fafbfd; --focus: #9cc4ff; --gbtn: #cfd6e2; --toast: #1d2433;
  --info: #e8f1ff; --infoink: #0b4fb3; --infoline: #c4dafc; --badline: #f5c2c2; --warnline: #f3d29b; --okline: #b7e4cf;
  --r: 12px;
  font-family: "Kantumruy Pro", "Noto Sans Khmer", "Khmer OS Battambang", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Dark theme: chosen with the ◐ button (assets/theme.js), or automatic from the phone's setting */
:root[data-theme="dark"] {
  --blue: #4c9dff; --sky: #33c4ff;
  --ink: #e6eaf2; --muted: #9aa4b5; --line: #2a3446; --bg: #0f1522; --card: #171f2e;
  --ok: #4cc79a; --okbg: #13322a; --warn: #f0b45a; --warnbg: #352a14; --bad: #ff7b7b; --badbg: #3a1c1f;
  --field: #111a28; --soft: #222c3d; --thead: #1b2435; --focus: #2f6fc4; --gbtn: #3a4558; --toast: #2a3446;
  --info: #15284a; --infoink: #9cc4ff; --infoline: #24426f; --badline: #5a2a2e; --warnline: #5a4520; --okline: #1f5443;
  color-scheme: dark;
}
:root[data-theme="dark"] .loginbox .brandlogo { background: #fff; border-radius: 14px; padding: 8px 12px; }
:root[data-theme="dark"] .top .logo { background: #fff; border-radius: 8px; }
:root[data-theme="dark"] .lessonframe { background: #fff; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.55; font-size: 16px; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: 56px; }
.top .logo { width: 34px; height: 34px; flex: none; }
.top .title { flex: 1; min-width: 0; }
.top .title b { display: block; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .title small { color: var(--muted); display: block; font-size: .78rem; }
.top .back { border: 0; background: none; font-size: 1.4rem; padding: 0 6px; cursor: pointer; color: var(--blue); }
.acct { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--blue); padding: 0; overflow: hidden; flex: none;
  background: var(--brand); color: #fff; font-weight: 700; cursor: pointer; display: grid; place-items: center; font-size: 1rem; }
.acct img, .acctbig img { width: 100%; height: 100%; object-fit: cover; display: block; }
.acctbig { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; background: var(--brand); color: #fff; font-size: 1.8rem;
  font-weight: 700; display: grid; place-items: center; margin: 0 auto 8px; }
.acctline { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: .92rem; cursor: pointer; }
.acctline .acct { width: 30px; height: 30px; border-width: 1px; font-size: .85rem; }
.langsw, .themesw { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 20px; padding: 4px 10px; font-size: .85rem; cursor: pointer; text-decoration: none; }
.themesw { min-width: 34px; padding: 4px 8px; font-size: 1rem; line-height: 1.2; }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px 90px; }
.wide main, main.wide { max-width: 1180px; }

/* cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.classcard { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.classcard .av { width: 46px; height: 46px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.15rem; flex: none; }
.classcard .info { flex: 1; min-width: 0; }
.classcard .info b { display: block; }
.muted { color: var(--muted); font-size: .88rem; }
.badge { display: inline-block; min-width: 22px; padding: 1px 8px; border-radius: 12px; font-size: .78rem; font-weight: 600; text-align: center; }
.badge.blue { background: var(--blue); color: #fff; }
.badge.ok { background: var(--okbg); color: var(--ok); }
.badge.warn { background: var(--warnbg); color: var(--warn); }
.badge.bad { background: var(--badbg); color: var(--bad); }
.badge.grey { background: var(--soft); color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

/* banners */
.banner { border-radius: var(--r); padding: 10px 14px; margin-bottom: 12px; font-size: .92rem; }
.banner.red { background: var(--badbg); color: var(--bad); border: 1px solid var(--badline); }
.banner.amber { background: var(--warnbg); color: var(--warn); border: 1px solid var(--warnline); }
.banner.blue { background: var(--info); color: var(--infoink); border: 1px solid var(--infoline); }
.banner.green { background: var(--okbg); color: var(--ok); border: 1px solid var(--okline); }

/* tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: -4px -14px 12px; padding: 0 10px; background: var(--card); position: sticky; top: 56px; z-index: 15; }
.tabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* forms */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: .86rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=time],
input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); font-size: 1rem; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); border-color: var(--blue); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--brand); color: #fff; border: 0; }
.btn.danger { background: var(--bad); color: #fff; border: 0; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: .85rem; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.google { background: var(--card); border: 1px solid var(--gbtn); }
.or { text-align: center; color: var(--muted); font-size: .85rem; margin: 14px 0; display: flex; align-items: center; gap: 10px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* report timeline */
.report .date { font-weight: 700; color: var(--blue); }
.report dl { margin: 8px 0 0; }
.report dt { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.report dd { margin: 0; white-space: pre-wrap; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; margin-top: 10px; }
.photos .ph { aspect-ratio: 1; border-radius: 8px; background: var(--soft) center/cover no-repeat; cursor: zoom-in; position: relative; overflow: hidden; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; }
.photos .ph .x { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 100; display: grid; place-items: center; }
.lightbox img { max-width: 96vw; max-height: 92vh; }
.lightbox button { position: absolute; top: 12px; right: 12px; background: #fff; border: 0; border-radius: 50%; width: 40px; height: 40px; font-size: 1.2rem; color: #1d2433; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 80px; }
.msg { max-width: 84%; padding: 8px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.msg.me { align-self: flex-end; background: var(--info); border-color: var(--infoline); }
.msg.sys { align-self: center; background: var(--warnbg); border-color: var(--warnline); font-size: .88rem; max-width: 96%; }
.msg .who { font-size: .76rem; color: var(--muted); }
.msg .body { white-space: pre-wrap; word-wrap: break-word; }
.msg .quote { border-left: 3px solid var(--sky); padding-left: 8px; color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.msg .act { font-size: .76rem; color: var(--blue); cursor: pointer; margin-top: 2px; }
.composer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 8px; z-index: 30; }
.composer .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 6px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 140px; flex: 1; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--card); }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.tbl th { font-size: .8rem; color: var(--muted); font-weight: 600; background: var(--thead); }
.tblwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }

/* dialogs */
dialog { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 16px; padding: 18px; width: min(520px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(15, 23, 42, .5); }
dialog h3 { margin-top: 0; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--toast); color: #fff; padding: 10px 16px;
  border-radius: 10px; z-index: 200; font-size: .92rem; max-width: 92vw; display: none; }

/* lesson frame */
.lessonframe { width: 100%; border: 1px solid var(--line); border-radius: var(--r); min-height: 400px; background: #fff; }

/* login */
.loginbox { max-width: 420px; margin: 6vh auto 0; }
.loginbox .brandlogo { display: block; width: 150px; margin: 0 auto 8px; }

.fab { position: fixed; right: 16px; bottom: 18px; z-index: 25; border-radius: 30px; padding: 14px 20px; box-shadow: 0 4px 14px rgba(10, 108, 240, .35); }

@media print {
  .top, .tabs, .btn, .composer, .banner, .fab, .noprint { display: none !important; }
  body { background: #fff; color: #1d2433; }
  .card { break-inside: avoid; border-color: #bbb; }
  main { max-width: none; padding: 0; }
}
/* printing always uses the light colours */
@media print {
  :root[data-theme="dark"] { --ink: #1d2433; --muted: #6b7280; --line: #e3e8f0; --bg: #fff; --card: #fff; --field: #fff;
    --soft: #eef1f6; --thead: #fafbfd; --blue: #0a6cf0; --info: #e8f1ff; --infoink: #0b4fb3; color-scheme: light; }
}
