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

/* The face scanned pages are written over in (vendor/caveat/README.md),
   fetched only once a page asks for it. */
@font-face {
  font-family: "Caveat";
  src: url("/assets/vendor/caveat/Caveat.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --hand: "Caveat", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  --bg: #f4f5f9;
  --surface: #ffffff;
  /* The sidebar, halfway between the page and the top bar. */
  --sidebar: #f9fafc;
  --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;
  --merit: #12b76a;
  --fault: #d92d20;
  --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);
  --picked: rgba(79, 70, 229, 0.22);
  --typed: #0e7490;
  --tooltip-typed: #67e8f9;
  --tooltip-bg: #1c2333;
  --tooltip-text: #eef1f7;
  --tooltip-muted: #a3adc2;
  --tooltip-rule: rgba(255, 255, 255, 0.12);
  /* The ruled paper an essay is written on; its grain is faint mottling under
     a fine speckle. */
  --paper: #fffdf7;
  --paper-rule: #c9d8ec;
  --paper-margin: #e59a9a;
  --paper-grain: url("data:image/svg+xml,\
%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E\
%3Cfilter id='m'%3E\
%3CfeTurbulence type='fractalNoise' baseFrequency='0.02' numOctaves='3' stitchTiles='stitch'/%3E\
%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.38 0 0 0 0 0.25 0.12 0 0 0 -0.045'/%3E\
%3C/filter%3E\
%3Cfilter id='f'%3E\
%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E\
%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.38 0 0 0 0 0.25 0.3 0 0 0 -0.1'/%3E\
%3C/filter%3E\
%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E\
%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E\
%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

/* User-written text takes its own direction; a new class showing a name joins
   this list. */
input,
textarea,
.item-name,
.draft-name,
.critic-title,
.critic-summary,
.chip-name,
.group-member,
.membership > span:first-child,
.preset-name,
.preset-brief,
.preset-read,
.criterion-read-text {
  unicode-bidi: plaintext;
}

/* A name stays at its row's start, beside its marks: `right`, as `start`
   would follow the name's own direction. */
:is(
  .item-name,
  .draft-name,
  .critic-title,
  .chip-name,
  .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: the interface's words hyphenate 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;
}

/* User-written text hyphenates only where its author did, as it need not be
   in the interface's language. */
input,
textarea,
.item-name,
.draft-name,
.critic-title,
.critic-summary,
.chip-name,
.group-member,
.membership > span:first-child {
  hyphens: manual;
}

/* Ticks and choices line up with the text beneath them, unindented. */
:where(input[type='checkbox'], input[type='radio']) {
  margin-inline-start: 0;
}

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

/* The page is the window's height, its columns scrolling each on its own. A
   percentage, unlike `vh`, follows a phone's toolbars and its page zoom. */
html,
body,
#root {
  height: 100%;
}

#root {
  position: relative;
}

/* Nothing scrolls sideways: whatever cannot fit is cut off instead. */
.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

/* A column at the window's side (the sidebar or the critics panel), reaching
   over `.app`'s padding to the window's edges. Its width is the dragged
   `--side-width` (set by `PanelEdge`), from its least content's
   (`--side-least`) to half the window; a window narrowed after a drag narrows
   it, down to its least width. */
.side-column {
  --side-pad-inner: 20px;
  --side-min: calc(
    var(--side-least) + var(--app-pad-inline) + var(--side-pad-inner) + 1px
  );
  position: relative;
  flex: 0 1 clamp(var(--side-min), var(--side-width, 0px), 50vw);
  min-width: var(--side-min);
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-block: calc(-1 * var(--app-pad-top)) calc(-1 * var(--app-pad-bottom));
  padding-block: var(--app-pad-top) var(--app-pad-bottom);
  background: var(--sidebar);
}

.panel-edge-start {
  inset-inline-start: -5px;
}

.panel-edge-end {
  inset-inline-end: -5px;
}

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

