/*
 * Compact yellow workspace theme.
 * The layout follows the operating-console rhythm used by the detection
 * system while keeping the composition system's own yellow identity.
 */
:root {
  --ink: #242116;
  --muted: #6d6959;
  --paper: #ffffff;
  --surface: #ffffff;
  --canvas: #f7f5ef;
  --brand: #f2b722;
  --brand-hover: #e0a408;
  --brand-strong: #a66d00;
  --brand-soft: #fff1b8;
  --brand-faint: #fff9e6;
  --brand-ink: #3f2e00;
  --topbar-teal: #2a9d8f;
  --topbar-yellow: #e9c46a;
  --topbar-orange: #e76f51;
  --topbar-cream: #fff1d6;
  --topbar-ink: #000;
  --small-accent: #7c5cc4;
  --small-border: #c9b9ee;
  --small-soft: #f0eaff;
  --small-faint: #fbf8ff;
  --green: var(--brand);
  --green-dark: var(--brand-strong);
  --green-soft: var(--brand-soft);
  --success: #21854a;
  --success-dark: #176538;
  --success-soft: #e8f5ec;
  --info: #276f9e;
  --info-soft: #eaf2f8;
  --gold: #c77700;
  --gold-soft: #fff0cf;
  --red: #b93831;
  --red-soft: #fceae8;
  --line: #ded9c9;
  --shadow: 0 1px 2px rgba(36, 33, 22, .05);
  --radius: 8px;
}

html { background: var(--canvas); }

