/* Papertrail - Core Styles */

/* Roboto, Roboto Serif and Roboto Mono, served from our own origin (fonts/,
   written by `npm run vendor`): Google Fonts saw every visitor's IP address. */
@import url('fonts/fonts.css');

/* CSS Variables */
:root {
  /* Colors - Warm Terracotta Theme */
  --color-primary: #c86a4a;
  --color-primary-hover: #b35a3a;
  --color-primary-light: #f5e6e0;

  --color-secondary: #8b7355;
  --color-secondary-hover: #735f45;

  --color-success: #6b9b6e;
  --color-warning: #d4934a;
  --color-error: #c85a4a;

  --color-bg: #faf8f6;
  --color-surface: #ffffff;
  --color-border: #e8dfd8;

  --color-text: #3b2f2a;
  --color-text-muted: #8b7355;
  --color-text-light: #a89884;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;

  /* Typography */
  --font-family: 'Roboto', sans-serif;
  --font-family-heading: 'Roboto Serif', serif;
  --font-family-mono: 'Roboto Mono', monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
}

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Keep the scrollbar's width reserved whether or not the page scrolls.
     .container is centred with `margin: 0 auto`, so on a system with classic
     scrollbars a short page and a long one centre against viewports 15px apart
     — and every card on the page steps 7.5px sideways when a teacher opens an
     assignment. `overflow-y: scroll` is the part every browser has honoured for
     years; `scrollbar-gutter` is the modern spelling, and reserves nothing on
     the overlay scrollbars where there is nothing to reserve. */
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
}

/* Accessibility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Layout */
#app {
  min-height: 100vh;
}

.view {
  min-height: 100vh;
}

.view[hidden] {
  display: none;
}

.container {
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: 600;
  line-height: 1.25;
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* A description is typed into a textarea, so the teacher's line breaks and
   indentation are part of what they wrote — a paragraph, then a list of
   requirements, then the deadline. HTML collapses every run of whitespace to a
   single space, so all of that arrived as one wall of text the moment the
   assignment was saved. pre-wrap keeps the breaks and still wraps long lines to
   the width of the card. tab-size: 4 because the browser default is 8, which
   indents a nested bullet a third of the way across a narrow card. */
.assignment-desc {
  white-space: pre-wrap;
  tab-size: 4;
}

/* A link inside an assignment description is surrounded by prose, so colour
   alone is not enough to tell it apart — it carries an underline at rest.
   Wrapped anywhere, because a pasted URL is often longer than the card. */
.desc-link {
  text-decoration: underline;
  overflow-wrap: anywhere;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: 500;
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  color: white;
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  color: var(--color-secondary);
  background-color: var(--color-surface);
  border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  color: var(--color-secondary-hover);
  background-color: var(--color-bg);
}

/* A quiet alternative under a stronger button ("Use a different email",
   "Log in with another school"): no border or fill until it is pointed at.
   Without this rule the class fell through to the browser's grey button. */
.btn-ghost {
  color: var(--color-text-muted);
  background-color: transparent;
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--color-text);
  background-color: var(--color-bg);
}

.btn-danger {
  color: white;
  background-color: var(--color-error, #dc2626);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.88);
}

.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.8125rem;
  white-space: nowrap;
  min-height: 28px;
}

.btn-loading[hidden] {
  display: none;
}

/* Forms */
.form-group {
  margin-bottom: var(--spacing-lg);
}

/* Every group is the same distance apart, but the same distance from *what* is
   not: a field ends at a crisp border, a line of hint text ends at the bottom
   of its line box, ~5px below the last visible letter. So a group that ends in
   text reads ~5px further from the next label than one that ends in a control,
   though both margins are identical. Pull that leading back.

   Only groups whose last *visible* child is text — `:last-child` is not enough,
   because a group can carry a hint that is hidden most of the time and would
   take the rule with it. That is also why such a hint must use the hidden
   attribute rather than an inline display:none: CSS can test the first and not
   the second. */
.form-group > .form-hint:not(:has(~ :not([hidden]))),
.form-group > .checkbox-with-hint:last-child {
  margin-bottom: -5px;
}

/* Pinned to the top-right of its field, level with the label, rather than
   sitting under the input. In flow it added a line box below Title and
   Description that no other field has, so those two gaps read wider than the
   ones under Due Date and Group Project however the margins were set. Used in
   exactly two places, both in the create-assignment form. */
.char-counter {
  position: absolute;
  top: 0;
  right: 0;
  font-size: var(--font-size-xs, 11px);
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Only the two groups that hold a counter, so nothing else in the form becomes
   a containing block for a descendant that did not ask to be contained. */
#create-assignment-form .form-group:has(> .char-counter) {
  position: relative;
}

.btn-show-more {
  display: block;
  background: none;
  border: none;
  padding: 0;
  margin-top: 4px;
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
  opacity: 0.8;
}

.btn-show-more:hover {
  opacity: 1;
}

label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
  color: var(--color-text);
}

/* Checkbox Labels */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  margin-bottom: var(--spacing-md);
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.checkbox-label span {
  font-weight: 500;
  color: var(--color-text);
}