/* Positioned over the page, as the bell's list and the banners hang from it. */
.top-bar {
  position: relative;
  z-index: 25;
  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 the account's name gives way first, cut short on one line, and
   the title last, so that the bar has no width it cannot shrink below. */
/* Room for the caret and an ellipsis at least. */
.top-bar > .lc-menu:has(> .account-name) {
  flex-shrink: 1000;
  min-width: 44px;
}

.top-bar .account-name {
  max-width: 100%;
}

.app-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

/*
 * Megalingual's language pickers, in the app's colours. The interface's toggle
 * is a bare flag, bordered on hover, its popup opening towards the start, as
 * it sits at the end of the bar.
 */
:root {
  --megalingual-text: var(--text);
  --megalingual-surface: var(--surface);
  --megalingual-border: var(--border);
  --megalingual-accent: var(--accent);
  --megalingual-active: var(--accent-soft);
  --megalingual-radius: var(--radius-sm);
  --megalingual-shadow: var(--shadow-md);
}

.item-row .written-in .flag {
  width: 16px;
  height: 11px;
}

/* A name before a guest's tag stops stretching and the tag takes the room,
   keeping the row's end in place. */
:is(.item-name, .draft-name):has(+ .guest-tag) {
  flex-grow: 0;
}

:is(.item-name, .draft-name) + .guest-tag {
  margin-inline-end: auto;
}

@keyframes notice-arrive {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ---- Pane header ---- */

/* Where `field-sizing` works, the field is as wide as its name, so that the
   pencil sits beside it. */
.name-field {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.name-field > input {
  flex: 0 1 auto;
  min-width: 3ch;
  field-sizing: content;
  padding: 2px 0;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  outline: none;
  text-overflow: ellipsis;
}

@supports not (field-sizing: content) {
  .name-field > input {
    flex-grow: 1;
  }
}

.name-field > input:not([readonly]):hover {
  border-bottom-color: var(--border);
}

.name-field > input:not([readonly]):focus {
  border-bottom-color: var(--accent);
}

.name-field > .icon {
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  cursor: text;
}

.name-field:hover > .icon,
.name-field:focus-within > .icon {
  color: var(--accent);
}

.pane-title {
  font-size: 22px;
  font-weight: 700;
}

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

/* A transparent border keeps every kind of button the same height. */
.btn {
  max-width: 100%;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  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-ghost {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

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

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

/* ---- Fields ---- */

/* A field in focus is ringed in the accent. */
.critic-rules:focus,
.sign-in-input:focus,
.group-enrol:focus,
.setting-select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* A field tinted until focused turns white. */
.critic-rules:focus,
.sign-in-input:focus,
.group-enrol:focus {
  background: var(--surface);
}

/* A control that is not a field is ringed alone, when reached by keyboard. */
.preset-row:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

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

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

.feedback-pane {
  padding-inline: var(--paper-edges);
}

.feedback-pane {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden auto;
  padding-block: 20px;
}

.feedback-overview-title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

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

/* A long name wraps; the count and marks after it never do. */
.chip-name {
  min-width: 0;
  font-weight: 600;
}

/* Paper's rules beneath a drawn essay, one under each line wherever its
   corrections pushed it (`--paper-rules`, set by AnnotatedEssay.rule). A
   border image, as it is drawn behind the text and tints yet reaches past the
   box to the sheet's edges without taking room or adding to the scroll. */
:is(.feedback-pane, .essay-marked) .annotated {
  border: 0 solid;
  border-image-source: var(--paper-rules, none);
  border-image-slice: 0 fill;
  border-image-width: 0;
  border-image-outset: 0 var(--paper-gutter) 100vh var(--paper-indent);
}

:is(.feedback-pane, .essay-marked) .annotated:dir(rtl) {
  border-image-outset: 0 var(--paper-indent) 100vh var(--paper-gutter);
}

@keyframes essay-caret {
  50% {
    opacity: 0;
  }
}

.annotation {
  cursor: help;
}

/* Only the band's ends are rounded. The vertical radii add the reach, so that
   the painted text keeps a 3px radius. */
.annotation > span:first-of-type {
  border-start-start-radius: 3px calc(3px + var(--reach-above));
  border-end-start-radius: 3px calc(3px + var(--reach-below));
}

.annotation > span:last-of-type {
  border-start-end-radius: 3px calc(3px + var(--reach-above));
  border-end-end-radius: 3px calc(3px + var(--reach-below));
}

/* Text typed since the essay was read in from a scan or a document, as in a
   pen of its own. Inside a struck original, the strike is the original's. */
.essay-typed {
  color: var(--typed);
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--typed);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
}

/* The place words are to move to: a wider space, tinted and underlined in
   their critic's colour; an empty inline, so that it wraps with the text
   beside it. */
/* ---- Critics panel ---- */

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

.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;
}

.item-remove,
.item-edit,
.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;
}

.item-edit:hover,
.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;
}

.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);
}