body {
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
textarea,
select { border-radius: 6px; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(242, 183, 34, .32);
  outline-offset: 2px;
}

/* One compact, always-visible application bar. */
.site-header,
.login-page .site-header {
  width: 100%;
  min-height: 72px;
  padding: 12px max(24px, calc((100vw - 1180px) / 2));
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(230px, 1fr);
  align-items: center;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 30;
  color: var(--topbar-ink);
  background: var(--topbar-yellow);
  border: 0;
  border-bottom: 4px solid var(--topbar-orange);
  box-shadow: 0 2px 8px rgba(24, 59, 53, .14);
  backdrop-filter: none;
}

.brand {
  min-width: 0;
  gap: 12px;
  color: var(--topbar-ink);
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
}
.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 0;
  color: inherit;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand strong {
  overflow: hidden;
  color: var(--topbar-ink);
  font-family: "Noto Sans SC", "Noto Sans CJK SC", "Noto Sans", sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand small { display: none; }

.main-nav {
  width: auto;
  min-width: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.main-nav a {
  min-width: 0;
  padding: 8px 13px;
  color: #000;
  border-radius: 5px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}
.main-nav a:hover { color: var(--topbar-ink); background: rgba(255, 241, 214, .55); }
.main-nav a.active {
  color: var(--topbar-ink);
  background: rgba(255, 241, 214, .82);
  box-shadow: inset 0 -2px 0 var(--topbar-teal);
}

.account-area {
  justify-self: end;
  gap: 10px;
  color: #000;
  font-size: 13px;
}
.account-name { color: #000; font-weight: 700; }
.site-header .printer-status {
  min-height: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  color: #000;
  background: rgba(255, 241, 214, .44);
  border: 1px solid rgba(24, 59, 53, .16);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}
.site-header .printer-status-unknown {
  color: #727272;
  border-color: rgba(114, 114, 114, .24);
  background: rgba(255, 255, 255, .3);
}
.site-header .printer-status-online {
  color: #000;
  border-color: rgba(42, 157, 143, .42);
  background: linear-gradient(180deg, rgba(255, 241, 214, .92) 0%, rgba(255, 241, 214, .7) 100%);
  box-shadow:
    0 0 0 1px rgba(255, 241, 214, .72) inset,
    0 0 18px rgba(42, 157, 143, .34),
    0 4px 12px rgba(42, 157, 143, .14);
}
.site-header .printer-status-offline {
  color: #727272;
  border-color: rgba(114, 114, 114, .24);
  background: rgba(255, 255, 255, .3);
}
.site-header .printer-status i {
  width: 12px;
  height: 12px;
  background: var(--topbar-teal);
  box-shadow: none;
  animation: none;
}
.site-header .printer-status-unknown i,
.site-header .printer-status-offline i {
  background: #727272;
  box-shadow: none;
  animation: none;
}
.site-header .printer-status-online i { box-shadow: none; animation: none; }
.site-header .text-button {
  min-height: 0;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--red);
  border: 1px solid var(--red);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}
.site-header .text-button:hover { color: #fff; background: #9f2f29; border-color: #9f2f29; }

/* Compact page frame and headings. */
.page-shell,
.admin-shell,
.writing-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 44px;
}
.admin-shell { width: min(1280px, calc(100% - 32px)); }
.overview-shell {
  width: min(1600px, calc(100% - 24px));
  padding-top: 18px;
}

h1 {
  margin-bottom: 5px;
  font-size: clamp(27px, 3vw, 34px);
  line-height: 1.16;
  letter-spacing: -.018em;
}
h2 { margin-bottom: 3px; font-size: 18px; line-height: 1.28; }
.eyebrow {
  margin-bottom: 4px;
  color: var(--brand-strong);
  font-size: 10px;
  letter-spacing: .11em;
}
.admin-hero .eyebrow { display: none; }

.hero-row,
.result-heading,
.writing-heading {
  min-height: 58px;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}
.hero-row > div:first-child { max-width: 820px; }
.hero-row p,
.result-heading p,
.panel-heading p { font-size: 13px; }
.back-link { margin-bottom: 8px; font-size: 12px; }

.flash-stack { gap: 6px; margin-bottom: 12px; }
.flash {
  padding: 9px 12px;
  border-radius: 6px;
  box-shadow: none;
  font-size: 13px;
}
.flash-success { color: var(--success-dark); background: var(--success-soft); border-color: #b9dec5; }
.flash-info { color: #285b7d; background: var(--info-soft); border-color: #c7ddea; }

/* Flat, information-first surfaces. */
.panel,
.task-card,
.result-card,
.history-list a,
.login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.panel-heading {
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.hero-actions form { margin: 0; }
.section-heading { gap: 12px; margin-bottom: 9px; }

.primary-button,
.secondary-button,
.small-button,
.table-button {
  border-radius: 6px;
  box-shadow: none;
  transition: background .12s ease, border-color .12s ease;
}
.primary-button {
  min-height: 40px;
  padding: 0 16px;
  color: var(--brand-ink);
  background: var(--brand);
  border-color: var(--brand-strong);
}
.primary-button:hover {
  color: var(--brand-ink);
  background: var(--brand-hover);
  border-color: var(--brand-strong);
  transform: none;
}
.secondary-button {
  min-height: 38px;
  padding: 0 14px;
  color: #544817;
  background: #fff;
  border-color: #cfc7ae;
}
.secondary-button:hover { background: var(--brand-faint); border-color: var(--brand-strong); box-shadow: none; }
.secondary-button.danger-button { color: var(--red); border-color: rgba(194, 50, 44, .35); }
.secondary-button.danger-button:hover { color: #9b1f1a; background: #fff2f1; border-color: rgba(194, 50, 44, .7); }
.small-button { min-height: 30px; padding: 0 10px; color: var(--brand-ink); background: var(--brand-soft); border-color: #ddc56b; }
.table-button { min-height: 30px; padding: 0 9px; border-radius: 5px; }
.table-button:hover { color: var(--brand-ink); background: var(--brand-soft); border-color: var(--brand-strong); }
.table-button.danger-button { color: var(--red); border-color: rgba(194, 50, 44, .35); }
.table-button.danger-button:hover { color: #9b1f1a; background: #fff2f1; border-color: rgba(194, 50, 44, .7); }

/* Keep success semantics green instead of conflating them with the brand. */
.status-pill:not(.inactive),
.review-status-completed {
  color: var(--success-dark);
  background: var(--success-soft);
}
.success-eyebrow,
.task-state-submitted,
.character-counter.is-ready strong,
.overview-summary > div:first-child strong { color: var(--success); }
.task-state-queued { color: #9a5a12; }
.task-state-processing { color: var(--info); }
.matrix-submitted { color: #fff; border-color: var(--success); background: var(--success); }
.matrix-status { width: auto; min-width: 58px; padding: 0 5px; font-size: 10px; font-weight: 400; text-align: center; white-space: nowrap; }
.matrix-cell-content { width: 100%; display: inline-flex; align-items: center; justify-content: flex-start; gap: 6px; min-width: 0; max-width: 100%; }
.matrix-current-score { flex: 0 0 auto; color: #8a8476; font-size: 9px; font-weight: 400; line-height: 1; white-space: nowrap; }
.matrix-waiting { color: #fff; border-color: var(--red); background: var(--red); }
.matrix-processing { color: var(--info); border-color: #b9d8ed; background: var(--info-soft); }
.matrix-paper { color: #fff; border-color: var(--info); background: var(--info); }
.matrix-symbol.matrix-empty { width: 0; min-width: 0; height: 19px; padding: 0; border: 0; background: transparent; }
.review-status-processing { color: var(--info); background: var(--info-soft); }
.submissions-table .workflow-status-queued { color: #9a5a12; background: #fff1d6; }
.submissions-table .workflow-status-processing { color: var(--info); background: var(--info-soft); }
.submissions-table .workflow-status-failed { color: #842f29; background: var(--red-soft); }
.submissions-table .workflow-status-paper-ready { color: #5b4696; background: #eee9ff; }
.submissions-table .workflow-status-paper-processing { color: #805b00; background: #fff2c9; }
.submissions-table .workflow-status-paper-revision { color: #9a351f; background: #ffe8df; }
.submissions-table .workflow-status-paper-completed { color: #11613b; background: #e4f6ec; }
.submissions-table .workflow-status-revision-needed { color: #155e75; background: #e5f6fb; }
.submissions-table .workflow-status-third-needed { color: #6848a3; background: #f0e9ff; }
.submissions-table .workflow-status-original-processing { color: #8a4b13; background: #fff1d6; }
.submissions-table .workflow-status-revision-processing { color: #285c8f; background: #e5f0ff; }
.submissions-table .workflow-status-third-processing { color: #7a3f87; background: #fae9ff; }
.submissions-table .workflow-status-not-submitted { color: #6a5a36; background: #f5eedb; }
.submissions-table .workflow-status-unknown { color: #5f5541; background: #f2eee5; }
.review-status.paper-decision-completed { color: #11613b; background: #e4f6ec; }
.review-status.paper-decision-revision { color: #8a351d; background: #fff0e8; }

.queue-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 14px;
}
.queue-summary-grid > div {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}
.queue-summary-grid strong {
  display: block;
  color: var(--brand-strong);
  font-size: 24px;
  line-height: 1;
}
.queue-summary-grid span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.print-queue-status-waiting { color: #8a6100; background: #fff3c9; }
.print-queue-status-sending { color: #007dcc; background: #e5f3fb; }
.print-queue-status-submitted { color: #26685a; background: #e8f5ef; }
.print-queue-status-printed { color: var(--success-dark); background: var(--success-soft); }
.print-queue-status-failed { color: #842f29; background: var(--red-soft); }

/* Lookup: 20 fields become four compact columns on desktop. */
.quota-card {
  min-width: 180px;
  padding: 9px 12px;
  column-gap: 9px;
  border-color: #dfc770;
  border-radius: 7px;
  background: var(--brand-soft);
}
.quota-card strong { font-size: 28px; color: var(--brand-strong); }
.quota-card small { font-size: 10px; }
.lookup-panel { padding: 17px; }
.lookup-tabs { gap: 4px; margin-bottom: 12px; padding: 4px; border-radius: 7px; }
.lookup-limit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.form-hint { margin: 0; color: var(--muted); font-size: 11px; font-weight: 600; line-height: 1.5; }
.lookup-tabs a { min-height: 34px; border-radius: 5px; font-size: 13px; }
.lookup-tabs a.active { color: var(--brand-ink); background: var(--brand-soft); }
.expression-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.expression-field {
  height: 42px;
  border-radius: 6px;
  background: #fffef9;
}
.expression-field:focus-within,
.textarea-label textarea:focus,
.table-search:focus,
.login-form input:focus,
.form-field input:focus,
.form-field select:focus,
.submission-filters input:focus,
.submission-filters select:focus,
.overview-controls input:focus,
.overview-controls select:focus,
.compact-search-label input:focus,
.writing-panel textarea:focus {
  border-color: var(--brand-strong);
  box-shadow: 0 0 0 3px rgba(242, 183, 34, .22);
}
.expression-field > span { width: 35px; flex-basis: 35px; }
.expression-field input { padding: 0 10px; font-size: 13px; }
.filled-counter { padding: 5px 9px; border-radius: 6px; }
.filled-counter b { color: var(--brand-strong); }
.print-mode-switch {
  gap: 6px;
  margin: -4px 0 12px;
  padding: 4px;
  border-radius: 8px;
  background: #fff9df;
}
.print-mode-switch span {
  min-height: 46px;
  padding: 8px 10px;
  border-radius: 6px;
}
.print-mode-switch strong { font-size: 13px; }
.print-mode-switch small { font-size: 10px; }
.print-mode-switch input:checked + span {
  border-color: rgba(189, 126, 11, .28);
  color: var(--brand-ink);
  box-shadow: 0 5px 14px rgba(72, 48, 7, .08);
}
.print-mode-switch input:checked + span strong { color: var(--brand-ink); }
.submit-row { gap: 12px; margin-top: 13px; padding-top: 12px; }
.history-section { margin-top: 22px; }
.lookup-history-heading { margin-bottom: 10px; }
.lookup-history-section { margin-top: 0; }
.history-list { gap: 6px; }
.history-list a { gap: 10px; padding: 9px 11px; }
.history-list a:hover { border-color: var(--brand-strong); background: var(--brand-faint); }
.history-icon { width: 30px; height: 30px; border-radius: 5px; color: var(--brand-strong); background: var(--brand-soft); }
.history-arrow { color: var(--brand-strong); }

/* Lookup results. */
.result-heading { margin-bottom: 12px; }
.print-actions { gap: 7px; }
.result-list { gap: 8px; }
.result-card { gap: 10px; padding: 12px; }
.result-number { color: var(--brand-strong); font-size: 14px; }
.result-content { gap: 6px; }
.result-source > span,
.result-japanese > span { margin-bottom: 2px; font-size: 10px; }
.result-source > strong {
  color: #5f5b50;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.result-japanese { padding: 8px 0 6px; }
.result-japanese > strong {
  display: block;
  color: #080808;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.46;
}
.result-card .ruby-text {
  display: inline;
  margin: 0;
  color: inherit;
  font-family: "MSGothicLocal", "MS Gothic", "Noto Sans JP", "Yu Gothic", monospace;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: 0;
}
.result-card .ruby-text rt {
  position: relative;
  top: var(--ruby-reading-offset, .19em);
  padding: 0;
  color: inherit;
  font-size: .48em;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
}

/* Account management and data tables. */
.admin-grid { grid-template-columns: minmax(310px, .75fr) minmax(0, 1.25fr); gap: 12px; }
.batch-panel,
.batch-result-panel { min-height: 0; padding: 16px; }
.textarea-label span { margin-bottom: 5px; }
.textarea-label textarea {
  min-height: 150px;
  padding: 10px;
  border-radius: 6px;
  background: #fffef9;
  line-height: 1.55;
}
.batch-panel .textarea-label textarea { height: 150px; min-height: 120px; }
.security-note { margin-top: 8px; }
.empty-illustration { width: 60px; height: 60px; margin-bottom: 10px; font-size: 30px; }
.credential-list { max-height: 230px; gap: 5px; }
.credential-list > div { padding: 7px 9px; border-radius: 5px; }
.users-panel { margin-top: 12px; padding: 15px; }
.table-search { width: 210px; height: 36px; border-radius: 6px; }
.table-wrap { border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.users-table { font-size: 13px; }
.users-table th {
  padding: 8px 10px;
  color: #625d4f;
  background: var(--brand-faint);
  font-size: 11px;
}
.submission-sort-trigger {
  color: inherit;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  text-decoration: none;
}
.submission-sort-trigger:hover,
.submission-sort-trigger:visited { color: inherit; text-decoration: none; }
.users-table td { padding: 8px 10px; }
.users-table tbody tr:nth-child(even) td { background: #fcfbf7; }
.student-class-prefix { margin-right: 5px; color: #8a8476; font-size: 10px; font-weight: 700; }
.row-actions { flex-wrap: wrap; gap: 5px; white-space: nowrap; }
.ban-user-form { display: inline-flex; align-items: center; gap: 5px; }
.ban-hours-input { width: 64px; min-height: 30px; padding: 4px 7px; border-radius: 5px; }
.score-heading,
.score-cell { min-width: 70px; text-align: left; }
.score-cell { color: var(--brand-strong); font-weight: 800; white-space: nowrap; }
.empty-table { padding: 30px !important; }
.password-code { color: #6c4800; background: var(--brand-soft); }

/* Student task and draft lists. */
.task-hero { margin-bottom: 12px; }
.task-open-count { color: var(--muted); background: transparent; }
.task-open-count strong { color: var(--red); background: transparent; }
.task-list,
.draft-list { gap: 8px; }
.task-card {
  min-height: 108px;
  grid-template-columns: minmax(0, 1fr) 142px;
  border-radius: 8px;
  overflow: hidden;
}
.task-card-main { padding: 13px 16px; }
.task-card-main h2 { margin: 6px 0 4px; font-size: 18px; }
.task-instructions { margin-bottom: 5px; font-size: 13px; -webkit-line-clamp: 1; }
.composition-type { min-height: 21px; padding: 1px 7px; border-radius: 4px; color: var(--brand-ink); background: var(--brand-faint); border-color: #d7c475; }
.composition-type-small { color: var(--small-accent); background: var(--small-soft); border-color: var(--small-border); }
.task-type-marker-small { color: var(--small-accent); }
.task-card-small { border-color: rgba(124, 92, 196, .24); }
.task-card-action { gap: 5px; padding: 12px; background: #fffaf0; }
.task-card-small .task-card-action { background: var(--small-faint); }
.task-card.task-card-compact {
  min-height: 64px;
  grid-template-columns: minmax(0, 1fr) auto auto;
}
.task-card-compact .task-card-main {
  align-items: flex-start;
  flex-direction: column;
  gap: 3px;
  padding: 11px 14px;
}
.task-card-meta { display: flex; align-items: center; gap: 5px; line-height: 1.15; }
.task-card-compact .task-card-main h2 { margin: 0; font-size: 18px; }
.task-card-compact .task-days-left { font-size: 10px; }
.task-card-status {
  min-width: 90px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 3px;
  justify-content: center;
  text-align: center;
}
.task-score-line {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.15;
  white-space: nowrap;
}
.task-card-compact .task-card-action { padding: 8px 12px; background: transparent; }
.task-card-compact .task-card-action .revision-task-button {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 5px;
  font-size: 13px;
}
.draft-card { min-height: 102px; grid-template-columns: minmax(0, 1fr) 140px; }
.draft-card-main { padding: 13px 16px; }
.draft-card-side { padding: 12px; background: #fffaf0; }
.draft-card-side > strong { color: var(--brand-strong); }

/* Writing screen: compact chrome, comfortable text, reachable actions. */
.writing-shell { width: min(980px, calc(100% - 32px)); }
.writing-heading h1 { margin-top: 5px; font-size: clamp(26px, 3vw, 32px); }
.word-rule { min-width: 116px; padding: 8px 11px; border-radius: 6px; }
.word-rule strong { color: var(--brand-strong); font-size: 24px; }
.task-requirement-panel { margin-bottom: 9px; padding: 12px 15px; border-radius: 7px; }
.task-requirement-panel h2 { margin-bottom: 4px; font-size: 15px; }
.task-requirement-panel p { font-size: 13px; }
.writing-panel { padding: 14px; border-radius: 8px; }
.writing-toolbar { margin-bottom: 6px; }
.character-counter strong { font-size: 19px; }
.optional-section-add { margin: 7px 0; }
.optional-section-add-introduction { margin-top: 3px; }
.optional-section-add-conclusion { margin-bottom: 0; }
.composition-points { gap: 8px; }
.composition-section { padding: 10px; border-radius: 7px; }
.composition-section-optional { margin: 8px 0; }
#add-title-button[hidden] { display: none; }
#composition-title {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid #cfd7d1;
  border-radius: 6px;
  outline: 0;
  color: #171c19;
  background: #fff;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", "PingFang SC", sans-serif;
  font-size: 17px;
  line-height: 1.75;
}
#composition-title:focus { border-color: #5e957b; box-shadow: 0 0 0 4px rgba(23, 107, 77, .09); }
#composition-title[readonly] { color: #38423c; background: #f5f6f3; }
.composition-section-heading { margin-bottom: 5px; }
.composition-section-heading > label small { margin-top: 2px; font-size: 12px; line-height: 1.35; }
.writing-panel textarea { min-height: 138px; padding: 12px; border-radius: 6px; font-size: 17px; line-height: 1.75; }
.revision-editor-panel textarea { min-height: 520px; line-height: 1.9; }
.composition-section-optional textarea { min-height: 100px; }
.writing-actions {
  margin: 12px -7px -7px;
  padding: 9px;
  position: static;
  border: 1px solid #e0cc7b;
  border-radius: 7px;
  background: #fff9e6;
  box-shadow: none;
}

/* Task editor and records toolbars. */
.admin-task-layout { grid-template-columns: minmax(300px, .68fr) minmax(480px, 1.32fr); gap: 12px; }
.task-editor,
.task-manager-panel,
.submissions-panel { padding: 15px; }
.form-field { gap: 4px; margin-bottom: 10px; }
.form-field input,
.form-field select,
.submission-filters input,
.submission-filters select,
.overview-controls input,
.overview-controls select { height: 38px; border-radius: 6px; }
.writing-points-list { gap: 6px; }
.writing-point-detail-row { grid-template-columns: 76px minmax(0, 1fr) auto; gap: 6px; }
.writing-point-detail-row > span { font-size: 11px; }
.type-choice { gap: 6px; margin-bottom: 10px; }
.type-choice legend { margin-bottom: 4px; }
.type-choice label > span { min-height: 48px; padding: 7px 9px; border-radius: 6px; }
.type-choice input:checked + .type-choice-big { color: var(--brand-ink); border-color: var(--brand-strong); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-strong); }
.type-choice input:checked + .type-choice-small { color: #312549; border-color: var(--small-accent); background: var(--small-soft); box-shadow: inset 0 0 0 1px var(--small-accent); }
.task-editor .textarea-label textarea { height: 110px; min-height: 88px; }
.managed-task-list { max-height: calc(100dvh - 190px); gap: 6px; }
.managed-task { border-radius: 6px; }
.managed-task summary { min-height: 52px; gap: 8px; padding: 8px 10px; }
.managed-task summary::after { content: none; display: none; }
.managed-task summary .status-pill { margin: 0; }
.managed-task-form { padding: 12px 12px 8px; }
.managed-task-form .textarea-label textarea { height: 88px; min-height: 72px; }
.managed-task-actions { margin-top: 9px; }

.compact-panel-toolbar { margin-bottom: 9px; }
@media (min-width: 768px) {
  .paper-review-shell .compact-panel-toolbar { flex-wrap: wrap; }
  .paper-review-shell .paper-review-record-heading { flex-wrap: wrap; max-width: 100%; }
  .paper-review-shell .paper-review-filters { flex: 1 1 620px; width: auto; min-width: 0; }
}
.inline-filters {
  width: min(620px, 72%);
  grid-template-columns: 155px minmax(190px, 1fr) auto;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}
.submission-filters { gap: 7px; }
.submission-filters label { gap: 3px; }
.submission-filters .secondary-button { height: 38px; }
.submission-filters-simple { grid-template-columns: minmax(200px, 1fr) 160px minmax(170px, 1fr) auto; }
.submissions-table { min-width: 1060px; }
.submissions-table .mobile-only { display: none !important; }
.desktop-row-actions {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}
.desktop-row-actions form { margin: 0; }
.mobile-actions-menu { display: none; }
.record-pagination { gap: 7px; padding-top: 10px; }
.pagination-status { font-size: 12px; }
.compact-search-label { min-width: 200px; gap: 3px; }
.compact-search-label input { height: 36px; border-radius: 6px; }

/* Review and handwriting screens. */
.review-waiting-card { margin-bottom: 9px; padding: 17px; }
.original-composition-panel { padding: 15px 17px; border-radius: 8px; }
.detail-section-heading { margin-bottom: 7px; }
.original-composition { padding-top: 10px; font-size: 15px; line-height: 1.72; }
.composition-summary-section { margin-top: 16px; }
.point-completion-section + .composition-summary-section { margin-top: 28px; }
.composition-summary-table { min-width: min(700px, 100%); }
.composition-summary-table th { padding: 8px 12px; font-size: 14px; }
.composition-summary-table td { padding: 10px 12px; font-size: 21px; }
.sentence-review-section { margin-top: 16px; }
.sentence-review-list { gap: 8px; }
.revision-continuity-status { margin-top: 8px; padding: 7px 9px; gap: 7px; }
.sentence-review-card { padding: 12px; border-radius: 7px; }
.sentence-review-card header { grid-template-columns: 27px minmax(0, 1fr); gap: 7px; padding-bottom: 7px; }
.sentence-review-card header > span { width: 25px; height: 25px; border-color: #d0b750; color: var(--brand-strong); }
.sentence-review-card header p { font-size: 14px; }
.sentence-review-card dl { margin-top: 8px; gap: 6px; }
.sentence-review-card dl > div { grid-template-columns: 54px minmax(0, 1fr); }
.point-completion-section { margin-top: 16px; }
.point-completion-list { gap: 8px; }
.point-completion-card { padding: 12px; border-radius: 7px; }
.point-completion-card header { grid-template-columns: 27px minmax(0, 1fr); gap: 7px; padding-bottom: 7px; }
.point-completion-card header > span { width: 25px; height: 25px; }
.point-completion-card header p { font-size: 14px; }
.point-completion-card dl { margin-top: 8px; gap: 6px; }
.point-completion-card dl > div { grid-template-columns: 76px minmax(0, 1fr); gap: 7px; }
.handwriting-upload-panel { margin-bottom: 9px; padding: 15px; }
.handwriting-upload-panel form { gap: 8px; }

/* Overview already follows the reference system; tighten and recolor it. */
.overview-hero { min-height: 50px; margin-bottom: 10px; }
.overview-controls { margin-bottom: 7px; }
.overview-cohort-switch { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.overview-cohort-switch .secondary-button { min-width: 76px; min-height: 40px; }
.overview-cohort-switch .secondary-button.active { background: var(--brand); border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.overview-controls .secondary-button,
.overview-refresh { height: 38px; }
.overview-controls .overview-class-label { min-width: 132px; flex: 0 0 150px; }
.overview-controls .overview-search-label { min-width: 180px; flex: 0 1 300px; }
.overview-summary { margin-bottom: 5px; }
.overview-summary > div { min-height: 48px; padding: 7px 11px; }
.overview-legend { margin: 4px 0; font-weight: 400; }
.overview-scope-tail { display: none; }
.composition-matrix-wrap { max-height: calc(100dvh - 205px); min-height: 0; }
.composition-matrix { min-width: 0; table-layout: auto; }
.composition-matrix tbody tr { height: 32px !important; max-height: 32px !important; }
.composition-matrix th,
.composition-matrix td { height: 32px; padding: 0 5px; }
.composition-matrix tbody th,
.composition-matrix tbody td { height: 32px !important; max-height: 32px !important; overflow: hidden; }
.composition-matrix thead th {
  width: auto;
  min-width: 116px;
  max-width: 12em;
  height: 68px;
  color: var(--brand-ink);
  background: var(--brand);
  border-color: rgba(63, 46, 0, .18);
}
.composition-matrix tbody td {
  width: auto;
  min-width: 116px;
  max-width: 12em;
}
.composition-matrix thead .matrix-sticky {
  color: var(--brand-ink);
  background: #f3d27a;
  border-color: rgba(63, 46, 0, .16);
}
.composition-matrix .matrix-sticky { width: 104px; min-width: 104px; max-width: 104px; }
.matrix-task-heading { width: auto; min-width: 116px; max-width: 12em; }
.matrix-cell-link,
.matrix-cell-static {
  width: 100%;
  height: 32px;
  min-height: 0;
  max-height: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.matrix-task-heading > span,
.matrix-task-heading > small { color: rgba(63, 46, 0, .72); }
.matrix-task-heading b { color: var(--brand-ink); }

/* A shorter, flatter login page. */
.login-page { background: var(--canvas); }
.login-shell {
  width: min(920px, calc(100% - 32px));
  min-height: calc(100vh - 64px);
  padding: 22px 0;
}
.login-card { min-height: 410px; grid-template-columns: 1.05fr .95fr; border-radius: 10px; box-shadow: 0 8px 28px rgba(66, 48, 0, .1); }
.login-intro {
  padding: 38px;
  color: var(--brand-ink);
  background: var(--brand);
}
.login-intro::after { right: -20px; bottom: -70px; color: rgba(63, 46, 0, .07); font-size: 270px; }
.login-intro .eyebrow { color: #6d4b00; }
.login-intro h1 { max-width: 430px; margin-top: 62px; font-size: clamp(32px, 4vw, 44px); }
.login-intro p { color: rgba(63, 46, 0, .72); }
.login-form { padding: 38px; }
.form-heading { margin-bottom: 20px; }
.form-heading h2 { font-size: 25px; }
.login-form label { margin-bottom: 12px; }
.login-form input { height: 42px; border-radius: 6px; background: #fffef9; }
.form-help { margin-top: 10px; }

.error-card { margin-top: 36px; padding: 30px; border-radius: 8px; box-shadow: var(--shadow); }

@media (min-width: 901px) {
  body {
    font-size: 15.5px;
    line-height: 1.52;
  }

  .hero-row p,
  .result-heading p,
  .panel-heading p,
  .task-requirement-panel p,
  .task-instructions,
  .history-list a,
  .result-card,
  .original-composition {
    font-size: 15px;
  }

  h2 { font-size: 20px; }

  .panel-heading { margin-bottom: 14px; }
  .lookup-panel,
  .task-editor,
  .task-manager-panel,
  .submissions-panel,
  .users-panel,
  .handwriting-upload-panel {
    padding: 18px;
  }

  .primary-button,
  .secondary-button,
  .small-button,
  .table-button {
    font-size: 14.5px;
  }
  .primary-button { min-height: 44px; padding-inline: 18px; }
  .secondary-button { min-height: 42px; padding-inline: 16px; }
  .small-button,
  .table-button { min-height: 34px; padding-inline: 11px; }

  .lookup-tabs a {
    min-height: 38px;
    font-size: 14.5px;
  }
  .expression-field { height: 46px; }
  .expression-field > span {
    width: 38px;
    flex-basis: 38px;
  }
  .expression-field input {
    padding-inline: 12px;
    font-size: 15px;
  }

  .textarea-label span,
  .form-field,
  .submission-filters label,
  .overview-controls label,
  .compact-search-label,
  .type-choice legend {
    font-size: 14.5px;
  }
  .form-field > small,
  .task-card-action small,
  .back-link {
    font-size: 12.5px;
  }
  .form-field input,
  .form-field select,
  .submission-filters input,
  .submission-filters select,
  .overview-controls input,
  .overview-controls select,
  .table-search,
  .compact-search-label input,
  .login-form input {
    height: 42px;
    padding-inline: 12px;
    font-size: 15px;
  }
  .textarea-label textarea {
    padding: 12px;
    font-size: 15px;
    line-height: 1.62;
  }

  .users-table {
    font-size: 14.5px;
  }
  .users-table th {
    padding: 10px 12px;
    font-size: 12px;
  }
  .users-table td {
    padding: 10px 12px;
  }
  .users-table td:first-child small {
    font-size: 12px;
  }
  .student-class-prefix {
    font-size: 11px;
  }

  .task-card-main {
    padding: 15px 18px;
  }
  .task-card-main h2,
  .task-card-compact .task-card-main h2 {
    font-size: 20px;
  }
  .task-card-action {
    padding: 14px;
  }
  .task-card-status {
    min-width: 104px;
    font-size: 13px;
  }
  .task-score-line {
    font-size: 12px;
  }
  .task-card-compact .task-card-action .revision-task-button {
    min-height: 34px;
    font-size: 14px;
  }

  .sentence-review-card header p,
  .point-completion-card header p {
    font-size: 15.5px;
  }
  .sentence-review-card dl,
  .point-completion-card dl {
    font-size: 14.5px;
  }
}

@media (max-width: 900px) {
  .site-header,
  .login-page .site-header {
    height: auto;
    min-height: 72px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 10px;
    padding: 12px 16px;
  }
  .site-header .brand { grid-column: 1; grid-row: 1; }
  .site-header .account-area { grid-column: 2; grid-row: 1; }
  .site-header .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(24, 59, 53, .14);
    overflow: visible;
  }
  .main-nav a { min-width: 0; padding: 7px 12px; font-size: 15px; }

  .page-shell,
  .admin-shell,
  .writing-shell { width: min(100% - 24px, 760px); padding-top: 18px; }
  .overview-shell { width: calc(100% - 16px); padding-top: 14px; }
  .hero-row,
  .result-heading { gap: 10px; }
  .expression-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid,
  .admin-task-layout { grid-template-columns: 1fr; }
  .managed-task-list { max-height: none; }
  .compact-panel-toolbar { align-items: stretch; flex-direction: column; }
  .inline-filters { width: 100%; }
  .sentence-review-list { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { font-size: 13px; }
  .site-header,
  .login-page .site-header {
    min-height: 62px;
    padding: 10px 12px;
    position: sticky;
  }
  .site-header .brand { gap: 7px; }
  .brand-mark { width: 32px; height: 32px; flex-basis: 32px; }
  .brand strong { font-size: 16px; }
  .account-area { gap: 8px; }
  .site-header .printer-status { padding: 3px 6px; font-size: 10px; }
  .site-header .text-button { padding: 3px 6px; font-size: 10px; }
  .account-name { display: none; }
  .main-nav a { min-height: 0; padding: 6px 10px; display: grid; place-items: center; font-size: 13px; }

  .page-shell,
  .admin-shell,
  .writing-shell { width: calc(100% - 20px); padding: 14px 0 30px; }
  h1 { font-size: 24px; }
  h2 { font-size: 17px; }
  .hero-row,
  .result-heading,
  .writing-heading { min-height: 0; margin-bottom: 10px; padding-bottom: 9px; }
  .hero-row p,
  .result-heading p { display: none; }
  .hero-row,
  .result-heading { align-items: stretch; flex-direction: column; }
  .task-hero { align-items: flex-start; flex-direction: row; gap: 14px; }
  .task-score-averages { align-self: center; gap: 7px; padding: 0; }
  .quota-card { width: 100%; }

  .lookup-panel,
  .batch-panel,
  .batch-result-panel,
  .users-panel,
  .task-editor,
  .task-manager-panel,
  .submissions-panel { padding: 12px; border-radius: 7px; }
  .expression-grid { grid-template-columns: 1fr; gap: 6px; }
  .expression-field { height: 40px; }
  .submit-row { align-items: stretch; flex-direction: column; }
  .submit-row .primary-button { width: 100%; }
  .result-list { grid-template-columns: 1fr; }
  .result-source > strong { font-size: 12px; }
  .result-japanese { padding: 7px 0 5px; }
  .result-japanese > strong { font-size: 22px; line-height: 1.44; }
  .print-actions { align-items: stretch; flex-direction: column; }
  .print-actions a,
  .print-actions button,
  .print-actions form { width: 100%; }

  .task-card,
  .draft-card { grid-template-columns: 1fr; }
  .task-card-main,
  .draft-card-main { padding: 12px; }
  .task-card-action,
  .draft-card-side { min-height: 60px; padding: 9px 12px; flex-direction: row; justify-content: space-between; border-top: 1px solid var(--line); border-left: 0; }
  .task-card-action .primary-button { width: auto; }
  .task-card.task-card-compact { min-height: 64px; grid-template-columns: minmax(0, 1fr) auto; }
  .task-card-compact .task-card-main { min-width: 0; gap: 5px; padding: 9px 6px 9px 10px; }
  .task-card-compact .task-card-main h2 { font-size: 16px; }
  .task-card-meta { width: 100%; gap: 7px; overflow: hidden; white-space: nowrap; }
  .task-card-compact .task-days-left,
  .task-card-compact .task-type-marker,
  .task-mobile-status,
  .task-mobile-status .task-state,
  .task-mobile-status .task-score-line { font-size: 10px; font-weight: 700; line-height: 1; }
  .task-card-compact .task-type-marker { color: var(--brand-strong); }
  .task-card-compact .task-days-left { color: #716d63; }
  .task-mobile-status { min-width: 0; display: contents; }
  .task-mobile-status .task-score-line { color: #987325; }
  .task-card-status { display: none; }
  .task-card-compact .task-card-action { min-height: 0; padding: 7px 9px; border: 0; }
  .task-card-compact .task-card-action .primary-button,
  .task-card-compact .task-card-action .table-button { width: auto; white-space: nowrap; }
  .writing-heading { align-items: stretch; flex-direction: column; }
  .word-rule { width: 100%; }
  .writing-panel,
  .task-requirement-panel { padding: 11px; }
  .writing-panel textarea { min-height: 130px; padding: 10px; font-size: 17px; }
  .writing-actions { align-items: stretch; flex-direction: column; }
  .writing-actions > div { display: grid; grid-template-columns: 1fr 1.25fr; }

  .inline-filters,
  .submission-filters,
  .overview-controls { grid-template-columns: 1fr; }
  .overview-controls {
    display: grid;
    gap: 7px;
  }
  .overview-controls .overview-scope-label,
  .overview-controls .overview-class-label,
  .overview-controls .overview-filter-button,
  .overview-controls .overview-refresh {
    display: none;
  }
  .lookup-limit-grid { grid-template-columns: 1fr; }
  .overview-controls .overview-search-label {
    width: 100%;
    min-width: 0;
  }
  .overview-summary {
    display: none;
  }
  .form-field input,
  .form-field select,
  .submission-filters input,
  .submission-filters select,
  .submission-filters .secondary-button,
  .overview-controls input,
  .overview-controls select,
  .primary-button,
  .secondary-button { min-height: 44px; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .hero-actions { justify-content: stretch; }
  .hero-actions .secondary-button,
  .hero-actions form { width: 100%; }
  .hero-actions form .secondary-button { width: 100%; }
  .queue-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-search,
  .compact-search-label { width: 100%; min-width: 0; }
  .row-actions { align-items: center; flex-direction: row; }
  .users-table { min-width: 700px; }
  .submissions-panel { padding: 8px 6px; }
  .submissions-panel .compact-panel-toolbar { padding-inline: 6px; }
  .submissions-panel .table-wrap { overflow: visible; }
  .submissions-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }
  .submissions-table th,
  .submissions-table td {
    padding: 9px 3px;
    overflow: visible;
    font-size: 12px;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
  }
  .submissions-table th { font-size: 10px; }
  .submissions-table tbody tr { height: 52px; }
  .submissions-table .desktop-only,
  .submissions-table .submission-task-column > .desktop-only { display: none !important; }
  .submissions-table .mobile-only { display: inline !important; }
  .submissions-table .submission-char-column,
  .submissions-table .submission-original-score-column { display: none; }
  .submissions-table .submission-task-column { width: 15%; padding-left: 6px; }
  .submissions-table .submission-student-column { width: 15%; }
  .submissions-table .submission-status-column { width: 22%; }
  .submissions-table .submission-time-column { width: 14%; }
  .submissions-table .submission-current-score-column { width: 21%; }
  .submissions-table .submission-actions-column { width: 40px; padding-right: 5px; text-align: right; }
  .submissions-table .mobile-task-title,
  .submissions-table .submission-student-column strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .submissions-table .mobile-task-title { display: block !important; }
  .submissions-table .review-status {
    max-width: 100%;
    padding: 4px 5px;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .submissions-table .submission-time-column,
  .submissions-table .score-cell { font-variant-numeric: tabular-nums; }
  .submissions-table .score-cell { min-width: 0; font-size: 11px; }
  .submissions-table .row-actions { display: table-cell; }
  .desktop-row-actions { display: none; }
  .mobile-actions-menu { position: relative; display: inline-block; width: 34px; }
  .mobile-actions-menu > summary {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--brand-ink);
    background: #fff;
    cursor: pointer;
    list-style: none;
    font-size: 22px;
    line-height: 1;
  }
  .mobile-actions-menu > summary::-webkit-details-marker { display: none; }
  .mobile-actions-menu:not([open]) > .action-menu-content { display: none; }
  .mobile-actions-menu[open] > .action-menu-content {
    position: absolute;
    z-index: 20;
    top: 38px;
    right: 0;
    width: 116px;
    display: grid;
    gap: 5px;
    padding: 7px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(32, 27, 16, .16);
    align-items: stretch;
    justify-items: stretch;
    text-align: center;
  }
  .mobile-actions-menu .action-menu-content > *,
  .mobile-actions-menu .action-menu-content form,
  .mobile-actions-menu .action-menu-content .table-button {
    width: 100% !important;
    min-width: 0;
    margin: 0;
    box-sizing: border-box;
  }
  .mobile-actions-menu .action-menu-content .table-button {
    display: flex;
    justify-content: center;
    padding-inline: 7px;
  }
  .composition-matrix thead th { width: auto; min-width: 112px; max-width: 12em; height: 64px; }
  .composition-matrix tbody tr,
  .composition-matrix tbody th,
  .composition-matrix tbody td { height: 32px !important; max-height: 32px !important; }
  .composition-matrix .matrix-sticky { width: 76px; min-width: 76px; max-width: 76px; }
  .matrix-task-heading,
  .composition-matrix tbody td { min-width: 112px; max-width: 12em; }
  .overview-scope-tail {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fffaf0;
  }
  .overview-scope-tail label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }
  .overview-scope-tail select {
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fffef9;
    font-size: 14px;
  }
  .overview-mobile-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .overview-mobile-actions .secondary-button,
  .overview-mobile-actions .table-button {
    width: 100%;
    min-height: 42px;
  }

  .login-shell { width: calc(100% - 24px); min-height: calc(100vh - 58px); padding: 16px 0; }
  .login-card { min-height: 390px; grid-template-columns: 1fr; }
  .login-intro { display: none; }
  .login-form { padding: 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
