/* Teaching — phone app styles. Light and dark follow the phone's setting. */

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #eef2f8;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --grid-line: #e7ecf3;
  --today: rgba(37, 99, 235, .06);
  --break: repeating-linear-gradient(135deg, rgba(148,163,184,.13) 0 6px, rgba(148,163,184,.04) 6px 12px);
  --shadow: 0 10px 30px rgba(15, 23, 42, .18);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --panel: #131c2e;
    --panel-2: #1a2540;
    --text: #e8edf6;
    --muted: #8b9ab3;
    --line: #22304a;
    --grid-line: #1b2740;
    --today: rgba(59, 130, 246, .10);
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Tahoma, "Geeza Pro", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; color: var(--text); }
h1, h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 0 4px; }

/* ---------------------------------------------------------------- layout */
#app { min-height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; padding-top: var(--safe-top);
          padding-bottom: calc(64px + var(--safe-bottom)); min-height: 100vh; }
.demo-banner {
  position: fixed; inset-inline: 0; top: 0; z-index: 30; padding: calc(var(--safe-top) + 2px) 12px 3px;
  background: #f59e0b; color: #111; font-size: 12px; font-weight: 700; text-align: center;
}
.demo-banner ~ .screen { padding-top: calc(var(--safe-top) + 20px); }

.bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.bar-title { flex: 1; font-size: 19px; font-weight: 800; text-align: center; letter-spacing: -.01em; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; font-size: 26px; line-height: 1;
            background: var(--panel); border: 1px solid var(--line); }
html[dir="rtl"] .icon-btn { transform: scaleX(-1); }
.subbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       padding: 12px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line);
       font-weight: 700; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-text { color: var(--danger); }
.btn.link { background: none; border: 0; color: var(--accent); margin-top: 14px; }
.btn:disabled { opacity: .6; }

