/* Themis global stylesheet: design tokens and component styles. */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #1c2333;
  --text-muted: #667085;
  --text-faint: #98a2b3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fd;
  --danger: #d92d20;
  --danger-strong: #b42318;
  --pass: #12b76a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.18);
}

* {
  box-sizing: border-box;
}

/*
 * What people write runs in its own direction, whatever the interface's: an
 * English name in a Hebrew page, or an Arabic one in an English page, is laid
 * out and aligned as it is written, whether typed into a field or shown as a
 * name, a critic's rules, or a row of a list.
 */
input,
textarea,
.item-name,
.attempt-name,
.critic-title,
.critic-summary,
.chip-name,
.rubric-task,
.account-name,
.group-member,
.membership > span:first-child,
.recipient-option label > span {
  unicode-bidi: plaintext;
}

/*
 * A name still sits at the start of its row, beside whatever marks it, rather
 * than at the start of its own direction, which would part them.
 */
:is(
  .item-name,
  .attempt-name,
  .critic-title,
  .chip-name,
  .rubric-task,
  .account-name,
  .group-member,
  .membership > span:first-child,
  .recipient-option label > span,
  .pane-title
):dir(rtl) {
  text-align: right;
}

/*
 * No word may push past its box, however long a language makes it (German and
 * Finnish compounds pass twenty letters): the interface's own words hyphenate
 * at their syllables, by the page's `lang`, and anything still too long breaks.
 */
body {
  margin: 0;
  font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  hyphens: auto;
}

/*
 * What people write is hyphenated only where they hyphenated it: it need not
 * be in the interface's language, whose rules `hyphens: auto` would apply, and
 * an essay under review must show nothing its writer did not write.
 */
input,
textarea,
.annotated,
.item-name,
.attempt-name,
.critic-title,
.critic-summary,
.chip-name,
.rubric-task,
.account-name,
.group-member,
.membership > span:first-child,
.recipient-option label > span {
  hyphens: manual;
}

/* ---- Layout ---- */

.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.app {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  gap: 24px;
  padding: 20px 28px 24px;
}

.essay-pane {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.pane-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Top bar ---- */

.top-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  padding-top: 4px;
}

.header-spacer {
  flex: 1 1 auto;
}

/*
 * On a phone, a long account name wraps rather than push the menus off: the
 * account menu alone gives way, as the rest of the bar never grows.
 */
.top-bar > .dropdown:has(> .account-name),
.top-bar .account-name {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* The way to the sidebar, on a screen too narrow to show it beside the essay. */
.menu-toggle {
  display: none;
  padding: 5px 10px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.dropdown {
  position: relative;
}

/* The button that opens a drop-down: unstyled until a menu gives it a look. */
.dropdown-toggle {
  font: inherit;
  cursor: pointer;
}

/* The flag of the language shown, opening the language menu. */
.language-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
}

.language-toggle:hover {
  border-color: var(--border-strong);
}

.flag {
  display: block;
  width: 21px;
  height: 14px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.15);
}

.account-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.account-name:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.account-caret {
  font-size: 10px;
}

/* A drop-down menu of choices, scrolling once it outgrows the window. */
.menu {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline-end: 0;
  z-index: 20;
  min-width: 160px;
  max-height: min(420px, max(160px, calc(100vh - 80px)));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  text-align: start;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.menu-item:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.menu-item-current {
  font-weight: 600;
  color: var(--accent);
}

/* ---- Pane header: the route's place and its actions ---- */

/* The name and deadline at the start, the actions at the end, the pages beneath. */
.pane-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 16px;
}