/* Group Settings */
.group-settings {
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

/* A checkbox on the same line as the hint that explains it. The field keeps the
   usual label-above-control shape, but the control itself is box-plus-sentence:
   a checkbox sitting alone under a label reads as unfinished, and the sentence
   is what the teacher is actually deciding about. The row is a <label>, so the
   whole sentence is the click target. Top-aligned, because the hint wraps to two
   lines in the longer locales. */
.checkbox-with-hint {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  margin: 0;
  font-weight: normal;
  cursor: pointer;
}

.checkbox-with-hint input[type="checkbox"] {
  width: auto;
  margin: 0.15rem 0 0;
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-with-hint .form-hint {
  margin: 0;
}

.checkbox-with-hint:has(input[type="checkbox"]:disabled) {
  cursor: not-allowed;
}

/* A BASIC licence disables the checkbox; grey the words with it, or the field
   reads as available. The row label is excluded because the PRO badge lives
   inside it, and opacity on the row would dim the badge along with everything
   else — a child cannot opt back out of a parent's opacity. */
#create-assignment-form .form-group:has(#group-toggle:disabled) > label:not(.checkbox-with-hint),
#create-assignment-form .form-group:has(#group-toggle:disabled) .form-hint {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Pre-enrolment: adding classes and students to an assignment up front.
   The panels borrow .group-settings' padding/border/radius so the two blocks
   read as the same kind of thing — they sit next to each other in the form and
   are never usable at the same time. */
.pre-enrol-actions {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  /* .form-hint sets `margin: 4px 0 0`, so without this the buttons sit flush
     against the hint above them. */
  margin-top: var(--spacing-sm);
}

.pre-enrol-panel {
  margin-top: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

/* The confirm button follows a <select> or the student list directly, both of
   which are full-width blocks, so it needs its own separation from them. */
.pre-enrol-panel .btn {
  margin-top: var(--spacing-md);
}

/* `input[type="search"]` is not in the generic input selector list further up,
   so without this it falls back to the browser's ~20-character default and is
   far too narrow to read a name and a class in. Matches the generic inputs
   rather than inventing a second look. */
.pre-enrol-panel input[type="search"] {
  display: block;
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: inherit;
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

/* Capped and scrollable: a school can have hundreds of students, and the list
   must not push the submit button off the screen. */
.pre-enrol-student-list {
  max-height: 16rem;
  overflow-y: auto;
  margin: var(--spacing-sm) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.pre-enrol-student-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}

.pre-enrol-student-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.pre-enrol-student-row.is-enrolled {
  opacity: 0.6;
  cursor: default;
}

.pre-enrol-student-class {
  margin-left: auto;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.pre-enrol-class-heading {
  position: sticky;
  top: 0;
  padding: 0.35rem 0.6rem;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  background: var(--color-bg);
}

.pre-enrol-summary {
  margin-top: var(--spacing-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.pre-enrol-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.2rem 0.3rem 0.2rem 0;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
}

.pre-enrol-chip button {
  padding: 0;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.pre-enrol-empty {
  padding: var(--spacing-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* The classes an assignment is set for, with a stop button each (edit mode;
   dashboards.js). Students who join them later get the assignment too. */
.class-targets .pre-enrol-summary {
  margin-bottom: 0;
}

.class-targets .form-hint {
  margin-top: var(--spacing-xs);
}

/* Co-teachers reuse the pre-enrolment panel and chips. The Add button is the
   panel's primary action, so it sits bottom-right under the select rather than
   packing left. */
.co-teachers-add {
  display: flex;
  flex-direction: column;
}

.co-teachers-add .btn {
  align-self: flex-end;
}

/* Group projects cannot be pre-filled, so the whole block greys out. */
.pre-enrol-disabled {
  opacity: 0.55;
}

/* The due date moved out of the title's two-column row and would otherwise
   stretch the date input across the full width of the card. */
#due-date-group .due-date-inputs {
  max-width: 26rem;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  display: block;
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: inherit;
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* The list above is inputs only, so a textarea keeps the UA's inline-block and
   sits on a text baseline — which reserves room under it for the descenders of
   the line it notionally belongs to. That is ~6.5px of dead space inside the
   .form-group, and the group's margin is measured from below it, so whatever
   follows a textarea sits 6.5px lower than it does after any other field.

   Not folded into the selector list above: that rule also sets line-height,
   which would change the textarea's own row height. */
textarea {
  display: block;
}

input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  outline: none;
}

input::placeholder {
  color: var(--color-text-light);
}

.hint {
  display: block;
  margin-top: var(--spacing-xs);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.error-message {
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  color: var(--color-error);
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
}

.error-message[hidden] {
  display: none;
}

/* Login View */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
}

#login-view[hidden] {
  display: none;
}

.login-header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

/* The mark from the landing page's header, so the page a school's link opens
   reads as the product the school chose. The heading says the name, so the
   image is decorative. */
.login-logo {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto var(--spacing-md);
}

.login-language-selector {
  margin-top: var(--spacing-lg);
  text-align: center;
  display: flex;
  justify-content: center;
}

.login-title {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.login-cursor {
  display: inline-block;
  font-weight: 300;
  color: var(--color-primary);
  animation: blink 1s step-end infinite;
  margin-left: 2px;
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* The login page is one column: the card of either step (the app's own .card:
   white, a warm hairline border, a faint shadow), and the fine print under the
   first. Set on the column and the card, not on #login-view, so the demo's copy
   of the page (demo/index.html, its own view id) has the same width. */
.login-options,
.login-card {
  width: 100%;
  max-width: 27rem;
  margin: 0 auto;
}

.login-options[hidden],
.login-card[hidden] {
  display: none;
}

/* Sign-in code entry (step 2 of the login flow). A class, not the form's id,
   so the demo's copy of the step is centred too. */
.signin-code {
  text-align: center;
}

.signin-code-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto var(--spacing-lg);
  background: var(--color-primary-light, #eff6ff);
  border-radius: 50%;
  color: var(--color-primary);
}

.signin-code-title {
  margin: 0 0 var(--spacing-sm);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

.signin-code-desc {
  margin: 0 0 4px;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.signin-code-email {
  margin: 0 0 var(--spacing-lg);
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.95rem;
  word-break: break-all;
}

.signin-code-group {
  text-align: left;
}

/* The code is six characters read off a screen and typed into another one, so
   it gets a monospace face (0/O and 1/I are told apart by shape, not context)
   and enough tracking to count the characters at a glance. */
.signin-code-input {
  font-family: 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-align: center;
  text-transform: uppercase;
}

.signin-code-input::placeholder {
  font-weight: 400;
  letter-spacing: 0.2em;
  opacity: 0.4;
}

.signin-code-group .hint {
  margin: var(--spacing-xs, 4px) 0 0;
  text-align: center;
}

.signin-code-actions {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Every control in the card is full width and the same height, so the school's
   buttons, the email field and the orange button stack as one column. */
.login-card .btn {
  width: 100%;
  min-height: 2.75rem;
  margin-top: var(--spacing-sm);
}

.login-email input[type="text"] {
  height: 2.75rem;
  padding-block: 0;
}

/* On a phone the page's and the card's padding took a third of the width.
   .card.login-card: .card's own padding comes later in this file. */
@media (max-width: 480px) {
  #login-view {
    padding: var(--spacing-lg) 0;
  }

  .card.login-card {
    padding: var(--spacing-lg);
  }
}

/* School login: the first way in, above the email form. Kennisnet's own Entree
   button artwork (KNF:Beeldmateriaal) can replace the button later. */
.school-login {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.school-login[hidden],
.school-login .btn[hidden],
.school-login-icon[hidden] {
  display: none;
}

.school-login .btn {
  margin-top: 0;
}

/* A long school name wraps into lines of even length. */
.school-login-label {
  text-wrap: balance;
}

/* Logging in somewhere else, as on any site's "continue with" button: white,
   dark text, and a border darker than a field's, so it reads as a button and
   leaves the orange to the form's own. */
.btn-school-login {
  position: relative;
  padding-inline: 2.25rem;
  color: var(--color-text);
  background-color: var(--color-surface);
  border-color: var(--color-text-light);
}

/* The arrow out of the box sits at the button's right edge, where it stays
   when the school's name wraps; beside the text it was pushed there anyway,
   but only on two lines. The side padding keeps the text clear of it. */
.btn-school-login > .school-login-icon:last-child {
  position: absolute;
  top: 50%;
  right: var(--spacing-md);
  transform: translateY(-50%);
}

/* "Another school", under the remembered one: the smaller, quieter way in. */
.school-login .btn-ghost {
  min-height: 2.25rem;
  font-size: var(--font-size-sm);
}

.btn-school-login:hover:not(:disabled) {
  background-color: var(--color-bg);
  border-color: var(--color-text-muted);
}

.school-login-icon {
  flex-shrink: 0;
}

/* Between the school login and the email form when both are there: the
   hairline the app's cards draw between their parts. No words; the two
   halves say what they are. */
.school-login:not([hidden]) + .login-email {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
}

/* A quiet "another school" carries its own space under its text. */
.school-login:not([hidden]):has(> .btn-ghost:not([hidden])) + .login-email {
  margin-top: var(--spacing-md);
}

/* What logging in means: fine print under the card, for either way in. */
.login-consent {
  margin-top: var(--spacing-lg);
  text-align: center;
}

/* Why a school login did not work, or the note after logging out of one: at
   the top of the card, above what it is about. */
.login-message {
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
  color: var(--color-text);
  background-color: var(--color-primary-light);
  border: 1px solid var(--color-border);
}

.login-message.is-error {
  color: var(--color-error);
  background-color: #fef2f2;
  border-color: #fecaca;
}

.login-message[hidden] {
  display: none;
}

/* App Header */
.app-header {
  padding: var(--spacing-md) var(--spacing-lg);
}

.header-content {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.header-top-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.header-bottom-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.app-logo {
  height: 18px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.user-name {
  font-weight: 500;
  color: var(--color-text);
  font-size: var(--font-size-base);
}

.user-school {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
}

.language-selector {
  position: relative;
  margin-left: 0;
}

.language-button {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.language-button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.language-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  display: none;
  z-index: 1001;
}

.language-dropdown.active {
  display: block;
}

.language-option {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 0.9375rem;
}

.language-option:hover {
  background: var(--color-bg);
}

.language-option.selected {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.header-spacer {
  width: 4rem;
}

/* Dashboard */
.dashboard-main {
  padding: var(--spacing-lg) 0 var(--spacing-2xl);
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: center;
  margin-bottom: var(--spacing-lg);
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-lg);
  border: 1px solid;
  transition: all var(--transition-fast);
}

.status-indicator::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background-color var(--transition-fast);
}

.status-connected {
  background-color: rgba(34, 197, 94, 0.1);
  border-color: var(--color-success);
  color: var(--color-success);
}

.status-connected::before {
  background-color: var(--color-success);
}

.status-disconnected {
  background-color: rgba(100, 116, 139, 0.1);
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}

.status-disconnected::before {
  background-color: var(--color-secondary);
}

.input-section {
  padding: var(--spacing-xl);
  background-color: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--spacing-2xl);
}

.doc-input-form .form-group {
  margin-bottom: var(--spacing-md);
}

.recent-section {
  margin-top: var(--spacing-2xl);
}

.recent-section h2 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--spacing-md);
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.recent-item:hover {
  border-color: var(--color-primary);
}

.recent-item-label {
  font-weight: 500;
}

.recent-item-date {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.empty-state {
  padding: var(--spacing-xl);
  text-align: center;
  color: var(--color-text-muted);
}

/* Analysis View */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-lg);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: var(--font-size-sm);
}

.legend-color {
  width: 1rem;
  height: 1rem;
  border-radius: var(--radius-sm);
}

.chart-container {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  height: 400px;
  position: relative;
}

.chart-container canvas {
  max-height: 100%;
}

/* Chart wrapper to prevent height growth */
.chart-wrapper {
  height: 400px;
  position: relative;
  width: 100%;
}

.chart-wrapper canvas {
  max-height: 100%;
  max-width: 100%;
  cursor: pointer;
}

.document-section {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.document-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.document-header h2 {
  font-size: var(--font-size-base);
  font-weight: 500;
}

.view-toggle {
  display: flex;
  gap: var(--spacing-xs);
}

.toggle-btn {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: var(--font-size-sm);
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toggle-btn:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.toggle-btn:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-left: -1px;
}

.toggle-btn.active {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.document-content {
  padding: var(--spacing-lg);
  min-height: 200px;
  max-height: 500px;
  overflow-y: auto;
  font-family: Georgia, serif;
  line-height: 1.8;
}

.document-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Diff highlighting */
.diff-add {
  padding: 1px 2px;
  border-radius: 2px;
}

.diff-delete {
  padding: 1px 2px;
  border-radius: 2px;
}

.diff-unchanged {
  /* No special styling for unchanged text */
}

/* Current revision info */
.revision-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-lg);
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
}

.revision-info-user {
  font-weight: 500;
}

.revision-info-stats {
  color: var(--color-text-muted);
}

.ai-controls {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.ai-controls[hidden] {
  display: none;
}

.pro-message {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.pro-message[hidden] {
  display: none;
}

/* Pro badge */
.pro-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: white;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  border-radius: var(--radius-sm);
  margin-left: var(--spacing-xs);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.8);
  z-index: 1000;
}

.loading-overlay[hidden] {
  display: none;
}

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .app-header {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .app-logo {
    height: 16px;
  }

  .user-name,
  .user-school {
    display: none;
  }

  .language-selector {
    font-size: 0.8125rem;
  }

  .btn-small {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.8125rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .app-logo {
    height: 16px;
  }

  .user-name {
    font-size: var(--font-size-sm);
  }

  .user-school {
    font-size: 0.8125rem;
  }

}

@media (max-width: 640px) {
  .document-header {
    flex-direction: column;
    gap: var(--spacing-sm);
    align-items: flex-start;
  }
}

/* ==================== Editor Styles ==================== */

.editor-main {
  min-height: calc(100vh - 60px);
  background: var(--color-bg);
  overflow-y: auto;
}

/* Loading Screen Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.loading-spinner .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--color-primary);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.loading-spinner .dot:nth-child(1) {
  animation-delay: 0s;
}

.loading-spinner .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-spinner .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse-dot {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.loading-subtitle {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
}

.editor-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.editor-header-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
}

.editor-header-stats {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.editor-header-stat {
  white-space: nowrap;
}

.editor-header-stat-label {
  color: var(--color-text-muted);
}

.editor-header-stat-sep {
  color: var(--color-border);
  user-select: none;
}

/* Status container in header (holds status text and sync refresh button) */
.status-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

/* Collaboration toolbar — fixed, sits just right of the formatting toolbar */
.key-controls[hidden] { display: none; }
.key-controls {
  position: fixed;
  bottom: 1rem;
  left: calc(50% + var(--toolbar-half-width, 280px) + 6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(59, 47, 42, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  transition: all 0.3s ease;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .key-controls {
    left: auto;
    right: 1rem;
    bottom: calc(1rem + 52px + 6px);
  }
}

.btn-key {
  height: 36px;
  padding: 0 var(--spacing-md);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-key.steal {
  background: #3b82f6;
  color: white;
}

.btn-key.steal:hover {
  background: #2563eb;
}

.btn-key.drop {
  background: #f97316;
  color: white;
}

.btn-key.drop:hover {
  background: #ea580c;
}

.key-holder-label {
  padding: var(--spacing-xs) var(--spacing-sm);
  background: #e5e7eb;
  color: #6b7280;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.key-timer {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  min-width: 30px;
  text-align: center;
}

.key-timer.warning {
  color: #f97316;
}

.key-timer.critical {
  color: #ef4444;
}

.btn-sync-refresh {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sync-refresh:hover {
  background: var(--color-surface-hover);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-sync-refresh:active {
  transform: scale(0.95);
}

.btn-sync-refresh.syncing {
  animation: spin 1s linear infinite;
  pointer-events: none;
}

.btn-sync-refresh.syncing svg {
  opacity: 0.6;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Zoom Controls */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--color-surface-alt, #f5f5f5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.btn-zoom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.btn-zoom:hover {
  background: var(--color-surface-hover, rgba(0,0,0,0.07));
  color: var(--color-text);
}

.btn-zoom:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.zoom-level-display {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  min-width: 36px;
  text-align: center;
  user-select: none;
  cursor: default;
}

/* Formatting Toolbar - Glassmorphic design, fixed at bottom center */
.formatting-toolbar {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(59, 47, 42, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  align-items: center;
  transition: all 0.3s ease;
  /* Stretch to fit the full button row (into the grey area beside the page),
     only clamping — and then wrapping — when it would exceed the viewport. */
  width: max-content;
  max-width: calc(100vw - 2rem);
}

.formatting-toolbar:hover,
.key-controls:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 32px 0 rgba(59, 47, 42, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.formatting-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  align-items: center;
  justify-content: center;
}
/* Don't let toolbar controls shrink — they should wrap to a new row instead of
   being squeezed thin when space is tight. */
.formatting-buttons > * { flex-shrink: 0; }

.format-btn {
  padding: var(--spacing-xs) var(--spacing-sm);
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  background: white;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.format-btn:hover {
  background: var(--color-bg);
  border-color: var(--color-primary);
}

.format-btn:active,
.format-btn.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--color-border);
  margin: 0 var(--spacing-xs);
}

/* Format dropdown for headings */
.format-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dropdown-chevron {
  opacity: 0.6;
}

.format-dropdown .dropdown-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 140px;
  z-index: 1000;
}

.format-dropdown.open .dropdown-menu {
  display: block;
}

.format-dropdown .dropdown-item {
  display: block;
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.format-dropdown .dropdown-item:hover {
  background: var(--color-bg);
}

.format-dropdown .dropdown-item.active {
  background: var(--color-primary);
  color: white;
}

/* Export menus — the one button behind every "give me this as a file".
   Deliberately not .format-dropdown: that one opens upward (bottom: 100%),
   which is right for the editor's bottom toolbar and wrong for all four of
   these, which hang off buttons near the top of a card or header. The
   .dropdown-menu / .dropdown-item vocabulary is shared with it on purpose, so
   the two read as the same control. */
.export-menu {
  position: relative;
  display: inline-block;
}

.export-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.export-menu .dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  padding: 4px 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 100%;
  white-space: nowrap;
  z-index: 1000;
}

/* For a trigger that sits against the right of a header, where a menu wider
   than its button would otherwise run off the viewport. */
.export-menu-end .dropdown-menu {
  left: auto;
  right: 0;
}

.export-menu.open .dropdown-menu {
  display: block;
}

.export-menu .dropdown-item {
  display: block;
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.export-menu .dropdown-item:hover,
.export-menu .dropdown-item:focus-visible {
  background: var(--color-bg);
}

/* Document Container - scrollable viewport for pages */
.document-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  background: #e5e5e5;
  padding: 2rem;
  display: flex;
  justify-content: center;
}

/* Zoom host — flex child of document-container, height driven by JS for correct scroll area */
.zoom-host {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start; /* prevent stretch from overriding pagesContainer's natural height */
}

/* Pages wrapper */
.document-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding-bottom: 4rem;
}

/* Individual page - matches PDF dimensions (US Letter: 8.5" x 11") */
.document-page {
  width: 8.5in;
  height: 11in;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

/* Page content area with 1" margins */
.document-page .page-content {
  position: absolute;
  top: 1in;
  left: 1in;
  right: 1in;
  bottom: 1in;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12pt;
  line-height: 1.6;
  color: #1a1a1a;
  outline: none;
  overflow: hidden;
}

/* Editable page content cursor */
.document-page .page-content[contenteditable="true"] {
  cursor: text;
}

/* Page number at bottom */
.document-page .page-number {
  position: absolute;
  bottom: 0.5in;
  left: 0;
  right: 0;
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 10pt;
  color: #666;
  pointer-events: none;
}

.document-page .page-number.hidden {
  display: none;
}

/* Placeholder for empty first page */
.document-page:first-child .page-content:empty:before {
  content: attr(data-placeholder);
  color: #999;
  pointer-events: none;
  font-style: italic;
}

/* Focus state - subtle highlight */
.document-page .page-content:focus {
  outline: none;
}

/* Selection highlight */
.document-page .page-content::selection,
.document-page .page-content *::selection {
  background: rgba(66, 133, 244, 0.3);
}

/* ===========================================================================
   Collaborative editor (TipTap + Yjs) — Track C
   The collaborative editor renders a single continuous .ProseMirror surface
   into the page container (no manual pagination). Style it to look like a
   document page so there is a visible, clickable writing area.
   =========================================================================== */
.document-pages .ProseMirror {
  width: 8.5in;
  min-height: 11in;
  box-sizing: border-box;
  padding: 1in;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  flex-shrink: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12pt;
  line-height: 1.6;
  color: #1a1a1a;
  outline: none;
  cursor: text;
}
.document-pages .ProseMirror:focus { outline: none; }

/* Typography inside the collaborative editor */
.document-pages .ProseMirror > :first-child { margin-top: 0; }
.document-pages .ProseMirror p { margin: 0 0 0.5em; }
.document-pages .ProseMirror h1 { font-size: 1.8em; margin: 0.6em 0 0.3em; }
.document-pages .ProseMirror h2 { font-size: 1.5em; margin: 0.6em 0 0.3em; }
.document-pages .ProseMirror h3 { font-size: 1.25em; margin: 0.6em 0 0.3em; }
.document-pages .ProseMirror ul,
.document-pages .ProseMirror ol { padding-left: 1.5em; margin: 0 0 0.5em; }
.document-pages .ProseMirror blockquote {
  border-left: 3px solid #ddd; padding-left: 1em; margin: 0 0 0.5em; color: #555;
}
.document-pages .ProseMirror img { max-width: 100%; height: auto; }
.document-pages .ProseMirror table {
  border-collapse: collapse; margin: 0 0 0.5em; width: 100%; table-layout: fixed;
}
.document-pages .ProseMirror th,
.document-pages .ProseMirror td {
  border: 1px solid #ccc; padding: 4px 8px; vertical-align: top;
}
.document-pages .ProseMirror th { background: #f5f5f5; font-weight: 600; }

/* Live presence cursors (CollaborationCursor) */
.document-pages .ProseMirror .collaboration-cursor__caret {
  border-left: 1px solid #0d0d0d;
  border-right: 1px solid #0d0d0d;
  margin-left: -1px; margin-right: -1px;
  pointer-events: none; position: relative; word-break: normal;
}
.document-pages .ProseMirror .collaboration-cursor__label {
  position: absolute; top: -1.4em; left: -1px;
  font-size: 11px; font-style: normal; font-weight: 600;
  line-height: 1; white-space: nowrap;
  color: #fff; padding: 0.1rem 0.3rem; border-radius: 3px 3px 3px 0;
  user-select: none; pointer-events: none;
}

/* Heading styles in page (matching PDF) */
.document-page .page-content h1 {
  font-size: 18pt;
  font-weight: bold;
  margin: 0.5em 0;
  line-height: 1.3;
}

.document-page .page-content h2 {
  font-size: 14pt;
  font-weight: bold;
  margin: 0.5em 0;
  line-height: 1.3;
}

.document-page .page-content h3 {
  font-size: 12pt;
  font-weight: bold;
  margin: 0.5em 0;
  line-height: 1.3;
}

.document-page .page-content p {
  margin: 0.5em 0;
}

/* Blockquote in page */
.document-page .page-content blockquote {
  margin: 0.5em 0 0.5em 1em;
  padding-left: 1em;
  border-left: 3px solid #ccc;
  font-style: italic;
  color: #555;
}

/* Lists in page */
.document-page .page-content ul,
.document-page .page-content ol {
  margin: 0.5em 0 0.5em 1.5em;
  padding-left: 0;
}

.document-page .page-content li {
  margin: 0.25em 0;
}

/* Text formatting in page */
.document-page .page-content strong {
  font-weight: bold;
}

.document-page .page-content em {
  font-style: italic;
}

.document-page .page-content u {
  text-decoration: underline;
}

.document-page .page-content s {
  text-decoration: line-through;
}

/* Read-only state for locked pages */
.document-page .page-content[contenteditable="false"] {
  background: #fafafa;
  cursor: not-allowed;
}

/* Scale down pages on smaller screens */
@media (max-width: 1000px) {
  .document-container {
    padding: 1rem;
  }

  .document-pages {
    transform: scale(0.6);
    transform-origin: top center;
  }
}

@media (max-width: 700px) {
  .document-pages {
    transform: scale(0.45);
  }
}

/*
 * Shown above a snapshot whose text the server could only rebuild approximately.
 * Deliberately a plain, factual note rather than a warning colour: nothing has
 * gone wrong with the student's work, and Papertrail reports data rather than
 * passing judgement on it.
 */
.snapshot-approximate-notice {
  margin: 0 0 var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-left: 3px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* Preview pages in analysis view (non-editable) */
.preview-pages {
  pointer-events: none;
}

/*
 * A preview page grows rather than hiding what it could not fit.
 *
 * The editor's `.document-page` is a fixed 11in box with `overflow: hidden`,
 * which is right there: its contenteditable reflows content into the next page
 * as you type, so nothing is ever left outside the box. The analysis view has no
 * reflow — it measures once, in JS, and whatever it mismeasured was silently
 * clipped out of existence. Images are the common case (they measure 0px tall
 * until they load, so a page gets badly overfilled), but a single table or
 * paragraph taller than one page did it too.
 *
 * Clipping a teacher's view of a student's work is the worst possible failure
 * here: it is invisible and it looks like the student didn't write it. An
 * over-long page is merely ugly. So: keep the page metaphor and the exact
 * printed proportions via min-height, and let the box grow when the measurement
 * was wrong. `distributeContentToPages` re-measures once images have loaded, so
 * growth should be rare and small — this is the net, not the mechanism.
 */
.preview-page {
  height: auto;
  min-height: 11in;
  overflow: visible;
}

/*
 * Content drives the page's height, so it cannot be absolutely positioned
 * against one. Same 1in margins, expressed as padding instead of insets.
 */
.preview-page .page-content {
  position: static;
  inset: auto;
  padding: 1in;
  overflow: visible;
  cursor: default;
}

/* The page number follows the content down when a page has grown. */
.preview-page .page-number {
  position: static;
  padding-bottom: 0.5in;
}

.editor-status {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.editor-status.saved {
  background: var(--color-success);
  color: white;
}

.editor-status.error {
  background: var(--color-error);
  color: white;
}

/* User Legend for Multi-User Attribution */
.user-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.user-legend-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.user-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.user-legend-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
}

/* Group Lobby for Group Projects */
.group-lobby {
  margin-bottom: var(--spacing-2xl);
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.group-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.group-card:not(.group-card-full):hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.group-card-full {
  opacity: 0.6;
  background: var(--color-bg);
}

.group-info {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.group-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.group-members {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.group-full-badge {
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--color-secondary);
  color: white;
  font-size: var(--font-size-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
}

.group-card-current {
  border-color: var(--color-primary);
}

.group-current-badge {
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--color-primary);
  color: white;
  font-size: var(--font-size-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
}

.assignment-group-name {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.btn-sm {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: var(--font-size-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-left: auto;
}

/* Editor header specific styling */
.editor-sticky-top {
  position: sticky;
  top: 0;
  z-index: 100;
}

.editor-header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.status-badge {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.status-badge.status-draft {
  background: var(--color-warning);
  color: white;
}

.status-badge.status-submitted {
  background: var(--color-success);
  color: white;
}

.status-badge.status-not_started {
  background: var(--color-secondary);
  color: white;
}
.status-badge.status-not_started {
  background: var(--color-secondary);
  color: white;
}

/* ==================== Analysis Styles ==================== */

#analysis-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#analysis-view[hidden] {
  display: none;
}

/* Live view (client/src/live-view.js): the analysis view's bar and document
   viewer, without the analysis. The viewer fills the page and scrolls. */
#live-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#live-view[hidden] {
  display: none;
}

.live-view-bar-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.live-view-bar-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-view-bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.live-view-bar-actions .btn[hidden] {
  display: none;
}

.live-view-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--spacing-lg);
}

.document-viewer.live-view-viewer {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.live-view-note {
  margin: 0 0 var(--spacing-md);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

@media (max-width: 640px) {
  .live-view-content {
    padding: var(--spacing-sm);
  }

  .document-viewer.live-view-viewer {
    padding: var(--spacing-sm);
  }
}

.analysis-main {
  background: var(--color-bg);
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Two-column layout */
.analysis-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left sidebar — no outer scroll; internal sections scroll if needed */
.analysis-sidebar {
  width: 280px;
  flex-shrink: 0;
  overflow: hidden;
  border-right: 1px solid var(--color-border);
  padding: 0 var(--spacing-lg) var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  background: var(--color-surface);
}

/* Process summary grows to fill available space, scrolls internally */
.analysis-sidebar .process-summary {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Right content area */
.analysis-content {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

/* Tab panels */
.analysis-tab-panel {
  padding: var(--spacing-lg);
}

.analysis-tab-panel:not(.active) {
  display: none;
}

/* Time-travel panel: flex column so controls bar sits above the viewer */
#tab-time-travel.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#tab-time-travel .document-viewer-layout {
  flex: 1;
  min-height: 400px;
}

/* Tab bar — combined top bar with back/title on left, tabs on right */
.analysis-tab-bar {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--spacing-lg);
  gap: var(--spacing-lg);
  min-height: 44px;
}

.analysis-back-btn {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.analysis-back-btn:hover {
  color: var(--color-text);
  background: var(--color-bg);
  border-color: var(--color-text-muted);
}

.analysis-sidebar-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.analysis-bar-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
}

.analysis-bar-student {
  font-size: var(--font-size-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* Marks an analysis opened on work that is still being written. */
.analysis-draft-badge {
  align-self: flex-start;
  margin-top: 4px;
}

.analysis-draft-badge[hidden] {
  display: none;
}

.analysis-tab-nav {
  display: flex;
  flex-direction: row;
  gap: 2px;
  margin-left: auto;
}

.analysis-tab-btn {
  padding: 0 var(--spacing-md);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.analysis-tab-btn:hover {
  color: var(--color-text);
}

.analysis-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Session list in sidebar */
.session-list-title,
.sidebar-section-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  font-weight: 600;
  margin: var(--spacing-sm) 0 2px 0;
}

.process-summary > .sidebar-section-label:first-child,
.process-summary > .session-list-title:first-child {
  margin-top: 0;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.session-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.session-card:hover {
  border-color: var(--color-primary);
  background: var(--color-surface);
}

.session-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.session-number {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.session-date {
  font-size: var(--font-size-xs, 0.7rem);
  color: var(--color-text-muted);
}

.session-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.session-duration {
  font-size: var(--font-size-xs, 0.7rem);
  color: var(--color-text-muted);
}

.session-range {
  font-size: var(--font-size-xs, 0.7rem);
  color: var(--color-text-muted);
  font-family: monospace;
}

.text-muted {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* Submissions View */
/* No inset of its own. This sits in the same container as the overview's
   assignment cards, which are laid straight into the list, so a padding here
   made every panel 3rem narrower than the card the teacher had just clicked,
   and started the view lower down the page than the overview starts. */
.submissions-view {
  padding: 0;
}

.submissions-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  flex-wrap: wrap;
}

.submissions-stats {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.stat-block {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  min-height: 36px;
  transition: all var(--transition-fast);
}

.stat-block-deadline {
  background: var(--color-surface);
  border-color: var(--color-error);
  color: var(--color-error);
}

.stat-block-enrolled {
  background: var(--color-surface);
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}

.stat-block-submitted {
  background: var(--color-surface);
  border-color: var(--color-success);
  color: var(--color-success);
}

.stat-content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.stat-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.75;
}

.stat-value {
  font-size: var(--font-size-base);
  font-weight: 600;
  line-height: 1.2;
}

.submissions-view h2 {
  margin-top: var(--spacing-md);
  margin-bottom: 0.5rem;
}

.submissions-view .text-muted {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}

.submissions-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.submission-card {
  padding: var(--spacing-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.submission-card-clickable {
  cursor: pointer;
  transition: all 0.2s;
}

.submission-card-clickable:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.submission-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.student-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.student-info h3 {
  margin: 0;
  font-size: var(--font-size-lg);
}

.student-id {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-family: var(--font-family-mono);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.submission-meta {
  display: flex;
  gap: var(--spacing-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
}

/* Two kinds of thing share this row: the Mark as read and Flag toggles, which
   are metadata the teacher sets about a submission, and the buttons, which do
   something. The buttons follow the rule and sit against the right edge; the
   toggles stay where they are, because right-aligning the row would carry them
   along and leave the row reading as one undifferentiated strip.

   Done with justify-content plus an auto margin on the last toggle rather than
   an auto margin on the first button, so the same rule also right-aligns the
   .papertrail viewer's copy of this row, which has a button and no toggles.

   The gap was 1.5rem, and each toggle carries 0.5rem of its own padding, so
   40px of white sat between "Mark as read" and "Flag" — far enough apart to
   read as unrelated when they are a pair. 0.5rem here matches the gap between
   buttons everywhere else in the app. */
.submission-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.submission-actions > .toggle-label:last-of-type {
  margin-right: auto;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  user-select: none;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  /* This is a <label>, so it inherited the 0.5rem the bare `label` rule gives a
     form field's caption to stand clear of its input. Nothing is stacked under
     this one: it sits in .submission-actions, which centres its children on
     their margin boxes, so that margin lifted both checkboxes 4px above the
     buttons beside them. */
  margin: 0;
}

.toggle-label:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.toggle-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--color-primary);
  border-radius: var(--radius-sm);
}

.toggle-text {
  font-weight: 500;
}

.toggle-flag {
  color: var(--color-text-muted);
}

.toggle-flag:hover {
  color: var(--color-error);
}

.toggle-flag .toggle-checkbox {
  accent-color: var(--color-error);
}

.submission-read {
  opacity: 0.7;
  background: var(--color-bg);
}

.submission-flagged {
  border-left: 4px solid var(--color-error);
  border-left-color: #ef4444;
}

.submission-badges {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.assignment-card-clickable {
  cursor: pointer;
  transition: all 0.2s;
}

.assignment-card-clickable:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.view-link {
  color: var(--color-primary);
  font-weight: 500;
  font-size: var(--font-size-sm);
  margin-top: var(--spacing-sm);
}

/* Timeline and fraud analysis styles abbreviated for space */

/* Waterfall Chart Styles */
.waterfall-chart-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  align-items: center;
}

#waterfall-canvas {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: white;
  max-width: 100%;
  height: auto;
}

.waterfall-legend {
  display: flex;
  gap: var(--spacing-xl);
  padding: var(--spacing-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-sm);
}

.legend-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid;
}

.legend-add {
  background: rgba(34, 197, 94, 0.6);
  border-color: rgb(34, 197, 94);
}

.legend-del {
  background: rgba(239, 68, 68, 0.6);
  border-color: rgb(239, 68, 68);
}

.legend-paste {
  background: rgba(147, 51, 234, 0.6);
  border-color: rgb(147, 51, 234);
}

.waterfall-info {
  padding: var(--spacing-md);
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: var(--font-size-sm);
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Document Viewer Styles */
/* Time travel controls — graph scrubber */
.time-travel-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.ttc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
}

.ttc-nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.ttc-indicator {
  font-weight: 500;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 90px;
  text-align: center;
}

.ttc-playback {
  display: flex;
  align-items: center;
  gap: 1px;
}

.ttc-playback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  min-width: 28px;
  padding: 0 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.ttc-playback-btn:hover {
  color: var(--color-text);
  background: var(--color-border);
}

.ttc-playback-btn.active {
  background: var(--color-border);
  color: var(--color-text);
}

.ttc-legend {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.ttc-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

/* The soft-deadline entry is static markup that both analysis views hide with
   the [hidden] attribute on assignments that have no soft deadline. The bare
   `display: flex` above is an author rule and so beats the UA [hidden] one,
   which left the swatch on screen for every assignment. */
.ttc-legend-item[hidden] { display: none; }

/* Stacked canvas graph */
.ttc-graph-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: crosshair;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.ttc-sparkline,
.ttc-heatmap {
  display: block;
  width: 100%;
}

.ttc-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.document-viewer {
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  min-height: 600px;
  max-height: 800px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.snapshot-meta {
  display: flex;
  align-items: stretch;
  padding-bottom: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  border-bottom: 2px solid var(--color-border);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.snapshot-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--color-bg-secondary, #f8f9fa);
  border-radius: var(--radius-md);
  padding: var(--spacing-xs) var(--spacing-sm);
}

.snapshot-meta-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  font-weight: 600;
}

.snapshot-meta-value {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  font-weight: 500;
}

/* ===== Analysis View v2 Components ===== */

/* Chart toolbar */
.chart-toolbar {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.chart-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-style: italic;
}

/* Key for the vertical rules on the velocity chart, under its toolbar. The
   swatches are drawn from the same weight and dash the canvas uses, so only
   the colour distinguishes the soft-deadline boundary from the time-travel
   cursor — which is the one thing the reader has to learn. */
.velocity-legend {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.velocity-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.btn-toggle {
  position: relative;
  transition: all 0.2s ease;
}

.btn.btn-toggle.active,
.btn.btn-toggle.active:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.btn.btn-toggle.active:hover {
  background-color: var(--color-primary-dark, #1d4ed8);
}

/* Writing Process Summary Panel */
.process-summary {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.process-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.process-stat {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: var(--spacing-sm);
}

.process-stat-label {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.process-stat-value {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.notable-events-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.notable-event-item {
  display: flex;
  flex-direction: column;
}

.notable-event-item.notable-event-highlighted > .notable-event-pill {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.06);
}

.notable-event-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs, 0.72rem);
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.notable-event-pill:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
}

.notable-event-pill[aria-expanded="true"] {
  border-color: var(--color-primary);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
}

.notable-event-icon {
  flex-shrink: 0;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
}

.notable-event-short {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notable-event-chevron {
  flex-shrink: 0;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  transition: transform var(--transition-fast);
}

.notable-event-pill[aria-expanded="true"] .notable-event-chevron {
  transform: rotate(180deg);
}

.notable-event-detail {
  padding: 6px 8px;
  font-size: var(--font-size-xs, 0.72rem);
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-primary);
  border-top: none;
  border-bottom-left-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  line-height: 1.4;
}

.notable-events-see-all {
  margin-top: 4px;
  background: none;
  border: none;
  padding: 2px 0;
  font-size: var(--font-size-xs, 0.72rem);
  color: var(--color-primary);
  cursor: pointer;
  text-align: left;
}

.notable-events-see-all:hover {
  text-decoration: underline;
}

/* Document Viewer Layout with Change Index */
.document-viewer-layout {
  display: flex;
  gap: var(--spacing-md);
}

.change-index {
  width: 200px;
  flex-shrink: 0;
  background: var(--color-bg-secondary, #f8f9fa);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  padding: var(--spacing-sm);
}

.change-index-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--spacing-sm);
}

.change-index-header h3 {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin: 0;
}

.change-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 600;
  background: var(--color-bg, #eee);
  padding: 2px 8px;
  border-radius: 10px;
}

.change-index-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  width: 100%;
  padding: var(--spacing-xs) var(--spacing-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  font-family: inherit;
}

.change-index-item:hover {
  background: white;
}

.change-type-indicator {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.change-type-indicator.addition {
  background: rgba(59, 130, 246, 0.15);
  color: rgb(59, 130, 246);
}

.change-type-indicator.deletion {
  background: rgba(220, 38, 38, 0.15);
  color: #dc2626;
}

.change-preview {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
}

.change-size {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.empty-state-small {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--spacing-md);
}

/* Diff flash highlight animation */
@keyframes diffFlash {
  0% { outline: 3px solid rgba(200, 106, 74, 0.8); outline-offset: 2px; }
  100% { outline: 3px solid transparent; outline-offset: 2px; }
}

.diff-highlight-flash {
  animation: diffFlash 2s ease-out;
}

/* Snapshot Slider */
/* .snapshot-slider removed — replaced by canvas-based ttc-graph-wrap */

/* Authorship Run (replaces per-character spans) */
.authorship-run {
  border-radius: 2px;
  transition: filter 0.15s ease;
  /* background-color set inline per-user */
}

.authorship-run:hover {
  filter: brightness(0.85);
}

/* Hide authorship tints when toggle is off */
.review-no-authorship .authorship-run {
  background-color: transparent !important;
}

/* Grammar wavy underlines.

   These are <mark> elements, and a <mark> comes with the browser's yellow
   background and black text. That yellow sat inside the .authorship-run span
   it replaced text in, so it painted over the author's tint: running a grammar
   check looked like it had switched Show authorship off, and toggling
   authorship back on appeared to do nothing on every word the checker had
   flagged. The toggle was working the whole time — it clears the run's
   background, which was already hidden underneath the mark.

   Both are therefore reset. The wave survives because it is text-decoration,
   not background, so a flagged word still reads as flagged whether or not it
   is tinted. `color: inherit` matters for the same reason as the background:
   marktext is black, and a mark should not repaint text sitting on a dark
   authorship colour. */
.grammar-error,
.grammar-warning {
  background-color: transparent;
  color: inherit;
  text-decoration-skip-ink: none;
  cursor: pointer;
  border-radius: 1px;
}

.grammar-error {
  text-decoration: underline wavy #dc2626;
}

.grammar-warning {
  text-decoration: underline wavy #d97706;
}

/* Temporary highlight when scrolling to a grammar mark */
.grammar-mark-highlight {
  background-color: rgba(251, 191, 36, 0.4) !important;
  outline: 2px solid #f59e0b;
  border-radius: 2px;
}

/* Review controls bar — no extra chrome; chart-toolbar provides layout */
.review-controls {
  background: transparent;
  border: none;
  flex-shrink: 0;
}

/* Grammar language selector + button group */
.review-grammar-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: visible; /* allow dropdown to overflow */
  background: var(--color-surface);
}

.grammar-lang-selector {
  margin-left: 0;
}

.grammar-lang-button {
  border: none !important;
  border-right: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) 0 0 var(--radius-md) !important;
  background: var(--color-bg) !important;
  padding: 0 10px !important;
  height: 100%;
  font-size: 0.8rem !important;
  gap: 5px !important;
}

.review-grammar-group .btn {
  border-radius: 0 var(--radius-md) var(--radius-md) 0 !important;
}

.grammar-lang-button:hover {
  background: var(--color-primary-light) !important;
  border-color: var(--color-border) !important;
  color: var(--color-text) !important;
}

.grammar-lang-dropdown {
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  border-radius: var(--radius-md) !important;
}

.grammar-lang-group-label {
  padding: 6px 12px 3px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  pointer-events: none;
}

.grammar-lang-option {
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease;
  color: var(--color-text);
}

.grammar-lang-option:hover {
  background: var(--color-bg);
}

.grammar-lang-option.selected {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.review-grammar-group > .btn {
  border: none;
  padding: 0 12px;
  font-size: 0.8rem;
  white-space: nowrap;
  align-self: stretch;
  height: auto;
}

/* Grammar sidebar items */
.grammar-issue-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--color-border);
}
.grammar-issue-item:last-child { border-bottom: none; }
.grammar-issue-active { background: var(--color-primary-light) !important; }
.grammar-issue-meta {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.grammar-issue--error .grammar-issue-meta { color: #dc2626; }
.grammar-issue--warning .grammar-issue-meta { color: #d97706; }
.grammar-issue-msg {
  font-size: 0.8rem;
  color: var(--color-text);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.grammar-issue-suggestion {
  font-size: 0.78rem;
  color: #16a34a;
  font-style: italic;
}

/* Responsive: change index collapses */
@media (max-width: 900px) {
  .document-viewer-layout {
    flex-direction: column;
  }
  .change-index {
    width: 100%;
    max-height: 200px;
  }
  .ttc-graph-wrap {
    min-height: 40px;
  }
  .authorship-section-label {
    width: 120px;
  }
}

.snapshot-content {
  font-family: var(--font-family);
  line-height: 1.8;
  color: var(--color-text);
  word-wrap: break-word;
}

/* Rich text formatting in snapshot content */
.snapshot-content h2 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 1em 0 0.5em 0;
  line-height: 1.3;
}

.snapshot-content ul,
.snapshot-content ol {
  margin: 0.5em 0;
  padding-left: 2em;
}

.snapshot-content li {
  margin: 0.25em 0;
}

.snapshot-content strong {
  font-weight: 700;
}

.snapshot-content em {
  font-style: italic;
}

.snapshot-content u {
  text-decoration: underline;
}

.snapshot-content p {
  margin: 0.5em 0;
}

.keyboard-hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--color-primary-light);
  border-radius: var(--radius-md);
}

/* Diff highlighting in document viewer */
.diff-addition {
  color: #3b82f6;
  text-decoration: underline;
  text-decoration-color: #3b82f6;
  text-decoration-thickness: 2px;
  background-color: rgba(59, 130, 246, 0.1);
}

.diff-deletion {
  color: #dc2626;
  text-decoration: line-through;
  text-decoration-color: #dc2626;
  text-decoration-thickness: 2px;
  background-color: rgba(220, 38, 38, 0.1);
  opacity: 0.8;
}

/* Generic Card Component */
.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  padding: 2rem;
  border: 1px solid var(--color-border);
}

/* Enhanced Form Styles */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: inherit;
  font-size: var(--font-size-base);
  transition: all 0.2s;
  background-color: white;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23334155' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px;
  padding-right: 2.5rem;
}

input[type="datetime-local"],
input[type="time"] {
  cursor: pointer;
  color-scheme: light;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: 0.6;
  cursor: pointer;
  padding: 0 2px;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.due-date-inputs {
  display: flex;
  gap: var(--spacing-sm);
}

.due-date-inputs input[type="date"] {
  flex: 1;
}

.due-date-inputs input[type="time"] {
  width: 7.5rem;
  flex-shrink: 0;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
input[type="number"]:focus,
select:focus,
/* Draggable taller when the instructions are long, but never wider: horizontal
   resize pulls the field out of the form's column. */
textarea {
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

/* Teacher Dashboard Sections */
.create-section {
  margin-bottom: 3rem;
}

.create-section .card {
  max-width: 100%;
}

.create-section h2 {
  margin: 0 0 1.5rem 0;
  font-size: var(--font-size-xl);
  color: var(--color-text);
}

.assignments-section {
  margin-top: var(--spacing-lg);
}

/* Opening one assignment hides the create section, which leaves this section
   first under the header. The margin above only exists to hold it clear of the
   create card, so with that card gone it has to go too — otherwise a single
   assignment opens lower than the overview it was clicked from. */
.create-section[hidden] + .assignments-section {
  margin-top: 0;
}

.assignments-section h2 {
  margin-bottom: 1.5rem;
  font-size: var(--font-size-xl);
  color: var(--color-text);
}

/* Local .papertrail file cards */
.assignment-card--local {
  background: var(--color-bg);
  border-style: dashed;
  cursor: pointer;
  padding: 1rem 1.5rem;
}

.assignment-card--local:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  border-color: var(--color-primary);
}

.assignment-local-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: #f0f0ff;
  color: #6366f1;
  border: 1px solid #c7d2fe;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Assignment List - Clean Hover Effect */
.assignment-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
}

.assignment-card-clickable {
  cursor: pointer;
}

.assignment-card-clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: var(--color-primary);
}

.assignment-card h3 {
  margin: 0 0 0.5rem 0;
  font-size: var(--font-size-lg);
  color: var(--color-text);
}

.assignment-card p {
  margin: 0 0 1rem 0;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.assignment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

/* "Set for H4D, including students who join later": its own line, since the
   meta row spreads its items apart. */
.assignment-classes {
  margin-bottom: 0.35rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Assignment open/closed state */
.assignment-closed {
  opacity: 0.85;
}

.assignment-open {
}

.assignment-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

/* The card's buttons sit on the title row, pushed to its right. They used to be
   a flex sibling of the whole content column, which then only got the width the
   buttons left over — for every row in it, including the divider above the
   access code and the code block itself, though the buttons stand beside the
   title alone. `margin-left: auto` rather than space-between on the row, which
   would push the status badge away from the title it belongs to. */
.assignment-title-row .assignment-actions {
  margin-left: auto;
}

/* The card's primary action, on its own row under the access code. */
.assignment-card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.assignment-title-row h3 {
  margin: 0;
}

.assignment-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.assignment-status-badge.status-open {
  background: #d1fae5;
  color: #065f46;
}

.assignment-status-badge.status-closed {
  background: #f1f5f9;
  color: #475569;
}

/* Held by more than one teacher. A label, not a state, so it is the brand's
   neutral blue rather than open/closed's green or grey. */
.assignment-status-badge.status-shared {
  background: #dbeafe;
  color: #1e40af;
}

.submissions-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Notable events indicator on submission cards */
.notable-events-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: default;
  white-space: nowrap;
}

/* Quick-scan pill — lives in .submission-badges next to the status badge */
.quick-scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: calc(var(--spacing-xs) - 1px) var(--spacing-sm);
  border-radius: 9999px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  transition: border-color 0.15s, color 0.15s;
  position: relative;
}
.quick-scan-btn:hover:not([disabled]):not([data-scanned]) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.quick-scan-btn[data-scanned="flagged"],
.quick-scan-btn[data-scanned="flagged"]:hover {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
  cursor: help;
}
.quick-scan-btn[data-scanned="clean"],
.quick-scan-btn[data-scanned="clean"]:hover {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
  cursor: default;
}
.quick-scan-btn[data-scanned="loading"] {
  cursor: default;
  opacity: 0.7;
}

/* Spinner inside the button */
.quick-scan-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: quick-scan-spin 0.6s linear infinite;
}
@keyframes quick-scan-spin {
  to { transform: rotate(360deg); }
}

/* Info icon inside the flagged quick-scan pill */
.qs-info-icon {
  display: none;
  flex-shrink: 0;
  opacity: 0.6;
}
.quick-scan-btn[data-scanned="flagged"] .qs-info-icon {
  display: block;
}

/* Tooltip panel — shown on hover of the flagged button */
.qs-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  max-width: 300px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 8px;
  z-index: 200;
  cursor: default;
  font-weight: 400;
  letter-spacing: 0;
  text-align: left;
}
.quick-scan-btn[data-scanned="flagged"]:hover .qs-tooltip {
  display: block;
}

/* Assignment closed banner in student editor */
.assignment-closed-banner {
  background: #fef3c7;
  border-bottom: 2px solid #f59e0b;
  color: #92400e;
  padding: 0.75rem 1.5rem;
  text-align: center;
  font-weight: 500;
  font-size: var(--font-size-sm);
}

/* Deadline countdown — centered pill below header (essay editor) */
.deadline-countdown-banner {
  background: transparent;
  border-bottom: none;
  padding: 0.5rem 0;
  text-align: center;
}

.deadline-countdown-banner[hidden] {
  display: none;
}

.deadline-countdown-banner span {
  display: inline-block;
  background: #eff6ff;
  border: 1.5px solid #3b82f6;
  color: #1e40af;
  border-radius: 9999px;
  padding: 0.3rem 1rem;
  font-size: var(--font-size-sm);
  font-weight: 500;
}

/* Deadline countdown — inline pill inside header (notebook editor) */
.deadline-countdown-pill {
  background: #eff6ff;
  border: 1.5px solid #3b82f6;
  color: #1e40af;
  border-radius: 9999px;
  padding: 0.25rem 0.85rem;
  font-size: var(--font-size-sm);
  font-weight: 500;
  white-space: nowrap;
}

.deadline-countdown-pill[hidden] {
  display: none;
}

/* Access Code Display */
.access-code-container {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.access-code-label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.access-code-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.access-code {
  font-family: var(--font-family-mono);
  background-color: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: var(--font-size-sm);
  color: #1f2937;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.btn-copy {
  padding: 0.4rem;
  min-width: auto;
  transition: all 0.2s ease;
}

.btn-copy:hover {
  background: #eff6ff;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-copy.btn-copied,
.btn-copy.btn-copied:hover {
  background-color: #10b981;
  border-color: #10b981;
  color: white;
  font-size: 13px;
  font-weight: 700;
}

.view-link {
  color: var(--color-primary);
  font-weight: 500;
}

/* Form Grid Layout */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: var(--spacing-md);
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* The primary action sits at the right end of the card, where the eye lands
   last, with Cancel beside it. Scoped to this form: .form-actions is shared
   with the group-settings form that dashboards.js renders, which is laid out
   left-aligned inside a narrower panel. */
#create-assignment-form .form-actions {
  justify-content: flex-end;
}

/* Student Enrollment Section */
.enroll-section {
  margin-bottom: 2rem;
}

.enroll-section h2 {
  margin: 0 0 0.5rem 0;
  font-size: var(--font-size-lg);
  color: var(--color-text);
}

.enroll-section .text-muted {
  margin: 0 0 1.5rem 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.enroll-form {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.enroll-form .form-group {
  flex: 1;
  margin-bottom: 0;
}

.enroll-form button {
  flex-shrink: 0;
  margin-bottom: 0;
  height: 45px;
  box-sizing: border-box;
  padding: var(--spacing-sm) var(--spacing-lg);
  line-height: 1.5;
}

.access-code-input {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-base);
  height: 45px;
  line-height: 1.5;
  padding: var(--spacing-sm) var(--spacing-md);
  box-sizing: border-box;
}

.enroll-message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.enroll-message-success {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.enroll-message-error {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

@media (max-width: 768px) {
  .enroll-form {
    flex-direction: column;
    align-items: stretch;
  }

  .enroll-form button {
    width: 100%;
  }
}

/* Assignment Card with Actions */
.assignment-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.assignment-card-content {
  flex: 1;
}

/* The primary action goes bottom-right of its container — see CLAUDE.md. On the
   student's cards this row is a block-level child of the card, so its buttons
   packed left against the description above them; on the teacher's card and in
   the .papertrail viewer the row is a content-sized flex sibling, where
   justify-content has nothing to distribute and this changes nothing. One rule
   rather than three, because the convention is one. */
.assignment-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Icon Buttons */
.btn-icon {
  padding: 0.5rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--color-surface);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

.btn-edit {
  color: var(--color-text);
}

.btn-edit:hover {
  background: #eff6ff;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-delete {
  color: #6b7280;
}

.btn-delete:hover {
  background: #fef2f2;
  border-color: #dc2626;
  color: #dc2626;
}

/* ================================
   Super Admin Dashboard Styles
   ================================ */

.admin-nav {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 0;
}

.tab-button {
  padding: var(--spacing-md) var(--spacing-lg);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -2px;
}

.tab-button:hover {
  color: var(--color-primary);
}

.tab-button.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.admin-content {
  max-width: 1200px;
  margin: 0 auto;
}

.tab-content {
  animation: fadeIn 0.3s ease;
}

.admin-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
}

.admin-section h2 {
  margin-top: 0;
  margin-bottom: var(--spacing-lg);
  color: var(--color-text);
  font-size: var(--font-size-xl);
}

.section-description {
  margin-bottom: var(--spacing-lg);
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
}

.section-description code {
  font-family: var(--font-family-mono);
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

.bulk-import-form {
  display: flex;
  gap: var(--spacing-md);
  align-items: center;
  flex-wrap: wrap;
}

.file-name-display {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
}

.admin-form {
  max-width: 600px;
}

.admin-form .form-group {
  margin-bottom: var(--spacing-lg);
}

.admin-form label {
  display: block;
  margin-bottom: var(--spacing-sm);
  color: var(--color-text);
  font-weight: 500;
}

.admin-form input {
  width: 100%;
  padding: var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  transition: border-color 0.2s ease;
}

.admin-form input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.admin-form small {
  display: block;
  margin-top: var(--spacing-xs);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.admin-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: var(--font-size-base);
}

.admin-table thead {
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
}

.admin-table th {
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.admin-table td {
  padding: 0 var(--spacing-md);
  height: 52px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  white-space: nowrap;
}

.admin-table td.actions {
  white-space: nowrap;
  text-align: right;
}

.admin-table tbody tr:hover {
  background: var(--color-bg);
}

/* Compact icon buttons inside tables — override the standalone 32px fixed size */
.admin-table .btn-icon,
.data-table .btn-icon {
  height: 28px;
  width: 28px;
  padding: 4px;
}

.usage-badge {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.usage-badge.usage-full {
  background: #fee2e2;
  color: var(--color-error);
}

.storage-cell {
  min-width: 120px;
}

.storage-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.storage-bar-mini {
  height: 4px;
  background: var(--color-bg);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.storage-bar-mini-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.storage-bar-mini-fill.storage-warning {
  background: var(--color-warning);
}

.storage-bar-mini-fill.storage-full {
  background: var(--color-error);
}

.license-badge {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-transform: uppercase;
}

.license-badge.license-pro {
  background: #dbeafe;
  color: #1e40af;
}

.license-badge.license-basic {
  background: #f3f4f6;
  color: #6b7280;
}

.license-badge.license-grace {
  background: #fef3c7;
  color: #92400e;
}

.grace-period-notice {
  padding: var(--spacing-md) var(--spacing-lg);
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: var(--border-radius);
  color: #92400e;
  font-size: 0.95rem;
  margin-bottom: var(--spacing-lg);
}

.pro-feature-badge {
  display: inline-flex;
  align-items: center;
  margin-left: var(--spacing-sm);
  padding: 2px 8px;
  background: #c0714a;
  color: white;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.checkbox-label .pro-feature-badge {
  color: white;
}

/* Order-independent, so it holds whichever side of the text the box sits on.
   Nothing uses .checkbox-label at the moment — the create-assignment form's
   group-project field was its last user and now pairs its checkbox with a hint
   via .checkbox-with-hint — but the pattern is kept for the next checkbox that
   wants a bold label beside the box rather than a sentence. */
.checkbox-label:has(input[type="checkbox"]:disabled) span {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.disabled,
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.empty-state {
  padding: var(--spacing-xl);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
}

.loading {
  padding: var(--spacing-xl);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
}

/* Logs Table Styles */

.logs-table .log-timestamp {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.logs-table .log-event {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
}

.log-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.log-badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.log-badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.log-badge-error {
  background: #fee2e2;
  color: #991b1b;
}

.log-badge-auth {
  background: #e0e7ff;
  color: #3730a3;
}

.log-badge-maint {
  background: #d1fae5;
  color: #065f46;
}

.log-level-warning {
  background: #fffbeb;
}

.log-level-error {
  background: #fef2f2;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* License Key Display */
.license-key-wrapper {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: nowrap;
}

.license-key {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  user-select: all;
}

.license-key.hidden {
  user-select: none;
  letter-spacing: 2px;
}

.btn-icon {
  background: none;
  border: none;
  padding: var(--spacing-xs);
  cursor: pointer;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  height: 32px;
  width: 32px;
}

.btn-icon:hover {
  background: var(--color-bg);
  color: var(--color-primary);
}

.btn-icon:active {
  transform: scale(0.95);
}

.btn-show-key:hover {
  color: var(--color-success);
}

.actions {
  display: flex;
  gap: var(--spacing-xs);
  align-items: center;
  min-height: 32px;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Modal */
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

.modal-large {
  max-width: 900px;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Modal Header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  margin: 0;
  font-size: var(--font-size-xl);
  color: var(--color-text);
}

.modal-close {
  padding: var(--spacing-xs);
}

/* Modal Body */
.modal-body {
  padding: var(--spacing-lg);
}

.modal-body .form-group {
  margin-bottom: var(--spacing-lg);
}

.modal-body .form-group:last-child {
  margin-bottom: 0;
}

/* Modal Footer */
.modal-footer {
  display: flex;
  gap: var(--spacing-md);
  justify-content: flex-end;
  padding-top: var(--spacing-lg);
  margin-top: var(--spacing-lg);
  border-top: 1px solid var(--color-border);
}

.modal-footer button {
  min-width: 100px;
}

/* Bulk Import Styles */
.success-message {
  color: var(--color-success);
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin: 0 0 var(--spacing-md);
}

.import-instructions {
  color: var(--color-text-muted);
  margin: 0 0 var(--spacing-lg);
  padding: var(--spacing-md);
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius-md);
}

.import-results {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: var(--spacing-lg);
}

.import-results .admin-table {
  font-size: var(--font-size-sm);
}

.import-results .license-key {
  font-size: 12px;
}

/* Statistics Tab Styles */
.statistics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
  margin: 0 0 var(--spacing-xs);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: var(--spacing-sm) 0;
  line-height: 1;
}

.stat-card .stat-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--spacing-xs);
}

.stat-card .stat-trend {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: var(--font-size-sm);
  margin-top: var(--spacing-sm);
}

.stat-card .stat-trend.positive {
  color: var(--color-success);
}

.stat-card .stat-trend.neutral {
  color: var(--color-text-muted);
}

.chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
}

.chart-container h3 {
  margin: 0 0 var(--spacing-lg);
  font-size: var(--font-size-lg);
  color: var(--color-text);
  font-weight: 600;
}

.chart-container canvas {
  max-height: 300px;
}

/* School Admin Dashboard Styles */

/* License Usage Section */
.license-usage-section {
  margin-bottom: var(--spacing-xl);
}

.license-usage {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

.license-usage.license-warning {
  border-color: var(--color-warning);
  background: #fffbeb;
}

.license-usage.license-full {
  border-color: var(--color-error);
  background: #fef2f2;
}

.license-usage-info h3 {
  margin: 0 0 var(--spacing-sm) 0;
  color: var(--color-text);
  font-size: var(--font-size-xl);
}

.license-type-display {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: var(--spacing-sm) 0;
}

.license-type-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.license-count {
  margin: var(--spacing-sm) 0;
  font-size: var(--font-size-lg);
  color: var(--color-text-muted);
}

.license-count strong {
  color: var(--color-text);
  font-size: var(--font-size-2xl);
}

.license-usage-bar {
  height: 8px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: var(--spacing-md);
}

.license-usage-progress {
  height: 100%;
  background: var(--color-primary);
  transition: width 0.3s ease;
}

.license-usage.license-warning .license-usage-progress {
  background: var(--color-warning);
}

.license-usage.license-full .license-usage-progress {
  background: var(--color-error);
}

.license-usage-progress.storage-bar-warning {
  background: var(--color-warning);
}

.license-usage-progress.storage-bar-full {
  background: var(--color-error);
}

/* ── Notices panel (both admin dashboards; client/src/notices.js) ───────── */

.notices-panel[hidden],
.notices-count[hidden] {
  display: none;
}

.notices-panel h2 {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.notices-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  padding: 0 0.4em;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font-size: var(--font-size-xs);
  font-weight: 600;
  line-height: 1.6;
}

.notices-list {
  display: flex;
  flex-direction: column;
}

.notice {
  --notice-color: var(--color-text-light);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-sm) var(--spacing-md);
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.notice:first-child {
  padding-top: 0;
}

.notice:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.notice-critical { --notice-color: var(--color-error); }
.notice-warning { --notice-color: var(--color-warning); }
.notice-info { --notice-color: var(--color-secondary); }

.notice-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--notice-color, var(--color-text-light));
}

.notice-dot-ok {
  --notice-color: var(--color-success);
}

.notice-content {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--spacing-sm);
  min-width: 12rem;
}

.notice-content strong {
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.notice-content span {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Dismiss on the left, the notice's own button last (bottom-right rule). */
.notice-buttons {
  display: flex;
  flex-shrink: 0;
  gap: var(--spacing-sm);
  margin-left: auto;
}

.notices-clear {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

/* After a CSV import that took the school to or past its licence limit. */
.import-licence-note {
  padding: var(--spacing-sm) var(--spacing-md);
  border-left: 3px solid var(--color-warning);
  background: var(--color-bg);
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

/* Super admin: the Organizations tab narrowed to one school by a notice. */
.sa-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* Role Badges */
.role-badge {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.role-badge.role-school_admin {
  background: #dbeafe;
  color: #1e40af;
}

.role-badge.role-teacher {
  background: #dcfce7;
  color: #166534;
}

.role-badge.role-student {
  background: #fef3c7;
  color: #92400e;
}

/* School admin: a deactivated user, greyed but still listed so they can be
   reactivated. The actions stay at full strength. */
.admin-table tr.user-deactivated td:not(.actions) {
  opacity: 0.55;
}

.user-status-badge {
  display: inline-block;
  margin-left: var(--spacing-xs);
  padding: 0 var(--spacing-xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* School admin, users list: someone who logs in with their school account */
.school-account-badge {
  display: inline-block;
  margin-left: var(--spacing-xs);
  padding: 0 var(--spacing-xs);
  border: 1px solid var(--color-secondary);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--color-secondary);
}

/* School admin, users list: narrowed by the new-teachers notice */
.user-list-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  background-color: var(--color-primary-light);
  font-size: var(--font-size-sm);
}

.org-login-links {
  margin-top: var(--spacing-md);
}

/* "Your school's login link" (school admin) and the same in the super admin's
   edit-organization window: one row per BRIN, the link and a copy button. */
.login-link-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin: var(--spacing-md) 0 0;
  padding: 0;
  list-style: none;
}

.login-link-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.login-link-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
}

/* Super admin, edit organization: the BRINs linked for the school login */
.org-brin-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin: 0 0 var(--spacing-sm);
  padding: 0;
  list-style: none;
}

.org-brin-list li {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 0 0 0 var(--spacing-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.org-brin-list li.text-muted {
  padding: 0;
  border: none;
}

.org-brin-add {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.org-brin-add input {
  max-width: 10rem;
  text-transform: uppercase;
}

.org-brin-preview {
  margin-top: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
}

.org-brin-preview p,
.org-brin-schools {
  margin: 0 0 var(--spacing-xs);
}

.org-brin-schools {
  padding-left: var(--spacing-md);
}

/* Section Header with Search */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.section-header h2 {
  margin: 0;
}

.search-box {
  flex: 0 0 300px;
}

.search-box input[type="search"] {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  transition: border-color var(--transition-base);
}

.search-box input[type="search"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Text Muted */
.text-muted {
  color: var(--color-text-muted);
  font-style: italic;
}

/* ================================
   Custom Modal System
   ================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
}

.modal-container {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 400px;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: var(--spacing-lg) var(--spacing-xl);
  border-bottom: 2px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.modal-header h2 {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
}

.modal-body {
  padding: var(--spacing-xl);
  overflow-y: auto;
  flex: 1;
}

.modal-body p {
  margin: 0 0 var(--spacing-md) 0;
  font-size: var(--font-size-base);
  color: var(--color-text);
  line-height: 1.6;
  white-space: pre-wrap;
}

.modal-input-label {
  display: block;
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-xs);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

.modal-input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: inherit;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  margin-top: var(--spacing-sm);
}

.modal-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-footer {
  padding: var(--spacing-lg) var(--spacing-xl);
  border-top: 2px solid var(--color-border);
  background: var(--color-bg-secondary);
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
}

.modal-footer .btn {
  min-width: 80px;
}

/* Responsive modal */
@media (max-width: 768px) {
  .modal-container {
    min-width: auto;
    width: 90%;
    margin: var(--spacing-md);
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-md);
  }
}

/* ================================
   Consent Popup
   ================================ */

.consent-popup-overlay[hidden] {
  display: none;
}

.consent-popup-body p {
  margin: 0 0 var(--spacing-md) 0;
}

.consent-popup-list {
  list-style: none;
  padding: 0;
  margin: var(--spacing-md) 0;
}

.consent-popup-list li {
  padding: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-xs);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-primary);
}

.consent-popup-list .consent-popup-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

.consent-popup-list .consent-popup-link:hover {
  text-decoration: underline;
}

.consent-popup-note {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  font-style: italic;
}

.consent-error {
  color: var(--color-error);
  font-size: var(--font-size-sm);
  margin-top: var(--spacing-sm);
}

/* ============================================
   Typing Speed Distribution Chart
   ============================================ */

.velocity-chart-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  width: 100%;
}

/* The toolbar and the legend bring their own 0.5rem bottom margin, which the
   container's flex gap added 1.5rem to: two rows of chart controls sat 2rem
   apart, where the Review tab's toolbar sits 0.5rem above its document. The
   gap is the row spacing now, so those margins go, and the separation between
   the two panels below is restored on the table itself. */
.velocity-chart-container .chart-toolbar,
.velocity-chart-container .velocity-legend {
  margin-bottom: 0;
}

.velocity-chart-container .velocity-stats-table {
  margin-top: var(--spacing-md);
}

.velocity-chart-container .chart-wrapper {
  height: 500px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.velocity-stats-table {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
}

.velocity-stats-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.velocity-stats-table thead {
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
}

.velocity-stats-table th {
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.velocity-stats-table td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.velocity-stats-table tbody tr:last-child td {
  border-bottom: none;
}

.velocity-stats-table tbody tr:hover {
  background: var(--color-bg);
}

.velocity-stats-table .color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: var(--spacing-sm);
  vertical-align: middle;
  border: 2px solid currentColor;
}

.velocity-stats-table td:nth-child(2),
.velocity-stats-table td:nth-child(3) {
  font-family: var(--font-family-mono);
  color: var(--color-primary);
}

.velocity-stats-table td:nth-child(4) {
  font-family: var(--font-family-mono);
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.velocity-stats-table td:nth-child(5) {
  color: var(--color-text-muted);
  text-align: center;
}

/* Responsive table */
@media (max-width: 768px) {
  .velocity-chart-container .chart-wrapper {
    height: 400px;
    padding: var(--spacing-md);
  }

  .velocity-stats-table {
    padding: var(--spacing-md);
  }

  .velocity-stats-table table {
    font-size: 0.75rem;
  }

  .velocity-stats-table th,
  .velocity-stats-table td {
    padding: var(--spacing-sm);
  }
}

/* ============================================
   Authorship Visualization
   ============================================ */

.authorship-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.authorship-legend {
  display: flex;
  gap: var(--spacing-lg);
  flex-wrap: wrap;
  align-items: center;
}

.authorship-legend-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text);
}

.authorship-legend-color {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
  border: 2px solid currentColor;
}

.authorship-legend-name {
  font-weight: 500;
}

.authorship-legend-count {
  color: var(--color-text-muted);
  font-family: var(--font-family-mono);
  font-size: 0.85rem;
}

.authorship-viewer {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  min-height: 400px;
  max-height: 800px;
  overflow-y: auto;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.8;
  color: var(--color-text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.authorship-viewer.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-style: italic;
}

.authorship-char {
  position: relative;
  border-bottom: 2px solid;
  border-bottom-color: transparent;
  transition: all 0.2s ease;
}

.authorship-char:hover {
  border-bottom-width: 3px;
  z-index: 10;
  filter: brightness(0.85);
}

/* Preserve formatting */
.authorship-viewer h1,
.authorship-viewer h2,
.authorship-viewer h3 {
  font-family: var(--font-family-heading);
  font-weight: 600;
  margin: var(--spacing-lg) 0 var(--spacing-md) 0;
  line-height: 1.4;
}

.authorship-viewer h1 {
  font-size: var(--font-size-2xl);
}

.authorship-viewer h2 {
  font-size: var(--font-size-xl);
}

.authorship-viewer h3 {
  font-size: var(--font-size-lg);
}

.authorship-viewer p {
  margin: var(--spacing-md) 0;
}

.authorship-viewer ul,
.authorship-viewer ol {
  margin: var(--spacing-md) 0;
  padding-left: var(--spacing-xl);
}

.authorship-viewer li {
  margin: var(--spacing-sm) 0;
}

.authorship-viewer strong {
  font-weight: 600;
}

.authorship-viewer em {
  font-style: italic;
}

.authorship-viewer u {
  text-decoration: underline;
}

/* Responsive authorship */
@media (max-width: 768px) {
  .authorship-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .authorship-legend {
    width: 100%;
  }

  .authorship-viewer {
    padding: var(--spacing-md);
    font-size: var(--font-size-sm);
  }
}

/* ================================
   GDPR Consent Notice Styles
   ================================ */
.consent-notice {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md);
  background: var(--color-surface-secondary);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--border-radius);
}

.consent-title {
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 var(--spacing-sm) 0;
  font-size: var(--font-size-base);
}

.consent-list {
  margin: var(--spacing-sm) 0;
  padding-left: var(--spacing-lg);
  list-style-type: disc;
}

.consent-list li {
  margin: var(--spacing-xs) 0;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

.consent-required {
  margin: var(--spacing-sm) 0 0 0;
  font-size: var(--font-size-sm);
  color: var(--color-warning);
  font-weight: 500;
  font-style: italic;
}

.consent-notice a {
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}

.consent-notice a:hover {
  color: var(--color-primary-dark);
}

/* Login page consent notice: fine print under the card. One muted line, then
   the three documents as plain underlined links with space between them; a
   separator would start the next line wherever the links wrap. */
.consent-notice-login {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
}

.consent-notice-login .consent-title {
  font-size: var(--font-size-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  margin: 0 0 var(--spacing-xs) 0;
}

.consent-notice-login .consent-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-xs) var(--spacing-md);
  list-style: none;
  padding: 0;
  margin: 0;
}

.consent-notice-login .consent-list li {
  font-size: var(--font-size-xs);
  margin: 0;
  line-height: 1.5;
}

.consent-notice-login .consent-list li .legal-link {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-decoration-color: var(--color-border);
  text-underline-offset: 2px;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

.consent-notice-login .consent-list li .legal-link:hover {
  color: var(--color-primary);
  text-decoration-color: currentColor;
}

/* Legal document links in consent notice */
.legal-link {
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}

.legal-link:hover {
  color: var(--color-primary-dark);
}

/* ================================
   Legal Document Viewer Styles
   ================================ */
.legal-document-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--spacing-lg);
}

.legal-document-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.legal-document-content {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  padding: var(--spacing-xl);
  margin-top: var(--spacing-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  line-height: 1.8;
  font-size: var(--font-size-base);
}

.legal-document-content h1 {
  font-size: 2rem;
  margin-bottom: var(--spacing-lg);
  color: var(--color-text);
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: var(--spacing-sm);
}

.legal-document-content h2 {
  font-size: 1.5rem;
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
  color: var(--color-text);
}

.legal-document-content h3 {
  font-size: 1.25rem;
  margin-top: var(--spacing-lg);
  margin-bottom: var(--spacing-sm);
  color: var(--color-text);
}

.legal-document-content p {
  margin-bottom: var(--spacing-md);
  color: var(--color-text-secondary);
}

.legal-document-content ul,
.legal-document-content ol {
  margin-left: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

.legal-document-content li {
  margin-bottom: var(--spacing-xs);
  color: var(--color-text-secondary);
}

.legal-document-content strong {
  color: var(--color-text);
  font-weight: 600;
}

.legal-document-content a {
  color: var(--color-primary);
  text-decoration: underline;
}

.legal-document-content a:hover {
  color: var(--color-primary-dark);
}

.legal-document-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--spacing-xl) 0;
}

.legal-document-content code {
  background: var(--color-surface-secondary);
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

/* Horizontal-scroll wrapper (added around every table by legal.js) so wide
   tables never push past the "paper" body — they scroll within it instead. */
.legal-document-content .table-scroll {
  margin: 1.5rem 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
}

.legal-document-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
  border-radius: var(--border-radius);
  overflow: hidden;
  font-size: 0.925rem;
}

/* Fallback margin for any table not wrapped (e.g. if JS hasn't run yet). */
.legal-document-content > table {
  margin: 1.5rem 0;
  border: 1px solid var(--color-border);
}

.legal-document-content th,
.legal-document-content td {
  border-bottom: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  padding: 1rem 1.25rem;
  text-align: left;
  vertical-align: top;
  line-height: 1.6;
  color: var(--color-text-secondary);
  /* Let long content wrap instead of forcing the column wider than the page. */
  overflow-wrap: break-word;
  word-break: break-word;
}

.legal-document-content th:last-child,
.legal-document-content td:last-child {
  border-right: none;
}

.legal-document-content tr:last-child td {
  border-bottom: none;
}

.legal-document-content th {
  background: var(--color-surface-secondary);
  font-weight: 600;
  color: var(--color-text);
}

.legal-document-content tr:nth-child(even) td {
  background: var(--color-surface-secondary);
}

/* ===========================================
   Account Popup Styles
   =========================================== */

.account-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.account-popup {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: accountPopupSlideIn 0.3s ease-out;
}

@keyframes accountPopupSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.account-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
}

.account-popup-header h2 {
  margin: 0;
  font-size: var(--font-size-xl);
  font-family: var(--font-family-heading);
  color: var(--color-text);
}

.account-close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.account-close-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.account-popup-body {
  padding: var(--spacing-lg);
}

.account-section {
  margin-bottom: var(--spacing-xl);
}

.account-section:last-child {
  margin-bottom: 0;
}

.account-section h3 {
  margin: 0 0 var(--spacing-md) 0;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  font-family: var(--font-family);
}

.account-section-description {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--spacing-md) 0;
  line-height: 1.5;
}

.account-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.account-buttons .btn {
  justify-content: center;
  display: flex;
  align-items: center;
}

.btn-block {
  width: 100%;
}

.btn-danger {
  background: var(--color-error);
  color: white;
  border: none;
}

.btn-danger:hover {
  background: #b34a3a;
}

/* Responsive */
@media (max-width: 600px) {
  .account-popup {
    max-width: 100%;
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* ===========================================
   Privacy Requests Styles
   =========================================== */

.gdpr-requests-section {
  margin-top: var(--spacing-2xl);
}

/* The requests table is wider than a phone; let it scroll inside its card
   instead of pushing the whole page sideways. */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.privacy-requests-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

.summary-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  text-align: center;
}

.summary-stat .stat-value {
  display: block;
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
}

.summary-stat .stat-label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--spacing-sm);
}

.privacy-requests-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
}

.privacy-requests-table thead {
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
}

.privacy-requests-table th {
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.privacy-requests-table td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
}

.privacy-request-row.deadline-critical {
  background: #fff5f5;
  border-left: 4px solid #c85a4a;
}

.privacy-request-row.deadline-warning {
  background: #fffaf0;
  border-left: 4px solid #d4934a;
}

.privacy-request-row.deadline-overdue {
  background: #ffe0e0;
  border-left: 4px solid #b34a3a;
  font-weight: 500;
}

.privacy-request-row.deadline-ok {
  border-left: 4px solid transparent;
}

.user-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-cell strong {
  color: var(--color-text);
}

.user-cell small {
  color: var(--color-text-muted);
  font-size: 0.85em;
}

.request-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.request-type-badge.access {
  background: #e6f4ff;
  color: #0056b3;
}

.request-type-badge.erasure {
  background: #ffe0e0;
  color: #c85a4a;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.status-pending {
  background: #fff9e6;
  color: #d4934a;
}

.status-badge.status-in_progress {
  background: #e6f4ff;
  color: #0056b3;
}

.status-badge.status-completed {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-badge.status-rejected {
  background: #ffe0e0;
  color: #c85a4a;
}

.deadline-info {
  font-size: var(--font-size-sm);
}

.deadline-info.deadline-critical,
.deadline-info.deadline-overdue {
  color: #c85a4a;
  font-weight: 600;
}

.deadline-info.deadline-warning {
  color: #d4934a;
  font-weight: 600;
}

.action-buttons {
  display: flex;
  gap: var(--spacing-sm);
}

.btn-approve {
  color: #2e7d32;
  background: #e8f5e9;
}

.btn-approve:hover {
  background: #c8e6c9;
}

.btn-reject {
  color: #c85a4a;
  background: #ffe0e0;
}

.btn-reject:hover {
  background: #ffcccc;
}

.text-muted {
  color: var(--color-text-muted);
}

.empty-state {
  text-align: center;
  padding: var(--spacing-2xl);
  color: var(--color-text-muted);
}

.empty-state svg {
  margin-bottom: var(--spacing-md);
}

.empty-state p {
  font-size: var(--font-size-lg);
  margin: var(--spacing-md) 0;
}

.empty-state small {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

/* Authorship Header Flexbox */
.authorship-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

/* Maintenance Tab Styles */

.maintenance-history {
  margin-top: 1rem;
}

.maintenance-history .note {
  color: var(--text-secondary);
  font-style: italic;
}

/* ================================
   PRO FEATURES - Report Builder
   ================================ */

/* Pro feature badge */
.pro-feature-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: #c0714a;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: var(--spacing-sm);
}

/* Pro toolbar button styling */
.format-btn-pro {
  position: relative;
}

.format-btn-pro::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 6px;
  height: 6px;
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  border-radius: 50%;
}

/* Table Picker - uses same pattern as heading dropdown */
.table-picker {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
}

.format-dropdown.open .table-picker {
  display: block;
}

/* Pro dropdown wrapper */
.format-dropdown-pro {
  display: inline-block;
}

.table-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 20px);
  grid-template-rows: repeat(10, 20px);
  gap: 2px;
}

.table-picker-cell {
  width: 20px;
  height: 20px;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  background: var(--color-bg);
  cursor: pointer;
  transition: background-color 0.1s, border-color 0.1s;
}

.table-picker-cell:hover,
.table-picker-cell.selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.table-picker-label {
  text-align: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Image Toolbar */
.image-toolbar,
.table-toolbar {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

/* Ensure hidden attribute works on toolbars */
.image-toolbar[hidden],
.table-toolbar[hidden],
.table-picker[hidden] {
  display: none !important;
}

.image-toolbar-btn,
.table-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--color-text);
  transition: background-color 0.15s;
}

.image-toolbar-btn:hover,
.table-toolbar-btn:hover {
  background: var(--color-primary-light);
}

.image-toolbar-btn.active,
.table-toolbar-btn.active {
  background: var(--color-primary);
  color: white;
}

.image-toolbar-delete:hover,
.table-toolbar-delete:hover {
  background: #fee2e2;
  color: #dc2626;
}

.image-toolbar-size-btn {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.image-toolbar-divider,
.table-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 4px;
}

/* Scroll to Top Button */
.scroll-to-top-btn {
  position: fixed;
  left: 24px;
  top: 100px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform 0.15s, background-color 0.15s, opacity 0.2s;
  z-index: 999;
  opacity: 0.9;
}

.scroll-to-top-btn:hover {
  background: var(--color-primary-light);
  transform: translateY(-2px);
  opacity: 1;
}

.scroll-to-top-btn:active {
  transform: translateY(0);
}

/* Editor Images */
.editor-image {
  max-width: 100%;
  height: auto;
  cursor: pointer;
  border-radius: 4px;
  transition: box-shadow 0.15s;
}

.editor-image:hover {
  box-shadow: 0 0 0 2px var(--primary-color-light);
}

.editor-image.selected {
  box-shadow: 0 0 0 2px var(--primary-color);
  outline: none;
}

/* Image resize handles */
.image-resize-container {
  position: relative;
  display: inline-block;
}

.image-resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--primary-color);
  border: 2px solid white;
  border-radius: 2px;
  cursor: nwse-resize;
}

.image-resize-handle.top-left {
  top: -5px;
  left: -5px;
  cursor: nwse-resize;
}

.image-resize-handle.top-right {
  top: -5px;
  right: -5px;
  cursor: nesw-resize;
}

.image-resize-handle.bottom-left {
  bottom: -5px;
  left: -5px;
  cursor: nesw-resize;
}

.image-resize-handle.bottom-right {
  bottom: -5px;
  right: -5px;
  cursor: nwse-resize;
}

/* Image alignment */
.editor-image[style*="float: left"] {
  margin-right: 1em;
  margin-bottom: 0.5em;
}

.editor-image[style*="float: right"] {
  margin-left: 1em;
  margin-bottom: 0.5em;
}

.editor-image[style*="margin-left: auto"][style*="margin-right: auto"] {
  display: block;
}

/* Editor Tables */
.editor-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  table-layout: fixed;
}

.editor-table th,
.editor-table td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  min-width: 50px;
}

.editor-table th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.editor-table tr:hover {
  background: rgba(var(--primary-color-rgb), 0.05);
}

.editor-table td:focus,
.editor-table th:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

/* Table selected state */
.editor-table.selected {
  box-shadow: 0 0 0 2px var(--primary-color);
}

/* Table column resize handle */
.table-col-resize {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
}

.table-col-resize:hover,
.table-col-resize.active {
  background: var(--primary-color);
}

/* Horizontal rule in editor */
.editor-hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.5em 0;
}

/* Superscript and subscript */
.page-content sup,
.page-content sub {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

.page-content sup {
  top: -0.5em;
}

.page-content sub {
  bottom: -0.25em;
}

/* Text highlight (mark) */
.page-content mark {
  background: #fef08a;
  padding: 0 2px;
  border-radius: 2px;
}

/* Image upload dropzone indicator */
.page-content.drag-over {
  background: rgba(var(--primary-color-rgb), 0.1);
  border: 2px dashed var(--primary-color);
}

/* Image loading placeholder */
.image-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
  border-radius: 4px;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.image-loading::before {
  content: '';
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Image Upload Progress Dropdown */
.image-upload-dropdown {
  position: fixed;
  z-index: 10000;
  min-width: 280px;
  max-width: 400px;

  /* Glassmorphic styling matching formatting toolbar */
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(59, 47, 42, 0.1),
              0 0 0 1px rgba(255, 255, 255, 0.1) inset;

  padding: var(--spacing-md);
  animation: fadeIn 0.2s ease;

  /* Prevent interaction */
  pointer-events: none;
}

/* Override hidden attribute when we want to show it */
.image-upload-dropdown:not([hidden]) {
  display: block !important;
}

.upload-progress-content {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.upload-status-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-status-icon .spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Success state */
.upload-status-icon .checkmark {
  width: 24px;
  height: 24px;
  color: var(--color-success);
}

/* Error state */
.upload-status-icon .error-icon {
  width: 24px;
  height: 24px;
  color: var(--color-error);
}

.upload-progress-text {
  flex: 1;
  min-width: 0;
}

.upload-stage {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 2px;
}

.upload-details {
  font-size: 12px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: var(--color-primary);
  transition: width 0.3s ease;
  width: 0%;
}

/* Error state styling */
.image-upload-dropdown.error {
  background: rgba(254, 226, 226, 0.9);
  border-color: rgba(220, 38, 38, 0.3);
}

.image-upload-dropdown.error .upload-progress-bar {
  background: rgba(220, 38, 38, 0.2);
}

.image-upload-dropdown.error .upload-progress-fill {
  background: var(--color-error);
}

/* Success state styling */
.image-upload-dropdown.success {
  background: rgba(220, 252, 231, 0.9);
  border-color: rgba(107, 155, 110, 0.3);
}

/* Pro feature locked state */
.pro-locked.format-btn-pro {
  opacity: 0.4;
  cursor: not-allowed;
}

/* For dropdown containers, only dim the inner button */
.format-dropdown-pro.pro-locked {
  cursor: not-allowed;
}

.format-dropdown-pro.pro-locked .format-btn-pro {
  opacity: 0.4;
}

.pro-locked {
  position: relative;
}

/* Re-enable pointer events so click shows upgrade message */
.pro-locked.format-btn-pro,
.format-dropdown-pro.pro-locked {
  pointer-events: auto;
}

/* Keep the dot but make it grey when locked */
.pro-locked.format-btn-pro::after,
.pro-locked .format-btn-pro::after {
  background: #9ca3af;
}

.format-btn-pro[disabled]:hover,
.pro-locked .format-btn-pro:hover {
  background: transparent;
}

/* Tooltip for locked pro features */
.pro-locked::before {
  content: 'Pro feature';
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: #1f2937;
  color: white;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  z-index: 10001;
  pointer-events: none;
}

.pro-locked:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Status badges: submission and privacy-request states */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.status-healthy { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
.status-badge.status-moderate { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.status-badge.status-at_risk { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.status-badge.status-inactive { background: rgba(107, 114, 128, 0.1); color: #6b7280; }

.empty-state.success {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  text-align: center;
}

/* Super-admin tab bar on narrow screens */
@media (max-width: 1024px) {
  .admin-nav {
    flex-wrap: wrap;
  }

  .tab-button {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
  }
}

/* ===== Create Section ===== */

.create-section-title {
  margin: 0 0 var(--spacing-lg);
  font-size: var(--font-size-xl);
  color: var(--color-text);
}

.create-section-subtitle {
  margin: 0 0 var(--spacing-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.create-type-back {
  margin-bottom: var(--spacing-md);
}

.coding-assignment-notice {
  margin: var(--spacing-sm) 0 var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: #1e40af;
  line-height: 1.5;
}

.coding-assignment-notice strong {
  display: block;
  margin-bottom: 4px;
}

.coding-assignment-notice p {
  margin: 0;
}

.coding-assignment-notice .coding-notice-limits {
  margin-top: 4px;
}

/* ===== Assignment Type Picker Cards ===== */

.assignment-type-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.assignment-type-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-xs);
  padding: var(--spacing-lg);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.assignment-type-card:hover:not(:disabled) {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.assignment-type-card--disabled,
.assignment-type-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--color-bg);
}

.type-card-icon {
  display: flex;
  align-items: center;
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
}

.type-card-label {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
}

.type-card-desc {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.coming-soon-badge {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  padding: 2px 8px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pro-badge-card {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  padding: 2px 8px;
  background: #1d4ed8;
  color: white;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

/* ===== Assignment Info Card (Submissions Header) ===== */

/* The 3rem below is the overview's section break, not a value of its own: there
   the create card stands 3rem clear of the assignment list, and this card stands
   in the same place on the page that follows it. At 2rem the same step down the
   page changed size depending on which of the two pages you were on. It sets the
   gap on its own — the list below collapses its smaller top margin into it. */
.assignment-info-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg) var(--spacing-xl);
  margin-bottom: var(--spacing-2xl);
  box-shadow: var(--shadow-sm);
}

.assignment-info-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.assignment-info-card-titles {
  flex: 1;
  min-width: 0;
}

.assignment-info-title {
  margin: 0 0 var(--spacing-xs);
  font-size: var(--font-size-2xl);
  color: var(--color-text);
  line-height: 1.2;
}

.assignment-info-desc {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
}

.assignment-type-badge {
  flex-shrink: 0;
  display: inline-block;
  padding: 4px 12px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: 9999px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
}

.assignment-info-stats {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--spacing-md);
  padding: var(--spacing-md) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--spacing-md);
}

.assignment-info-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-xs);
}

.assignment-info-stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.assignment-info-stat-value {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
}

.deadline-relative-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--color-bg-subtle, #f3f4f6);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.deadline-relative-pill--overdue {
  background: #fef2f2;
  color: #b91c1c;
}

.assignment-info-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .assignment-type-cards {
    grid-template-columns: 1fr;
  }

  .assignment-info-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Notebook Editor ──────────────────────────────────────────────────────── */

.notebook-main {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
  background: var(--color-bg);
}

.notebook-container {
  max-width: 860px;
  margin: 0 auto;
}

.nb-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-sm);
}

.nb-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--spacing-sm);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.nb-block-type-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.nb-block-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nb-btn {
  padding: 2px 7px;
  font-size: 0.78rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s;
}

.nb-btn:hover:not(:disabled) {
  background: var(--color-bg);
  color: var(--color-text);
}

.nb-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nb-btn-run {
  padding: 2px 10px;
  font-size: 0.78rem;
  border: 1px solid rgba(0,0,0,0.25);
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.06);
  color: var(--color-text);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.nb-btn-run:hover:not(:disabled) {
  background: rgba(0,0,0,0.15);
}

.nb-btn-run--running {
  opacity: 0.6;
  cursor: not-allowed;
}

.nb-btn-reset:hover:not(:disabled) {
  color: #c2410c;
  border-color: #c2410c;
  background: #fff7ed;
}

.nb-delete-confirm {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nb-delete-confirm-label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  font-family: 'Roboto Mono', monospace;
}

.nb-btn-delete-confirm--yes {
  border-color: #dc2626;
  color: #dc2626;
}

.nb-btn-delete-confirm--yes:hover {
  background: #dc2626;
  color: #fff;
}

.nb-block-content {
  display: block;
  width: 100%;
  min-height: 80px;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-surface);
  font-family: var(--font-body);
  box-sizing: border-box;
  field-sizing: content;
}

.nb-block-content--code {
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  background: #1e1e2e;
  color: #cdd6f4;
  min-height: 100px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.nb-block-output {
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-size: 0.82rem;
  background: #f8f9fa;
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
  min-height: 24px;
}

.nb-block-output--error {
  background: #fff5f5;
  color: #c0392b;
}

.nb-output-text {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  white-space: pre-wrap;
  word-break: break-all;
}

.nb-output-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin-top: var(--spacing-sm);
  border-radius: var(--radius-sm);
}

.nb-add-block-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 4px 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.nb-block:hover + .nb-add-block-row,
.nb-add-block-row:hover,
#notebook-add-block-top {
  opacity: 1;
}

#notebook-add-block-top {
  margin-bottom: var(--spacing-sm);
}

.nb-add-btn {
  padding: 3px 12px;
  font-size: 0.78rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.nb-add-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ── Notebook Analysis View ─────────────────────────────────────────────── */

/* Tab buttons: same underline style as .analysis-tab-btn */
.nb-analysis-tab-btn {
  padding: 0 var(--spacing-md);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.nb-analysis-tab-btn:hover {
  color: var(--color-text);
}

.nb-analysis-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Tab panels: identical to .analysis-tab-panel */
.nb-analysis-tab-panel {
  padding: var(--spacing-lg);
}

.nb-analysis-tab-panel:not(.active) {
  display: none;
}

/* Time travel panel: flex column so controls sit above block viewer */
#nb-tab-time-travel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 400px;
}

/* Playback buttons: identical to .ttc-playback-btn */
.nb-ttc-playback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.nb-ttc-playback-btn:hover {
  color: var(--color-text);
  background: var(--color-border);
}

.nb-ttc-playback-btn.active {
  background: var(--color-border);
  color: var(--color-text);
}

/* Block viewer (replaces .document-viewer) */
.nb-blocks-viewer {
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  min-height: 600px;
  max-height: 800px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
  flex: 1;
  min-width: 0;
}

.nb-blocks-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

/* Individual block cards */
.nb-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.nb-block--changed {
  border-left: 3px solid #e67e22;
}

.nb-block--added {
  border-left: 3px solid #27ae60;
}

.nb-block-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 5px var(--spacing-sm);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

/* Change badges */
.nb-change-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
}

.nb-change-badge--changed {
  background: #fef3e2;
  color: #e67e22;
}

.nb-change-badge--added {
  background: #eafaf1;
  color: #27ae60;
}

/* Code block (dark background) */
.nb-code-block {
  margin: 0;
  padding: var(--spacing-sm) var(--spacing-md);
  overflow-x: auto;
  background: #1e1e2e;
}

.nb-code-block code {
  font-family: 'Roboto Mono', 'Courier New', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #cdd6f4;
  white-space: pre;
}

/* Text block */
.nb-text-block {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text);
  white-space: pre-wrap;
}

/* Interactive tab */
.nb-interactive-notice {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--spacing-md);
}

#nb-interactive-blocks {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.nb-int-run-row {
  padding: 6px var(--spacing-sm);
  border-top: 1px solid var(--color-border);
}

.nb-int-run-btn {
  font-size: 0.8rem;
}

/* ── Type badge coding variant ────────────────────────────────────────────── */

.assignment-type-badge--coding {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #1d4ed8;
}

/* Smaller pill used in the assignment list (between title and description) */
.assignment-type-badge--list {
  display: inline-block;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.assignment-type-card--coding .type-card-icon {
  color: #1d4ed8;
}

/* Language-specific block header colors */
.nb-block--lang-javascript .nb-block-header {
  background: #fef9c3;
  border-bottom-color: #ca8a04;
}
.nb-block--lang-javascript .nb-block-type-label {
  color: #854d0e;
}
.nb-block--lang-sql .nb-block-header {
  background: #dcfce7;
  border-bottom-color: #16a34a;
}
.nb-block--lang-sql .nb-block-type-label {
  color: #166534;
}

/* Template notebook container in assignment creation form */
.template-notebook-container {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--spacing-sm);
  max-height: 500px;
  overflow-y: auto;
}

.form-hint-inline {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: normal;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 4px 0 0;
}

/* ===========================================================================
   Super-admin console (#admin-dashboard-view)

   One card style (.service-card) and one spacing rule (.sa-stack and .sa-grid)
   for every tab. These rules used to be spread over four parts of this file,
   with the same classes defined two and three times and a block scoped to an
   id that does not exist, so cards butted into each other and charts squashed.
   Everything here is scoped to the view, because some of its class names
   (.section-header, .stat-label, .empty-state) are shared with other screens.

   Charts fill a fixed-height .sa-chart box (maintainAspectRatio: false in
   admin.js), so a card never grows empty space under its chart.
   =========================================================================== */

/* The security panels and maintenance results toggle `hidden` while also
   having a display of their own; `hidden` has to win. */
#admin-dashboard-view [hidden] {
  display: none !important;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

#admin-dashboard-view .sa-stack {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

#admin-dashboard-view .sa-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--spacing-lg);
}

#admin-dashboard-view .sa-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#admin-dashboard-view .sa-grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: var(--spacing-md);
}

@media (max-width: 900px) {
  #admin-dashboard-view .sa-grid:not(.sa-grid-auto) {
    grid-template-columns: minmax(0, 1fr);
  }
}

#admin-dashboard-view .section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm) var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

#admin-dashboard-view .section-header h2 {
  margin: 0;
}

#admin-dashboard-view .section-description {
  margin: 0 0 var(--spacing-lg);
  font-size: var(--font-size-sm);
}

#admin-dashboard-view .sa-stack > .section-description {
  margin: 0;
}

/* Actions sit bottom-right of their container (CLAUDE.md). */
#admin-dashboard-view .sa-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
}

/* ── Cards ──────────────────────────────────────────────────────────────── */

#admin-dashboard-view .service-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--spacing-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

#admin-dashboard-view .service-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-xs) var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--color-border);
}

#admin-dashboard-view .service-card-header strong {
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* An organization's name is a proper noun: no capitals transform. A long
   name wraps beside its dot instead of dropping below it. */
#admin-dashboard-view .sa-org-card .service-card-header {
  flex-wrap: nowrap;
  align-items: flex-start;
}

#admin-dashboard-view .sa-org-card .service-card-header .sa-dot {
  margin-top: 0.5em;
}

#admin-dashboard-view .sa-org-card .service-card-header strong {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--font-size-base);
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-text);
}

