:root {
  --cream: #FAF6EC;
  --paper: #FFFDF7;
  --ink: #211C13;
  --muted: #6B6253;
  --line: #E6DEC9;
  --gold: #8C6818;          /* text only */
  --present: #1F7A4D;
  --present-bg: #E5F3EA;
  --warn: #A63D2A;
  --warn-bg: #FBE9E4;
  --tap: 56px;
  --r: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--cream);
  color: var(--ink);
  font: 17px/1.45 "Assistant", "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); }
bdi { unicode-bidi: isolate; }

header.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line);
}
header.bar h1 { font-size: 19px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.bar .sub { color: var(--muted); font-size: 14px; font-weight: 400; }
.iconbtn {
  min-width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--paper); display: inline-flex; align-items: center; justify-content: center;
  padding: 0 10px; cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 15px;
}
.iconbtn svg { width: 22px; height: 22px; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 120px; }
main.wide { max-width: 1100px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 18px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.gold { color: var(--gold); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--cream); font-weight: 700; cursor: pointer;
}
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--paper); color: var(--warn); border-color: var(--warn); }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=number], input[type=date], input:not([type]), select, textarea {
  min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; width: 100%;
}
label.f { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 15px; }

/* class list */
.classlist a {
  display: flex; align-items: center; gap: 12px; padding: 16px; margin-bottom: 10px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  text-decoration: none; color: var(--ink); min-height: 72px;
}
.classlist .name { font-size: 20px; font-weight: 700; }
.classlist .meta { color: var(--muted); font-size: 14px; }
.chev { margin-inline-start: auto; color: var(--muted); font-size: 22px; }
[dir=rtl] .chev { transform: scaleX(-1); }

/* date bar */
.datebar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.datebar .date { flex: 1; text-align: center; font-weight: 700; font-size: 18px; }
.datebar .date small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--line); font-size: 13px; font-weight: 600; }
.pill.ok { background: var(--present-bg); color: var(--present); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* roster: the screen a teacher lives in */
.roster { list-style: none; padding: 0; margin: 0; }
.roster li {
  display: flex; align-items: stretch; gap: 6px; margin-bottom: 8px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.roster li.on { background: var(--present-bg); border-color: #B9DDC7; }
.roster .who {
  flex: 1; display: flex; align-items: center; gap: 12px; padding: 0 14px; min-height: var(--tap);
  background: none; border: 0; text-align: start; cursor: pointer; font-size: 19px; font-weight: 600;
  touch-action: manipulation; user-select: none;
}
.roster .tick {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); flex: none;
  display: inline-flex; align-items: center; justify-content: center; background: #fff;
}
.roster li.on .tick { background: var(--present); border-color: var(--present); color: #fff; }
.roster .extra { display: flex; align-items: center; gap: 4px; padding-inline-end: 8px; }
.roster .extra button {
  min-width: 46px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.roster .extra .plus { border-color: var(--gold); color: var(--gold); }
.roster .extra .n { min-width: 28px; text-align: center; font-weight: 700; color: var(--gold); }
.roster li:not(.on) .extra { visibility: hidden; }
/* "+1" / "+2" must read left-to-right inside Hebrew, or they show as "1+". */
.roster .extra .plus, .roster .extra .n { direction: ltr; unicode-bidi: isolate; }
.datebar .iconbtn { font-size: 26px; }

.lessonbox textarea { min-height: 52px; resize: vertical; }
.photo-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.photo-row img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.camera { display: inline-flex; align-items: center; gap: 8px; }
.camera input { display: none; }

.footer-actions {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 4;
  background: linear-gradient(to top, var(--cream) 70%, transparent); padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
.footer-actions .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; }
.footer-actions .btn { flex: 1; }

.sync { font-size: 13px; color: var(--muted); }
.sync.pending { color: var(--gold); }
.sync.err { color: var(--warn); }

.toast {
  position: fixed; inset-inline: 16px; bottom: 90px; z-index: 50; margin: 0 auto; max-width: 520px;
  background: var(--ink); color: var(--cream); padding: 12px 16px; border-radius: 12px; font-weight: 600;
  opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: 86vh;
  background: var(--paper); color: var(--ink);
}
dialog::backdrop { background: rgba(33, 28, 19, .45); }
dialog .dh { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
dialog .dh h3 { margin: 0; flex: 1; font-size: 18px; }
dialog .db { padding: 16px; overflow: auto; max-height: calc(86vh - 70px); }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.tablewrap { overflow-x: auto; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.tabs button { min-height: 44px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--paper); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--ink); color: var(--cream); border-color: var(--ink); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; padding-top: 6px; }
.bars .b { flex: 1; background: #D9CBA4; border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bars .b:last-child { background: var(--gold); }
.bars .b span { position: absolute; top: -18px; inset-inline: 0; text-align: center; font-size: 11px; color: var(--muted); }
.barlabels { display: flex; gap: 4px; font-size: 11px; color: var(--muted); }
.barlabels span { flex: 1; text-align: center; }

.codebox { font-size: 34px; font-weight: 800; letter-spacing: 6px; text-align: center; padding: 14px; background: var(--cream); border-radius: 12px; direction: ltr; }

.login { max-width: 420px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { font-size: 26px; margin: 0 0 4px; }
.login input { font-size: 24px; text-align: center; letter-spacing: 3px; direction: ltr; }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin: 30px 0 10px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.hidden { display: none !important; }

@media print {
  header.bar, .footer-actions, .noprint, .toast { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { max-width: none; padding: 0; }
  .card { border: 0; padding: 0; background: none; }
}