.seg { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.seg.wide { display: flex; } .seg.wide button { flex: 1; }

/* ---------------------------------------------------------------- tabs */
.tabs {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20; display: flex;
  padding: 6px 4px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
       font-size: 11px; font-weight: 700; color: var(--muted); padding: 2px 0; }
.tab.on { color: var(--accent); }
.tab-icon { position: relative; font-size: 21px; line-height: 1.1; }
.badge { position: absolute; top: -4px; inset-inline-end: -12px; min-width: 18px; height: 18px; padding: 0 5px;
         border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; }

/* ---------------------------------------------------------------- week grid */
.grid { flex: 1; display: flex; flex-direction: column; min-height: 0; margin: 0 6px;
        background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.grid-head { display: grid; grid-template-columns: 44px repeat(var(--cols), 1fr);
             border-bottom: 1px solid var(--line); background: var(--panel); }
.day-head { display: flex; flex-direction: column; align-items: center; padding: 6px 0 5px; }
.dh-w { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.dh-n { font-size: 18px; font-weight: 800; width: 32px; height: 32px; line-height: 32px; border-radius: 16px; text-align: center; }
.day-head.is-today .dh-w { color: var(--accent); }
.day-head.is-today .dh-n { background: var(--accent); color: #fff; }

.grid-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
               height: calc(100vh - var(--safe-top) - var(--safe-bottom) - 64px - 170px); min-height: 300px; }
.grid-body { position: relative; display: grid; grid-template-columns: 44px repeat(var(--cols), 1fr); }
.grid-body .gutter { position: relative; }
.hour-label { position: absolute; inset-inline-end: 6px; transform: translateY(-50%); font-size: 10px;
              font-weight: 700; color: var(--muted); white-space: nowrap; }
.hour-label:first-child { transform: none; top: 2px !important; }
.col { position: relative; border-inline-start: 1px solid var(--grid-line);
       background-image: linear-gradient(var(--grid-line) 1px, transparent 1px);
       background-size: 100% var(--hour); }
.col.is-today { background-color: var(--today); }

.brk { position: absolute; inset-inline: 2px; border-radius: 6px; background: var(--break);
       display: flex; align-items: center; justify-content: center; text-align: center;
       font-size: 10px; font-weight: 700; color: var(--muted); overflow: hidden; pointer-events: none; }

.lesson {
  position: absolute; display: flex; flex-direction: column; align-items: flex-start; gap: 0;
  inset-inline-start: calc(var(--lane) * 100% / var(--lanes) + 2px);
  width: calc(100% / var(--lanes) - 4px);
  padding: 4px 5px; border-radius: 8px; overflow: hidden; text-align: start;
  background: color-mix(in srgb, var(--c) 22%, var(--panel));
  border-inline-start: 4px solid var(--c);
  color: var(--text); font-size: 11px; line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.lesson .l-time { font-size: 10px; font-weight: 700; opacity: .8; }
.lesson .l-name { font-weight: 800; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.lesson .l-inst { font-size: 10px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.lesson .l-meta { margin-top: auto; font-size: 10px; font-weight: 700; opacity: .9; }
.lesson.small .l-inst { display: none; }
/* Narrow columns (a week on a phone): names wrap rather than lose their end. */
.grid.narrow .lesson { padding: 3px 3px; }
.grid.narrow .lesson .l-name { white-space: normal; word-break: break-all; font-size: 11px; line-height: 1.1; }
.grid.narrow .lesson .l-inst { display: none; }
.grid.narrow .lesson .l-time { font-size: 9px; }
.grid.narrow .lesson.tiny .l-name { white-space: nowrap; }
.grid.narrow .dh-w { font-size: 10px; }
.lesson.tiny { flex-direction: row; align-items: center; gap: 4px; }
.lesson.tiny .l-inst, .lesson.tiny .l-meta { display: none; }
.lesson.st-recorded { background: var(--c); color: var(--ink, #fff); border-inline-start-color: color-mix(in srgb, var(--c) 70%, #000); }
.lesson.st-overdue { box-shadow: 0 0 0 2px var(--danger) inset; }
.lesson.st-overdue .l-meta b { color: var(--danger); }
.lesson.st-cancelled { background: repeating-linear-gradient(135deg, var(--panel-2) 0 6px, var(--panel) 6px 12px);
                       color: var(--muted); border-inline-start-color: var(--muted); opacity: .85; }
.lesson.st-cancelled .l-name { text-decoration: line-through; }
.lesson:active { transform: scale(.98); }

.now { position: absolute; inset-inline: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.now::before { content: ""; position: absolute; inset-inline-start: -5px; top: -4px; width: 10px; height: 10px;
               border-radius: 5px; background: var(--danger); }

.totals { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
          padding: 8px 14px; font-size: 12px; font-weight: 700; color: var(--muted); }
.totals .money { color: var(--ok); }

/* ---------------------------------------------------------------- lists */
.list { padding: 4px 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.list-day { margin-top: 10px; font-size: 13px; font-weight: 800; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-weight: 600; }
.next { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
       background: color-mix(in srgb, var(--c) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line));
       border-radius: 14px; padding: 10px 12px 10px 0; padding-inline-start: 0; overflow: hidden; }
.row-bar { align-self: stretch; width: 5px; background: var(--c); border-radius: 0 3px 3px 0; }
html[dir="rtl"] .row-bar { border-radius: 3px 0 0 3px; }
.row-time { display: flex; flex-direction: column; min-width: 64px; font-size: 13px; }
.row-time small, .row-main small { color: var(--muted); font-size: 12px; }
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-main b { font-size: 15px; }
.row-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.st-cancelled { opacity: .7; } .row.st-cancelled b { text-decoration: line-through; }
.row-break { display: flex; justify-content: space-between; padding: 6px 12px; border-radius: 10px;
             background: var(--break); color: var(--muted); font-size: 12px; font-weight: 700; }
.chip { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800;
        background: var(--panel-2); white-space: nowrap; }
.chip.st-recorded { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.chip.st-overdue { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.chip.st-planned { color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h3 { font-size: 15px; margin-bottom: 6px; }
.card p { margin: 4px 0; }

/* ---------------------------------------------------------------- login */
.login { max-width: 420px; margin: 0 auto; padding: calc(var(--safe-top) + 48px) 20px 40px; text-align: center; }
.login-mark { font-size: 54px; }
.login h1 { font-size: 28px; margin: 6px 0; }
.login form { text-align: start; margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
input[type=email], input[type=password], input[type=text], input[type=date], input[type=time], input[type=number] {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); font-size: 16px;   /* 16px stops iOS zooming into the field */
}
.login-error { color: var(--danger); min-height: 1em; margin: 0; font-size: 13px; }

/* ---------------------------------------------------------------- sheets */
#sheet { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
#sheet.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .2s; }
#sheet.open .sheet-backdrop { opacity: 1; }
.sheet { position: absolute; inset-inline: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
         background: var(--panel); border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
         padding-bottom: calc(16px + var(--safe-bottom));
         transform: translateY(100%); transition: transform .25s ease; }
#sheet.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 4px; }
.sh-head { margin: 4px 14px 0; padding: 12px 14px; border-radius: 14px;
           background: color-mix(in srgb, var(--c) 18%, var(--panel)); border-inline-start: 6px solid var(--c); }
.sh-title { font-size: 20px; font-weight: 800; }
.sh-sub { color: var(--muted); font-size: 13px; }
.sh-body { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.sh-body h3 { font-size: 14px; margin-top: 8px; }
.facts { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.note { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; margin: 4px 0; }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.count { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 10px;
         background: var(--panel-2); font-size: 11px; font-weight: 700; color: var(--muted); }
.count b { font-size: 18px; color: var(--text); }
.c-present b { color: var(--ok); } .c-absent b { color: var(--danger); } .c-late b { color: var(--warn); }

.form .row3 { display: flex; gap: 8px; } .form .row3 label { flex: 1; min-width: 0; }
.students-head { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.students { display: flex; flex-direction: column; gap: 6px; }
.student { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); }
.st-name { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-status { display: flex; gap: 4px; }
.sb { width: 34px; height: 34px; border-radius: 9px; font-weight: 800; font-size: 13px;
      background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.sb.on.sb-present { background: var(--ok); border-color: var(--ok); color: #fff; }
.sb.on.sb-absent { background: var(--danger); border-color: var(--danger); color: #fff; }
.sb.on.sb-late { background: var(--warn); border-color: var(--warn); color: #fff; }
.sb.on.sb-excused { background: #0891b2; border-color: #0891b2; color: #fff; }
.sticky-save { position: sticky; bottom: 0; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 8px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line);
        font-weight: 700; font-size: 13px; }
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------------------------------------------------------------- toast */
.toast { position: fixed; z-index: 60; inset-inline: 16px; bottom: calc(80px + var(--safe-bottom));
         padding: 12px 14px; border-radius: 12px; background: #0f172a; color: #fff; font-weight: 700;
         text-align: center; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--danger); }

@media (min-width: 700px) {
  .lesson { font-size: 12px; } .lesson .l-name { font-size: 13px; }
}