#admin-dashboard-view .sa-org-card .service-desc {
  flex: 0 0 auto;
  margin-top: 0.2em;
}

#admin-dashboard-view .sa-org-card .service-stat-label {
  flex-basis: 10rem;
}

#admin-dashboard-view .service-desc {
  margin-left: auto;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: right;
}

#admin-dashboard-view .sa-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--color-text-light));
}

#admin-dashboard-view .service-card-stats {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-sm);
}

#admin-dashboard-view .service-stat-row {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-md);
  font-size: var(--font-size-sm);
}

#admin-dashboard-view .service-stat-label {
  flex: 0 0 8rem;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

#admin-dashboard-view .service-stat-muted {
  font-size: var(--font-size-xs);
  font-weight: 400;
  color: var(--color-text-muted);
}

#admin-dashboard-view .service-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-xs) var(--spacing-md);
  margin-top: auto;
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--color-border);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Calls and failures per period on a service card. */
#admin-dashboard-view .sa-mini-table {
  width: 100%;
  margin-bottom: var(--spacing-sm);
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

#admin-dashboard-view .sa-mini-table th,
#admin-dashboard-view .sa-mini-table td {
  padding: 2px 0;
  text-align: right;
  white-space: nowrap;
}

#admin-dashboard-view .sa-mini-table thead th {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-muted);
}

