@font-face { font-family: "Iosevka"; font-weight: 400; font-display: swap; src: url("/fonts/iosevka-400.woff2") format("woff2"); }
@font-face { font-family: "Iosevka"; font-weight: 600; font-display: swap; src: url("/fonts/iosevka-600.woff2") format("woff2"); }

:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --line: #e2e2de;
  --control: #8a8f96;      /* borders of inputs and buttons: 3:1 on white */
  --text: #1c1e21;
  --muted: #5f656d;
  --ok: #1e7a4c;
  --bad: #b42318;
  --bad-bg: #fdeceb;
  --info: #1f5fbf;
  --mono: "Iosevka", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--mono); font-variant-ligatures: none; }
[hidden] { display: none !important; }
a { color: var(--info); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
::selection { background: var(--info); color: #fff; }
.muted { color: var(--muted); }
.ok { color: var(--ok); } .bad { color: var(--bad); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button, input, textarea, select {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--control);
  border-radius: 3px; padding: 6px 12px; min-height: 40px;
}
button { cursor: pointer; }
button:hover { background: var(--bg); }
button.primary { background: var(--text); color: var(--panel); border-color: var(--text); font-weight: 600; }
button.primary:hover { background: #33373c; }
button.quiet { border-color: transparent; color: var(--info); padding-left: 0; padding-right: 0; background: none; }
button.danger { color: var(--bad); border-color: var(--bad); }
button[aria-pressed="true"].seg { background: var(--text); color: var(--panel); border-color: var(--text); }
textarea { width: 100%; min-height: 140px; resize: vertical; }
label { display: block; color: var(--muted); font-size: 14px; margin-bottom: 4px; }
@media (pointer: coarse) { button, input, select { min-height: 44px; } }

/* ------------------------------------------------------------ frame */
.bar { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; color: var(--text); text-decoration: none; letter-spacing: .03em; }
nav { display: flex; gap: 4px; flex: 1; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 3px; }
nav a:hover { color: var(--text); }
nav a[aria-current="page"] { color: var(--text); background: var(--bg); font-weight: 600; }
.out { color: var(--muted); }
.msg { margin: 0; padding: 8px 16px; background: var(--bad-bg); color: var(--bad); border-bottom: 1px solid var(--line); }
.msg.ok { background: #eaf5ee; color: var(--ok); }
main { max-width: 880px; margin: 0 auto; padding: 20px 16px 48px; }
main:focus { outline: none; }
h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 600; margin: 28px 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 16px; }

/* ------------------------------------------------------------ start form */
.start { display: grid; grid-template-columns: 12rem 8rem auto; justify-content: start; gap: 12px; align-items: end; }
.start input { width: 100%; }
@media (max-width: 640px) { .start, .edit.two { grid-template-columns: 1fr 1fr; } .start button, .edit.two button { grid-column: 1 / -1; } }

/* ------------------------------------------------------------ lists */
.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.list > li + li { border-top: 1px solid var(--line); }
.item { display: grid; grid-template-columns: 15ch 7ch minmax(0, 1fr) auto; gap: 4px 14px; align-items: baseline; padding: 10px 14px; color: var(--text); text-decoration: none; }
a.item:hover { background: var(--bg); }
.item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .item { grid-template-columns: auto auto 1fr auto; } .item .t { grid-column: 1 / -1; white-space: normal; } }
.empty { padding: 16px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 14px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
th.num, td.num { text-align: right; }
tr.off td { color: var(--muted); }
.scroll { overflow-x: auto; }

/* ------------------------------------------------------------ marking attendance */
.head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: baseline; }
.count { font-size: 18px; font-weight: 600; }
.edit { display: grid; grid-template-columns: 11rem 7rem minmax(0, 1fr) auto; gap: 10px; align-items: end; margin: 14px 0 18px; }
.edit input { width: 100%; }
@media (max-width: 640px) { .edit { grid-template-columns: 1fr 1fr; } .edit .wide, .edit button { grid-column: 1 / -1; } }
.edit.one { grid-template-columns: minmax(0, 1fr) auto; }
.edit.two { grid-template-columns: 12rem 8rem auto; justify-content: start; }
select { min-width: 7rem; }
.sticky { position: sticky; top: var(--bar-h, 50px); z-index: 2; background: var(--bg); padding: 10px 0; margin-bottom: 4px; }
.more { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 14px; }
.more summary { cursor: pointer; color: var(--muted); }
.more summary:hover { color: var(--text); }
.finish { display: grid; grid-template-columns: 10rem minmax(0, 1fr) auto; gap: 12px; align-items: end; margin-top: 20px; }
.finish input { width: 100%; }
@media (max-width: 640px) { .finish { grid-template-columns: 1fr; } }
.live { color: var(--info); font-weight: 600; }
.finish.one { grid-template-columns: minmax(0, 1fr) auto; }
.item-r { grid-template-columns: minmax(0, 1fr) auto; }
.mark.accept[aria-pressed="false"] { background: var(--panel); border-color: var(--line); }
.mark.accept[aria-pressed="false"] .state { color: var(--bad); font-weight: 400; }
.mark.accept[aria-pressed="true"] { background: #eaf5ee; border-color: var(--ok); }
.mark.accept[aria-pressed="true"] .state { color: var(--ok); font-weight: 600; }
.att { margin-top: 2px; }
.att td { padding: 7px 12px; }
.att .n { width: 3.5ch; text-align: right; padding-right: 4px; }
.att .st { width: 1%; white-space: nowrap; text-align: right; }
.att tr.tap { cursor: pointer; }
.att tr.tap:hover td { background: var(--bg); }
.att .state { min-height: 30px; padding: 2px 12px; min-width: 9ch; color: var(--ok); border-color: var(--line); }
.att tr.absent td { background: var(--bad-bg); }
.att tr.absent .state { color: var(--bad); border-color: var(--bad); font-weight: 600; }
.att.retake .state { color: var(--bad); }
.att.retake tr.done td { background: #eaf5ee; }
.att.retake tr.done .state { color: var(--ok); border-color: var(--ok); font-weight: 600; }
.nowrap { white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; margin-bottom: 14px; }
.filters .seg-row { margin-bottom: 0; }
.debts .st { white-space: nowrap; text-align: right; }
.formrow td { background: var(--bg); }
.take { display: grid; grid-template-columns: 11rem 8rem minmax(0, 1fr) auto auto; gap: 10px; align-items: end; }
.take input { width: 100%; }
@media (max-width: 640px) { .take { grid-template-columns: 1fr 1fr; } .take .wide { grid-column: 1 / -1; } }
.att .g { width: 1%; padding-left: 4px; padding-right: 4px; }
.att .grade { width: 6ch; min-height: 30px; padding: 2px 6px; text-align: right; border-color: var(--line); }
.att .grade:hover { border-color: var(--control); }
.att .grade.saved { border-color: var(--ok); }
@media (pointer: coarse) { .att .grade { min-height: 40px; } }
@media (pointer: coarse) { .att .state { min-height: 40px; } }
.marks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mark { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; text-align: left; border-color: var(--line); }
.mark .state { color: var(--ok); }
.mark[aria-pressed="false"] { background: var(--bad-bg); border-color: var(--bad); }
.mark[aria-pressed="false"] .state { color: var(--bad); font-weight: 600; }
.mark .r { color: var(--muted); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.actions .push { margin-left: auto; }

.box + .summary { margin-top: 20px; }
.summary { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0 0 16px; }
.summary b { font-size: 20px; display: block; }
.seg-row { display: inline-flex; margin-bottom: 12px; }
.seg-row button { border-radius: 0; margin-left: -1px; } .seg-row button:first-child { border-radius: 3px 0 0 3px; margin-left: 0; } .seg-row button:last-child { border-radius: 0 3px 3px 0; }

/* ------------------------------------------------------------ login */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-box { width: min(320px, 90vw); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 22px; display: grid; gap: 10px; }
.login-box h1 { margin: 0 0 6px; font-size: 16px; }
.login-box input { width: 100%; }
.login-error { margin: 0; min-height: 1.5em; color: var(--bad); }