.pane-heading {
  grid-column: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* The name of the task or rubric, edited in place by whoever may. */
.pane-title {
  width: 100%;
  padding: 2px 0;
  font-family: inherit;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  outline: none;
  text-overflow: ellipsis;
}

.pane-title:not([readonly]):hover {
  border-bottom-color: var(--border);
}

.pane-title:not([readonly]):focus {
  border-bottom-color: var(--accent);
}

/* The pages within a task, for whoever may edit it. */
.route-tabs {
  grid-column: 1 / -1;
  justify-self: start;
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.route-tab {
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.route-tab:hover {
  color: var(--text);
}

.route-tab-current {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
}

.pane-actions {
  grid-column: 2;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Buttons ---- */

.btn {
  max-width: 100%;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease, transform 0.05s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  color: #ffffff;
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-ghost {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.btn-ghost:hover {
  background: #f9fafb;
  border-color: var(--text-faint);
}

/* ---- Essay editor ---- */

.editor {
  flex: 1 1 auto;
  padding: 20px 22px;
  font-size: 16px;
  line-height: 1.7;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  outline: none;
  resize: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.editor:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.editor::placeholder {
  color: var(--text-faint);
}

/* ---- Review pane ---- */

.review-pane {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.review-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.chip-toggle {
  cursor: pointer;
  user-select: none;
}

.chip-check {
  margin-block: 0;
  margin-inline: 0 7px;
  cursor: pointer;
}

.chip-hidden {
  opacity: 0.45;
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-inline-end: 7px;
}

.chip-name {
  font-weight: 600;
}

.chip-count {
  margin-inline-start: 6px;
  color: var(--text-muted);
}

.annotated {
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 2.2;
}

.annotation {
  cursor: help;
}

/* The band is rounded at its ends only, so its pieces read as one span. */
.annotation > span:first-of-type {
  border-start-start-radius: 3px;
  border-end-start-radius: 3px;
}

.annotation > span:last-of-type {
  border-start-end-radius: 3px;
  border-end-end-radius: 3px;
}

.annotation-original {
  /* Tints cover the band; underlines occupy one 2px lane each, so no layer
     may repeat. */
  background-repeat: no-repeat;
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}

.annotation-correction {
  font-size: 0.72em;
  font-weight: 500;
}

.correction-sep {
  color: var(--text-faint);
  font-weight: 400;
}

/* ---- Critics panel ---- */

.critics-panel {
  flex: 0 0 340px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-title {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.critics-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-inline-end: 2px;
}

.critic-card {
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
}

.critic-card:hover {
  box-shadow: var(--shadow-md);
}

.critic-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.critic-colour {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.critic-colour::-webkit-color-swatch-wrapper {
  padding: 0;
}

.critic-colour::-webkit-color-swatch {
  border: 1px solid rgba(16, 24, 40, 0.1);
  border-radius: 50%;
}

.critic-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  border: none;
  outline: none;
  background: transparent;
  border-radius: 4px;
}

/* The small icon buttons on a row: remove and nest. */
.item-remove,
.group-nest {
  border: none;
  padding: 4px 6px;
  color: var(--text-faint);
  font-size: 13px;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.item-remove:hover {
  color: var(--danger);
  background: #fef3f2;
}

.group-nest:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.critic-rules {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  font-family: inherit;
  color: var(--text-muted);
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.critic-rules:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}

.critic-rules::placeholder {
  color: var(--text-faint);
}

.add-item {
  margin-top: 10px;
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease,
    background-color 0.15s ease;
}

.add-item:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---- Tasks panel ---- */


/* ---- Lists of named items (tasks, attempts, rubrics, groups) ---- */

.item-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-inline-end: 2px;
}

/* A selectable row and a group card share one look. */
.item-row,
.group-card {
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.item-row:hover,
.group-card:hover {
  box-shadow: var(--shadow-md);
}

.item-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-block: 8px;
  padding-inline: 12px 6px;
  cursor: pointer;
}

.item-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.item-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-empty {
  margin: 0;
  padding: 4px 2px;
  font-size: 13px;
  color: var(--text-faint);
}

/* ---- Attempts ---- */

.tasks-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.task-entry {
  margin-bottom: 8px;
}

.task-entry > .item-row {
  margin-bottom: 0;
}

.task-work {
  margin-block: 6px 4px;
  margin-inline: 10px 0;
  padding-inline-start: 10px;
  border-inline-start: 2px solid var(--border);
}

.task-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 8px;
}

.task-section .panel-title {
  margin-bottom: 6px;
  font-size: 11px;
}

.task-section .item-row {
  margin-bottom: 6px;
  padding-block: 6px;
  padding-inline: 10px 4px;
}

.task-section .attempt-name {
  font-size: 13px;
}

.task-section .add-item {
  margin-top: 2px;
  padding: 7px;
  font-size: 13px;
}

.task-list {
  flex: 0 1 auto;
  max-height: 240px;
}

.attempt-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attempt-grade {
  flex: 0 0 auto;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
}

.attempt-pass {
  background: var(--pass);
}

.attempt-fail {
  background: var(--danger);
}

.submission-summary {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.submission-date {
  font-size: 12px;
  color: var(--text-faint);
}

.submission-evaluated {
  background: var(--text-muted);
}

.grade-partial {
  opacity: 0.75;
}

.submission-final {
  flex: 0 0 auto;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---- Assignment ---- */

.assigned-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.assigned-badge {
  flex: 0 0 auto;
  font-size: 9px;
  line-height: 1;
  color: var(--accent);
}

.recipient-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-block: 5px;
  padding-inline: 10px 12px;
  font-size: 13px;
  color: var(--text);
}

.recipient-option:hover {
  background: var(--accent-soft);
}

.recipient-option label,
.recipient-option label > span {
  min-width: 0;
}

.recipient-option label {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.recipient-section {
  padding-block: 6px 2px;
  padding-inline: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

/* ---- Grading ---- */

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 8px;
  margin-bottom: 12px;
}

.panel-header .panel-title {
  min-width: 0;
  margin: 0;
}

.grading-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.grading-toggle input {
  accent-color: var(--accent);
  cursor: pointer;
}

.weight-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.weight-total-invalid {
  color: var(--danger);
  border-color: var(--danger);
}

.critic-grading {
  margin-top: 10px;
}

.critic-weight {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.weight-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.weight-slider {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.weight-input {
  width: 64px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
  text-align: end;
  color: var(--text);
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.weight-input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}

.weight-unit {
  font-size: 13px;
  color: var(--text-faint);
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: #ffffff;
  background: var(--accent);
}

.grade-badge.grade-pass {
  background: var(--pass);
}

.grade-badge.grade-fail {
  background: var(--danger);
}

.grade-score {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.grade-max {
  opacity: 0.75;
}

.grade-outcome {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.22);
}

.grade-scale {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 6px 12px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.scale-field {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 0;
  min-width: 0;
}

.scale-input {
  width: 100%;
  min-width: 0;
  margin-inline-start: 0;
}

.grade-label {
  font-weight: 500;
  opacity: 0.85;
}

.grade-value {
  font-weight: 700;
}

.chip-grade {
  margin-inline-start: 6px;
  font-weight: 700;
}

/* ---- Sign-in ---- */

.app-root {
  height: 100%;
}

.sign-in-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

/* The language menu, at the top end of the sign-in screen. */
.sign-in-language {
  position: absolute;
  top: 12px;
  inset-inline-end: 16px;
}

.sign-in-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 360px;
  padding: 28px 30px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.sign-in-card .app-title {
  margin-bottom: 2px;
}

.sign-in-card .app-subtitle {
  padding: 0 0 18px 0;
}

.sign-in-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.sign-in-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sign-in-input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}

.sign-in-error {
  min-height: 18px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--danger);
}

.sign-in-submit {
  width: 100%;
}

.sign-in-toggle {
  margin-top: 12px;
  padding: 4px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

.sign-in-toggle:hover {
  color: var(--accent);
}

/* ---- Groups panel ---- */

.groups-panel {
  flex: 1 1 auto;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.groups-error {
  min-height: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--danger);
}

.groups-error:not(:empty) {
  min-height: 18px;
  margin-bottom: 8px;
}

.group-card {
  padding: 10px 12px;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 4px;
}

.group-nest {
  padding: 4px 7px;
  font-size: 14px;
}

.group-members {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 7px 0;
}

.group-member {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-block: 2px;
  padding-inline: 9px 4px;
  font-size: 12px;
  background: var(--accent-soft);
  border-radius: 999px;
}

.group-member-remove {
  padding: 0 3px;
  font-size: 10px;
  color: var(--text-faint);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.group-member-remove:hover {
  color: var(--danger);
}

.group-enrol {
  width: 100%;
  padding: 5px 9px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.group-enrol:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}

.group-enrol::placeholder {
  color: var(--text-faint);
}

.group-members .list-empty {
  padding: 0;
}

/* Members reached only through subgroups: read-only, so outlined. */
.group-reached {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin: 0 0 7px;
}

.group-reached-label {
  width: 100%;
  font-size: 11px;
  color: var(--text-faint);
}

.group-member-indirect {
  padding-inline-end: 9px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ---- Group sections: invitations, groups you manage, memberships ---- */

.group-section,
.group-section + .groups-managed {
  margin-top: 18px;
}

.group-section .panel-title,
.groups-managed .panel-title {
  margin-bottom: 8px;
}

.membership {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 6px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.membership-action {
  padding: 2px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.membership-action:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.membership .membership-action + .membership-action {
  margin-inline-start: 4px;
}

.membership-from {
  color: var(--text-faint);
}

/* An invitee is not a member yet: greyed, in outline rather than filled. */
.group-member-pending {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-faint);
}

/* ---- Scrollbars ---- */

.critics-list::-webkit-scrollbar,
.item-list::-webkit-scrollbar,
.review-pane::-webkit-scrollbar {
  width: 8px;
}

.critics-list::-webkit-scrollbar-thumb,
.item-list::-webkit-scrollbar-thumb,
.review-pane::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.critics-list::-webkit-scrollbar-thumb:hover,
.item-list::-webkit-scrollbar-thumb:hover,
.review-pane::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* ---- Confirmation dialog (ConfirmDialog) ---- */

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 24, 40, 0.35);
}

.confirm-dialog {
  width: min(420px, calc(100vw - 48px));
  padding: 20px 22px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.confirm-subject {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.confirm-consequence {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-danger {
  color: #ffffff;
  background: var(--danger);
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  background: var(--danger-strong, #b42318);
}

/* ---- Side panel ---- */

/*
 * The side columns keep their width whatever they hold: without `min-width: 0`
 * a flex item grows to its longest unbroken text, so one long name or word
 * would widen the column and crush the essay between them.
 */
.side-panel {
  flex: 0 0 240px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 18px;
}

.side-panel > .tasks-panel {
  flex: 1 1 auto;
}

.rubrics-panel {
  flex: 0 0 auto;
  max-height: 45%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.rubric-uses {
  flex: 0 0 auto;
  min-width: 20px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* ---- Rubric selection ---- */

.rubric-picker {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}

.rubric-picker:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

/* ---- Rubric page ---- */

.rubric-page {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px;
}

.scaling-editor {
  margin-bottom: 12px;
}

.scaling-note {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.rubric-unavailable {
  font-size: 12px;
  color: var(--text-muted);
}

/* Beside an essay: the rubric its task is marked against. */
.rubric-name {
  margin: -6px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.pane-status {
  margin: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.pane-status p {
  margin: 0 0 12px;
}

.rubric-note {
  max-width: 620px;
  margin: 10px 0 28px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

.rubric-subtitle {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.rubric-tasks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rubric-task {
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.rubric-task:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.rubric-empty {
  margin: 0;
  font-size: 13px;
  color: var(--text-faint);
}

/* ---- Critics read rather than configured ---- */

.critic-compact {
  padding: 10px 12px;
}

.critic-compact:hover {
  box-shadow: var(--shadow-sm);
}

.critic-compact .critic-header {
  margin-bottom: 4px;
}

.critic-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.critic-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.critic-weight-note {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-muted);
}

.critic-summary {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.critic-summary:empty {
  display: none;
}

/* Beside an essay the rules are cut short; the whole is a hover away. */
.critic-brief .critic-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

.critic-brief .critic-summary:empty {
  display: none;
}

/* ---- Sign-in hints ---- */

.sign-in-hint {
  margin: -8px 0 12px 0;
  font-size: 12px;
  color: var(--text-faint);
}

.sign-in-hint:empty {
  display: none;
}

.sign-in-warning {
  color: var(--danger);
}

.sign-in-links {
  display: flex;
  justify-content: space-between;
}

/* ---- Account page ---- */

.account-pane {
  max-width: 520px;
  overflow-y: auto;
}

.account-who {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: var(--text-muted);
}

.section {
  margin-bottom: 24px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.section-text {
  margin: 0 0 12px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.account-warning {
  color: var(--danger);
  font-weight: 600;
}

.account-notice {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--pass);
}

/* Recovery codes, shown once: monospaced, in two columns, easy to copy. */
.account-codes {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 6px 24px;
  margin: 0 0 16px 0;
  padding: 12px 16px;
  list-style: none;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 14px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  user-select: all;
}

/* ---- Routes ---- */

.route-link {
  margin-top: 8px;
}

.invitation-count {
  margin-inline-start: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.submissions-pane,
.settings-pane {
  max-width: 720px;
  overflow-y: auto;
}

.submission-row {
  margin-bottom: 8px;
}

.submission-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 8px 8px;
}

/* Sharing: who holds access to a task or rubric. */

.sharing-panel .recipient-list {
  margin-top: 8px;
}

.sharing-level {
  margin-inline-start: auto;
  font: inherit;
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.sharing-others {
  margin-top: 8px;
}

.sharing-other {
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.sharing-error {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--danger);
  min-height: 1em;
}

/* The roster: who a task is set for, and whether they have submitted. */

.roster-row {
  cursor: default;
  justify-content: space-between;
}

.roster-submitted {
  cursor: pointer;
}

.roster-status {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.roster-late .roster-status {
  color: var(--danger);
}

/* Anchors: essays of known grade, edited in the task's settings. */

.anchor-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.anchor-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.anchor-essay {
  flex: 1;
  min-height: 72px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}

.anchor-essay:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.anchor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* The due date, in the header and in the settings. */

.due-note {
  font-size: 12px;
  color: var(--text-muted);
}

.due-input {
  width: auto;
  min-width: 190px;
}

/* Tabs: one concern of a page at a time. */

/* Tabs wrap onto another row rather than widen the page in a wordy language. */
.tab-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab-current {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* The final-grade controls sit in the row as if unwrapped, until hidden. */
.final-grade {
  display: contents;
}

/* One way of handling a task's work, chosen among several. */
.work-choice {
  display: flex;
  margin-bottom: 8px;
}

/* A lone numeric field beside a label, sized to its digits. */

.scale-field-single {
  flex: 0 1 auto;
}

.scale-field-single .scale-input {
  width: 5.5em;
}

.scale-field-single .due-input {
  width: auto;
}

/* The head of a submission on display: who wrote it, and its evaluations. */

.submission-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.submission-heading {
  flex: 1 0 100%;
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.evaluation-chip {
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
}

.evaluation-chip:hover {
  color: var(--text);
}

.evaluation-current {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---- Middling screens: the columns draw in before they stack ---- */

@media (max-width: 1200px) {
  .app {
    gap: 16px;
    padding: 16px 18px 20px;
  }

  .pane-title {
    font-size: 19px;
  }

  .side-panel {
    flex-basis: 210px;
  }

  .critics-panel {
    flex-basis: 290px;
  }
}

/* ---- Narrow screens ---- */

/* The drawer's backdrop, which exists only while the drawer is open. */
.side-scrim {
  display: none;
}

@media (max-width: 960px) {
  .app-shell {
    overflow-y: auto;
  }

  .top-bar {
    position: sticky;
    top: 0;
    z-index: 25;
    padding: 8px 14px;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .app {
    flex: 0 0 auto;
    flex-direction: column;
    gap: 20px;
    padding: 14px 14px 28px;
  }

  .side-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 35;
    width: min(300px, 85vw);
    padding: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  /* A right-to-left page keeps the drawer off its right edge instead. */
  .side-panel:dir(rtl):not(.side-open) {
    transform: translateX(100%);
  }

  .side-panel.side-open {
    transform: none;
  }

  .side-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 34;
    background: rgba(16, 24, 40, 0.35);
  }

  .side-panel > .tasks-panel,
  .rubrics-panel {
    flex: 0 0 auto;
    max-height: none;
  }

  .item-list,
  .task-list,
  .critics-list {
    max-height: none;
    overflow: visible;
  }

  .essay-pane,
  .pane-body,
  .critics-panel {
    flex: 0 0 auto;
  }

  .editor {
    min-height: 55vh;
  }

  .review-pane,
  .rubric-page,
  .submissions-pane,
  .settings-pane,
  .account-pane,
  .groups-panel {
    max-width: none;
    overflow: visible;
  }

  .pane-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .pane-actions {
    grid-column: 1;
    justify-self: stretch;
  }

  .route-tabs {
    width: 100%;
  }

  .route-tab {
    flex: 1 1 0;
    text-align: center;
  }

  .pane-actions {
    flex-wrap: wrap;
  }

  .pane-actions .btn {
    flex: 1 1 auto;
  }

  .grade-scale,
  .anchor-row,
  .roster-row {
    flex-wrap: wrap;
  }

  .anchor-essay {
    flex: 1 1 100%;
  }

  .account-codes {
    grid-template-columns: 1fr;
  }

  .confirm-dialog {
    width: calc(100vw - 32px);
  }
}