#admin-dashboard-view .sa-mini-table tbody th {
  font-size: var(--font-size-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  text-align: left;
}

#admin-dashboard-view .sa-mini-table td {
  width: 22%;
  font-weight: 600;
}

#admin-dashboard-view .text-danger { color: var(--color-error); }
#admin-dashboard-view .text-warning { color: var(--color-warning); }

#admin-dashboard-view .empty-state {
  padding: var(--spacing-lg) var(--spacing-md);
  font-size: var(--font-size-sm);
}

#admin-dashboard-view .empty-state.success {
  color: #15803d;
  background: rgba(34, 197, 94, 0.08);
  border-radius: var(--radius-md);
}

/* ── Charts ─────────────────────────────────────────────────────────────── */

#admin-dashboard-view .sa-chart {
  position: relative;
  min-width: 0;
  height: 220px;
}

#admin-dashboard-view .sa-chart-tall {
  height: 300px;
}

/* ── Overview ───────────────────────────────────────────────────────────── */

/* Action items are the notices panel: its rules are with .notice, shared with
   the school admin's panel. Only the count badge sits in this card's header. */
#admin-dashboard-view #action-items-card .service-card-header .notices-count {
  margin-left: var(--spacing-xs);
}

#admin-dashboard-view .active-user-card,
#admin-dashboard-view .quick-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm) var(--spacing-md);
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