.item-edit {
  display: inline-flex;
  align-items: center;
}

.item-edit .icon {
  width: 14px;
  height: 14px;
}

/* ---- Lists of named items ---- */

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

.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);
}

/* A row's ends are equally inset; a trailing icon button insets its glyph. */
.item-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-block: 8px;
  padding-inline: 12px;
  cursor: pointer;
}

.item-row > :is(.item-remove, .item-edit):last-child {
  margin-inline-end: -6px;
}

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

.item-name,
.draft-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;
}

.standing-practice {
  color: var(--text-muted);
  background: var(--bg);
}

.standing-due {
  color: var(--accent);
  background: var(--accent-soft);
}

.standing-overdue,
.standing-missed {
  color: var(--danger);
  background: rgba(217, 45, 32, 0.1);
}

.standing-handed-in {
  color: #067647;
  background: rgba(18, 183, 106, 0.12);
}

.standing-late {
  color: #b54708;
  background: #fef0c7;
}

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

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

/* The badges beside a draft or a submission. */
.draft-grade {
  flex: 0 0 auto;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.draft-grade {
  color: #ffffff;
}

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

.grade-max {
  opacity: 0.75;
}

.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);
}

/* A long choice is cut short rather than overflowing the row. */
.grade-scale > .language-picker {
  min-width: 0;
}

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

.scale-field > .lc-number-input {
  width: calc(5.5em + var(--lc-number-steps));
}

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

.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-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 0;
  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;
}

/* Renamed in place, so it reads as a name until hovered or focused. */
.group-header > input.item-name {
  padding: 2px 0;
  font-family: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  outline: none;
}

.group-header > input.item-name:hover {
  border-bottom-color: var(--border);
}

.group-header > input.item-name:focus {
  border-bottom-color: var(--accent);
}

.group-header > .item-remove:last-child {
  margin-inline-end: -6px;
}

.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-members .list-empty {
  padding: 0;
}

.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 ---- */

.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-action[aria-pressed='true'] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

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

/* Spaced on both sides: on a right-to-left page, a Latin name puts this note
   on its right. */
.membership-from {
  margin-inline: 8px;
  color: var(--text-faint);
}

/* The groups enclosing a membership, before its name: Year 9 › 8A. The
   chevron is mirrored on a right-to-left page by the browser itself. */
.membership-enclosing {
  color: var(--text-muted);
}

.membership-enclosing::after {
  content: ' › ';
}

.membership-joined {
  flex-wrap: wrap;
}

.membership-joined > span:first-child {
  flex: 1 1 0;
  min-width: 0;
}

.membership-members {
  display: flex;
  flex-wrap: wrap;
  flex-basis: 100%;
  gap: 5px;
}

.membership-members .group-member {
  padding-inline-end: 9px;
}

.group-member-pending {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-faint);
}

