/* Balanced editorial styles for «Проверка» (7 grades, multi-filters, DOCX/PDF/scan viewer). */

.hw-root {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

@media (min-width: 921px) {
  .main:has(#hw-review-root) {
    padding-block: 14px 16px;
  }

  .main:has(#hw-review-root) > .page {
    max-width: none;
    gap: 0;
    height: calc(100dvh - 30px);
  }

  body:has(#hw-review-root) .mini-chat-dock {
    display: none !important;
  }

  .hw-root {
    height: 100%;
    min-height: 0;
    gap: 8px;
  }

  .hw-viewer-scroll.is-fit-page {
    flex: 1 1 0;
    container-type: size;
  }

  .hw-viewer-scroll.is-fit-page .hw-pdf-page-img,
  .hw-viewer-scroll.is-fit-page .hw-scan-img {
    max-height: calc(100cqh - 44px);
  }
}

.hw-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hw-top-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hw-h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hw-pending-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.hw-pending-badge.is-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.hw-pending-badge.is-ok {
  background: var(--confirm-soft);
  color: var(--confirm);
}

.hw-top-btns {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.hw-refresh-btn {
  width: 36px;
  height: 36px;
  flex: none;
}

.hw-refresh-btn svg {
  width: 16px;
  height: 16px;
}

.hw-add-btn {
  height: 36px;
  min-height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  flex: none;
}

.hw-add-lbl-short {
  display: none;
}

/* Unified horizontal filter bar */
.hw-filter-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hw-search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 200px;
  min-width: 170px;
}

.hw-search-ico {
  position: absolute;
  left: 13px;
  color: var(--muted);
  display: inline-flex;
  pointer-events: none;
}

.hw-search-ico svg {
  width: 15px;
  height: 15px;
}

.hw-ctrl {
  min-height: 38px;
  height: 38px;
  font-size: 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  min-width: 0;
}

.hw-search-box .hw-ctrl {
  padding: 0 14px 0 36px;
  width: 100%;
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--line) 80%, transparent);
}

:root[data-theme="dark"] .hw-search-box .hw-ctrl {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
}

.hw-select-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
}

.hw-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 124px;
  max-width: 210px;
}

.hw-select-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 38px;
  min-height: 38px;
  padding: 0 11px 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.hw-select-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
}