#admin-dashboard-view .active-user-card:first-child,
#admin-dashboard-view .quick-stat:first-child {
  padding-top: 0;
}

#admin-dashboard-view .active-user-card:last-child,
#admin-dashboard-view .quick-stat:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

#admin-dashboard-view .metric-label,
#admin-dashboard-view .quick-stat .stat-label {
  flex-shrink: 0;
  font-size: var(--font-size-sm);
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  opacity: 1;
  color: var(--color-text-muted);
}

#admin-dashboard-view .metric-value,
#admin-dashboard-view .quick-stat .stat-value {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text);
}

#admin-dashboard-view .metric-right {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0 var(--spacing-sm);
  min-width: 0;
  text-align: right;
}

#admin-dashboard-view .active-now-breakdown {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

#admin-dashboard-view .metric-change {
  min-width: 3.5em;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-align: right;
}

#admin-dashboard-view .change-up { color: var(--color-success); }
#admin-dashboard-view .change-down { color: var(--color-error); }
#admin-dashboard-view .change-neutral { color: var(--color-text-muted); }

/* Label, bytes, bar, share: a grid, so the bars line up whatever the label. */
#admin-dashboard-view .sa-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 5.5em minmax(3rem, 1fr) 2.5em;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-sm);
}

#admin-dashboard-view .sa-bar-label {
  overflow: hidden;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#admin-dashboard-view .sa-bar-row strong,