.group-member-admit {
  padding: 0 3px;
  font-size: 11px;
  color: var(--pass);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.group-member-admit:hover {
  color: var(--text);
}

/* A card's parts beneath its members, each under a rule and a small heading.
   Its managers are a sharing section, without the box it has on a page. */
.group-part {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-part,
.group-card > .sharing-panel {
  margin: 10px 0 0;
  padding: 10px 0 0;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.group-part-title,
.group-card > .sharing-panel > .panel-title {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.group-card > .sharing-panel > .panel-title {
  margin-bottom: 8px;
}

.group-part-note,
.group-card > .sharing-panel > .section-text {
  font-size: 12px;
  color: var(--text-faint);
}

.group-part-note {
  margin: 2px 0 0;
}

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

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

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

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

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

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

/* ---- Read-in work, shared by the importer, essay origins and hand-ins ---- */

.scanner-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.origin-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.origin-note > span {
  min-width: 0;
}

.origin-note .icon {
  width: 16px;
  height: 16px;
}

.btn-active {
  background: var(--accent-soft);
}

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

/* ---- Choices in a task's settings ---- */

.setting-select {
  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;
}

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

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

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

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

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

.critic-compact {
  padding: 4px 6px 4px 10px;
  margin-bottom: 6px;
}

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

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

/* The controls ending the row keep clear of the name, which toggles. */
.critic-compact .critic-peek-toggle {
  margin-inline-end: 8px;
}

/* The row's name, which shows or hides the description and criteria. */
.critic-peek-toggle {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 28px;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: start;
  background: transparent;
  border: none;
  cursor: pointer;
}

.critic-peek-caret {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-inline-start: -4px;
  color: var(--text-muted);
  border-radius: 6px;
  transition: transform 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.critic-peek-caret .icon {
  width: 18px;
  height: 18px;
}

.critic-peek-toggle:hover .critic-peek-caret {
  color: var(--accent);
  background: var(--accent-soft);
}

.critic-peek-toggle[aria-expanded="true"] .critic-peek-caret {
  transform: rotate(180deg);
}

.critic-peek {
  padding: 2px 0 6px;
}

.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-summary {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* After the rule above, so that it wins over it while empty. */
.critic-summary:empty {
  display: none;
}

.sign-in-links {
  display: flex;
  flex-wrap: wrap;
  column-gap: 12px;
}

/* The first link's end margin, not the second's start, pushes them apart: wrapped,
   each line keeps its link at the start, rather than the second moving to the end. */
.sign-in-links > .sign-in-toggle:first-child {
  margin-inline-end: auto;
}

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

.account-pane {
  max-width: 520px;
  overflow: hidden 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);
}

/* Only padding below the last content: no empty note, no trailing margin. */
.section > :is(p, div, span):empty {
  margin-block: 0;
}

.section > :nth-last-child(1 of :not(:is(p, div, span):empty)) {
  margin-bottom: 0;
}

.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);
}

.allowance-meter {
  height: 8px;
  margin: 0 0 8px 0;
  overflow: hidden;
  background: var(--accent-soft);
  border-radius: 999px;
}

.allowance-spent {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.allowance-out .allowance-spent {
  background: var(--danger);
}

.account-pending {
  margin: 0 0 16px 0;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius);
}

.account-pending .section-text {
  margin-bottom: 8px;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.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;
}

/* A fieldset grows to its content's width by default; this one draws nothing
   and never does. */
.frozen-fields {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: none;
}

/* The language picker is a button of its own, so dims as the fields do. */
.frozen-fields:disabled .language-picker {
  opacity: 0.7;
  cursor: default;
}

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

.preset-tree {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.preset-children {
  padding-inline-start: 14px;
  border-inline-start: 1px solid var(--border);
  margin-inline-start: 7px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  text-align: start;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.preset-row:hover {
  background: var(--accent-soft);
}

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

.preset-name {
  min-width: 0;
  font-weight: 500;
}

.preset-folder > .preset-name {
  font-weight: 600;
}

.preset-brief {
  flex: 1 1 100%;
  min-width: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.preset-caret {
  display: inline-block;
  width: 10px;
  color: var(--text-faint);
  transition: transform 0.12s ease;
}

.preset-row[aria-expanded="true"] > .preset-caret {
  transform: rotate(90deg);
}

.preset-row[aria-expanded="false"] > .preset-caret:dir(rtl) {
  transform: scaleX(-1);
}

/* A row of the drop-down adding a critic, which opens to say more, and the
   button ending it, which alone adds its critic. */
.preset-pick {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}

.preset-pick > .preset-row {
  flex: 1 1 auto;
  width: auto;
}

/* Folded, a description shows one line. */
.preset-pick > .preset-row:not(.preset-open) > .preset-brief {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.preset-pick .preset-brief:empty {
  display: none;
}

.preset-pick > .preset-row > .critic-dot {
  align-self: center;
}

.preset-add {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-block-start: 1px;
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease,
    border-color 0.15s ease;
}

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

.preset-add[aria-disabled='true'] {
  color: var(--text-faint);
  background: transparent;
  border-color: transparent;
  cursor: default;
}

.preset-add .icon {
  width: 16px;
  height: 16px;
}

.preset-read {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preset-read-name {
  margin: 0;
  font-size: 18px;
}

.preset-read-brief {
  margin: 0;
  color: var(--text-muted);
}

/* ---- Middling screens ---- */

@media (max-width: 1200px) {
  .pane-title {
    font-size: 19px;
  }

}

@media (max-width: 960px) {
  /* The page scrolls as a whole, the browser's own way: a phone's Safari
     leaves dead space beneath a box of the window's height whenever it zooms
     the page out or its keyboard has been open. */
  html,
  body,
  #root,
  .app-shell {
    height: auto;
  }

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

  .top-bar > .language-toggle {
    flex-shrink: 0;
  }

  /* The language list spans the bar, as its toggle sits too far in to hang from. */
  .top-bar > .language-toggle {
    position: static;
  }

  .top-bar > .language-toggle .megalingual-popup {
    inset-inline: 14px;
    width: auto;
    min-width: 0;
  }

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

  .feedback-pane,
  .account-pane,
  .groups-panel {
    max-width: none;
    overflow: visible;
  }

  .grade-scale {
    flex-wrap: wrap;
  }

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

}

/* A phone's Safari zooms in on any tapped field of smaller type, and stays
   zoomed. `#root` outranks every field's own size but the two larger
   titles'. */
@media (max-width: 960px) and (pointer: coarse) {
  #root :is(input, textarea, select):not(
      .pane-title,
      .calibration-name-field > input,
      [type='checkbox'],
      [type='radio'],
      [type='range']
    ) {
    font-size: 16px;
  }
}

/* ---- Phones ---- */

@media (max-width: 400px) {
  .top-bar {
    gap: 6px;
    padding-inline: 10px;
  }

  .critic-card {
    padding: 12px;
  }
}

.group-share.group-shared {
  color: var(--accent);
}

.model-only-note {
  margin: 0;
  font-size: 12px;
  font-style: italic;
  color: var(--text-faint);
}

/* A criterion read, and the same criterion with its marks in the feedback. */
.criterion-read-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
}

.criterion-read-row .criterion-icon {
  margin-block-start: 1px;
}

.criterion-read-text {
  flex: 1 1 auto;
  min-width: 0;
}

.criterion-bands {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0 0;
  padding-inline-start: 22px;
  list-style: none;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.criterion-band {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.criterion-band > span:last-child {
  min-width: 0;
}

.criterion-band-marks {
  flex: none;
  min-width: 3.2em;
  font-weight: 600;
}

/* ---- Calibration, a page of its own ---- */

.calibration-note {
  max-width: 640px;
  margin: 40px auto;
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
}

.calibration-problem {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-block-end: 16px;
  padding: 10px 14px;
  color: var(--danger-strong);
  background: #fef3f2;
  border-radius: var(--radius-sm);
}

.calibration-guidance {
  margin-block-end: 16px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.calibration-guidance > summary {
  font-weight: 600;
  cursor: pointer;
}

.calibration-heading {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.calibration-essay {
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  hyphens: manual;
}

/* ---- Calibration data ---- */

.calibration-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.calibration-title {
  margin: 0;
  font-size: 22px;
}

.calibration-view .calibration-guidance {
  margin: 0;
}

.calibration-model-row > span {
  font-size: 14px;
}

.calibration-model-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.calibration-select {
  max-width: 100%;
  padding: 7px 10px;
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