.hw-select-wrap.is-open .hw-select-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hw-select-btn.is-filtered {
  border-color: var(--accent);
  background-color: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.hw-select-lbl {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.25;
}

.hw-select-chev {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex: none;
  display: block;
  transition: transform 0.16s ease, color 0.12s ease;
}

.hw-select-btn:hover .hw-select-chev,
.hw-select-wrap.is-open .hw-select-chev {
  color: var(--ink);
}

.hw-select-wrap.is-filtered .hw-select-chev {
  color: var(--accent);
}

.hw-select-wrap.is-open .hw-select-chev {
  transform: rotate(180deg);
}

.hw-select-menu {
  min-width: 190px;
  max-width: min(290px, calc(100vw - 24px));
  width: max-content;
  z-index: 60;
}

.hw-select-wrap.is-align-left .hw-select-menu {
  left: 0;
  right: auto;
}

.hw-select-wrap.is-align-center .hw-select-menu {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  animation: none;
}

.hw-select-wrap.is-align-right .hw-select-menu {
  left: auto;
  right: 0;
}

.hw-select-opt-lbl {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hw-select-opt-ok {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  flex: none;
}

.hw-select-opt-ok svg {
  width: 14px;
  height: 14px;
}

.hw-seg {
  display: inline-flex;
  align-items: center;
  height: 38px;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  flex: none;
}

.hw-seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.hw-seg-btn:hover:not(.is-on) {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--ink);
}

.hw-seg-btn.is-on {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.hw-seg-cnt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  opacity: 1;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  color: var(--ink-2);
}

.hw-seg-btn.is-on .hw-seg-cnt {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

:root[data-theme="dark"] .hw-seg {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .hw-seg-btn {
  color: #8ea0b2;
}

:root[data-theme="dark"] .hw-seg-btn.is-on {
  background: rgba(94, 181, 247, 0.18);
  color: #6ab9f7;
  box-shadow: none;
}

:root[data-theme="dark"] .hw-seg-cnt {
  background: rgba(255, 255, 255, 0.14);
  color: #dce7f2;
}

:root[data-theme="dark"] .hw-seg-btn.is-on .hw-seg-cnt {
  background: rgba(94, 181, 247, 0.24);
  color: #6ab9f7;
}

.hw-reset-btn {
  height: 38px;
  min-height: 38px;
  border-radius: 999px;
  padding: 0 12px;
  flex: none;
}

.hw-error-banner {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 13px;
  font-weight: 500;
}

/* Add work drawer */
.hw-add-panel {
  position: relative;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  overflow: visible;
}

.hw-add-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hw-add-grid {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.hw-add-close {
  flex: none;
  width: 38px;
  height: 38px;
  min-height: 38px;
  border-radius: 10px;
}

.hw-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-2);
  min-width: 0;
}

.hw-field > span,
.hw-field > label {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hw-add-panel .input {
  height: 34px;
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 10px;
}

.hw-add-row-bot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hw-add-note-field {
  flex: 1 1 auto;
  min-width: 0;
}

.hw-add-note-field .hw-add-note-inp,
.hw-add-note-inp {
  flex: 1 1 auto;
  min-width: 0;
  height: 24px;
  min-height: 24px;
  max-height: 96px;
  padding: 1px 0 0 !important;
  line-height: 1.3;
  resize: vertical;
  overflow-y: auto;
}

.hw-add-attach,
.hw-add-submit {
  height: 34px;
  min-height: 34px;
  flex: none;
  white-space: nowrap;
  border-radius: 10px;
}

.hw-combo {
  position: relative;
}

.hw-combo-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 210px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 40;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg, 0 12px 28px rgba(15, 23, 42, 0.14));
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hw-combo-opt {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.hw-combo-opt:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.hw-combo-lbl {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.hw-combo-meta {
  flex: none;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 999px;
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hw-combo-opt:hover .hw-combo-meta {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
}

.hw-combo-empty {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--muted);
}

:root[data-theme="dark"] .hw-combo-menu {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.hw-file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hw-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink);
}

.hw-chip-del {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.hw-chip-del:hover {
  color: var(--bad);
}

/* Balanced full-height split sheet so header, queue, viewer, and bottom dock fill desktop cleanly */
.hw-sheet {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  max-height: none;
  min-width: 0;
}

.hw-sheet.is-queue-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.hw-sheet.is-queue-collapsed > .hw-list-pane {
  display: none;
}

/* Left queue pane */
.hw-list-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
}

.hw-rows {
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 2px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.hw-row {
  appearance: none;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  width: 100%;
  min-width: 0;
  transition: background-color 0.12s ease;
}

.hw-row:hover {
  background: var(--surface-2);
}

.hw-row.is-cur {
  background: var(--accent-soft);
}

.hw-row-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.hw-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.hw-dot.is-pending { background: var(--warn); }
.hw-dot.is-warn { background: var(--warn); }
.hw-dot.is-good { background: var(--confirm); }
.hw-dot.is-accent { background: var(--accent); }
.hw-dot.is-bad { background: var(--bad); }

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

.hw-group-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 6px;
  white-space: nowrap;
  flex: none;
}

.hw-row.is-cur .hw-group-tag {
  background: var(--surface);
}

.hw-row-task {
  font-size: 12.5px;
  color: var(--ink-2);
  padding-left: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hw-row-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-left: 14px;
  min-width: 0;
}

.hw-row-subj {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.hw-row-pills {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

.hw-file-kind {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
}

.hw-mini-grade {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
}

.hw-mini-grade.is-good { background: var(--confirm-soft); color: var(--confirm); }
.hw-mini-grade.is-accent { background: var(--accent-soft); color: var(--accent); }
.hw-mini-grade.is-warn { background: var(--warn-soft); color: var(--warn); }
.hw-mini-grade.is-bad { background: var(--bad-soft); color: var(--bad); }

.hw-row-date {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.hw-empty-state {
  padding: 32px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

/* Right pane: pinned header + scrollable viewer + pinned bottom grading dock */
.hw-canvas-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.hw-empty-canvas {
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.hw-empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.hw-canvas-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.hw-canvas-who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hw-mobile-back {
  display: none;
  flex: none;
}

.hw-queue-toggle {
  width: 32px;
  height: 32px;
  flex: none;
  color: var(--ink-2);
}

.hw-queue-toggle.is-collapsed {
  width: auto;
  height: 32px;
  padding: 0 10px;
  gap: 6px;
  font-weight: 600;
}

.hw-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.hw-canvas-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hw-canvas-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.hw-canvas-student {
  font-size: 15px;
  color: var(--ink);
}

.hw-status-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.hw-status-badge.is-pending,
.hw-status-badge.is-warn { background: var(--warn-soft); color: var(--warn); }
.hw-status-badge.is-good { background: var(--confirm-soft); color: var(--confirm); }
.hw-status-badge.is-accent { background: var(--accent-soft); color: var(--accent); }
.hw-status-badge.is-bad { background: var(--bad-soft); color: var(--bad); }

.hw-canvas-subline {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hw-canvas-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.hw-prompt-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  min-height: 32px;
}

.hw-prompt-btn.is-on {
  background: var(--accent-soft);
  color: var(--accent);
}

.hw-nav-btn {
  width: 32px;
  height: 32px;
}

.hw-nav-pos {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 4px;
  white-space: nowrap;
}

.hw-rot-180 svg {
  transform: rotate(180deg);
}

.hw-del-btn {
  width: 32px;
  height: 32px;
  color: var(--muted);
}

.hw-del-btn:hover {
  color: var(--bad);
  background: var(--bad-soft);
}

/* Collapsible task prompt panel without ugly focus outlines */
.hw-prompt-box {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hw-prompt-meta {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.hw-prompt-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
}

/* Pinned toolbar & scrollable document / scan viewer */
.hw-viewer-top {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.hw-viewer-top .hw-viewer-bar {
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
}

.hw-viewer-top .hw-student-note {
  padding: 6px 10px;
  font-size: 12.5px;
  line-height: 1.35;
}

.hw-viewer-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  contain: layout paint;
  padding: 12px 16px;
  background: var(--bg);
}

.hw-viewer-scroll.is-fit-page {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hw-viewer-scroll.is-fit-page .hw-viewer-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hw-viewer-scroll.is-fit-page .hw-pdf-pages {
  width: 100%;
  align-items: center;
}

.hw-viewer-scroll.is-fit-page .hw-pdf-page-card {
  width: fit-content;
  max-width: 100%;
  padding: 8px;
}

.hw-viewer-scroll.is-fit-page .hw-img-stage {
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  padding: 10px;
}

.hw-viewer-scroll.is-fit-page .hw-pdf-page-img,
.hw-viewer-scroll.is-fit-page .hw-scan-img {
  width: auto;
  max-width: 100%;
  max-height: max(300px, calc(100dvh - 445px));
  object-fit: contain;
}

.hw-viewer-scroll.is-fit-width .hw-pdf-page-card {
  width: min(100%, 880px);
  padding: 10px;
}

.hw-viewer-scroll.is-fit-width .hw-img-stage {
  width: min(100%, 880px);
  margin: 0 auto;
  min-height: 0;
  padding: 12px;
}

.hw-viewer-scroll.is-fit-width .hw-pdf-page-img,
.hw-viewer-scroll.is-fit-width .hw-scan-img {
  width: 100%;
  max-width: 100%;
  max-height: none;
  height: auto;
}

.hw-viewer-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.hw-student-note {
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}

.hw-note-lbl {
  font-weight: 600;
  color: var(--muted);
}

.hw-doc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hw-doc-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.hw-doc-tab:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.hw-doc-tab.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.hw-ext-mini {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-2);
}

.hw-viewer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.hw-viewer-filemeta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hw-ext-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}

.hw-ext-pill.is-lg {
  font-size: 13px;
  padding: 4px 10px;
}

.hw-viewer-fname {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hw-viewer-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.hw-viewer-stage {
  min-width: 0;
}

/* Editorial document paper (DOCX & plain text essays) */
.hw-doc-paper {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 24px;
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.hw-doc-h {
  margin: 0 0 2px;
  font-size: 16.5px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink);
}

.hw-doc-p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.hw-doc-loading {
  color: var(--muted);
  font-size: 13.5px;
}

.hw-doc-table-wrap {
  overflow-x: auto;
  margin-top: 4px;
}

.hw-doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}

.hw-doc-table th,
.hw-doc-table td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

.hw-doc-table th {
  background: var(--surface-2);
  font-weight: 600;
}

/* Scan / image stage */
.hw-img-stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  overflow: auto;
}

.hw-scan-img {
  display: block;
  max-width: 100%;
  max-height: 520px;
  height: auto;
  border-radius: 6px;
  cursor: zoom-in;
  transition: transform 0.18s ease;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.hw-img-stage.is-sideways .hw-scan-img {
  max-width: 440px;
  max-height: 440px;
  margin: 28px 0;
}

/* PDF rendered pages */
.hw-pdf-pages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.hw-pdf-page-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hw-pdf-page-num {
  align-self: flex-end;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.hw-pdf-page-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  cursor: zoom-in;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.hw-doc-fallback {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

/* Pinned bottom 7-grade grading dock */
.hw-grade-dock {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 9px 16px 11px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.hw-grade-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.hw-grade-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 2px;
}

.hw-grade-pill {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.hw-grade-pill:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.hw-grade-pill.is-selected.is-good {
  background: var(--confirm-soft);
  border-color: var(--confirm);
  color: var(--confirm);
  font-weight: 700;
}

.hw-grade-pill.is-selected.is-accent {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.hw-grade-pill.is-selected.is-warn {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
  font-weight: 700;
}

.hw-grade-pill.is-selected.is-bad {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: var(--bad);
  font-weight: 700;
}

.hw-grade-submit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hw-comment-inp {
  flex: 1 1 220px;
  height: 38px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 999px;
}

.hw-save-btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.hw-save-btns .btn {
  height: 38px;
  min-height: 38px;
  border-radius: 999px;
}

/* Fullscreen scan lightbox */
.hw-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 14, 22, 0.86);
  display: flex;
  flex-direction: column;
}

.hw-lightbox-top {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: #ffffff;
  background: rgba(24, 27, 32, 0.94);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.hw-lightbox-title {
  justify-self: start;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hw-lightbox-zoom-slot {
  justify-self: center;
}

.hw-lightbox-tools {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hw-lightbox-top .btn.ghost,
.hw-lightbox-top .icon-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.hw-lightbox-top .btn.ghost:hover,
.hw-lightbox-top .icon-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.45);
}

.hw-lightbox-body {
  flex: 1 1 auto;
  overflow: auto;
  display: flex;
  padding: 24px;
}

.hw-lightbox-canvas {
  margin: auto;
  flex-shrink: 0;
  cursor: default;
}

.hw-lightbox-img {
  display: block;
  width: auto;
  height: calc(80vh * var(--hw-lb-zoom, 1));
  max-width: none;
  max-height: none;
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  transition: width 0.14s ease, height 0.14s ease, transform 0.18s ease;
}

/* Chrome-like zoom toolbar control */
.hw-zoom-ctrl {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 30px;
  padding: 0 4px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-2, #f8fafc);
  color: var(--text, #0f172a);
  flex-shrink: 0;
}

.hw-zoom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background 0.14s ease, opacity 0.14s ease;
}

.hw-zoom-btn:hover:not(:disabled) {
  background: rgba(128, 128, 128, 0.14);
}

.hw-zoom-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.hw-zoom-menu-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.hw-zoom-val {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.12));
  border-radius: 4px;
  background: var(--surface, #ffffff);
  color: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.14s ease;
}

.hw-zoom-val:hover {
  background: var(--surface-2, #f1f5f9);
}

.hw-zoom-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  min-width: 92px;
  max-height: 310px;
  overflow-y: auto;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface, #ffffff);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.hw-zoom-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text, #0f172a);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}

.hw-zoom-opt:hover {
  background: var(--surface-2, #f1f5f9);
}

.hw-zoom-opt.is-active {
  background: var(--accent-soft, rgba(59, 130, 246, 0.14));
  color: var(--accent, #2563eb);
  font-weight: 700;
}

.hw-zoom-ctrl.is-dark {
  height: 32px;
  padding: 0 6px;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(60, 64, 67, 0.92);
  color: #ffffff;
}

.hw-zoom-ctrl.is-dark .hw-zoom-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.hw-zoom-ctrl.is-dark .hw-zoom-val {
  height: 24px;
  background: #1b1d20;
  color: #ffffff;
}

.hw-zoom-ctrl.is-dark .hw-zoom-val:hover {
  background: #111315;
}

.hw-zoom-ctrl.is-dark .hw-zoom-menu {
  background: #242629;
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
}

.hw-zoom-ctrl.is-dark .hw-zoom-opt {
  color: #e5e7eb;
}

.hw-zoom-ctrl.is-dark .hw-zoom-opt:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hw-zoom-ctrl.is-dark .hw-zoom-opt.is-active {
  background: rgba(96, 165, 250, 0.24);
  color: #93c5fd;
}

.hw-viewer-scroll.is-zoomed {
  overflow: auto !important;
}

.hw-viewer-scroll.is-zoomed .hw-pdf-pages {
  align-items: flex-start;
}

.hw-viewer-scroll.is-zoomed .hw-pdf-page-card,
.hw-viewer-scroll.is-zoomed .hw-img-stage {
  margin: 0 auto;
  max-width: none !important;
  flex-shrink: 0;
}

.hw-viewer-scroll.is-zoomed .hw-pdf-page-img,
.hw-viewer-scroll.is-zoomed .hw-scan-img {
  width: 100%;
  height: auto;
  max-width: none !important;
  max-height: none !important;
}

/* Mobile & Tablet responsive */
@media (max-width: 920px) {
  .hw-sheet {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .hw-list-pane {
    border-right: 0;
  }

  .hw-rows {
    max-height: none;
  }

  .hw-list-pane.is-mobile-hidden {
    display: none;
  }

  .hw-canvas-pane {
    display: none;
    height: auto;
  }

  .hw-canvas-pane.is-mobile-open {
    display: flex;
  }

  .hw-mobile-back {
    display: inline-flex;
    width: 32px;
    height: 32px;
  }

  .hw-queue-toggle {
    display: none;
  }

  .hw-viewer-scroll {
    overflow: visible;
  }

  .hw-viewer-scroll.is-zoomed {
    overflow: auto;
    max-height: 72vh;
  }

  .hw-add-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 641px) and (max-width: 1220px) {
  .hw-filter-bar {
    flex-wrap: wrap;
  }

  .hw-search-box {
    order: 1;
  }

  .hw-seg {
    order: 2;
  }

  .hw-select-row {
    order: 3;
    flex: 1 0 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .hw-select-wrap,
  .hw-select-btn {
    flex: none;
    max-width: none;
    width: 100%;
  }

  .hw-reset-btn {
    order: 4;
  }
}

@media (max-width: 640px) {
  .hw-lightbox-top {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title tools"
      "zoom zoom";
    padding: 10px 12px;
    gap: 8px;
  }

  .hw-lightbox-title {
    grid-area: title;
  }

  .hw-lightbox-zoom-slot {
    grid-area: zoom;
    justify-self: center;
  }

  .hw-lightbox-tools {
    grid-area: tools;
  }

  .hw-lightbox-body {
    padding: 12px;
  }

  .hw-lightbox-img {
    width: calc(92vw * var(--hw-lb-zoom, 1));
    height: auto;
  }

  .hw-topbar {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .hw-h1 {
    font-size: 21px;
  }

  .hw-add-btn {
    padding: 0 12px;
    font-size: 13px;
  }

  .hw-add-lbl-full {
    display: none;
  }

  .hw-add-lbl-short {
    display: inline;
  }

  .hw-filter-bar {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .hw-search-box {
    order: 1;
    flex: none;
    width: 100%;
    min-width: 0;
  }

  .hw-search-box .hw-ctrl {
    height: 40px;
    min-height: 40px;
    font-size: 14px;
  }

  .hw-select-row {
    order: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex: none;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .hw-select-wrap {
    flex: none;
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .hw-select-btn {
    flex: none;
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 34px;
    min-height: 34px;
    font-size: 11.5px;
    letter-spacing: -0.01em;
    padding: 0 7px 0 9px;
    gap: 3px;
  }

  .hw-select-chev {
    width: 12px;
    height: 12px;
  }

  .hw-seg {
    order: 3;
    display: flex;
    flex: none;
    width: 100%;
    max-width: 100%;
    height: 36px;
    padding: 3px;
    gap: 2px;
    overflow: hidden;
    justify-content: space-between;
  }

  .hw-seg-btn {
    flex: 1 1 auto;
    min-width: 0;
    height: 28px;
    padding: 0 6px;
    font-size: 11.5px;
    gap: 4px;
  }

  .hw-seg-cnt {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10.5px;
  }

  .hw-reset-btn {
    order: 4;
    align-self: flex-start;
    height: 34px;
    min-height: 34px;
  }

  .hw-save-btns {
    width: 100%;
  }

  .hw-save-btns .btn {
    flex: 1 1 0;
    justify-content: center;
  }

  .hw-canvas-head,
  .hw-prompt-box,
  .hw-viewer-scroll,
  .hw-grade-dock {
    padding-left: 12px;
    padding-right: 12px;
  }

  .hw-canvas-head {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
  }

  .hw-canvas-who {
    flex: 1 1 100%;
  }

  .hw-canvas-subline {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .hw-canvas-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .hw-doc-paper {
    padding: 14px 14px;
  }

  .hw-grade-sep {
    display: none;
  }

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

  .hw-add-row-top {
    align-items: flex-start;
  }

  .hw-add-row-bot {
    flex-wrap: wrap;
  }

  .hw-add-note-inp {
    flex: 1 1 100%;
  }

  .hw-combo-menu {
    min-width: 0;
  }
}