#admin-dashboard-view .sa-bar-row .service-stat-muted {
  text-align: right;
  white-space: nowrap;
}

#admin-dashboard-view .storage-pct-bar {
  height: 4px;
  overflow: hidden;
  background: var(--color-border);
  border-radius: 2px;
}

#admin-dashboard-view .storage-pct-bar > span {
  display: block;
  height: 100%;
  border-radius: 2px;
}

/* ── Organizations ──────────────────────────────────────────────────────── */

#admin-dashboard-view .sa-create-org {
  max-width: none;
}

#admin-dashboard-view .sa-form-fields {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 0 var(--spacing-lg);
}

#admin-dashboard-view .sa-create-org .form-group {
  margin-bottom: var(--spacing-md);
}

/* Inputs and the select the same height, side by side. */
#admin-dashboard-view .sa-create-org input,
#admin-dashboard-view .sa-create-org select {
  height: 2.875rem;
  padding: 0 0.75rem;
  line-height: normal;
}

#admin-dashboard-view .sa-create-org select {
  padding-right: 2.5rem;
}

@media (max-width: 760px) {
  #admin-dashboard-view .sa-form-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

#admin-dashboard-view .sa-org-storage {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

#admin-dashboard-view .sa-org-storage .storage-bar-mini {
  width: 96px;
  margin: 0;
  background: var(--color-border);
}

