/* Termaneh teacher app — «دفتر کلاس» on a phone: ruled paper, ink blue, red stamps. */
:root {
	--paper: #f7f1e3;
	--paper-2: #fffdf7;
	--paper-3: #efe7d1;
	--ink: #1f2a5a;
	--ink-2: #5b6488;
	--stamp: #c23b2e;
	--stamp-soft: #f6dcd8;
	--saffron: #d8a31a;
	--saffron-soft: #f8ecc6;
	--saffron-ink: #7a5600;
	--pencil: #3f7a4f;
	--pencil-soft: #dcebdd;
	--rule: #d9cfb8;
	--font: "Termaneh Sep", "Termaneh Estedad", Tahoma, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; letter-spacing: normal; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.7; min-height: 100vh; overscroll-behavior-y: contain; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; border-radius: 4px; }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.boot { padding: 40px 16px; text-align: center; color: var(--ink-2); }
.hidden { display: none !important; }

/* Header */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--ink); color: var(--paper); }
.bar h1 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.4; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .back { appearance: none; border: 0; background: transparent; color: var(--paper); font-size: 24px; line-height: 1; min-width: 44px; min-height: 44px; margin-inline-start: -8px; }
.bar .sub { font-size: 12.5px; opacity: .85; display: block; font-weight: 400; }
.iconbtn { appearance: none; border: 1px solid rgba(247, 241, 227, .4); background: transparent; color: var(--paper); border-radius: 6px; min-width: 44px; min-height: 44px; font-size: 18px; }
.net { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 0 10px; min-height: 28px; border-radius: 999px; border: 1px solid rgba(247, 241, 227, .4); }
.net i { width: 8px; height: 8px; border-radius: 50%; background: #7fd18f; display: inline-block; }
.net.is-off i { background: var(--saffron); }
.net.is-off { color: var(--saffron-soft); border-color: var(--saffron); }

/* Content */
.wrap { padding: 14px 16px; display: grid; gap: 12px; }
.date-line { font-size: 14px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.notice { border: 1.5px solid var(--saffron); background: var(--saffron-soft); color: var(--saffron-ink); border-radius: 6px; padding: 10px 12px; font-size: 14px; display: grid; gap: 6px; }
.notice.is-bad { border-color: var(--stamp); background: var(--stamp-soft); color: #7d2118; }
.notice.is-ok { border-color: var(--pencil); background: var(--pencil-soft); color: #25502f; }
.notice button { justify-self: start; }
.card { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; text-align: start; width: 100%; padding: 14px 16px; background: var(--paper-2); border: 1.5px solid var(--rule); border-radius: 8px; min-height: 76px; color: inherit; }
.card:active { background: var(--paper-3); }
.card .t { font-weight: 700; font-size: 17px; line-height: 1.5; }
.card .m { font-size: 13.5px; color: var(--ink-2); grid-column: 1; }
.card .s { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.stamp { display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; line-height: 26px; font-size: 13px; font-weight: 700; border: 1.5px solid currentColor; border-radius: 3px; transform: rotate(-2deg); white-space: nowrap; }
.stamp.is-todo { color: var(--saffron-ink); background: var(--saffron-soft); }
.stamp.is-done { color: var(--pencil); background: var(--pencil-soft); }
.stamp.is-queued { color: var(--ink); background: var(--paper-3); border-style: dashed; }
.stamp.is-off { color: var(--ink-2); border-style: dashed; }
.stamp.is-bad { color: var(--stamp); background: var(--stamp-soft); }
.empty { text-align: center; color: var(--ink-2); padding: 36px 12px; border: 1.5px dashed var(--rule); border-radius: 8px; }

/* Buttons */
.btn { appearance: none; min-height: 48px; padding: 0 18px; border-radius: 8px; border: 1.5px solid var(--ink); background: var(--paper-2); color: var(--ink); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.is-primary { background: var(--ink); color: var(--paper); }
.btn.is-wide { width: 100%; min-height: 54px; font-size: 17px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.is-small { min-height: 38px; font-size: 14px; padding: 0 12px; }
.link { appearance: none; background: none; border: 0; padding: 8px 0; color: var(--ink); text-decoration: underline; min-height: 44px; }

/* Login */
.login { padding: 28px 18px; display: grid; gap: 14px; }
.login h2 { margin: 0; font-size: 22px; line-height: 1.5; }
.login p { margin: 0; color: var(--ink-2); }
.field { display: grid; gap: 4px; }
.field label { font-weight: 700; font-size: 14px; }
.field input, .field textarea { width: 100%; min-height: 50px; padding: 8px 12px; border: 1.5px solid var(--rule); border-radius: 8px; background: var(--paper-2); font-size: 18px; }
.field textarea { min-height: 76px; font-size: 16px; resize: vertical; }
.field input[dir="ltr"] { text-align: left; letter-spacing: .05em; }
.err { color: #7d2118; font-size: 14px; }

/* Roster */
.hint { font-size: 14px; color: var(--ink-2); padding: 0 2px; }
.roster { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.stu { background: var(--paper-2); border: 1.5px solid var(--rule); border-radius: 8px; padding: 10px 12px; display: grid; gap: 8px; }
.stu.is-absent { border-color: var(--stamp); background: #fff6f4; }
.stu.is-late { border-color: var(--saffron); background: #fffaf0; }
.stu.is-excused, .stu.is-leave { border-color: var(--ink-2); background: #f4f1ea; }
.stu .nm { font-weight: 700; font-size: 16.5px; line-height: 1.5; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.stu .nm small { font-weight: 400; color: var(--ink-2); font-size: 13px; }
.opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.opt { appearance: none; min-height: 46px; border-radius: 8px; border: 1.5px solid var(--rule); background: var(--paper); font-size: 14.5px; font-weight: 600; padding: 0 2px; }
.opt[aria-pressed="true"] { color: var(--paper); border-color: transparent; }
.opt.o-absent[aria-pressed="true"] { background: var(--stamp); }
.opt.o-late[aria-pressed="true"] { background: var(--saffron); color: #3b2a00; }
.opt.o-excused[aria-pressed="true"], .opt.o-leave[aria-pressed="true"] { background: var(--ink-2); }
.late-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.late-row .btn { min-height: 40px; min-width: 44px; padding: 0 10px; }
.late-row output { min-width: 5ch; text-align: center; font-weight: 700; }
.notes { display: grid; gap: 10px; background: var(--paper-2); border: 1.5px solid var(--rule); border-radius: 8px; padding: 12px; }
.notes summary { font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.dock { position: sticky; inset-inline: 0; bottom: 0; z-index: 6; background: var(--paper-2); border-top: 1.5px solid var(--ink); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.dock-in { max-width: 560px; margin: 0 auto; display: grid; gap: 8px; }
.tally { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--ink-2); justify-content: center; }
.tally b { color: var(--ink); }
.toast { position: fixed; inset-inline: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 9; max-width: 528px; margin: 0 auto; background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 8px; text-align: center; font-weight: 600; }
.toast.is-bad { background: #7d2118; }
@media (prefers-reduced-motion: no-preference) { .stamp { animation: pop .25s ease-out; } @keyframes pop { from { transform: scale(1.35) rotate(-8deg); opacity: 0; } to { transform: rotate(-2deg); opacity: 1; } } }

/* Tabs and grades */
.tabs { position: fixed; inset-inline: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--paper-2); border-top: 1.5px solid var(--ink); padding-bottom: env(safe-area-inset-bottom); max-width: 560px; margin: 0 auto; }
.tabs a { display: flex; align-items: center; justify-content: center; min-height: 54px; text-decoration: none; color: var(--ink-2); font-weight: 600; border-top: 3px solid transparent; margin-top: -1.5px; }
.tabs a[aria-current="page"] { color: var(--ink); border-top-color: var(--stamp); background: var(--paper-3); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
.chip { appearance: none; flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--rule); background: var(--paper-2); font-weight: 600; white-space: nowrap; }
.chip[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chips.is-sub .chip { min-height: 38px; font-size: 14px; }
.gr-row { grid-template-columns: 1fr 96px; align-items: center; }
.gr-row .nm { grid-column: 1; }
.gr-row .gcell { grid-column: 2; grid-row: 1; width: 96px; min-height: 52px; text-align: center; font-size: 22px; font-weight: 700; border: 1.5px solid var(--rule); border-radius: 8px; background: var(--paper); }
.gr-row .gcell:focus { border-color: var(--ink); outline: 3px solid var(--saffron); }
.gr-row.is-dirty .gcell { background: var(--saffron-soft); border-color: var(--saffron); }
.gr-row .err { grid-column: 1 / -1; margin: 0; }

/* The submit bar sits after the last card (sticky, not fixed), so it never covers one. */
.toolrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolrow .btn { flex: 0 0 auto; }
.search { flex: 1 1 160px; min-width: 0; min-height: 44px; border: 1.5px solid var(--rule); border-radius: 8px; background: var(--paper-2); padding: 0 12px; font: inherit; color: inherit; }
.btn.online { display: flex; justify-content: center; text-decoration: none; }
