/* Teacher/Student Portal (loaded only by portal.html; uses the tokens in style.css) */
.portal { padding: 56px 0 96px; min-height: 70vh; }
[hidden] { display: none !important; }

.login-card { max-width: 420px; margin: 24px auto 0; }
.login-card h1 { font-size: 2rem; }
.login-card .small-print { margin: 0 0 20px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.field input, .field select, .toolbar input, .toolbar select {
  width: 100%; font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-card .btn { width: 100%; }
.login-card .btn:disabled { opacity: .6; cursor: wait; }
.form-error { color: #b42318; min-height: 1.4em; margin: 12px 0 0; font-size: .95rem; }

.portal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.portal-head h1 { font-size: clamp(1.8rem, 3.4vw, 2.4rem); margin: 0; }
.signed-in-as { font-size: 1.1rem; color: var(--ink-2); }
.signed-in-as strong { color: var(--ink); }
.signed-in-as .me-id { color: var(--ink-2); white-space: nowrap; } /* the user name (StudentID) after the name */
#school-name::before { content: "\00b7"; margin: 0 .45em; color: var(--ink-3); } /* a middle dot: "dprins . Lincoln High School" */
#school-name { font-weight: 600; color: var(--ink); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.toolbar input { flex: 1 1 200px; width: auto; }
.toolbar select { flex: 0 1 240px; width: auto; }
.sorts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sorts > span { font-size: .9rem; color: var(--ink-3); margin-right: 2px; }
.sorts button {
  font: 600 .92rem/1 var(--body); padding: 10px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
}
.sorts button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.sorts .arrow { display: inline-block; min-width: 1em; font-size: .7em; margin-left: 4px; }
.hint { font-size: .88rem; color: var(--ink-3); margin: 0 0 14px; }

.roster { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.student { background: var(--card); }
.student:nth-of-type(even) { background: #f1efe6; }

/* Column headings that sort (Students list and Class roster): click to sort on the column, again to reverse */
.roster-head {
  display: grid; grid-template-columns: minmax(0,1.3fr) minmax(0,1.3fr) minmax(0,1fr) 110px 16px; gap: 12px; align-items: center;
  padding: 6px 18px; background: #e9e6da; border-bottom: 1px solid var(--line);
}
.roster-head .col-sort { justify-self: start; }
.roster-head .col-sort[data-sort="grade"] { justify-self: end; }
.col-sort {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 4px 8px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,.7); box-shadow: 0 1px 0 rgba(0,0,0,.04);
  font: 600 .85rem/1.2 var(--body); color: var(--ink-2); text-align: inherit; border-radius: 6px;
}
.col-sort:hover { background: #fff; border-color: var(--accent); }
.col-sort:hover .col-label { color: var(--accent-dark); }
.col-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.col-sort[aria-pressed="true"] { color: var(--accent-dark); border-color: var(--accent); background: #fff; }
.col-label { white-space: nowrap; }
.col-sort .arrow { display: inline-block; min-width: 1em; font-size: .75em; margin-left: 4px; }
.col-sort[aria-pressed="false"] .arrow { opacity: .45; } /* ↕: sortable, not the current sort */
.roster-none { padding: 12px 18px; margin: 0; }
.student + .student { border-top: 1px solid var(--line); }
.student-row {
  display: grid; grid-template-columns: minmax(0,1.3fr) minmax(0,1.3fr) minmax(0,1fr) 110px 16px; gap: 12px; align-items: center; width: 100%;
  padding: 8px 18px; background: none; border: 0; font: inherit; color: var(--ink); text-align: left; cursor: pointer;
}
.student-row:hover { background: var(--accent-soft); }
.student-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.s-name { font-weight: 600; }
.s-class, .s-done { color: var(--ink-2); font-size: .95rem; }
.chev { color: var(--ink-3); transition: transform .15s; }
.student-row[aria-expanded="true"] .chev { transform: rotate(90deg); }

.mistakes { display: inline-block; justify-self: end; min-width: 2em; text-align: center; font-weight: 600; font-size: .88rem; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.m-good { background: #dcf3e3; color: #14622b; }
.m-ok { background: #fdf0c4; color: #7a5200; }
.m-bad { background: #fde0dc; color: #a12418; }

.student-detail { border-top: 1px solid var(--line); background: var(--paper); padding: 8px 18px 18px; }
.item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.item-head .item-done { margin-left: auto; color: var(--ink-2); font-size: .92rem; }
.tag { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 4px; background: #eceae2; color: var(--ink-2); }
.tag-test { background: #e9e1fa; color: #4b2a99; }
.tag-quiz { background: #dff1f5; color: #0b5c70; }
.status { font-size: .85rem; color: var(--ink-3); }
.st-graded { color: #14622b; font-weight: 600; }
.st-submitted { color: var(--accent-dark); font-weight: 600; }
.bar { height: 6px; background: #e8e6dc; border-radius: 3px; margin: 10px 0; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.pages { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.pages li { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ink-2); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px 5px 10px; }
.pages .mistakes { padding: 1px 8px; }

@media (max-width: 760px) {
  .roster-head { display: flex; flex-wrap: wrap; gap: 2px 16px; }
  .roster-head > span:empty { display: none; }
  .student-row { grid-template-columns: 1fr auto 20px; }
  .s-class, .s-done { grid-column: 1; }
  .student-row .mistakes { grid-column: 2; grid-row: 1; }
  .student-row .chev { grid-column: 3; grid-row: 1; }
  .item-head .item-done { margin-left: 0; }
}

.pdf-btn {
  display: inline-flex; align-items: center; gap: 6px; font: 600 .85rem/1 var(--body); color: var(--ink);
  padding: 4px 12px 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer;
}
.pdf-btn:hover { border-color: #d93025; background: #fff5f4; }
.pdf-btn:disabled { opacity: .6; cursor: wait; }
.pdf-ico { flex: none; }

/* Signed in: header turns the app's toolbar blue (#7BA6D3, sampled from the app's top bar). */
body.signed-in .site-header { background: #7BA6D3; backdrop-filter: none; border-bottom-color: #6690bd; }
body.signed-in .site-header .nav a { color: var(--ink); }
body.signed-in .site-header .nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--ink); }

/* Portal greyed out when the account has no school (portal.js setSchoolLock); hover, focus or click shows why. */
.nav a[data-view="portal"] { position: relative; }
.nav .why { display: none; }
body.signed-in .site-header .nav a.locked { color: #5d6b7a; cursor: not-allowed; }
.nav a.locked .why {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 20; width: max-content; max-width: min(300px, calc(100vw - 32px));
  padding: 10px 12px; border-radius: 6px; background: #1f2933; color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.18);
  font: 400 .85rem/1.4 var(--body); white-space: normal; cursor: default;
}
.nav a.locked:hover .why, .nav a.locked:focus-visible .why, .nav a.locked.show-why .why { display: block; }

/* Recent user names (kept in this browser; passwords stay in the browser's password manager) */
.recent-users { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -8px 0 16px; font-size: .85rem; color: var(--ink-3); }
.recent-users .chip { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: #fff; overflow: hidden; }
.recent-users .chip button { border: 0; background: none; font: inherit; color: var(--ink); padding: 4px 4px 4px 10px; cursor: pointer; }
.recent-users .chip button.forget { color: var(--ink-3); padding: 4px 9px 4px 4px; font-size: 1rem; line-height: 1; }
.recent-users .chip button:hover { color: var(--accent); }
.recent-users .chip button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.remember { display: flex; align-items: center; gap: 8px; margin: -6px 0 16px; font-size: .9rem; color: var(--ink-2); cursor: pointer; }
.remember input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
#password.saved-pw { letter-spacing: .1em; }

/* Tabs: Students | Class roster | Classes */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 20px; overflow-x: auto; scrollbar-width: none; }
.tabs [role=tab] {
  position: relative; font: 600 .97rem/1 var(--body); color: var(--ink-2); background: none; border: 0; cursor: pointer;
  padding: 12px 16px; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs [role=tab]:hover { color: var(--ink); }
.tabs [role=tab][aria-selected="true"] { color: var(--accent-dark); border-bottom-color: var(--accent); }
.tabs [role=tab]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }
.tab-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d97706; margin-left: 6px; vertical-align: 2px; }

/* Class roster: a spreadsheet of students (rows) x classes (columns) */
.grid-actions { display: flex; gap: 8px; margin-left: auto; }
.grid-actions .btn:disabled { opacity: .5; cursor: default; }
.grid-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: auto; max-height: 70vh; }
.class-grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: .95rem; }
.class-grid th, .class-grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--card); }
.class-grid thead th { position: sticky; top: 0; z-index: 2; background: #f1efe6; vertical-align: bottom; padding: 10px 12px; text-align: center; }
.class-grid .g-name { position: sticky; left: 0; z-index: 1; text-align: left; min-width: 200px; max-width: 280px; padding: 8px 14px; font-weight: 600; }
.class-grid thead .g-name { z-index: 3; }
.class-grid tbody tr:nth-child(even) th, .class-grid tbody tr:nth-child(even) td { background: #faf9f4; }
.class-grid tbody tr:hover th, .class-grid tbody tr:hover td { background: var(--accent-soft); }
.class-grid .g-user { text-align: left; padding: 8px 14px; font-size: .88rem; color: var(--ink-2); white-space: nowrap; }
.class-grid thead .g-user { color: var(--ink); }
.class-grid .g-name small { display: block; font-weight: 400; font-size: .82rem; color: var(--ink-3); overflow-wrap: anywhere; }
.g-col { min-width: 110px; }
.g-head { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; color: var(--ink); }
.class-grid .col-sort { font: 700 .95rem/1.25 var(--body); color: var(--ink); }
.class-grid .col-sort[aria-pressed="true"] { color: var(--accent-dark); }
.class-grid .g-col .col-sort { align-items: center; text-align: center; }
.class-grid .g-col .col-label { white-space: normal; max-width: 160px; overflow-wrap: anywhere; }
.g-count { display: block; margin-top: 4px; font-weight: 400; font-size: .78rem; color: var(--ink-3); }
.class-grid td.g-cell { text-align: center; padding: 0; }
.class-grid td.g-cell.changed, .class-grid tbody tr td.g-cell.changed { background: #fef3c7; box-shadow: inset 0 0 0 2px #f2c94c; }
.class-grid input[type=checkbox] { width: 18px; height: 18px; margin: 10px; accent-color: var(--accent); cursor: pointer; }
.class-grid input[type=checkbox]:disabled { cursor: default; }
.g-none { padding: 18px; color: var(--ink-3); text-align: center; }
.grid-empty { padding: 28px 18px; text-align: center; color: var(--ink-2); }
.grid-empty p { margin: 0 0 12px; }

/* Classes list */
.class-add { display: flex; gap: 10px; align-items: flex-end; max-width: 560px; }
.class-add .field { flex: 1; margin-bottom: 0; }
.class-add .btn { flex: none; }
#class-error { margin: 8px 0 12px; }
.class-list { list-style: none; margin: 0; padding: 0; max-width: 720px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); counter-reset: cls; }
.class-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; counter-increment: cls; }
.class-row + .class-row { border-top: 1px solid var(--line); }
.class-row::before { content: counter(cls); width: 1.6em; text-align: right; color: var(--ink-3); font-size: .85rem; flex: none; }
.class-name { flex: 1; min-width: 0; font: 600 1rem/1.3 var(--body); color: var(--ink); padding: 8px 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; }
.class-name:hover { border-color: var(--line); }
.class-name:focus { border-color: var(--line); background: #fff; outline: 2px solid var(--accent); outline-offset: 1px; }
.class-count { font-size: .88rem; color: var(--ink-3); white-space: nowrap; }
.class-btns { display: flex; gap: 4px; flex: none; }
.icon-btn { font: 600 .9rem/1 var(--body); min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-dark); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover { border-color: #b42318; color: #b42318; background: #fff5f4; }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.class-empty { padding: 18px; color: var(--ink-3); }

@media (max-width: 760px) {
  .grid-actions { margin-left: 0; width: 100%; }
  .grid-actions .btn { flex: 1; }
  .class-grid .g-name { min-width: 140px; max-width: 170px; }
  .class-add { flex-direction: column; align-items: stretch; }
  .class-row { flex-wrap: wrap; }
  .class-name { flex-basis: calc(100% - 2.6em); }
  .class-count { margin-left: 2.6em; }
  .class-btns { margin-left: auto; }
}

/* Files: link files to classes */
.file-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.file-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr) auto; gap: 8px 16px; align-items: center; padding: 12px 16px; }
.file-row + .file-row { border-top: 1px solid var(--line); }
.file-main { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-date { font-size: .82rem; color: var(--ink-3); }
.file-links { display: flex; flex-wrap: wrap; gap: 6px; }
.file-unlinked { font-size: .88rem; color: var(--ink-3); }
.link-chip { display: inline-flex; align-items: center; gap: 2px; font-size: .84rem; border-radius: 999px; padding: 3px 4px 3px 10px; background: #eceae2; color: var(--ink-2); }
.link-chip.p1 { background: #e3eefc; color: #1d4f91; }
.link-chip.p2 { background: #dff1f5; color: #0b5c70; }
.link-chip.p3 { background: #e9e1fa; color: #4b2a99; }
.link-chip.p4 { background: #eceae2; color: var(--ink-2); }
.link-chip .unlink { border: 0; background: none; color: inherit; opacity: .7; cursor: pointer; font: 600 1rem/1 var(--body); padding: 0 6px; border-radius: 50%; }
.link-chip .unlink:hover { opacity: 1; }
.link-chip .unlink:focus-visible { outline: 2px solid var(--accent); opacity: 1; }
.link-chip:not(:has(.unlink)) { padding-right: 10px; }
.link-btn { white-space: nowrap; }
.link-form { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(200px, 2fr) minmax(140px, 1fr) minmax(150px, 1fr) auto; gap: 10px 12px; align-items: end;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.link-form .field { margin: 0; }
.link-form select, .link-form input { width: 100%; font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
.link-form select:focus, .link-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.link-form option:disabled { color: #9aa29c; }
.link-form .link-error { grid-column: 1 / -1; margin: 0; min-height: 0; }
.link-form .link-error:empty { display: none; }
.file-empty { padding: 18px; color: var(--ink-3); }

@media (max-width: 760px) {
  .file-row { grid-template-columns: 1fr auto; }
  .file-links { grid-column: 1 / -1; grid-row: 2; }
  .link-form { grid-template-columns: 1fr; } /* one field per row: the date box leaves no room beside it */
  .link-form-btns .btn { width: 100%; }
}

/* Term on the Classes tab and under the roster's column headings */
.class-add { max-width: 720px; }
.class-add .term-field { flex: 0 1 200px; }
.class-term { flex: 0 1 170px; min-width: 0; font: .95rem/1.3 var(--body); color: var(--ink-2); padding: 8px 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; }
.class-term::placeholder { color: var(--ink-3); opacity: .7; }
.class-term:hover { border-color: var(--line); }
.class-term:focus { border-color: var(--line); background: #fff; outline: 2px solid var(--accent); outline-offset: 1px; }
.g-head .g-term { display: block; font-weight: 400; font-size: .78rem; color: var(--ink-2); }
@media (max-width: 760px) {
  .class-add .term-field { flex: 1 1 auto; }
  .class-term { flex-basis: calc(100% - 2.6em); margin-left: 2.6em; }
}

/* Term dropdowns and the Terms tab */
select.class-term { cursor: pointer; }
.field select:disabled { opacity: .6; }
.term-add .date-field { flex: 0 1 170px; }
.term-list { max-width: 820px; }
.term-row { flex-wrap: wrap; gap: 6px 10px; }
.term-row .term-name { min-width: 8em; }
.term-row .class-btns { margin-left: auto; }
.term-date { flex: none; width: 136px; font: .9rem/1.3 var(--body); color: var(--ink-2); padding: 7px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; }
.term-date:hover { border-color: var(--line); }
.term-date:focus { border-color: var(--line); background: #fff; outline: 2px solid var(--accent); outline-offset: 1px; }
.term-dash { color: var(--ink-3); margin: 0 -6px; }
.term-row.archived .term-name, .term-row.archived .term-date { color: var(--ink-3); }
.term-row.archived .term-name { font-weight: 400; font-style: italic; }
/* a school term: the school's name; read-only when I'm not one of its School admins */
.term-school { flex: none; font: 600 .75rem/1.2 var(--body); color: var(--accent-dark); background: #eef3fb; border: 1px solid #d6e2f3; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.term-row.read-only .term-name, .term-row.read-only .term-date { color: var(--ink-2); cursor: default; }
.term-row.read-only .term-name:hover, .term-row.read-only .term-date:hover { border-color: transparent; }
#term-error { margin: 8px 0 12px; }
@media (max-width: 760px) {
  .term-add .date-field { flex: 1 1 auto; }
  .term-date[data-f="start"] { margin-left: 2.6em; }
  .term-date { width: auto; flex: 1 1 0; min-width: 0; padding: 6px 4px; font-size: .85rem; }
  .term-dash { margin: 0; }
  .term-row::after { content: ""; flex-basis: 100%; order: 8; margin-top: -6px; } /* count and buttons on their own line */
  .term-row .class-count { order: 9; }
  .term-row .class-btns { order: 10; }
}

/* "Are you sure?" dialog for deletes */
.btn-danger { background: #b42318; border-color: #b42318; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8f1c13; border-color: #8f1c13; }
.btn-danger:disabled { opacity: .45; cursor: default; }
.confirm-dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--card); color: var(--ink); box-shadow: 0 24px 60px rgba(0, 0, 0, .28); }
.confirm-dialog::backdrop { background: rgba(23, 32, 26, .45); }
.confirm-dialog form { padding: 22px 22px 18px; }
.confirm-dialog h2 { font-size: 1.25rem; margin: 0 0 10px; overflow-wrap: anywhere; }
.confirm-dialog p { margin: 0 0 22px; color: var(--ink-2); line-height: 1.5; }
.confirm-btns { display: flex; justify-content: flex-end; gap: 10px; }
/* Profile save result: one line per thing saved, a mark in front (green = done, grey = unchanged, red = not saved) */
.result-dialog #result-body:empty { display: none; }
.result-list { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 8px; }
.result-list:empty { display: none; }
.result-list li { display: flex; gap: 10px; align-items: baseline; line-height: 1.45; }
.result-list li::before { content: "\2713"; flex: none; width: 1.2em; font-weight: 700; color: #1a7f37; }
.result-list li.same { color: var(--ink-3); }
.result-list li.same::before { content: "\2013"; color: var(--ink-3); }
.result-list li.fail::before { content: "\2715"; color: #b42318; }
.result-dialog.failed h2 { color: #b42318; }
@media (max-width: 760px) {
  .confirm-btns { flex-direction: column-reverse; }
  .confirm-btns .btn { width: 100%; }
}

/* CSV upload: buttons on the Students / Class roster / Classes tabs, and the preview dialog */
.toolbar .csv-btn { margin-left: auto; }
/* Classes tab: the Add form on the left, Upload CSV at the right edge like the other tabs (lined up with the Add button) */
.class-toolbar { align-items: flex-end; margin-bottom: 0; }
.class-toolbar .class-add { flex: 1 1 520px; }
.class-toolbar .csv-btn { align-self: flex-end; }
.class-toolbar .field input, .class-toolbar .field select { width: 100%; flex: none; } /* not the .toolbar input sizes */
.csv-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; }
.csv-sub { font-size: .92rem; }
.csv-remove-opt { margin: -10px 0 14px; }
.csv-summary { margin: 0 0 10px; color: var(--ink); font-weight: 600; }
.csv-table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; }
.csv-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.csv-table th { position: sticky; top: 0; background: var(--paper); text-align: left; font-weight: 600; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.csv-table td { padding: 6px 10px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.csv-table tr:first-child td { border-top: 0; }
.csv-line-no { color: var(--ink-3); width: 3.5em; }
.csv-act { display: inline-block; white-space: nowrap; font-size: .78rem; font-weight: 700; border-radius: 4px; padding: 2px 7px; background: #eceae2; color: var(--ink-2); }
.csv-create .csv-act, .csv-add .csv-act, .csv-link .csv-act { background: #e3f1e6; color: #1e6b34; }
.csv-update .csv-act { background: #e3eefc; color: #1d4f91; }
.csv-remove .csv-act { background: #fdf1dc; color: #8a5300; }
.csv-error .csv-act { background: #fde7e5; color: #b42318; }
.csv-error td:last-child { color: #b42318; }
.csv-same td { color: var(--ink-3); }
#csv-error:empty { display: none; }

/* CSV format dialog: the sample file with each field coloured like its column in the table below */
.csv-format .csv-sub { margin-bottom: 16px; }
.csvf-h { font: 600 .95rem/1.3 var(--head); margin: 0 0 6px; }
.csvf-sample { margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
  font: 500 .88rem/1.6 ui-monospace, Consolas, monospace; white-space: pre; overflow-x: auto; }
.csvf-head { font-weight: 700; }
.csvf-comma { color: var(--ink-3); font-weight: 700; padding: 0 1px; }
.csvf-empty { color: var(--ink-3); font-style: normal; }
.csvf-c1 { color: #1d4ed8; } .csvf-c2 { color: #b45309; } .csvf-c3 { color: #15803d; } .csvf-c4 { color: #7c3aed; } .csvf-c5 { color: #be123c; } .csvf-c6 { color: #0e7490; } .csvf-c7 { color: #4d7c0f; }
.csvf-chip { font-weight: 700; }
.csvf-req, .csvf-opt { display: inline-block; font-size: .72rem; font-weight: 600; border-radius: 4px; padding: 1px 6px; margin-left: 4px; white-space: nowrap; }
.csvf-req { background: #fde7e5; color: #b42318; }
.csvf-opt { background: #eceae2; color: var(--ink-2); }
.csvf-cols td:nth-child(2) { white-space: nowrap; }
.csvf-rules { margin: 4px 0 18px; padding-left: 20px; font-size: .88rem; color: var(--ink-2); line-height: 1.5; display: grid; gap: 4px; }
.csvf-dl { margin-right: auto; }
@media (max-width: 760px) {
  .csvf-dl { margin-right: 0; }
  .csvf-cols td:nth-child(2) { white-space: normal; }
  .toolbar .csv-btn { margin-left: 0; }
  .csv-table-wrap { max-height: 32vh; }
  .csv-dialog form { padding: 18px 16px 14px; }
}

/* LiveShare Contacts and User Profile views */
.contacts-intro { max-width: 60em; }
.contacts-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-bottom: 8px; }
.contacts-grid .card { padding: 18px 20px; box-shadow: none; }
.contacts-grid h2 { font-size: 1.1rem; margin: 0 0 10px; }
.contacts-grid .field { margin-bottom: 10px; }
.contacts-grid textarea, .contacts-grid select { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); resize: vertical; }
.contacts-grid textarea:focus, .contacts-grid select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.contacts-grid .small-print { margin: 0 0 12px; }
.contacts-grid .btn:disabled, #pf-clear:disabled { opacity: .45; cursor: default; }
.class-members { margin-bottom: 10px; }
.member-all { margin: 0 0 6px; font-weight: 600; }
.member-list { list-style: none; margin: 0; padding: 4px 10px; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.member-list li { padding: 3px 0; }
.member-list .remember { margin: 0; }
.member-list small { color: var(--ink-3); }
.member-list .member-note { font-style: italic; }
#contact-error, .contact-result { margin: 8px 0; }
#contact-error:empty, .contact-result:empty { display: none; }
.contacts-toolbar { margin-top: 18px; }
.contacts-toolbar .contact-all { margin: 0; white-space: nowrap; }
.contacts-toolbar #contact-search { flex: 1 1 200px; }
.contact-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.contact-row { display: flex; align-items: center; gap: 14px; padding: 8px 14px; }
.contact-row + .contact-row { border-top: 1px solid var(--line); }
.contact-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.contact-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.contact-nick { color: var(--ink-3); }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; background: #eceae2; }
.avatar.letter { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: 6px; border-radius: 3px; background: var(--c); transform: rotate(45deg); }
.avatar.letter span { transform: rotate(-45deg); color: #fff; font: 700 1rem/1 Georgia, serif; }

.profile-card { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 10px 32px; max-width: 900px; padding: 24px; box-shadow: none; }
.profile-fields .field { margin-bottom: 14px; }
.field .pw-wrap { display: flex; gap: 8px; align-items: center; margin: 0; font-weight: 400; font-size: 1rem; } /* not the .field span label style */
.pw-wrap input { flex: 1; min-width: 0; }
.pw-eye { flex: none; font: 600 .85rem/1 var(--body); padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink-2); cursor: pointer; }
.pw-eye[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-dark); }
.profile-photo { display: flex; flex-direction: column; align-items: center; gap: 10px; border-left: 1px solid var(--line); padding-left: 32px; }
.profile-photo .btn { width: 100%; max-width: 260px; }
.profile-photo .small-print { margin: 0; text-align: center; }
.photo-frame { width: 150px; height: 150px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.photo-frame img.avatar { width: 150px; height: 150px; }
.photo-frame .avatar.letter { width: 100px; height: 100px; }
.photo-frame .avatar.letter span { font-size: 3rem; }
.profile-msg { grid-column: 1 / -1; margin: 0; }
.profile-msg:empty { display: none; }
.profile-ok { color: #1e6b34; font-weight: 600; }
#pf-error { color: #d92d20; font-weight: 600; } /* plain red, so "Type your original password…" stands out */
@media (max-width: 760px) {
  .contacts-grid { grid-template-columns: 1fr; }
  .profile-card { grid-template-columns: 1fr; padding: 18px 16px; }
  .profile-photo { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 18px; }
}

/* Classes: Code and Section (a school's several Algebra-I in one term) */
#class-add { max-width: 980px; flex: 1 1 640px; }
#class-add > .field:first-child { flex: 2 1 220px; }
.class-add .code-field { flex: 0 1 110px; }
.class-add .section-field { flex: 0 1 160px; }
.class-code, .class-section { min-width: 0; font: .95rem/1.3 var(--body); color: var(--ink-2); padding: 8px 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; }
.class-code { flex: 0 1 70px; }
.class-section { flex: 0 1 120px; }
.class-code::placeholder, .class-section::placeholder { color: var(--ink-3); opacity: .7; }
.class-code:hover, .class-section:hover { border-color: var(--line); }
.class-code:focus, .class-section:focus { border-color: var(--line); background: #fff; outline: 2px solid var(--accent); outline-offset: 1px; }
.class-list { max-width: 960px; }
@media (max-width: 760px) {
  .class-add .code-field, .class-add .section-field { flex: 1 1 auto; }
  .class-code { flex: 1 1 70px; margin-left: 2.6em; }
  .class-section { flex: 1 1 120px; }
}