#admin-dashboard-view .sa-org-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

/* ── Integrity ──────────────────────────────────────────────────────────── */

#admin-dashboard-view .integrity-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
}

#admin-dashboard-view .integrity-view-toggle {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

#admin-dashboard-view .integrity-view-btn {
  padding: 6px 14px;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
}

#admin-dashboard-view .integrity-view-btn + .integrity-view-btn {
  border-left: 1px solid var(--color-border);
}

#admin-dashboard-view .integrity-view-btn.active {
  color: #fff;
  background: var(--color-primary);
}

#admin-dashboard-view .integrity-view-btn:hover:not(.active) {
  background: var(--color-bg);
}

#admin-dashboard-view .sa-headline {
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-lg) var(--spacing-md);
  text-align: center;
}

#admin-dashboard-view .headline-number {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-text);
}

#admin-dashboard-view .headline-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

#admin-dashboard-view .sa-trend {
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
}

/* ── Tables (integrity, services) ───────────────────────────────────────── */

#admin-dashboard-view .data-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#admin-dashboard-view .sa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

#admin-dashboard-view #cost-awareness-table .sa-table {
  min-width: 560px;
}

#admin-dashboard-view .sa-table th {
  padding: var(--spacing-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

#admin-dashboard-view .sa-table td {
  padding: var(--spacing-sm);
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}

#admin-dashboard-view .sa-table tr:last-child td {
  border-bottom: none;
}

#admin-dashboard-view .sa-table .num {
  text-align: right;
  white-space: nowrap;
}

#admin-dashboard-view .cost-awareness-section h3 {
  margin: 0 0 var(--spacing-sm);
  font-size: var(--font-size-lg);
}

/* ── Logs ───────────────────────────────────────────────────────────────── */

#admin-dashboard-view .log-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm) var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

#admin-dashboard-view .log-filters > .btn {
  margin-left: auto;
}

#admin-dashboard-view .filter-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

#admin-dashboard-view .filter-label {
  margin: 0;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
}

/* Global selects are full-width; these sit in a row. */
#admin-dashboard-view .form-select {
  width: auto;
  padding: 6px 2rem 6px 10px;
  font-size: var(--font-size-sm);
  background-color: var(--color-surface);
  background-position: right 0.6rem center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

#admin-dashboard-view .sa-hint {
  margin: 0 0 var(--spacing-xs);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

#admin-dashboard-view .log-entries-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 65vh;
  overflow-y: auto;
}

#admin-dashboard-view .log-entry {
  display: grid;
  grid-template-columns: 8px 13rem minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: var(--spacing-sm);
  padding: 6px 10px;
  font-size: var(--font-size-sm);
  line-height: 1.4;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

#admin-dashboard-view .log-entry:hover {
  background: var(--color-bg);
}

#admin-dashboard-view .log-entry:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

#admin-dashboard-view .log-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

#admin-dashboard-view .log-event-type {
  overflow: hidden;
  font-family: var(--font-family-mono);
  font-size: 11px;
  color: var(--color-text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#admin-dashboard-view .log-message-text {
  min-width: 0;
  overflow: hidden;
  color: var(--color-text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#admin-dashboard-view .log-user-text {
  max-width: 16rem;
  overflow: hidden;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#admin-dashboard-view .log-time-text {
  font-family: var(--font-family-mono);
  font-size: 11px;
  color: var(--color-text-light);
  white-space: nowrap;
}

#admin-dashboard-view .log-metadata {
  display: none;
  grid-column: 2 / -1;
  max-height: 240px;
  margin: var(--spacing-xs) 0 0;
  padding: var(--spacing-sm);
  overflow: auto;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  cursor: text;
}

#admin-dashboard-view .log-entry.is-expanded {
  align-items: start;
  background: var(--color-bg);
}

#admin-dashboard-view .log-entry.is-expanded .log-message-text,
#admin-dashboard-view .log-entry.is-expanded .log-event-type {
  overflow: visible;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#admin-dashboard-view .log-entry.is-expanded .log-metadata {
  display: block;
}

/* Phone: event and time on top, then the message, then who. */
@media (max-width: 760px) {
  #admin-dashboard-view .log-entry {
    grid-template-columns: 8px minmax(0, 1fr) auto;
    row-gap: 2px;
  }

  #admin-dashboard-view .log-time-text {
    grid-column: 3;
    grid-row: 1;
  }

  #admin-dashboard-view .log-message-text,
  #admin-dashboard-view .log-user-text {
    grid-column: 2 / -1;
  }

  #admin-dashboard-view .log-user-text {
    max-width: none;
    text-align: left;
  }

  #admin-dashboard-view .log-metadata {
    grid-column: 1 / -1;
  }
}

/* Security panels, under the log list */
#admin-dashboard-view #security-panels {
  margin-top: var(--spacing-lg);
}

#admin-dashboard-view .sa-ip-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--spacing-xs) 0;
  border-bottom: 1px solid var(--color-border);
}

#admin-dashboard-view .sa-ip-row:last-child {
  border-bottom: none;
}

#admin-dashboard-view .sa-ip-row code {
  padding: 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
  background: none;
  overflow-wrap: anywhere;
}

#admin-dashboard-view .sa-ip-row span {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

#admin-dashboard-view .sa-pattern-row {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-md);
  padding: var(--spacing-xs) 0;
  font-size: var(--font-size-sm);
}

#admin-dashboard-view .sa-pattern-severity {
  display: inline-flex;
  flex: 0 0 5rem;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ── Settings ───────────────────────────────────────────────────────────── */

#admin-dashboard-view .sa-task p {
  margin: 0 0 var(--spacing-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

#admin-dashboard-view .sa-task .sa-actions {
  margin-top: auto;
}

#admin-dashboard-view .maintenance-result {
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  border-radius: var(--radius-sm);
}

#admin-dashboard-view .maintenance-result.success {
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #10b981;
}

#admin-dashboard-view .maintenance-result.error {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #ef4444;
}

/* ===========================================================================
   Collaborative editor — table/image controls + analysis-view parity (Track C)
   =========================================================================== */

/* Tables & images in the teacher analysis/preview views, matching the editor */
.page-content table { border-collapse: collapse; margin: 0 0 0.5em; width: 100%; table-layout: fixed; }
.page-content th, .page-content td { border: 1px solid #ccc; padding: 4px 8px; vertical-align: top; }
.page-content th { background: #f5f5f5; font-weight: 600; }
.page-content img { max-width: 100%; height: auto; }
.document-pages .ProseMirror mark, .page-content mark {
  background-color: #fef08a; border-radius: 2px; padding: 0 1px;
}
/* TipTap resizable-column helper class (appears in saved HTML) */
.ProseMirror .column-resize-handle,
.page-content .column-resize-handle { display: none; }

/* Bubble menus (table & image floating controls) */
.collab-bubble-menu {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  max-width: 320px; box-sizing: border-box;
  background: #2d2a26; border-radius: 6px;
  padding: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.collab-bubble-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: #fff; border: none; border-radius: 4px;
  min-width: 28px; height: 28px; padding: 0 7px; font-size: 12px; line-height: 1;
  cursor: pointer;
}
.collab-bubble-btn-icon { padding: 0; }
.collab-bubble-btn svg { display: block; }
.collab-bubble-btn:hover { background: rgba(255,255,255,0.18); }
.collab-bubble-sep { width: 1px; align-self: stretch; margin: 2px 3px; background: rgba(255,255,255,0.18); }

/* Loading skeletons (shown only on a true cold load, never after a cached or
   optimistic render) — perceived speed: appears instantly, no blank flash. */
.skeleton-card {
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: var(--spacing-md); margin-bottom: var(--spacing-sm); background: var(--color-surface);
}
.skeleton-line {
  height: 12px; border-radius: 6px; margin: 8px 0;
  background: linear-gradient(90deg, #ececec 25%, #f5f5f5 37%, #ececec 63%);
  background-size: 400% 100%; animation: skeleton-shimmer 1.4s ease infinite;
}
.skeleton-line-title { height: 18px; width: 45%; }
.skeleton-line-text { width: 80%; }
.skeleton-line-short { width: 30%; }
@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) { .skeleton-line { animation: none; } }

/* Font family / size dropdown triggers show a glyph + chevron like the heading
   button (the two glyphs in the size button render as large + small "A"). */
.font-size-icon { font-weight: 700; line-height: 1; }
.font-size-icon .fs-lg { font-size: 14px; }
.font-size-icon .fs-sm { font-size: 9px; }
.font-family-icon { font-family: Georgia, 'Times New Roman', serif; font-weight: 700; font-size: 14px; line-height: 1; }

/* Toolbar: text colour swatch button (wraps a native colour input).
   Force the same 36px box and centred icon as the other buttons; the colour
   bar is absolutely positioned so it never affects the button's height. The
   `margin:0` overrides the global `label { margin-bottom }` that was pushing
   this label (it is a <label>) upward in the centred toolbar row. */
.color-btn {
  position: relative; flex: 0 0 auto; margin: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; box-sizing: border-box;
}
.color-btn svg { display: block; }
.color-btn .color-bar {
  position: absolute; left: 50%; bottom: 5px; transform: translateX(-50%);
  width: 18px; height: 3px; border-radius: 1px; background: #1a1a1a; pointer-events: none;
}
.color-btn input[type="color"] {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%;
  border: none; padding: 0; margin: 0; cursor: pointer;
}

/* Toolbar: highlight colour dropdown */
.highlight-menu { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px; min-width: 0; }
.hl-swatch {
  width: 22px; height: 22px; border: 1px solid rgba(0,0,0,0.18); border-radius: 4px;
  cursor: pointer; padding: 0; font-size: 12px; color: #555; background: #fff;
}
.hl-swatch:hover { transform: scale(1.08); }
.hl-swatch.hl-none { display: flex; align-items: center; justify-content: center; }

/* Find & replace panel — fixed near the top-right so it never collides with
   the bottom formatting toolbar. Hidden by default; only shown when the
   [hidden] attribute is removed (the bare `display:flex` previously beat the
   UA [hidden] rule, so it leaked onto the page on load and couldn't close). */
.find-replace-panel {
  position: fixed; top: 84px; right: 24px; z-index: 2000;
  background: #fff; border: 1px solid var(--color-border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18); padding: 8px;
  flex-direction: column; gap: 6px;
}
.find-replace-panel[hidden] { display: none; }
.find-replace-panel:not([hidden]) { display: flex; }
.find-replace-row { display: flex; align-items: center; gap: 4px; }
.find-replace-input {
  height: 30px; border: 1px solid var(--border-color, #d8d2c8); border-radius: 6px;
  padding: 0 8px; font-size: 13px; width: 160px;
}
.find-count { font-size: 12px; color: #777; min-width: 34px; text-align: center; }
.find-btn {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; white-space: nowrap;
  height: 30px; min-width: 30px; border: 1px solid var(--border-color, #d8d2c8); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 13px; line-height: 1; color: #2d2a26; padding: 0 8px;
  box-sizing: border-box;
}
.find-btn:hover { border-color: #c86a4a; }
.find-btn-text { width: auto; padding: 0 12px; }
.find-close { border: none; color: #999; }

/* Find & replace match highlighting in the editor */
.document-pages .ProseMirror .search-match { background: rgba(200,168,74,0.35); border-radius: 2px; }
.document-pages .ProseMirror .search-match-current { background: rgba(200,106,74,0.55); }

/* Table size picker popup */
.collab-table-picker {
  position: fixed; z-index: 1000; background: #fff; border: 1px solid #ddd;
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.18); padding: 10px;
}
.collab-table-picker-grid { display: grid; gap: 2px; }
.collab-table-picker-cell {
  width: 18px; height: 18px; border: 1px solid #ccc; border-radius: 2px; background: #fff;
}
.collab-table-picker-cell.active { background: #c86a4a; border-color: #c86a4a; }
.collab-table-picker-label { text-align: center; margin-top: 6px; font-size: 12px; color: #555; }

/* ─────────────────────────────────────────────────────────────────────────────
   Soft deadline
   The advisory deadline: students keep writing past it, and the teacher's report
   marks what was written after. One plum accent everywhere it appears (pill,
   graph tint, session badge, marked text) so the marking reads as one idea, and
   deliberately distinct from the author palette in the Contribution Map.
   ───────────────────────────────────────────────────────────────────────────── */

.soft-deadline-pill {
  background: #fdf4ff;
  border: 1.5px solid #a21caf;
  color: #86198f;
  border-radius: 9999px;
  padding: 0.25rem 0.85rem;
  font-size: var(--font-size-sm);
  font-weight: 500;
  white-space: nowrap;
}

.soft-deadline-pill--passed {
  background: var(--color-surface, #f8fafc);
  border-color: #cbd5e1;
  color: var(--color-text-muted);
}

.soft-deadline-pill[hidden] {
  display: none;
}

/* Assignment cards (teacher list + student list) */
.assignment-soft-deadline {
  color: #86198f;
}

/* Sidebar summary line under the process stats */
.soft-deadline-note {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: var(--spacing-sm);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.soft-deadline-swatch {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: rgb(162, 28, 175);
}

/* Part of the history recorded without editing data (the hollow timeline rings) */
.recording-gap-note {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: var(--spacing-sm);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.recording-gap-swatch {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid #94a3b8;
}

/* Session cards that ran past the soft deadline */
.session-after-soft {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: #fdf4ff;
  color: #86198f;
}

/* Text written after the soft deadline, in the Review document.
   An underline rather than a background so it composes with the authorship
   tint underneath it, and survives the authorship toggle (which clears
   background only) — the two markings answer different questions. */
.after-soft-deadline {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: rgba(162, 28, 175, 0.9);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

/* Review legend: a miniature of what a grammar mark actually looks like in the
   document, keyed the same way as --soft-deadline below. */
.authorship-legend-color--possible-typo {
  /* No fill, because a flagged word no longer has one — the wave is the whole
     of what the checker adds, and whatever is behind it belongs to the author
     who wrote the word. The box edge is the swatch's own outline, in the wave's
     colour family so the entry reads as one thing; it is not a claim that a
     mark draws a border.

     CSS has no wavy border, so the wave is an inline SVG tiled along the
     bottom. The bottom border is transparent rather than absent: it reserves
     the same 2px the other three take, so the box keeps its size and the wave
     has that edge to itself instead of sitting on top of a solid line.
     background-origin: border-box runs the wave the full width, level with the
     outer bottom edge. */
  border-color: #f59e0b;
  border-bottom-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='4' viewBox='0 0 8 4'%3E%3Cpath d='M0 3 Q2 0 4 3 T8 3' fill='none' stroke='%23d97706' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: bottom left;
  background-origin: border-box;
}

.authorship-legend-color--soft-deadline {
  background: #fdf4ff;
  border-color: #a21caf;
  border-bottom: 3px dotted rgba(162, 28, 175, 0.9);
}

/* Notebook blocks changed after the soft deadline */
.nb-block--after-soft {
  box-shadow: inset 3px 0 0 rgba(162, 28, 175, 0.9);
}

.nb-change-badge--after-soft {
  background: #fdf4ff;
  color: #86198f;
}

/* Create-assignment form: the checkbox that turns the due date into a soft one.
   Disabled until a date exists, because unchecked it applies to nothing. */
.soft-deadline-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-weight: 400;
  cursor: pointer;
}

.soft-deadline-toggle input {
  width: auto;
  margin: 0;
  accent-color: #a21caf;
}

.soft-deadline-toggle.is-disabled {
  opacity: 0.55;
  cursor: default;
}

/* Maintenance mode (middleware.ts): covers the app when an API call answers
   503 { maintenance: true }. Above everything, including modals. */
.maintenance-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  background: rgba(59, 47, 42, 0.55);
}

.maintenance-panel {
  max-width: 32rem;
  padding: var(--spacing-xl);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  text-align: center;
}

.maintenance-panel h2 {
  margin: 0 0 var(--spacing-sm);
}

.maintenance-panel p {
  margin: 0 0 var(--spacing-lg);
  color: var(--color-text-muted);
  line-height: 1.55;
}
