:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #68717a;
  --line: #d9dee5;
  --surface: #f7f8fa;
  --panel: #ffffff;
  --accent: #1f7a68;
  --accent-strong: #125f50;
  --warning: #a64d00;
  --danger: #b3261e;
  --major: #8f5c00;
  --minor: #50627a;
  --shadow: 0 14px 34px rgba(20, 31, 43, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

.phone-landscape-only {
  display: none;
}

.phone-only {
  display: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fdfdfd;
}

.release-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #c8e3dc;
  border-radius: 8px;
  background: #edf8f5;
  color: var(--accent-strong);
}

.release-banner div {
  display: grid;
  gap: 2px;
}

.release-banner span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.release-banner strong,
.release-banner time {
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #22322f;
  color: #ffffff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.file-picker,
button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

button.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.field {
  display: grid;
  gap: 7px;
}

.exercise-picker {
  min-width: 260px;
}

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

select {
  width: 100%;
  min-height: 40px;
  padding: 0 36px 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.voice-grid {
  display: grid;
  gap: 12px;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
}

.workspace.result-layout #gradingSummary {
  order: 1;
}

.workspace.result-layout #basicJudgement {
  order: 2;
}

.workspace.result-layout .exercise-section {
  order: 3;
}

.workspace.result-layout .content-grid {
  order: 4;
}

.result-summary-card,
.exercise-section,
.report-section,
.basic-judgement {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.result-summary-card {
  position: relative;
  z-index: 1;
  display: grid;
  margin-bottom: 10px;
  overflow: hidden;
}

.result-summary-row {
  display: grid;
  grid-template-columns: minmax(190px, 25%) minmax(720px, 75%);
  align-items: stretch;
}

.domain-score-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.domain-score {
  display: grid;
  min-width: 0;
  min-height: 68px;
  gap: 3px;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  border-left: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}

.domain-score:last-child {
  border-right: 0;
}

.domain-score:hover,
.domain-score:focus-visible {
  background: #f2f8f6;
}

.domain-score > span,
.domain-score small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.domain-score > strong {
  font-size: 15px;
  white-space: nowrap;
}

.domain-score > strong b {
  color: var(--accent-strong);
  font-size: 20px;
}

.domain-score small {
  color: var(--danger);
  font-weight: 700;
}

.domain-score .domain-judgement {
  margin-top: 4px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
}

.desktop-tablet-score-summary .domain-score.has-error > span,
.desktop-tablet-score-summary .domain-score.has-error > strong,
.desktop-tablet-score-summary .domain-score.has-error > strong b,
.desktop-tablet-score-summary .domain-score.has-error .domain-judgement,
.desktop-tablet-score-summary .domain-score.has-error small {
  color: var(--danger);
}

.score-origin-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-height: 38px;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
}

.score-origin-line strong {
  color: var(--text);
}

.score-cap-reason {
  flex-basis: 100%;
  color: var(--danger);
  font-size: 12px;
}

.basic-judgement {
  margin-bottom: 10px;
  overflow: hidden;
}

.basic-judgement-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.basic-judgement-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.basic-judgement-item {
  min-width: 0;
  padding: 10px 14px;
}

.basic-judgement-item + .basic-judgement-item {
  border-left: 1px solid var(--line);
}

.basic-judgement-item h3 {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.basic-success {
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
}

.basic-error {
  display: grid;
  gap: 5px;
  font-size: 13px;
  line-height: 1.4;
}

.basic-error p {
  margin: 0;
}

.basic-error-label {
  color: var(--muted);
}

.basic-error-title,
.basic-deduction {
  color: var(--danger);
  font-weight: 800;
}

.basic-cadence-issues {
  display: grid;
  gap: 7px;
}

.basic-cadence-issue {
  display: grid;
  gap: 2px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.basic-cadence-issue:first-child {
  padding-top: 0;
  border-top: 0;
}

.basic-cadence-issue span {
  color: var(--muted);
  line-height: 1.4;
}

.technical-result-state[hidden] {
  display: none;
}

.score-panel {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-panel strong {
  font-size: 42px;
  line-height: 1;
}

.score-panel > #scoreLabel {
  color: var(--muted);
  font-size: 14px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.report-section {
  min-width: 0;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.section-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h2 {
  font-size: 17px;
}

.exercise-section {
  position: relative;
  z-index: 2;
  margin-bottom: 16px;
  overflow: visible;
}

.exercise-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.exercise-meta {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.exercise-meta strong {
  color: var(--ink);
  font-size: 14px;
}

.exercise-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.knowledge-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.knowledge-tags span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef4f8;
  color: #2f5f73;
  font-size: 12px;
  font-weight: 700;
}

.knowledge-ai-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8f2020;
  font-size: 12px;
  font-weight: 700;
}

.knowledge-ai-status span {
  padding: 3px 7px;
  border-radius: 4px;
  background: #fdecec;
  color: #a91f1f;
}

.knowledge-toggle.active,
.knowledge-toggle[aria-pressed="true"] {
  border-color: #b52a2a;
  background: #fff1f1;
  color: #a91f1f;
}

.score-board {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.score-content {
  transform:
    translate3d(
      var(--score-pan-x, 0px),
      var(--score-pan-y, 0px),
      0
    )
    scale(var(--score-zoom, 1));
  transform-origin: 0 0;
}

.exercise-controls {
  display: grid;
  grid-template-columns:
    minmax(170px, 1fr)
    minmax(150px, 0.8fr)
    minmax(150px, 0.8fr)
    minmax(140px, 0.7fr)
    auto
    auto
    minmax(190px, 1.1fr);
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.accidental-field select {
  min-width: 140px;
}

.exercise-controls p {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}

.split-mode-button.active,
.split-mode-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e7f5f1;
  color: var(--accent-strong);
}

.split-action-panel {
  position: fixed;
  z-index: 60;
  display: grid;
  width: min(430px, calc(100vw - 28px));
  gap: 10px;
  padding: 14px;
  border: 1px solid #b8d7cf;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(20, 31, 43, 0.2);
  transform: translateX(-50%);
}

.split-action-panel[hidden] {
  display: none;
}

.split-action-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.split-action-heading strong {
  font-size: 15px;
}

.split-action-heading span {
  color: var(--muted);
  font-size: 12px;
}

.split-action-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.split-action-options button {
  min-height: 40px;
  padding: 6px 10px;
  border-color: #b8d7cf;
  background: #f3fbf8;
  color: var(--accent-strong);
  font-size: 13px;
}

.split-action-options button.remove-split {
  border-color: #d9dee5;
  background: #ffffff;
  color: #7b3f00;
}

.split-target {
  cursor: pointer;
}

.split-target.selected {
  fill: #d8eee8;
  stroke: var(--accent);
  stroke-width: 1.6;
}

.harmony-split-line {
  pointer-events: none;
}

.key-picker {
  position: relative;
}

.key-picker-trigger {
  width: 100%;
  min-height: 40px;
  justify-content: space-between;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
  font-weight: 500;
}

.key-picker-trigger::after {
  content: "⌄";
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.key-picker-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  width: min(420px, calc(100vw - 48px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.key-picker-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.key-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

.key-picker-column-title {
  padding: 2px 10px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.key-picker-option {
  min-height: 34px;
  justify-content: flex-start;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.key-picker-option:hover,
.key-picker-option.selected {
  border-color: #c8e3dc;
  background: #edf8f5;
  color: var(--accent-strong);
}

.exercise-svg {
  display: block;
  width: 100%;
  min-width: 0;
  height: auto;
  touch-action: manipulation;
}

.answer-hit {
  cursor: crosshair;
}

.function-hit {
  cursor: pointer;
}

.cadence-hit {
  cursor: pointer;
}

.cadence-hit:hover {
  fill: #fff1df;
  fill-opacity: 0.7;
}

.key-answer-control,
.key-answer-hit {
  cursor: pointer;
}

.key-answer-control:focus-visible .key-answer-hit {
  stroke: var(--accent);
  stroke-width: 2;
}

.issue-list,
.chord-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.issue-list-heading {
  flex-wrap: wrap;
}

.issue-list-heading h2 {
  flex: 0 0 auto;
}

.issue-filters {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
}

.issue-filter {
  min-height: 32px;
  padding: 5px 9px;
  border-color: #d5dbe1;
  background: #f6f7f8;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.issue-filter.active,
.issue-filter[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e7f5f1;
  color: var(--accent-strong);
}

.issue-filter span {
  font-weight: 900;
}

.issue-list.empty,
.chord-list.empty {
  color: var(--muted);
}

.issue {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: #ffffff;
}

.issue.critical {
  border-left-color: var(--danger);
}

.issue.major {
  border-left-color: var(--major);
}

.issue.minor {
  border-left-color: var(--minor);
}

.issue.info {
  border-left-color: var(--accent);
  background: #f6fbf8;
}

.issue-time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.issue-title {
  margin-bottom: 5px;
  font-weight: 800;
}

.issue-detail {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 8px;
}

.issue-meta span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef3f0;
  color: #3e5148;
  font-size: 11px;
  font-weight: 700;
}

.issue-evidence,
.issue-related {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.foundation-related-issues {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.foundation-related-issues summary {
  width: fit-content;
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 800;
}

.foundation-related-issues div {
  display: grid;
  gap: 6px;
  margin-top: 7px;
}

.foundation-related-issues p {
  display: grid;
  gap: 2px;
  margin: 0;
  padding-left: 10px;
  border-left: 2px solid #d8e3df;
}

.foundation-related-issues span {
  line-height: 1.4;
}

@media (min-width: 768px) and (min-height: 601px) {
  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .result-summary-row {
    grid-template-columns: minmax(140px, 1.25fr) repeat(5, minmax(110px, 1fr));
    min-height: 108px;
    max-height: 130px;
    overflow-x: auto;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .domain-score-grid {
    display: contents;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .score-panel,
  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .domain-score {
    min-height: 122px;
    max-height: 130px;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .score-domain-card {
    display: grid;
    grid-template-rows: 22px 38px 32px 22px;
    align-content: center;
    justify-items: center;
    gap: 0;
    min-width: 0;
    padding: 10px 8px;
    text-align: center;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .domain-label {
    grid-row: 1;
    align-self: center;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .domain-score-value {
    grid-row: 2;
    align-self: center;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .domain-status {
    grid-row: 3;
    align-self: center;
    width: 100%;
    overflow: hidden;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .domain-deduction {
    grid-row: 4;
    align-self: center;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-score-summary .cadence-domain-card .domain-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    max-width: 190px;
    min-width: 0;
    font-size: 10px;
    line-height: 14px;
    white-space: nowrap;
    text-align: center;
  }

  body:not(.phone-landscape):not(.phone-portrait) #basicJudgement {
    display: none !important;
  }
}

body.phone-landscape .domain-judgement,
body.phone-portrait .domain-judgement {
  display: none !important;
}

.score-review-section {
  display: contents;
}

.review-question-bar {
  display: none;
}

@media (min-width: 768px) and (min-height: 601px) {
  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .exercise-section,
  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .exercise-body {
    display: contents;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .exercise-section > .section-title,
  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page #exerciseMeta {
    display: none;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .score-review-section {
    position: static;
    order: 3;
    display: block;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    flex: none;
    align-self: flex-start;
    margin-bottom: 10px;
    overflow: visible;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .review-question-bar {
    display: flex;
    min-height: 46px;
    gap: 12px;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--line);
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .review-question-text {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
    align-items: center;
    overflow: hidden;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .review-question-text > strong {
    flex: 1 1 auto;
    min-width: 120px;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .review-question-text .knowledge-tags {
    flex: 0 1 auto;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .review-question-text .knowledge-tags span {
    padding: 3px 7px;
    font-size: 11px;
    white-space: nowrap;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .review-question-text .knowledge-ai-status {
    display: none;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page #reviewEditButton {
    flex: 0 0 auto;
    min-height: 38px;
    white-space: nowrap;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .review-score-viewport {
    position: relative;
    display: flex;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    flex: none;
    align-self: flex-start;
    align-items: flex-start;
    justify-content: flex-start;
    overflow: visible;
    box-sizing: border-box;
    margin: 0;
    padding: 8px 12px 6px 24px;
    border: 0;
    border-radius: 0 0 8px 8px;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .review-score-svg {
    flex: 0 0 auto;
    display: block;
    width: auto;
    height: auto;
    min-height: 0;
    max-width: 100%;
    max-height: none;
    flex-grow: 0;
    margin: 0;
    padding: 0;
    transform: none;
    transform-origin: top left;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-result-page .content-grid {
    order: 4;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked #currentErrorPanel {
    margin-top: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked #currentErrorPanel > .current-error-header {
    display: flex;
    min-height: 48px;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked #currentErrorPanel > .current-error-header h2 {
    margin: 0;
    font-size: 18px;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked #currentErrorPanel .current-error-summary {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked #currentErrorPanel .current-error-detail {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-current-error {
    min-height: 0;
    gap: 7px;
    padding: 14px 52px 14px 18px;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-current-error h3 {
    font-size: 16px;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-current-error p {
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
  }

  body:not(.phone-landscape):not(.phone-portrait).grading-locked .desktop-tablet-current-error .issue-meta {
    margin-top: 0;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-modal-layer:not([hidden]) {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: auto;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-modal-backdrop {
    position: absolute;
    z-index: 1000;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.32);
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-tonality-modal {
    position: relative;
    z-index: 1001;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: min(520px, calc(100vw - 48px));
    max-width: 520px;
    max-height: min(640px, calc(100dvh - 64px));
    overflow-y: auto;
    padding: 20px;
    border-radius: 14px;
    background: #fff;
    box-sizing: border-box;
    pointer-events: auto;
    transform: none;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-tonality-modal:not([hidden]) {
    display: block;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-tonality-modal[hidden] {
    display: none !important;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-tonality-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 16px;
  }

  body:not(.phone-landscape):not(.phone-portrait) .desktop-tablet-tonality-option {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 8px 12px;
    text-align: left;
  }
}

.issue-penalty {
  color: var(--danger);
  font-weight: 800;
  white-space: nowrap;
}

.issue.info .issue-penalty {
  color: var(--accent-strong);
}

.chord {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.chord-time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chord strong {
  display: block;
  margin-bottom: 4px;
}

.chord span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .toolbar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .voice-grid {
    grid-template-columns: 1fr 1fr;
  }

  .result-summary-row {
    grid-template-columns: minmax(180px, 25%) minmax(720px, 75%);
    overflow-x: auto;
  }

  .domain-score-grid {
    min-width: 720px;
    overscroll-behavior-inline: contain;
  }

  .domain-score {
    min-width: 144px;
  }

  .exercise-controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  .toolbar,
  .workspace {
    padding: 16px;
  }

  .voice-grid {
    grid-template-columns: 1fr;
  }

  .result-summary-row {
    grid-template-columns: 150px minmax(720px, 1fr);
  }

  .score-panel {
    position: sticky;
    left: 0;
    z-index: 2;
    border-right: 1px solid var(--line);
    background: var(--panel);
  }

  .basic-judgement-grid {
    grid-template-columns: 1fr;
  }

  .basic-judgement-item + .basic-judgement-item {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .issue {
    grid-template-columns: 1fr;
  }

  .issue-penalty {
    white-space: normal;
  }

  .exercise-controls {
    grid-template-columns: 1fr;
  }

  .split-action-panel {
    right: 0;
    bottom: 0;
    left: 0 !important;
    width: 100%;
    max-width: none;
    padding: 16px max(16px, env(safe-area-inset-right))
      calc(16px + env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 14px 14px 0 0;
    transform: none;
  }

  .split-action-options {
    grid-template-columns: 1fr;
  }
}

/* v1.5 dedicated phone-landscape workspace */
@media (orientation: landscape) and (max-width: 1000px) and (max-height: 600px) {
  html,
  body {
    width: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  body.phone-landscape {
    --phone-top: 44px;
    --phone-tools: 56px;
    --phone-error-detail: 112px;
    --phone-summary: 50px;
    --phone-basic: 34px;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    font-size: 14px;
    overscroll-behavior: none;
  }

  body.phone-landscape .phone-landscape-only:not([hidden]) {
    display: flex;
  }

  body.phone-landscape .phone-landscape-only[hidden] {
    display: none !important;
  }

  body.phone-landscape .phone-landscape-topbar {
    position: fixed;
    z-index: 90;
    top: env(safe-area-inset-top);
    right: 0;
    left: 0;
    height: var(--phone-top);
    align-items: center;
    gap: 4px;
    padding: 3px max(6px, env(safe-area-inset-right)) 3px max(6px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
  }

  body.phone-landscape .phone-top-button {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 38px;
    padding: 0 10px;
    border-color: #cfd6dc;
    background: #ffffff;
    color: var(--ink);
    font-size: 13px;
  }

  body.phone-landscape .phone-top-button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
  }

  body.phone-landscape .phone-exercise-title {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    padding: 0 4px;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phone-landscape .app-shell {
    display: block;
    width: 100%;
    height: 100dvh;
    min-height: 0;
  }

  body.phone-landscape .toolbar {
    position: fixed;
    z-index: 110;
    top: calc(env(safe-area-inset-top) + var(--phone-top));
    bottom: env(safe-area-inset-bottom);
    left: 0;
    width: min(320px, 76vw);
    overflow-y: auto;
    gap: 10px;
    padding: 12px max(12px, env(safe-area-inset-left));
    border-right: 1px solid var(--line);
    border-bottom: 0;
    background: #ffffff;
    box-shadow: 16px 0 40px rgba(20, 31, 43, 0.22);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.phone-landscape.phone-question-open .toolbar {
    transform: translateX(0);
  }

  body.phone-landscape.phone-question-open::after {
    position: fixed;
    z-index: 105;
    top: calc(env(safe-area-inset-top) + var(--phone-top));
    right: 0;
    bottom: env(safe-area-inset-bottom);
    left: 0;
    content: "";
    background: rgba(20, 31, 43, 0.28);
  }

  body.phone-landscape .toolbar .release-banner,
  body.phone-landscape .toolbar .brand,
  body.phone-landscape .toolbar .file-picker,
  body.phone-landscape .toolbar #sampleButton,
  body.phone-landscape .toolbar #gradeButton {
    display: none;
  }

  body.phone-landscape .toolbar .exercise-picker {
    min-width: 0;
    gap: 5px;
  }

  body.phone-landscape .toolbar select {
    min-height: 38px;
    font-size: 13px;
  }

  body.phone-landscape .toolbar button {
    min-height: 40px;
  }

  body.phone-landscape .workspace {
    position: fixed;
    z-index: 1;
    top: calc(env(safe-area-inset-top) + var(--phone-top));
    right: 0;
    bottom: calc(env(safe-area-inset-bottom) + var(--phone-tools));
    left: 0;
    display: block;
    min-width: 0;
    overflow: hidden;
    padding: 6px;
  }

  body.phone-landscape.phone-graded-locked .workspace {
    bottom: calc(env(safe-area-inset-bottom) + var(--phone-error-detail));
  }

  body.phone-landscape.phone-has-result .workspace {
    top: calc(env(safe-area-inset-top) + var(--phone-top) + var(--phone-summary) + var(--phone-basic));
  }

  body.phone-landscape.phone-has-result.phone-summary-collapsed .workspace {
    top: calc(env(safe-area-inset-top) + var(--phone-top) + 32px + var(--phone-basic));
  }

  body.phone-landscape .exercise-section {
    position: absolute;
    inset: 6px;
    z-index: 2;
    height: auto;
    margin: 0;
    overflow: hidden;
    border-radius: 6px;
    box-shadow: none;
  }

  body.phone-landscape .exercise-section > .section-title,
  body.phone-landscape .exercise-meta,
  body.phone-landscape .exercise-controls,
  body.phone-landscape .assist-tools,
  body.phone-landscape .content-grid > #currentErrorPanel {
    display: none !important;
  }

  body.phone-landscape .exercise-body {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
  }

  body.phone-landscape .score-board {
    width: 100%;
    height: 100%;
    overflow: auto;
    border: 0;
    border-radius: 0;
    overscroll-behavior: contain;
    touch-action: none;
  }

  body.phone-landscape .exercise-svg {
    width: 100%;
    min-width: 760px;
    height: auto;
    touch-action: none;
    transform-origin: top left;
  }

  body.phone-landscape .exercise-load-notice,
  body.phone-landscape .result-stale-notice {
    position: absolute;
    z-index: 8;
    top: 7px;
    left: 50%;
    width: max-content;
    max-width: 80%;
    padding: 7px 10px;
    font-size: 12px;
    transform: translateX(-50%);
  }

  body.phone-landscape .phone-answer-toolbar {
    position: fixed;
    z-index: 80;
    right: 0;
    bottom: env(safe-area-inset-bottom);
    left: 0;
    height: var(--phone-tools);
    align-items: stretch;
    gap: 4px;
    overflow-x: auto;
    padding: 4px max(6px, env(safe-area-inset-right)) 4px max(6px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    scrollbar-width: none;
  }

  body.phone-landscape .phone-answer-toolbar button {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 11px;
    border-color: #cfd6dc;
    background: #ffffff;
    color: var(--ink);
    font-size: 13px;
    white-space: nowrap;
  }

  body.phone-landscape .phone-answer-toolbar button.active {
    border-color: var(--accent);
    background: #e7f5f1;
    color: var(--accent-strong);
  }

  body.phone-landscape .phone-answer-toolbar span {
    color: var(--accent-strong);
    font-weight: 900;
  }

  body.phone-landscape #gradingSummary {
    position: fixed;
    z-index: 68;
    top: calc(env(safe-area-inset-top) + var(--phone-top));
    right: 0;
    left: 0;
    display: none;
    height: var(--phone-summary);
    margin: 0;
    overflow: hidden;
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
  }

  body.phone-landscape.phone-has-result #gradingSummary {
    display: block;
  }

  body.phone-landscape.phone-summary-collapsed #gradingSummary {
    height: 32px;
  }

  body.phone-landscape .result-summary-row {
    display: grid;
    height: 100%;
    grid-template-columns: 112px minmax(0, 1fr);
    overflow: hidden;
  }

  body.phone-landscape .score-panel {
    position: relative;
    z-index: 2;
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 5px;
    padding: 5px 8px;
    border-right: 1px solid var(--line);
    background: #ffffff;
  }

  body.phone-landscape .score-panel .eyebrow {
    display: none;
  }

  body.phone-landscape .score-panel strong {
    font-size: 28px;
  }

  body.phone-landscape .score-panel > #scoreLabel {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phone-landscape .domain-score-grid {
    display: flex;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.phone-landscape .domain-score {
    min-width: 116px;
    min-height: 44px;
    padding: 5px 9px;
    border-width: 0 1px 0 0;
    border-radius: 0;
    font-size: 12px;
    white-space: nowrap;
  }

  body.phone-landscape .domain-score strong {
    font-size: 13px;
  }

  body.phone-landscape .domain-score small {
    font-size: 10px;
  }

  body.phone-landscape .score-origin-line {
    position: absolute;
    z-index: 4;
    right: 42px;
    bottom: 1px;
    left: 118px;
    overflow: hidden;
    padding: 2px 6px;
    background: #fff8ec;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phone-landscape .phone-summary-toggle {
    position: absolute;
    z-index: 7;
    top: 3px;
    right: 3px;
    min-height: 28px;
    padding: 0 7px;
    border-color: #d5dbe1;
    background: #ffffff;
    color: var(--muted);
    font-size: 11px;
  }

  body.phone-landscape.phone-summary-collapsed #gradingSummary .domain-score-grid,
  body.phone-landscape.phone-summary-collapsed #gradingSummary #scoreLabel,
  body.phone-landscape.phone-summary-collapsed #gradingSummary .score-origin-line {
    display: none;
  }

  body.phone-landscape.phone-summary-collapsed #gradingSummary .result-summary-row {
    grid-template-columns: 112px 1fr;
  }

  body.phone-landscape.phone-summary-collapsed #gradingSummary .score-panel strong {
    font-size: 24px;
  }

  body.phone-landscape #basicJudgement {
    position: fixed;
    z-index: 67;
    top: calc(env(safe-area-inset-top) + var(--phone-top) + var(--phone-summary));
    right: 0;
    left: 0;
    display: none;
    height: var(--phone-basic);
    margin: 0;
    overflow-x: auto;
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
    white-space: nowrap;
  }

  body.phone-landscape.phone-has-result #basicJudgement:not([hidden]) {
    display: block;
  }

  body.phone-landscape.phone-summary-collapsed #basicJudgement {
    top: calc(env(safe-area-inset-top) + var(--phone-top) + 32px);
  }

  body.phone-landscape .basic-judgement-header,
  body.phone-landscape .basic-judgement-item h3 {
    display: none;
  }

  body.phone-landscape .basic-judgement-grid {
    display: flex;
    min-width: max-content;
    height: 100%;
  }

  body.phone-landscape .basic-judgement-item {
    display: flex;
    min-width: 240px;
    align-items: center;
    padding: 4px 10px;
    border: 0;
    border-right: 1px solid var(--line);
  }

  body.phone-landscape .basic-success,
  body.phone-landscape .basic-error {
    font-size: 12px;
  }

  body.phone-landscape .basic-error {
    display: flex;
    gap: 8px;
  }

  body.phone-landscape .basic-error p {
    white-space: nowrap;
  }

  body.phone-landscape .basic-cadence-issues {
    display: flex;
    gap: 8px;
    font-size: 12px;
  }

  body.phone-landscape .phone-current-error-bar {
    position: fixed;
    z-index: 79;
    right: 0;
    bottom: env(safe-area-inset-bottom);
    left: 0;
    height: var(--phone-error-detail);
    align-items: stretch;
    gap: 8px;
    padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
  }

  body.phone-landscape.phone-error-expanded {
    --phone-error-detail: 130px;
  }

  body.phone-landscape .phone-current-error-content {
    display: grid;
    min-width: 0;
    flex: 1 1 auto;
    align-content: start;
    gap: 3px;
    overflow: auto;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
  }

  body.phone-landscape .phone-current-error-content strong {
    color: var(--ink);
    font-size: 14px;
  }

  body.phone-landscape .phone-current-error-content span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phone-landscape.phone-error-expanded .phone-current-error-content span {
    white-space: normal;
  }

  body.phone-landscape .phone-current-error-content small {
    font-size: 11px;
  }

  body.phone-landscape .phone-error-actions {
    display: grid;
    flex: 0 0 auto;
    grid-template-columns: repeat(2, auto);
    gap: 4px;
  }

  body.phone-landscape .phone-error-actions button {
    min-height: 44px;
    padding: 0 9px;
    border-color: #cfd6dc;
    background: #ffffff;
    color: var(--ink);
    font-size: 12px;
  }

  body.phone-landscape .content-grid {
    display: block;
  }

  body.phone-landscape #issuePanel {
    position: static;
    display: block;
    height: auto;
    overflow: visible;
    border-radius: 8px;
    background: #ffffff;
  }

  body.phone-landscape #issuePanel .section-title {
    height: 48px;
    flex-wrap: nowrap;
    gap: 5px;
    padding: 17px 8px 5px;
  }

  body.phone-landscape #issuePanel .section-title h2 {
    font-size: 14px;
    white-space: nowrap;
  }

  body.phone-landscape #issuePanel .issue-filters {
    gap: 3px;
  }

  body.phone-landscape #issuePanel .issue-filter,
  body.phone-landscape #issuePanel #copyButton {
    min-height: 30px;
    padding: 3px 7px;
    font-size: 11px;
  }

  body.phone-landscape #issuePanel .issue-list {
    height: auto;
    overflow: visible;
    gap: 6px;
    padding: 6px 8px calc(12px + env(safe-area-inset-bottom));
  }

  body.phone-landscape #issuePanel .issue {
    min-height: 48px;
    grid-template-columns: 94px minmax(0, 1fr) auto;
    gap: 7px;
    padding: 7px 8px;
    border-radius: 6px;
  }

  body.phone-landscape #issuePanel .issue-time,
  body.phone-landscape #issuePanel .issue-detail,
  body.phone-landscape #issuePanel .issue-penalty {
    font-size: 12px;
  }

  body.phone-landscape #issuePanel .issue-title {
    margin-bottom: 2px;
    font-size: 13px;
  }

  body.phone-landscape #issuePanel .issue-detail {
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }

  body.phone-landscape #issuePanel .issue-meta,
  body.phone-landscape #issuePanel .issue-evidence,
  body.phone-landscape #issuePanel .issue-related {
    display: none;
  }

  body.phone-landscape #issuePanel .issue.phone-expanded .issue-detail {
    display: block;
    -webkit-line-clamp: unset;
  }

  body.phone-landscape #issuePanel .issue.phone-expanded .issue-meta,
  body.phone-landscape #issuePanel .issue.phone-expanded .issue-evidence,
  body.phone-landscape #issuePanel .issue.phone-expanded .issue-related {
    display: flex;
  }

  body.phone-landscape .phone-panel-backdrop {
    position: fixed;
    z-index: 150;
    inset: 0;
    background: rgba(20, 31, 43, 0.32);
  }

  body.phone-landscape .phone-bottom-panel {
    position: fixed;
    z-index: 160;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    max-height: 78dvh;
    overflow-y: auto;
    padding: 10px max(12px, env(safe-area-inset-right))
      calc(12px + env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    border-radius: 14px 14px 0 0;
    background: #ffffff;
    box-shadow: 0 -18px 50px rgba(20, 31, 43, 0.28);
  }

  body.phone-landscape .phone-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
  }

  body.phone-landscape .phone-panel-heading strong {
    font-size: 15px;
  }

  body.phone-landscape .phone-panel-heading button,
  body.phone-landscape .phone-choice-options button {
    min-height: 44px;
    border-color: #cfd6dc;
    background: #ffffff;
    color: var(--ink);
  }

  body.phone-landscape .phone-choice-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  body.phone-landscape .phone-choice-options button {
    padding: 6px 8px;
    font-size: 13px;
  }

  body.phone-landscape .phone-choice-options button.active {
    border-color: var(--accent);
    background: #e7f5f1;
    color: var(--accent-strong);
  }

  body.phone-landscape .split-action-panel {
    right: 0;
    bottom: calc(env(safe-area-inset-bottom) + var(--phone-tools));
    left: 0 !important;
    width: 100%;
    max-width: none;
    padding: 10px max(12px, env(safe-area-inset-right))
      10px max(12px, env(safe-area-inset-left));
    border-radius: 12px 12px 0 0;
    transform: none;
  }

  body.phone-landscape .split-action-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.phone-landscape .key-picker-overlay .key-picker-menu {
    top: auto;
    right: 0;
    bottom: calc(env(safe-area-inset-bottom) + var(--phone-tools));
    left: 0;
    width: 100%;
    max-height: 74dvh;
    padding: 10px max(12px, env(safe-area-inset-right))
      10px max(12px, env(safe-area-inset-left));
    border-radius: 14px 14px 0 0;
    transform: none;
  }

  body.phone-landscape .action-panel-backdrop {
    align-items: end;
    padding: 0;
  }

  body.phone-landscape .action-panel {
    max-height: 80dvh;
    overflow-y: auto;
    padding: 14px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    border-radius: 14px 14px 0 0;
  }
}

/* v1.5.1 phone-landscape review: score first, details on demand */
@media (orientation: landscape) and (max-width: 1000px) and (max-height: 600px) {
  body.phone-landscape {
    --phone-review-nav: 52px;
    --phone-review-detail: 90px;
  }

  body.phone-landscape.phone-has-result #gradingSummary,
  body.phone-landscape.phone-has-result #basicJudgement {
    display: none !important;
  }

  body.phone-landscape.phone-has-result .workspace,
  body.phone-landscape.phone-has-result.phone-summary-collapsed .workspace {
    top: calc(env(safe-area-inset-top) + var(--phone-top));
  }

  body.phone-landscape.phone-graded-locked .workspace {
    bottom: calc(env(safe-area-inset-bottom) + var(--phone-review-nav));
  }

  body.phone-landscape.phone-graded-locked.phone-error-active .workspace {
    bottom: calc(env(safe-area-inset-bottom) + var(--phone-review-nav) + var(--phone-review-detail));
  }

  body.phone-landscape.phone-graded-locked.phone-error-active.phone-error-expanded {
    --phone-review-detail: 35dvh;
  }

  body.phone-landscape .phone-score-button {
    border-color: #d8b36c;
    background: #fff8e8;
    color: #754b00;
    font-weight: 900;
  }

  body.phone-landscape .phone-current-error-bar {
    right: 0;
    bottom: calc(env(safe-area-inset-bottom) + var(--phone-review-nav));
    left: 0;
    display: flex;
    height: var(--phone-review-detail);
    max-height: 35dvh;
    gap: 8px;
    overflow: hidden;
    padding: 7px max(8px, env(safe-area-inset-right)) 7px max(8px, env(safe-area-inset-left));
  }

  body.phone-landscape .phone-current-error-bar[hidden] {
    display: none !important;
  }

  body.phone-landscape .phone-error-detail-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: stretch;
    gap: 4px;
  }

  body.phone-landscape .phone-error-detail-actions button {
    min-height: 44px;
    padding: 0 9px;
    border-color: #cfd6dc;
    background: #ffffff;
    color: var(--ink);
    font-size: 12px;
  }

  body.phone-landscape .phone-error-navigation {
    position: fixed;
    z-index: 81;
    right: 0;
    bottom: env(safe-area-inset-bottom);
    left: 0;
    height: var(--phone-review-nav);
    align-items: center;
    gap: 4px;
    overflow: hidden;
    padding: 4px max(6px, env(safe-area-inset-right)) 4px max(6px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.99);
  }

  body.phone-landscape .phone-error-navigation[hidden] {
    display: none !important;
  }

  body.phone-landscape .phone-error-navigation-summary {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    padding: 0 6px;
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phone-landscape .phone-error-navigation button {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 10px;
    border-color: #cfd6dc;
    background: #ffffff;
    color: var(--ink);
    font-size: 12px;
  }

  body.phone-landscape .phone-current-error-content {
    overflow-y: auto;
  }

  body.phone-landscape:not(.phone-error-expanded) .phone-current-error-content span {
    display: -webkit-box;
    overflow: hidden;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.phone-landscape .score-error-connector-label {
    display: none;
  }

  body.phone-landscape .score-error-connector-label.score-error-selected {
    display: block;
  }

  body.phone-landscape.phone-error-active .score-error-muted {
    opacity: 0.16 !important;
  }

  body.phone-landscape #issuePanel .section-title {
    position: sticky;
    z-index: 3;
    top: 44px;
    height: 42px;
    flex-wrap: nowrap;
    padding: 4px 8px;
    background: #ffffff;
  }

  body.phone-landscape #issuePanel .section-title h2,
  body.phone-landscape #issuePanel #copyButton {
    display: none;
  }

  body.phone-landscape #issuePanel .issue-filters {
    flex: 1 1 auto;
    gap: 4px;
  }

  body.phone-landscape #issuePanel .issue-filter {
    min-height: 34px;
  }

  body.phone-landscape #issuePanel .issue-list {
    display: grid;
    height: auto;
    min-height: 0;
    overflow: visible;
    gap: 6px;
    padding: 7px 8px calc(16px + env(safe-area-inset-bottom));
  }

  body.phone-landscape #issuePanel .issue {
    min-height: 56px;
    grid-template-columns: 98px minmax(0, 1fr) auto;
    align-items: start;
  }

  body.phone-landscape #issuePanel .issue-detail {
    -webkit-line-clamp: 1;
  }

  body.phone-landscape #issuePanel .issue.phone-expanded {
    min-height: 112px;
  }

  body.phone-landscape .phone-review-page {
    position: fixed;
    z-index: 185;
    inset: 0;
    display: block;
    width: 100%;
    height: 100dvh;
    overflow-y: auto;
    padding-top: env(safe-area-inset-top);
    background: var(--surface);
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  body.phone-landscape .phone-review-page[hidden] {
    display: none !important;
  }

  body.phone-landscape .phone-review-page-header {
    position: sticky;
    z-index: 2;
    top: 0;
    display: grid;
    height: 44px;
    grid-template-columns: 72px 1fr 72px;
    align-items: center;
    padding: 4px 8px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
    text-align: center;
  }

  body.phone-landscape .phone-review-page-header button {
    min-height: 36px;
    border-color: #cfd6dc;
    background: #ffffff;
    color: var(--ink);
    font-size: 12px;
  }

  body.phone-landscape .phone-score-panel-content {
    display: grid;
    gap: 8px;
    padding: 10px max(10px, env(safe-area-inset-right))
      calc(16px + env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  body.phone-landscape .phone-score-total,
  body.phone-landscape .phone-score-domains,
  body.phone-landscape .phone-score-cap,
  body.phone-landscape .phone-basic-judgement {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
  }

  body.phone-landscape .phone-score-total {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    padding: 8px;
  }

  body.phone-landscape .phone-score-total strong {
    font-size: 30px;
  }

  body.phone-landscape .phone-score-domains {
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    overflow-x: auto;
  }

  body.phone-landscape .phone-score-domain {
    display: grid;
    gap: 3px;
    padding: 9px;
    border-right: 1px solid var(--line);
    font-size: 12px;
  }

  body.phone-landscape .phone-score-domain strong {
    font-size: 15px;
  }

  body.phone-landscape .phone-score-cap {
    display: grid;
    gap: 4px;
    padding: 9px;
    color: #754b00;
    font-size: 13px;
  }

  body.phone-landscape .phone-score-cap small {
    font-size: 12px;
  }

  body.phone-landscape .phone-basic-judgement {
    display: grid;
    gap: 6px;
    padding: 10px;
  }

  body.phone-landscape .phone-basic-judgement h3 {
    margin: 0;
    font-size: 15px;
  }

  body.phone-landscape .phone-basic-judgement .basic-success {
    font-size: 13px;
  }
}

/* v1.3 interaction state and grading-location UI */
.load-exercise-button.attention {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.12);
}

.grade-action {
  min-width: 112px;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.grade-action.unavailable {
  border-color: #9aa2aa;
  background: #9aa2aa;
  color: #ffffff;
}

.grade-action.available {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.result-stale-notice {
  padding: 12px 14px;
  border: 1px solid #b9bec5;
  border-radius: 8px;
  background: #f1f2f4;
  color: #59616a;
  font-weight: 800;
  text-align: center;
}

.result-summary-card.result-stale,
.basic-judgement.result-stale,
.current-error-panel.result-stale,
.issue-list.result-stale {
  filter: grayscale(0.9);
  opacity: 0.58;
}

.previous-error-toggle {
  border-color: #d7aa6b;
  background: #fff8ec;
  color: #8a520d;
}

.previous-error-location,
.previous-error-location-label {
  cursor: pointer;
}

.previous-error-location {
  filter: drop-shadow(0 1px 1px rgba(102, 63, 10, 0.14));
}

.previous-result-badge,
.edited-location-badge {
  border: 1px solid #d7aa6b;
  background: #fff4df !important;
  color: #8a520d !important;
}

.edited-location-badge {
  border-color: #c7ccd2;
  background: #f2f3f5 !important;
  color: #59616a !important;
}

.exercise-controls {
  grid-template-columns: minmax(170px, 0.75fr) minmax(420px, 1.8fr) minmax(170px, 0.75fr);
  align-items: start;
}

.score-board {
  position: relative;
}

.score-board.not-loaded {
  background: #eef0f2;
}

.exercise-svg.not-loaded-preview {
  filter: grayscale(1);
  opacity: 0.46;
}

.exercise-svg.exercise-loading {
  pointer-events: none;
}

.score-board.loading .not-loaded-score-overlay {
  border-color: #9fcabe;
  background: rgba(247, 252, 250, 0.94);
}

.score-board.loading .not-loaded-score-overlay strong {
  color: var(--accent-strong);
}

.not-loaded-score-overlay {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(390px, calc(100% - 32px));
  gap: 8px;
  padding: 18px 22px;
  border: 1px solid rgba(104, 113, 122, 0.56);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #41484f;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 12px 34px rgba(20, 31, 43, 0.12);
}

.not-loaded-score-overlay[hidden] {
  display: none;
}

.not-loaded-score-overlay strong {
  font-size: 18px;
}

.not-loaded-score-overlay span {
  color: var(--muted);
  font-size: 14px;
}

.exercise-load-notice {
  padding: 9px 12px;
  border: 1px solid #b8d7cf;
  border-radius: 7px;
  background: #edf8f5;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.exercise-load-notice[hidden],
.exercise-controls[hidden],
.assist-tools[hidden],
.section-actions > [hidden] {
  display: none;
}

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

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-help-button {
  flex: 0 0 auto;
  width: 26px;
  min-height: 26px;
  padding: 0;
  border-color: #cfd5db;
  border-radius: 50%;
  background: #ffffff;
  color: #59616a;
  font-size: 12px;
  font-weight: 900;
}

.field-help-button[aria-expanded="true"] {
  border-color: #9fcabe;
  background: #edf8f5;
  color: var(--accent-strong);
}

.field-help-text {
  padding: 7px 9px;
  border-radius: 6px;
  background: #f4f6f7;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field-help-text[hidden] {
  display: none;
}

.cadence-control {
  gap: 8px;
}

.cadence-mode-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.cadence-mode {
  min-height: 44px;
  white-space: nowrap;
}

.cadence-mode.active,
.cadence-mode[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e7f5f1;
  color: var(--accent-strong);
}

.cadence-mode.clear.active {
  border-color: #b66a63;
  background: #fff1f0;
  color: #8f2019;
}

.completion-status {
  color: #8f5c00;
  font-size: 12px;
}

.completion-status.complete {
  color: var(--accent-strong);
}

.assist-tools {
  display: grid;
  grid-template-columns: minmax(130px, 0.4fr) minmax(360px, 1fr) minmax(210px, 0.6fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.assist-tools h3 {
  margin: 3px 0 0;
  font-size: 15px;
}

.assist-tool-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.assist-tool-actions button {
  width: 100%;
  min-height: 44px;
  white-space: nowrap;
}

.assist-tool-feedback {
  min-height: 20px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.key-picker-overlay {
  position: fixed;
  z-index: 70;
  inset: 0;
  pointer-events: none;
}

.key-picker-backdrop {
  position: fixed;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(20, 31, 43, 0.28);
  pointer-events: auto;
}

.key-picker-backdrop[hidden] {
  display: none;
}

.key-picker-overlay .key-picker-menu {
  z-index: 1;
  top: 50%;
  left: 50%;
  width: min(460px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 48px));
  overflow: auto;
  padding: 16px;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  box-shadow: 0 24px 70px rgba(20, 31, 43, 0.28);
}

.key-picker-title {
  display: block;
  margin: 2px 4px 10px;
  font-size: 16px;
}

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

.current-error-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  padding: 14px;
}

.current-error-panel[hidden] {
  display: none !important;
}

.current-error-detail.empty {
  color: var(--muted);
  font-size: 13px;
}

.current-error-card {
  position: relative;
  display: grid;
  gap: 9px;
  padding: 16px;
  border: 1px solid #e3b3af;
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  background: #fffafa;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.current-error-card.focused {
  border-color: #b3261e;
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.14);
}

.current-error-card.related {
  opacity: 0.76;
}

.current-error-card:not(.expanded) .issue-rule,
.current-error-card:not(.expanded) .issue-evidence,
.current-error-card:not(.expanded) .issue-related {
  display: none;
}

.current-error-expand {
  justify-self: start;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid #d6dde3;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.current-error-card > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.current-error-card h3 {
  margin: 0;
  font-size: 17px;
}

.issue-rule {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.current-error-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.current-error-penalty {
  position: absolute;
  top: 16px;
  right: 16px;
  color: var(--danger);
}

.issue {
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.issue.selected {
  border-color: #c94c43;
  background: #fff8f7;
}

.issue.focused {
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.11);
}

.score-error-target,
.score-error-region,
.score-error-connector,
.score-error-connector-label {
  cursor: pointer;
}

ellipse.score-error-note {
  fill: var(--danger) !important;
  stroke: var(--danger) !important;
}

line.score-error-note,
path.score-error-note {
  stroke: var(--danger) !important;
}

text.score-error-note {
  fill: var(--danger) !important;
}

.score-error-function {
  stroke: var(--danger) !important;
  color: var(--danger);
}

text.score-error-function {
  fill: var(--danger) !important;
}

rect.score-error-function {
  stroke-width: 2.2 !important;
}

.score-error-cadence {
  fill: var(--danger) !important;
  stroke: var(--danger) !important;
}

.score-error-selected {
  opacity: 1 !important;
  filter: drop-shadow(0 0 2px rgba(179, 38, 30, 0.45));
}

.score-error-muted {
  opacity: 0.2 !important;
}

.score-error-related {
  opacity: 0.48 !important;
}

@media (max-width: 800px) {
  .current-error-detail {
    grid-template-columns: minmax(0, 1fr);
  }
}

.answer-hit.active-input-target {
  stroke: var(--accent);
  stroke-width: 1.8;
  fill: #e5f4ef;
  opacity: 0.82;
}

.action-panel-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 31, 43, 0.42);
}

.action-panel-backdrop[hidden] {
  display: none;
}

.action-panel {
  display: grid;
  width: min(460px, 100%);
  gap: 14px;
  padding: 20px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 26px 80px rgba(20, 31, 43, 0.3);
}

.action-panel h2 {
  font-size: 19px;
}

.action-panel > p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.action-panel-items {
  display: grid;
  gap: 8px;
}

.action-panel-item {
  min-height: 44px;
  justify-content: flex-start;
  border-color: #e1b4b0;
  background: #fff8f7;
  color: #7f2721;
  text-align: left;
}

.action-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1040px) {
  .exercise-controls {
    grid-template-columns: 1fr 1fr;
  }

  .assist-tools {
    grid-template-columns: minmax(120px, 0.4fr) minmax(360px, 1fr);
  }

  .assist-tool-feedback {
    grid-column: 1 / -1;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .exercise-controls,
  .content-grid,
  .assist-tools {
    grid-template-columns: 1fr;
  }

  .cadence-mode-buttons {
    grid-template-columns: 1fr;
  }

  .assist-tool-actions {
    grid-template-columns: 1fr;
  }

  .assist-tool-feedback {
    grid-column: auto;
  }

  .key-picker-overlay .key-picker-menu {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 78vh;
    border-radius: 14px 14px 0 0;
    transform: none;
  }

  .action-panel-backdrop {
    align-items: end;
    padding: 0;
  }

  .action-panel {
    width: 100%;
    border-radius: 14px 14px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

/* v1.5.2 Safari root scrolling in phone landscape */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  html,
  body,
  #root {
    position: static;
    width: 100%;
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.phone-landscape {
    --topbar-height: calc(44px + env(safe-area-inset-top));
    --bottom-bar-height: calc(56px + env(safe-area-inset-bottom));
    min-height: calc(100dvh + 56px);
    padding-top: 0;
    padding-bottom: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: auto;
    touch-action: pan-y pinch-zoom;
  }

  body.phone-landscape.phone-landscape-page {
    width: 100%;
    min-height: calc(100dvh + 56px);
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.phone-landscape .phone-landscape-topbar {
    position: sticky;
    top: 0;
    right: auto;
    left: auto;
    width: 100%;
    height: var(--topbar-height);
    padding-top: calc(3px + env(safe-area-inset-top));
  }

  body.phone-landscape .app-shell {
    width: 100%;
    min-height: calc(
      var(--visible-viewport-height, 100dvh)
      - var(--topbar-height)
      - var(--bottom-bar-height)
    );
    height: auto;
    overflow: visible;
  }

  body.phone-landscape .workspace,
  body.phone-landscape.phone-has-result .workspace,
  body.phone-landscape.phone-has-result.phone-summary-collapsed .workspace,
  body.phone-landscape.phone-graded-locked .workspace {
    position: static;
    inset: auto;
    min-height: calc(
      var(--visible-viewport-height, 100dvh)
      - var(--topbar-height)
      - var(--bottom-bar-height)
    );
    height: auto;
    overflow: visible;
  }

  body.phone-landscape.phone-graded-locked.phone-error-active .workspace {
    min-height: calc(
      var(--visible-viewport-height, 100dvh)
      - var(--topbar-height)
      - var(--bottom-bar-height)
      - var(--phone-review-detail)
    );
  }

  body.phone-landscape .phone-landscape-workspace {
    height: auto;
    overflow: visible;
  }

  body.phone-landscape .exercise-section {
    position: relative;
    inset: auto;
    min-height: calc(
      var(--visible-viewport-height, 100dvh)
      - var(--topbar-height)
      - var(--bottom-bar-height)
      - 12px
    );
    height: auto;
    overflow: visible;
  }

  body.phone-landscape.phone-graded-locked.phone-error-active .exercise-section {
    min-height: calc(
      var(--visible-viewport-height, 100dvh)
      - var(--topbar-height)
      - var(--bottom-bar-height)
      - var(--phone-review-detail)
      - 12px
    );
  }

  body.phone-landscape .exercise-body {
    min-height: inherit;
    height: auto;
    overflow: visible;
  }

  body.phone-landscape .score-board {
    min-height: inherit;
    height: auto;
    overflow-x: visible;
    overflow-y: visible;
    overscroll-behavior: auto;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  body.phone-landscape .exercise-svg {
    touch-action: pan-y;
  }

  body.phone-landscape .phone-answer-toolbar,
  body.phone-landscape .phone-error-navigation {
    position: sticky;
    right: auto;
    bottom: 0;
    left: auto;
    width: 100%;
    height: var(--bottom-bar-height);
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
  }

  body.phone-landscape .phone-current-error-bar {
    position: sticky;
    right: auto;
    bottom: var(--bottom-bar-height);
    left: auto;
    width: 100%;
  }

  body.phone-landscape #issuePanel {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    min-height: calc(100dvh + 56px);
    height: auto;
    overflow: visible;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.phone-landscape #issuePanel .issue-list {
    min-height: calc(100dvh - 86px + 56px);
    height: auto;
    overflow: visible;
  }
}

/* 手机横屏批改结算：谱面只缩小不放大，当前错误与清单保持紧凑。 */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  body.phone-landscape.phone-landscape-result-page #gradingSummary,
  body.phone-landscape.phone-landscape-result-page #basicJudgement {
    display: none !important;
  }

  body.phone-landscape.phone-landscape-result-page .workspace,
  body.phone-landscape.phone-landscape-result-page .exercise-section,
  body.phone-landscape.phone-landscape-result-page .exercise-body {
    min-height: 0;
    height: auto;
  }

  body.phone-landscape.phone-landscape-result-page .exercise-section {
    margin: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.phone-landscape.phone-landscape-result-page .exercise-body,
  body.phone-landscape.phone-landscape-result-page .score-review-section {
    display: block;
    width: 100%;
    min-height: 0;
    height: auto;
    max-height: none;
    flex: none;
    padding: 0;
    margin: 0;
  }

  body.phone-landscape.phone-landscape-result-page .result-score-viewport,
  body.phone-landscape.phone-landscape-result-page .review-score-viewport {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    flex: none;
    flex-grow: 0;
    padding: 4px 8px 6px;
    margin: 0;
    overflow: hidden;
    box-sizing: border-box;
    border: 0;
    border-radius: 0;
    background: #fff;
    touch-action: pan-y;
  }

  body.phone-landscape.phone-landscape-result-page .result-score-content,
  body.phone-landscape.phone-landscape-result-page .review-score-svg {
    position: relative;
    display: block;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    flex: none;
    flex-grow: 0;
    transform: none !important;
    transform-origin: 0 0;
  }

  body.phone-landscape.phone-landscape-result-page .phone-landscape-no-error {
    display: block;
    margin: 8px 6px;
    padding: 10px 12px;
    border: 1px solid #cfe2dc;
    border-radius: 8px;
    background: #f2faf7;
    color: var(--accent-strong);
    font-size: 14px;
    font-weight: 700;
  }

  body.phone-landscape.phone-landscape-result-page .phone-landscape-no-error[hidden] {
    display: none;
  }

  body.phone-landscape.phone-landscape-result-page.phone-error-active .content-grid > #currentErrorPanel {
    display: block !important;
    max-height: none;
    margin: 6px 6px 0;
    overflow: visible;
  }

  body.phone-landscape.phone-landscape-result-page #currentErrorPanel .current-error-header {
    min-height: 36px;
    padding: 5px 10px;
  }

  body.phone-landscape.phone-landscape-result-page #currentErrorPanel .current-error-header h2 {
    overflow: hidden;
    font-size: 15px;
    line-height: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phone-landscape.phone-landscape-result-page #currentErrorPanel .phone-inline-error-actions button {
    min-height: 30px;
    padding: 0 7px;
    font-size: 11px;
  }

  body.phone-landscape.phone-landscape-result-page #currentErrorPanel .current-error-detail {
    display: grid;
    max-height: none;
    overflow-x: hidden;
    overflow-y: visible;
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    padding: 5px 8px 7px;
  }

  body.phone-landscape.phone-landscape-result-page #issuePanel {
    margin: 6px 6px 8px;
  }

  body.phone-landscape.phone-landscape-result-page #issuePanel .error-list-header,
  body.phone-landscape.phone-landscape-result-page #issuePanel .phone-landscape-error-header {
    min-height: 42px;
    padding: 5px 8px;
  }

  body.phone-landscape.phone-landscape-result-page #issuePanel .phone-landscape-error-header h2 {
    font-size: 14px;
    line-height: 19px;
  }

  body.phone-landscape.phone-landscape-result-page #issuePanel .issue-list {
    gap: 6px;
    padding: 6px;
  }

  body.phone-landscape.phone-landscape-result-page .mobile-result-error-card {
    display: block;
    min-height: 0;
    margin: 0 0 6px;
    padding: 8px 12px;
  }

  body.phone-landscape.phone-landscape-result-page .mobile-result-error-card .error-card-heading {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
  }

  body.phone-landscape.phone-landscape-result-page .mobile-result-error-card .error-location {
    font-size: 11px !important;
    line-height: 16px !important;
    white-space: nowrap;
  }

  body.phone-landscape.phone-landscape-result-page .mobile-result-error-card .error-title {
    margin: 0;
    overflow: hidden;
    font-size: 14px !important;
    font-weight: 650;
    line-height: 19px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phone-landscape.phone-landscape-result-page .mobile-result-error-card .error-description {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 2px;
    margin-bottom: 0;
    font-size: 12px !important;
    line-height: 17px !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.phone-landscape.phone-landscape-result-page .mobile-result-error-card .error-deduction {
    font-size: 13px !important;
    line-height: 18px !important;
    white-space: nowrap;
  }

  body.phone-landscape.phone-landscape-result-page .mobile-result-error-card .error-tag {
    padding: 1px 6px !important;
    font-size: 10px !important;
    line-height: 15px !important;
  }

  body.phone-landscape.phone-landscape-result-page #currentErrorPanel .mobile-result-error-card .issue-meta {
    display: flex;
    gap: 4px;
    margin-top: 3px;
  }

  body.phone-landscape.phone-landscape-result-page #issuePanel .issue-meta,
  body.phone-landscape.phone-landscape-result-page #issuePanel .issue-evidence,
  body.phone-landscape.phone-landscape-result-page #issuePanel .issue-related,
  body.phone-landscape.phone-landscape-result-page #issuePanel .foundation-related-issues {
    display: none !important;
  }
}

/* 手机批改结果中的当前错误固定为简洁摘要，不提供技术详情展开。 */
body.phone-result-readonly #currentErrorPanel .current-error-expand,
body.phone-result-readonly #currentErrorPanel .issue-rule,
body.phone-result-readonly #currentErrorPanel .issue-evidence,
body.phone-result-readonly #currentErrorPanel .issue-related,
body.phone-result-readonly #currentErrorPanel .foundation-related-issues {
  display: none !important;
}

/* v1.6.11 portrait editing uses the real visual viewport; readonly results stay unchanged */
@media (orientation: portrait) and (max-width: 600px) {
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"],
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] {
    display: grid;
    width: 100%;
    min-height: 0;
    height: var(--phone-visual-height, 100dvh);
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
    overflow: hidden;
    background: #fff;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] > .phone-portrait-topbar,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] > .phone-portrait-topbar {
    position: static;
    grid-row: 1;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] > .app-shell,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] > .app-shell {
    display: block;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .workspace,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .workspace {
    display: grid;
    width: 100%;
    min-height: 0;
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 0;
    padding: 0;
    overflow: hidden;
    background: #fff;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .exercise-section,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .exercise-body,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .score-review-section,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .content-grid,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #issuePanel,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .exercise-section,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .exercise-body,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .score-review-section,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .content-grid,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #issuePanel {
    display: contents;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #gradingSummary,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #basicJudgement,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .technical-result-state,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #currentErrorPanel,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .exercise-load-notice,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .result-stale-notice,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #gradingSummary,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #basicJudgement,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .technical-result-state,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #currentErrorPanel,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .exercise-load-notice,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .result-stale-notice {
    display: none !important;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .exercise-meta,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .exercise-meta {
    grid-row: 1;
    min-height: 36px;
    height: auto;
    padding: 8px 10px;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .phone-portrait-score-viewport,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .phone-portrait-score-viewport {
    position: relative;
    grid-row: 2;
    width: 100%;
    min-height: 0;
    height: 100%;
    max-height: none;
    overflow: hidden;
    background: #fff;
    touch-action: none;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .phone-portrait-score-content,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .phone-portrait-score-content {
    transform-origin: 0 0;
    will-change: transform;
    touch-action: none;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .phone-portrait-edit-toolbar,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .phone-portrait-edit-toolbar {
    position: static;
    z-index: 10;
    grid-row: 3;
    display: grid;
    width: 100%;
    min-height: 58px;
    grid-template-columns: 0.72fr 0.76fr 1.25fr 1.28fr 1.16fr 0.62fr;
    gap: 4px;
    overflow: hidden;
    padding: 6px max(6px, env(safe-area-inset-right)) 6px max(6px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: #fff;
    box-sizing: border-box;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .phone-portrait-edit-toolbar[hidden],
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .phone-portrait-edit-toolbar[hidden] {
    display: none !important;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .phone-portrait-edit-toolbar button,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .phone-portrait-edit-toolbar button {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    height: 46px;
    padding: 0 4px;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.15;
    text-overflow: clip;
    white-space: nowrap;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #issuePanel .phone-portrait-error-header,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #issuePanel .phone-portrait-error-header {
    position: static;
    z-index: 9;
    grid-row: 4;
    display: flex;
    width: 100%;
    min-height: 58px;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    overflow: hidden;
    padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: #fff;
    box-sizing: border-box;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #issuePanel .phone-portrait-error-header h2,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #issuePanel .phone-portrait-error-header h2 {
    font-size: 13px;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #issuePanel .issue-filters,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #issuePanel .issue-filters {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
    gap: 3px;
    overflow: hidden;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #issuePanel .issue-filter,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #issuePanel .issue-filter {
    min-width: 0;
    min-height: 34px;
    height: 34px;
    flex: 0 1 auto;
    padding: 0 5px;
    font-size: 11px;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #issuePanel #copyButton,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #issuePanel #copyButton {
    display: none;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] .phone-portrait-edit-result-status,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] .phone-portrait-edit-result-status {
    min-width: 0;
    margin-left: auto;
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
  }

  body.phone-portrait.phone-portrait-edit-page[data-page-state="answering"] #issuePanel .phone-portrait-error-list,
  body.phone-portrait.phone-portrait-edit-page[data-page-state="editing-after-grade"] #issuePanel .phone-portrait-error-list {
    display: none;
  }

  body.phone-portrait.phone-portrait-edit-page.phone-portrait-edit-errors-open #issuePanel {
    position: fixed;
    z-index: 35;
    top: calc(var(--portrait-topbar-height) + env(safe-area-inset-top));
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    width: 100%;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    -webkit-overflow-scrolling: touch;
  }

  body.phone-portrait.phone-portrait-edit-page.phone-portrait-edit-errors-open #issuePanel .phone-portrait-error-header {
    position: sticky;
    z-index: 2;
    top: 0;
  }

  body.phone-portrait.phone-portrait-edit-page.phone-portrait-edit-errors-open #issuePanel .phone-portrait-error-list {
    display: grid;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow: visible;
  }
}


/* v1.5.3 phone-landscape results in the document flow */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  html,
  body,
  #root {
    position: static;
    width: 100%;
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.phone-landscape {
    --bottom-toolbar-height: 56px;
    min-height: calc(100dvh + 48px);
  }

  body.phone-landscape.phone-landscape-page {
    min-height: calc(100dvh + 48px);
    height: auto;
    overflow: visible;
  }

  body.phone-landscape.phone-graded-locked {
    --bottom-bar-height: 0px;
  }

  body.phone-landscape .app-shell,
  body.phone-landscape .workspace,
  body.phone-landscape.phone-has-result .workspace,
  body.phone-landscape.phone-has-result.phone-summary-collapsed .workspace,
  body.phone-landscape.phone-graded-locked .workspace,
  body.phone-landscape.phone-graded-locked.phone-error-active .workspace,
  body.phone-landscape .phone-landscape-workspace {
    position: static;
    inset: auto;
    min-height: 0;
    height: auto;
    overflow: visible;
  }

  body.phone-landscape .exercise-section,
  body.phone-landscape.phone-graded-locked.phone-error-active .exercise-section {
    min-height: calc(
      var(--visible-viewport-height, 100dvh)
      - var(--topbar-height)
      - var(--bottom-bar-height)
      - 12px
    );
    scroll-margin-top: var(--topbar-height);
  }

  body.phone-landscape .content-grid {
    display: block;
    width: 100%;
    overflow: visible;
  }

  body.phone-landscape .content-grid > #currentErrorPanel {
    display: none !important;
  }

  body.phone-landscape.phone-error-active .content-grid > #currentErrorPanel {
    display: block !important;
    margin: 6px;
    border-radius: 8px;
  }

  body.phone-landscape #currentErrorPanel .section-title {
    min-height: 42px;
    padding: 5px 8px;
  }

  body.phone-landscape #currentErrorPanel .section-title h2 {
    font-size: 14px;
  }

  body.phone-landscape .phone-inline-error-actions {
    align-items: center;
    gap: 4px;
  }

  body.phone-landscape .phone-inline-error-actions button {
    min-height: 36px;
    padding: 0 9px;
    border-color: #cfd6dc;
    background: #ffffff;
    color: var(--ink);
    font-size: 12px;
  }

  body.phone-landscape #currentErrorPanel .current-error-detail {
    grid-template-columns: minmax(0, 1fr);
    padding: 7px 8px 9px;
  }

  body.phone-landscape #currentErrorPanel .current-error-card {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 9px 10px;
  }

  body.phone-landscape #currentErrorPanel .current-error-card > span,
  body.phone-landscape #currentErrorPanel .current-error-card h3,
  body.phone-landscape #currentErrorPanel .current-error-card p {
    grid-column: 1;
    margin: 0;
  }

  body.phone-landscape #currentErrorPanel .current-error-card h3 {
    font-size: 15px;
  }

  body.phone-landscape #currentErrorPanel .current-error-card p {
    font-size: 13px;
  }

  body.phone-landscape #currentErrorPanel .current-error-penalty {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: start;
  }

  body.phone-landscape #issuePanel {
    position: static;
    inset: auto;
    display: block;
    width: auto;
    min-height: 0;
    height: auto;
    margin: 6px;
    overflow: visible;
    border-radius: 8px;
    box-shadow: none;
    transform: none;
    transition: none;
    overscroll-behavior-y: auto;
  }

  body.phone-landscape #issuePanel .section-title {
    position: sticky;
    z-index: 90;
    top: var(--topbar-height);
    display: flex;
    min-height: 44px;
    height: auto;
    flex-wrap: nowrap;
    gap: 5px;
    padding: 5px 7px;
    background: rgba(255, 255, 255, 0.98);
  }

  body.phone-landscape #issuePanel .section-title h2 {
    display: block;
    flex: 0 0 auto;
    font-size: 14px;
    white-space: nowrap;
  }

  body.phone-landscape #issuePanel .issue-filters {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 3px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.phone-landscape #issuePanel .issue-filters::-webkit-scrollbar {
    display: none;
  }

  body.phone-landscape #issuePanel .issue-filter,
  body.phone-landscape #issuePanel #copyButton {
    display: inline-flex;
    min-height: 34px;
    flex: 0 0 auto;
    padding: 0 8px;
    font-size: 12px;
    white-space: nowrap;
  }

  body.phone-landscape #issuePanel .issue-filter.active {
    border-color: var(--accent);
    background: #e7f5f1;
    color: var(--accent-strong);
  }

  body.phone-landscape #issuePanel .issue-list,
  body.phone-landscape .phone-landscape-error-list {
    display: grid;
    min-height: 0;
    max-height: none;
    height: auto;
    overflow: visible;
    gap: 6px;
    padding: 7px;
  }

  body.phone-landscape #issuePanel .issue {
    min-height: 56px;
    grid-template-columns: 94px minmax(0, 1fr) auto;
    align-items: start;
    gap: 6px;
    padding: 8px 9px;
  }

  body.phone-landscape #issuePanel .issue-time {
    font-size: 12px;
  }

  body.phone-landscape #issuePanel .issue-title {
    font-size: 14px;
    line-height: 1.25;
  }

  body.phone-landscape #issuePanel .issue-detail {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.35;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }

  body.phone-landscape #issuePanel .issue-meta,
  body.phone-landscape #issuePanel .issue-evidence,
  body.phone-landscape #issuePanel .issue-related {
    display: none;
  }

  body.phone-landscape #issuePanel .issue.phone-expanded {
    min-height: 96px;
  }

  body.phone-landscape #issuePanel .issue.phone-expanded .issue-detail {
    display: block;
    overflow: visible;
  }

  body.phone-landscape #issuePanel .issue.phone-expanded .issue-meta {
    display: flex;
  }

  body.phone-landscape #issuePanel .issue.phone-expanded .issue-evidence,
  body.phone-landscape #issuePanel .issue.phone-expanded .issue-related {
    display: block;
  }

  body.phone-landscape .key-picker-backdrop {
    z-index: 999;
  }

  body.phone-landscape .key-picker-overlay .phone-landscape-tonality-panel {
    position: fixed;
    z-index: 1000;
    top: auto;
    right: auto;
    bottom: calc(
      var(--bottom-toolbar-height, 56px)
      + env(safe-area-inset-bottom)
      + 8px
    );
    left: 50%;
    width: min(520px, calc(100vw - 32px));
    min-width: 0;
    max-width: 520px;
    max-height: min(420px, 70dvh);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px;
    border-radius: 12px;
    box-sizing: border-box;
    transform: translateX(-50%);
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  body.phone-landscape .phone-landscape-tonality-grid {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
  }

  body.phone-landscape .phone-landscape-tonality-option {
    width: 100%;
    min-width: 0;
    min-height: 38px;
    padding: 6px 12px;
    box-sizing: border-box;
    text-align: left;
  }

  body.phone-landscape .phone-landscape-tonality-option.selected {
    border-color: #c8e3dc;
    background: #edf8f5;
    color: var(--accent-strong);
  }
}


/* v1.5.4 keep the landscape edit toolbar and error header in separate layers */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  body.phone-landscape .phone-landscape-topbar {
    z-index: 40;
  }

  body.phone-landscape .exercise-section,
  body.phone-landscape #currentErrorPanel,
  body.phone-landscape #issuePanel {
    z-index: 1;
  }

  body.phone-landscape .phone-landscape-edit-toolbar {
    position: sticky;
    z-index: 30;
    right: auto;
    bottom: 0;
    left: auto;
    width: 100%;
    height: auto;
    min-height: var(--bottom-toolbar-height, 56px);
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.98);
    transform: none;
  }

  body.phone-landscape .phone-landscape-edit-toolbar[hidden] {
    display: none !important;
  }

  body.phone-landscape #issuePanel .phone-landscape-error-header {
    position: sticky;
    z-index: 20;
    top: var(--topbar-height, 44px);
    right: auto;
    bottom: auto;
    left: auto;
    width: 100%;
    margin: 0;
    background: rgba(255, 255, 255, 0.98);
    transform: none;
  }

  body.phone-landscape.is-editing #issuePanel .phone-landscape-error-header {
    position: static;
    z-index: auto;
    top: auto;
  }
}

/* v1.6.0 dedicated phone-portrait layout; document/body remain the scroll owner */
@media (orientation: portrait) and (max-width: 600px) {
  html,
  body,
  #root {
    position: static;
    width: 100%;
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.phone-portrait {
    --portrait-topbar-height: 48px;
    --edit-toolbar-height: 56px;
    width: 100%;
    min-height: calc(100dvh + 48px);
    height: auto;
    padding: 0 0 calc(var(--edit-toolbar-height) + env(safe-area-inset-bottom) + 8px);
    overflow: visible;
    background: #f4f6f7;
    font-size: 14px;
    touch-action: pan-y pinch-zoom;
  }

  body.phone-portrait.phone-graded-locked {
    padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
  }

  body.phone-portrait .phone-landscape-only:not([hidden]) {
    display: flex;
  }

  body.phone-portrait .phone-landscape-only[hidden] {
    display: none !important;
  }

  body.phone-portrait .phone-portrait-topbar {
    position: sticky;
    z-index: 40;
    top: 0;
    display: flex;
    width: 100%;
    min-height: calc(var(--portrait-topbar-height) + env(safe-area-inset-top));
    align-items: flex-end;
    gap: 3px;
    padding: env(safe-area-inset-top) 6px 4px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
  }

  body.phone-portrait .phone-top-button {
    min-width: 0;
    min-height: 44px;
    flex: 0 0 auto;
    padding: 0 8px;
    border-color: #cfd6dc;
    background: #fff;
    color: var(--ink);
    font-size: 12px;
    white-space: nowrap;
  }

  body.phone-portrait .phone-top-button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
  }

  body.phone-portrait .phone-exercise-title {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    padding: 0 2px 13px;
    font-size: 12px;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phone-portrait .app-shell {
    display: block;
    width: 100%;
    min-height: 100dvh;
    height: auto;
    overflow: visible;
  }

  body.phone-portrait .toolbar {
    position: fixed;
    z-index: 120;
    top: auto;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom) + 8px);
    left: 12px;
    display: none;
    width: auto;
    max-height: 75dvh;
    overflow-x: hidden;
    overflow-y: auto;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 20px 56px rgba(20, 31, 43, 0.28);
    -webkit-overflow-scrolling: touch;
  }

  body.phone-portrait.phone-question-open .toolbar {
    display: grid;
  }

  body.phone-portrait .toolbar .release-banner,
  body.phone-portrait .toolbar .brand,
  body.phone-portrait .toolbar .file-picker,
  body.phone-portrait .toolbar #sampleButton,
  body.phone-portrait .toolbar #gradeButton {
    display: none;
  }

  body.phone-portrait .toolbar .exercise-picker {
    min-width: 0;
    gap: 4px;
  }

  body.phone-portrait .toolbar select,
  body.phone-portrait .toolbar button {
    min-height: 44px;
    font-size: 14px;
  }

  body.phone-portrait .workspace,
  body.phone-portrait .phone-landscape-workspace {
    position: static;
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 100dvh;
    height: auto;
    flex-direction: column;
    gap: 6px;
    overflow: visible;
    padding: 6px 0 0;
  }

  body.phone-portrait #gradingSummary {
    order: 1;
  }

  body.phone-portrait #basicJudgement {
    order: 2;
  }

  body.phone-portrait .exercise-section {
    order: 3;
  }

  body.phone-portrait .phone-portrait-edit-toolbar {
    order: 4;
  }

  body.phone-portrait .technical-result-state {
    order: 5;
  }

  body.phone-portrait .content-grid {
    order: 6;
  }

  body.phone-portrait .exercise-section {
    position: static;
    width: 100%;
    min-height: 0;
    height: auto;
    margin: 0;
    overflow: visible;
    border-width: 1px 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.phone-portrait .exercise-section > .section-title,
  body.phone-portrait .exercise-controls,
  body.phone-portrait .assist-tools {
    display: none !important;
  }

  body.phone-portrait .exercise-body {
    display: block;
    width: 100%;
    height: auto;
    padding: 0;
  }

  body.phone-portrait .exercise-meta {
    display: block;
    min-height: 34px;
    overflow: hidden;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
  }

  body.phone-portrait .exercise-meta strong {
    display: block;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.phone-portrait .exercise-meta .knowledge-tags,
  body.phone-portrait .exercise-meta .knowledge-ai-status {
    display: none;
  }

  body.phone-portrait.phone-portrait-meta-expanded .exercise-meta .knowledge-tags,
  body.phone-portrait.phone-portrait-meta-expanded .exercise-meta .knowledge-ai-status {
    display: flex;
    margin-top: 6px;
  }

  body.phone-portrait .score-board {
    width: 100%;
    min-height: 300px;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
    border: 0;
    border-radius: 0;
    overscroll-behavior-y: auto;
    touch-action: pan-y;
  }

  body.phone-portrait .exercise-svg {
    display: block;
    width: 100%;
    min-width: 760px;
    height: auto;
    transform-origin: top left;
    touch-action: pan-y;
  }

  body.phone-portrait .exercise-load-notice,
  body.phone-portrait .result-stale-notice {
    width: calc(100% - 16px);
    margin: 6px 8px;
    padding: 7px 10px;
    font-size: 12px;
  }

  body.phone-portrait .phone-portrait-edit-toolbar {
    position: sticky;
    z-index: 30;
    bottom: 0;
    display: flex;
    width: 100%;
    min-height: var(--edit-toolbar-height);
    align-items: stretch;
    gap: 4px;
    overflow-x: auto;
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    scrollbar-width: none;
  }

  body.phone-portrait .phone-portrait-edit-toolbar::-webkit-scrollbar {
    display: none;
  }

  body.phone-portrait .phone-portrait-edit-toolbar[hidden] {
    display: none !important;
  }

  body.phone-portrait .phone-portrait-edit-toolbar button {
    min-height: 44px;
    flex: 0 0 auto;
    padding: 0 10px;
    border-color: #cfd6dc;
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    white-space: nowrap;
  }

  body.phone-portrait .phone-portrait-edit-toolbar button.active {
    border-color: var(--accent);
    background: #e7f5f1;
    color: var(--accent-strong);
  }

  body.phone-portrait:not(.phone-has-result) #gradingSummary,
  body.phone-portrait:not(.phone-has-result) #basicJudgement {
    display: none !important;
  }

  body.phone-portrait.phone-has-result #gradingSummary {
    display: block;
    width: 100%;
    margin: 0;
    overflow: hidden;
    border-width: 1px 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.phone-portrait #gradingSummary .phone-summary-toggle {
    display: none;
  }

  body.phone-portrait #gradingSummary .result-summary-row {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    min-height: 58px;
    overflow: hidden;
  }

  body.phone-portrait #gradingSummary .score-panel {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0;
    padding: 5px;
    border-right: 1px solid var(--line);
    cursor: pointer;
  }

  body.phone-portrait #gradingSummary .score-panel .eyebrow {
    font-size: 10px;
  }

  body.phone-portrait #gradingSummary .score-panel strong {
    font-size: 30px;
    line-height: 1;
  }

  body.phone-portrait #gradingSummary .score-panel #scoreLabel {
    display: none;
  }

  body.phone-portrait #gradingSummary .domain-score-grid {
    display: flex;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.phone-portrait #gradingSummary .domain-score-grid::-webkit-scrollbar {
    display: none;
  }

  body.phone-portrait #gradingSummary .domain-score {
    min-width: 104px;
    min-height: 56px;
    flex: 0 0 auto;
    padding: 6px 8px;
    border-width: 0 1px 0 0;
    border-radius: 0;
    font-size: 12px;
    white-space: nowrap;
  }

  body.phone-portrait #gradingSummary .domain-score strong {
    font-size: 13px;
  }

  body.phone-portrait #gradingSummary .domain-score small {
    font-size: 10px;
  }

  body.phone-portrait #gradingSummary .score-origin-line {
    padding: 5px 8px;
    background: #fff8ec;
    font-size: 11px;
  }

  body.phone-portrait.phone-has-result #basicJudgement:not([hidden]) {
    display: block;
    width: 100%;
    margin: 0;
    border-width: 1px 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.phone-portrait #basicJudgement .basic-judgement-header,
  body.phone-portrait #basicJudgement .basic-judgement-item h3 {
    display: none;
  }

  body.phone-portrait #basicJudgement .basic-judgement-grid {
    display: flex;
    min-width: 0;
    gap: 6px;
    overflow-x: auto;
    padding: 7px 8px;
    scrollbar-width: none;
  }

  body.phone-portrait #basicJudgement .basic-judgement-item {
    min-width: max-content;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 12px;
  }

  body.phone-portrait #basicJudgement p,
  body.phone-portrait #basicJudgement .review-compact {
    margin: 0;
  }

  body.phone-portrait .content-grid {
    display: block;
    width: 100%;
    overflow: visible;
  }

  body.phone-portrait #currentErrorPanel {
    display: none !important;
    width: auto;
    margin: 0 6px 6px;
    border-radius: 8px;
    box-shadow: none;
  }

  body.phone-portrait.phone-error-active #currentErrorPanel {
    display: block !important;
  }

  body.phone-portrait #currentErrorPanel .section-title {
    min-height: 42px;
    gap: 4px;
    padding: 5px 8px;
  }

  body.phone-portrait #currentErrorPanel .section-title h2 {
    font-size: 14px;
  }

  body.phone-portrait .phone-inline-error-actions {
    align-items: center;
    gap: 3px;
    overflow-x: auto;
  }

  body.phone-portrait .phone-inline-error-actions button {
    min-height: 36px;
    flex: 0 0 auto;
    padding: 0 8px;
    border-color: #cfd6dc;
    background: #fff;
    color: var(--ink);
    font-size: 11px;
  }

  body.phone-portrait #currentErrorPanel .current-error-detail {
    grid-template-columns: minmax(0, 1fr);
    max-height: none;
    overflow: visible;
    padding: 7px 8px 9px;
  }

  body.phone-portrait #currentErrorPanel .current-error-card {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 9px 10px;
  }

  body.phone-portrait #currentErrorPanel .current-error-card > span,
  body.phone-portrait #currentErrorPanel .current-error-card h3,
  body.phone-portrait #currentErrorPanel .current-error-card p {
    grid-column: 1;
    margin: 0;
  }

  body.phone-portrait #currentErrorPanel .current-error-card h3 {
    font-size: 15px;
  }

  body.phone-portrait #currentErrorPanel .current-error-card p {
    font-size: 13px;
  }

  body.phone-portrait #currentErrorPanel .current-error-penalty {
    grid-column: 2;
    grid-row: 1 / span 3;
  }

  body.phone-portrait #issuePanel {
    position: static;
    display: block;
    width: auto;
    min-height: 0;
    height: auto;
    margin: 0 6px 8px;
    overflow: visible;
    border-radius: 8px;
    box-shadow: none;
  }

  body.phone-portrait #issuePanel .phone-portrait-error-header {
    position: static;
    z-index: auto;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    display: flex;
    min-height: 44px;
    height: auto;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 5px 7px;
    background: #fff;
    transform: none;
  }

  body.phone-portrait #issuePanel .section-title h2 {
    flex: 0 0 auto;
    font-size: 14px;
    white-space: nowrap;
  }

  body.phone-portrait #issuePanel .issue-filters {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 3px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.phone-portrait #issuePanel .issue-filters::-webkit-scrollbar {
    display: none;
  }

  body.phone-portrait #issuePanel .issue-filter,
  body.phone-portrait #issuePanel #copyButton {
    min-height: 34px;
    flex: 0 0 auto;
    padding: 0 7px;
    font-size: 11px;
    white-space: nowrap;
  }

  body.phone-portrait #issuePanel .phone-portrait-error-list {
    display: grid;
    min-height: 0;
    max-height: none;
    height: auto;
    overflow: visible;
    gap: 6px;
    padding: 7px;
  }

  body.phone-portrait #issuePanel .issue {
    min-height: 58px;
    grid-template-columns: 78px minmax(0, 1fr) auto;
    align-items: start;
    gap: 5px;
    padding: 8px;
  }

  body.phone-portrait #issuePanel .issue-time {
    font-size: 11px;
  }

  body.phone-portrait #issuePanel .issue-title {
    font-size: 14px;
    line-height: 1.25;
  }

  body.phone-portrait #issuePanel .issue-detail {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.35;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }

  body.phone-portrait #issuePanel .issue-meta,
  body.phone-portrait #issuePanel .issue-evidence,
  body.phone-portrait #issuePanel .issue-related {
    display: none;
  }

  body.phone-portrait #issuePanel .issue.phone-expanded {
    min-height: 100px;
  }

  body.phone-portrait #issuePanel .issue.phone-expanded .issue-detail {
    display: block;
    overflow: visible;
  }

  body.phone-portrait #issuePanel .issue.phone-expanded .issue-meta {
    display: flex;
  }

  body.phone-portrait #issuePanel .issue.phone-expanded .issue-evidence,
  body.phone-portrait #issuePanel .issue.phone-expanded .issue-related {
    display: block;
  }

  body.phone-portrait .exercise-error-label:not(.selected),
  body.phone-portrait .exercise-error-connector-label:not(.selected) {
    display: none;
  }

  body.phone-portrait.phone-error-active .exercise-error-mark:not(.selected),
  body.phone-portrait.phone-error-active .exercise-error-connector:not(.selected),
  body.phone-portrait.phone-error-active .exercise-error-background:not(.selected) {
    opacity: 0.24;
  }

  body.phone-portrait .key-picker-backdrop {
    z-index: 999;
  }

  body.phone-portrait .key-picker-overlay .phone-portrait-tonality-panel {
    position: fixed;
    z-index: 1000;
    top: auto;
    right: auto;
    bottom: calc(env(safe-area-inset-bottom) + 68px);
    left: 50%;
    width: calc(100vw - 24px);
    min-width: 0;
    max-width: 520px;
    max-height: 65dvh;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px;
    border-radius: 12px;
    box-sizing: border-box;
    transform: translateX(-50%);
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  body.phone-portrait .phone-portrait-tonality-grid {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 10px;
  }

  body.phone-portrait .phone-portrait-tonality-option {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 6px 10px;
    box-sizing: border-box;
    text-align: left;
  }

  body.phone-portrait .phone-portrait-tonality-option.selected {
    border-color: #c8e3dc;
    background: #edf8f5;
    color: var(--accent-strong);
  }

  body.phone-portrait .phone-panel-backdrop {
    position: fixed;
    z-index: 109;
    inset: 0;
    background: rgba(20, 31, 43, 0.3);
  }

  body.phone-portrait .phone-bottom-panel {
    position: fixed;
    z-index: 110;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom) + 8px);
    left: 12px;
    width: auto;
    max-height: 65dvh;
    overflow-y: auto;
    padding: 12px;
    border-radius: 14px;
    background: #fff;
  }

  body.phone-portrait .phone-choice-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  body.phone-portrait .phone-choice-options button {
    min-height: 44px;
  }

  body.phone-portrait .phone-review-page {
    position: fixed;
    z-index: 140;
    inset: 0;
    display: block;
    overflow-y: auto;
    background: #f4f6f7;
    -webkit-overflow-scrolling: touch;
  }

  body.phone-portrait .phone-review-page-header {
    position: sticky;
    z-index: 2;
    top: 0;
    display: grid;
    min-height: 48px;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: env(safe-area-inset-top) 10px 4px;
    background: #fff;
  }

  body.phone-portrait .phone-score-panel-content {
    display: grid;
    gap: 8px;
    padding: 10px 10px calc(16px + env(safe-area-inset-bottom));
  }
}

/* v1.6.1 keep zoom inside the score viewport across phone orientation changes */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px),
       (orientation: portrait) and (max-width: 600px) {
  body.phone-landscape .score-viewport,
  body.phone-portrait .score-viewport {
    overflow: hidden;
    touch-action: pan-y;
  }

  body.phone-landscape .score-content,
  body.phone-portrait .score-content {
    width: 100%;
    transform:
      translate3d(
        var(--score-pan-x, 0px),
        var(--score-pan-y, 0px),
        0
      )
      scale(var(--score-zoom, 1));
    transform-origin: 0 0;
    touch-action: pan-y;
    will-change: transform;
  }

  body.phone-portrait #phoneUndoButton {
    display: inline-flex;
  }

  body.phone-portrait #phoneUndoButton[hidden] {
    display: none !important;
  }

  body.phone-portrait #phoneUndoButton:disabled,
  body.phone-landscape #phoneUndoButton:disabled {
    border-color: #d8dde1;
    background: #eef1f3;
    color: #9aa3aa;
    opacity: 1;
  }

  body.phone-portrait .phone-exercise-title {
    flex-basis: 28px;
  }
}

/* v1.6.2 mobile portal sheets and full-width landscape canvas */
.mobile-sheet-layer:not([hidden]) {
  display: contents;
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px),
       (orientation: portrait) and (max-width: 600px) {
  body.phone-landscape .mobile-sheet-layer:not([hidden]),
  body.phone-portrait .mobile-sheet-layer:not([hidden]) {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: block;
    pointer-events: none;
  }

  body.phone-landscape .mobile-sheet-backdrop,
  body.phone-portrait .mobile-sheet-backdrop {
    position: absolute;
    z-index: 1000;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.28);
    pointer-events: auto;
  }

body.phone-landscape .mobile-sheet-panel,
body.phone-portrait .mobile-sheet-panel {
  position: absolute;
  z-index: 1001;
  top: auto;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    pointer-events: auto;
  -webkit-overflow-scrolling: touch;
}

body.phone-landscape .mobile-sheet-panel:not([hidden]),
body.phone-portrait .mobile-sheet-panel:not([hidden]) {
  display: block;
}

  body.phone-landscape.has-mobile-sheet .phone-landscape-edit-toolbar,
  body.phone-portrait.has-mobile-sheet .phone-portrait-edit-toolbar {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  body.phone-landscape .phone-landscape-topbar,
  body.phone-portrait .phone-portrait-topbar {
    z-index: 100;
  }

  body.phone-landscape .phone-landscape-edit-toolbar,
  body.phone-portrait .phone-portrait-edit-toolbar {
    z-index: 90;
  }

  body.phone-landscape #issuePanel .phone-landscape-error-header,
  body.phone-portrait #issuePanel .phone-portrait-error-header {
    z-index: 50;
  }
}

@media (orientation: portrait) and (max-width: 600px) {
  body.phone-portrait .mobile-sheet-panel {
    right: 12px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-width: none;
    max-height: calc(
      100dvh
      - env(safe-area-inset-top)
      - env(safe-area-inset-bottom)
      - 32px
    );
    padding: 12px;
    border-radius: 16px;
    transform: none;
  }
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html,
  body,
  #root {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: 0;
    overflow-x: clip;
    background: #fff;
  }

  body.phone-landscape.phone-landscape-page {
    width: var(--mobile-viewport-width, 100%);
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding-right: 0;
    padding-left: 0;
    overflow-x: clip;
    background: #fff;
  }

  body.phone-landscape .app-shell,
  body.phone-landscape .workspace,
  body.phone-landscape .phone-landscape-workspace,
  body.phone-landscape .exercise-section,
  body.phone-landscape .exercise-body,
  body.phone-landscape .content-grid,
  body.phone-landscape #currentErrorPanel,
  body.phone-landscape #issuePanel {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin-right: 0;
    margin-left: 0;
  }

  body.phone-landscape .app-shell,
  body.phone-landscape .workspace,
  body.phone-landscape .phone-landscape-workspace,
  body.phone-landscape .exercise-section,
  body.phone-landscape .exercise-body,
  body.phone-landscape .content-grid {
    overflow-x: clip;
  }

  body.phone-landscape .phone-landscape-topbar,
  body.phone-landscape .phone-landscape-edit-toolbar {
    width: 100%;
    max-width: none;
    padding-right: max(8px, env(safe-area-inset-right));
    padding-left: max(8px, env(safe-area-inset-left));
    background: #fff;
  }

  body.phone-landscape .phone-landscape-score-viewport {
    position: relative;
    width: 100%;
    max-width: none;
    min-width: 0;
    overflow: hidden;
    background: #fff;
  }

  body.phone-landscape .phone-landscape-score-content {
    position: relative;
    width: max-content;
    max-width: none;
    min-width: 0;
    transform-origin: 0 0;
  }

  body.phone-landscape .mobile-sheet-panel {
    right: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 50%;
    width: min(520px, calc(100% - 32px));
    max-width: 520px;
    max-height: min(420px, 75dvh);
    padding: 12px;
    border-radius: 12px;
    transform: translateX(-50%);
  }
}

/* v1.6.13: readonly landscape score height follows the rendered score. */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  body.phone-landscape.phone-landscape-result-page .exercise-section,
  body.phone-landscape.phone-landscape-result-page.phone-graded-locked .exercise-section,
  body.phone-landscape.phone-landscape-result-page.phone-graded-locked.phone-error-active .exercise-section {
    position: relative;
    inset: auto;
    min-height: 0;
    height: auto;
    max-height: none;
    margin: 0;
    overflow: visible;
  }

  body.phone-landscape.phone-landscape-result-page .score-review-section,
  body.phone-landscape.phone-landscape-result-page .result-score-viewport,
  body.phone-landscape.phone-landscape-result-page .review-score-viewport {
    min-height: 0;
    max-height: none;
    flex: none;
    flex-grow: 0;
    margin: 0;
  }

  body.phone-landscape.phone-landscape-result-page .result-score-viewport,
  body.phone-landscape.phone-landscape-result-page .review-score-viewport {
    height: auto;
    padding: 4px 8px 6px;
  }

  body.phone-landscape.phone-landscape-result-page.phone-error-active .content-grid > #currentErrorPanel {
    position: static;
    min-height: 0;
    max-height: none;
    margin: 6px 6px 0;
    overflow: visible;
  }

  body.phone-landscape.phone-landscape-result-page #issuePanel {
    position: static;
    min-height: 0;
    height: auto;
    margin: 6px 6px 8px;
    overflow: visible;
  }

  body.phone-landscape.phone-landscape-result-page #currentErrorPanel .mobile-result-error-card,
  body.phone-landscape.phone-landscape-result-page #issuePanel .issue.mobile-result-error-card {
    display: block;
    min-height: 0;
    margin: 0 0 6px;
    padding: 8px 12px;
  }
}

/* v1.6.14: final phone-landscape result card typography override. */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  body.phone-landscape.phone-landscape-result-page .current-error-section .mobile-result-error-card,
  body.phone-landscape.phone-landscape-result-page .issue-panel .mobile-result-error-card {
    min-height: 0;
    padding: 8px 12px;
  }

  body.phone-landscape.phone-landscape-result-page .current-error-section .error-location,
  body.phone-landscape.phone-landscape-result-page .issue-panel .error-location {
    font-size: 11px !important;
    line-height: 16px !important;
  }

  body.phone-landscape.phone-landscape-result-page .current-error-section .error-title,
  body.phone-landscape.phone-landscape-result-page .issue-panel .error-title {
    font-size: 14px !important;
    line-height: 19px !important;
    font-weight: 650;
  }

  body.phone-landscape.phone-landscape-result-page .current-error-section .error-description,
  body.phone-landscape.phone-landscape-result-page .issue-panel .error-description {
    margin-top: 2px;
    font-size: 12px !important;
    line-height: 17px !important;
  }

  body.phone-landscape.phone-landscape-result-page .current-error-section .error-deduction,
  body.phone-landscape.phone-landscape-result-page .issue-panel .error-deduction {
    font-size: 13px !important;
    line-height: 18px !important;
    font-weight: 650;
  }
}

/* v1.6.15: smaller readonly phone-landscape error item typography only. */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
  body.phone-landscape.phone-landscape-result-page .current-error-section .mobile-result-error-card,
  body.phone-landscape.phone-landscape-result-page .issue-panel .mobile-result-error-card {
    min-height: 0;
    padding: 6px 10px !important;
  }

  body.phone-landscape.phone-landscape-result-page .current-error-section .error-location,
  body.phone-landscape.phone-landscape-result-page .issue-panel .error-location {
    font-size: 9px !important;
    line-height: 12px !important;
  }

  body.phone-landscape.phone-landscape-result-page .current-error-section .error-title,
  body.phone-landscape.phone-landscape-result-page .issue-panel .error-title {
    font-size: 11px !important;
    line-height: 14px !important;
    font-weight: 650;
  }

  body.phone-landscape.phone-landscape-result-page .current-error-section .error-description,
  body.phone-landscape.phone-landscape-result-page .issue-panel .error-description {
    margin-top: 2px !important;
    font-size: 9px !important;
    line-height: 12px !important;
  }

  body.phone-landscape.phone-landscape-result-page .current-error-section .error-deduction,
  body.phone-landscape.phone-landscape-result-page .issue-panel .error-deduction {
    font-size: 11px !important;
    line-height: 14px !important;
    font-weight: 650;
  }

  body.phone-landscape.phone-landscape-result-page .current-error-section .error-tag,
  body.phone-landscape.phone-landscape-result-page .issue-panel .error-tag {
    font-size: 8px !important;
    line-height: 11px !important;
  }
}

/* v1.6.16 tablet layouts reuse the compact mobile structure at tablet sizes. */
body.layout-tablet-portrait,
body.layout-tablet-landscape {
  --tablet-topbar-height: 56px;
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  background: #fff;
}

body.layout-tablet-landscape {
  --tablet-topbar-height: 52px;
}

body.layout-tablet-portrait .phone-landscape-only:not([hidden]),
body.layout-tablet-landscape .phone-landscape-only:not([hidden]) {
  display: flex;
}

body.layout-tablet-portrait .phone-landscape-only[hidden],
body.layout-tablet-landscape .phone-landscape-only[hidden] {
  display: none !important;
}

body.layout-tablet-portrait #phoneSummaryToggle,
body.layout-tablet-landscape #phoneSummaryToggle {
  display: none !important;
}

body.layout-tablet-portrait > .phone-landscape-topbar,
body.layout-tablet-landscape > .phone-landscape-topbar {
  position: relative;
  z-index: 40;
  width: 100%;
  height: var(--tablet-topbar-height);
  min-height: var(--tablet-topbar-height);
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

body.layout-tablet-portrait .phone-top-button,
body.layout-tablet-landscape .phone-top-button {
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border-color: #cfd6dc;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

body.layout-tablet-portrait .phone-top-button.primary,
body.layout-tablet-landscape .phone-top-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

body.layout-tablet-portrait .tablet-topbar .question-button,
body.layout-tablet-landscape .tablet-topbar .question-button {
  width: auto;
  min-width: 72px;
  height: 46px;
  padding: 0 18px;
  border: 1.5px solid #1d7f6e;
  background: #e8f4f1;
  color: #0f6658;
  font-weight: 700;
}

body.layout-tablet-portrait .tablet-topbar .question-button.is-active,
body.layout-tablet-landscape .tablet-topbar .question-button.is-active {
  background: #1d7f6e;
  color: #fff;
}

body.layout-tablet-portrait .tablet-topbar .tablet-knowledge-hint,
body.layout-tablet-landscape .tablet-topbar .tablet-knowledge-hint {
  min-width: 126px;
  height: 44px;
  border-color: #a9b8b4;
  background: #fff;
  color: #245c52;
  font-weight: 650;
}

/* v1.6.21 phone-only topbar actions and contact-author dialog */
body.phone-landscape .phone-only:not([hidden]),
body.phone-portrait .phone-only:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.layout-tablet-portrait .phone-only,
body.layout-tablet-landscape .phone-only,
body:not(.phone-landscape):not(.phone-portrait) .phone-only {
  display: none !important;
}

body.phone-landscape .phone-contact-button,
body.phone-portrait .phone-contact-button {
  border-color: #07c160;
  background: #fff;
  color: #079447;
  font-weight: 700;
  white-space: nowrap;
}

body.phone-landscape .phone-knowledge-hint.active,
body.phone-portrait .phone-knowledge-hint.active {
  border-color: var(--accent);
  background: #e8f4f1;
  color: var(--accent-strong);
}

body.phone-landscape .phone-contact-portrait-label,
body.phone-portrait .phone-contact-landscape-label {
  display: none;
}

body.phone-landscape .contact-author-backdrop,
body.phone-portrait .contact-author-backdrop {
  position: fixed;
  z-index: 1300;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(20, 31, 43, 0.46);
}

body.phone-landscape .contact-author-backdrop[hidden],
body.phone-portrait .contact-author-backdrop[hidden],
body:not(.phone-landscape):not(.phone-portrait) .contact-author-backdrop {
  display: none !important;
}

body.phone-landscape .contact-author-dialog,
body.phone-portrait .contact-author-dialog {
  width: min(100%, 520px);
  max-height: min(80dvh, 420px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid #d9e4e1;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(20, 31, 43, 0.22);
}

body.phone-landscape .contact-author-heading,
body.phone-portrait .contact-author-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body.phone-landscape .contact-author-heading h2,
body.phone-portrait .contact-author-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
}

body.phone-landscape .contact-author-close,
body.phone-portrait .contact-author-close {
  min-height: 36px;
  padding: 6px 12px;
  border-color: #d4dbdf;
  background: #fff;
  color: var(--muted);
}

body.phone-landscape .contact-author-wechat-row,
body.phone-portrait .contact-author-wechat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

body.phone-landscape .contact-author-wechat-row strong,
body.phone-portrait .contact-author-wechat-row strong {
  min-width: 0;
  font-size: 16px;
  white-space: nowrap;
}

body.phone-landscape #copyWechatButton,
body.phone-portrait #copyWechatButton {
  min-height: 40px;
  padding: 7px 14px;
  border-color: #07c160;
  background: #eaf9f0;
  color: #078e45;
  font-weight: 700;
  white-space: nowrap;
}

body.phone-landscape .contact-purpose,
body.phone-portrait .contact-purpose {
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
}

body.phone-landscape .wechat-copy-feedback,
body.phone-portrait .wechat-copy-feedback {
  margin: 10px 0 0;
  color: #078e45;
  font-size: 13px;
  font-weight: 700;
}

body.phone-landscape .wechat-copy-feedback[hidden],
body.phone-portrait .wechat-copy-feedback[hidden] {
  display: none;
}

@media (orientation: landscape) and (max-width: 1000px) and (max-height: 600px) {
  body.phone-landscape .phone-top-button {
    padding-right: 8px;
    padding-left: 8px;
    white-space: nowrap;
  }

  body.phone-landscape .phone-knowledge-hint,
  body.phone-landscape .phone-contact-button {
    font-size: 12px;
  }

  body.phone-landscape .contact-author-dialog {
    width: min(520px, calc(100vw - 32px));
    max-height: min(76dvh, 250px);
    padding: 12px 14px;
  }

  body.phone-landscape .contact-author-wechat-row {
    margin-top: 8px;
  }

  body.phone-landscape .contact-purpose {
    margin-top: 8px;
    white-space: nowrap;
  }
}

@media (orientation: portrait) and (max-width: 600px) {
  body.phone-portrait .phone-portrait-topbar {
    gap: 2px;
    padding-right: 4px;
    padding-left: 4px;
  }

  body.phone-portrait .phone-top-button {
    padding-right: 5px;
    padding-left: 5px;
    font-size: 11px;
  }

  body.phone-portrait .phone-exercise-title {
    padding-right: 1px;
    padding-left: 1px;
  }

  body.phone-portrait .contact-author-dialog {
    width: min(420px, calc(100vw - 24px));
  }

  body.phone-portrait .contact-author-wechat-row {
    align-items: stretch;
    flex-direction: column;
  }

  body.phone-portrait .contact-purpose {
    max-width: 20em;
  }
}

body.layout-tablet-portrait .tablet-topbar .tablet-knowledge-hint.active,
body.layout-tablet-landscape .tablet-topbar .tablet-knowledge-hint.active {
  border-color: #1d7f6e;
  background: #e8f4f1;
  color: #0f6658;
}

@media (max-width: 720px) {
  body.layout-tablet-portrait .tablet-topbar .tablet-knowledge-hint {
    min-width: 68px;
    padding: 0 10px;
    font-size: 0;
  }

  body.layout-tablet-portrait .tablet-topbar .tablet-knowledge-hint::after {
    content: "AI标注";
    font-size: 13px;
  }
}

body.layout-tablet-portrait .phone-exercise-title,
body.layout-tablet-landscape .phone-exercise-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  padding: 0 6px;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.layout-tablet-portrait .app-shell,
body.layout-tablet-landscape .app-shell {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

body.layout-tablet-portrait .toolbar,
body.layout-tablet-landscape .toolbar {
  position: fixed;
  z-index: 110;
  top: var(--tablet-topbar-height);
  bottom: 0;
  left: 0;
  width: min(360px, 72vw);
  overflow-y: auto;
  gap: 12px;
  padding: 16px;
  border-right: 1px solid var(--line);
  border-bottom: 0;
  background: #fff;
  box-shadow: 16px 0 40px rgba(20, 31, 43, 0.22);
  transform: translateX(-105%);
  transition: transform 180ms ease;
}

body.layout-tablet-portrait.phone-question-open .toolbar,
body.layout-tablet-landscape.phone-question-open .toolbar {
  transform: translateX(0);
}

body.layout-tablet-portrait.phone-question-open::after,
body.layout-tablet-landscape.phone-question-open::after {
  position: fixed;
  z-index: 105;
  inset: var(--tablet-topbar-height) 0 0;
  content: "";
  background: rgba(20, 31, 43, 0.28);
}

body.layout-tablet-portrait .toolbar .release-banner,
body.layout-tablet-portrait .toolbar .brand,
body.layout-tablet-portrait .toolbar .file-picker,
body.layout-tablet-portrait .toolbar #sampleButton,
body.layout-tablet-portrait .toolbar #gradeButton,
body.layout-tablet-landscape .toolbar .release-banner,
body.layout-tablet-landscape .toolbar .brand,
body.layout-tablet-landscape .toolbar .file-picker,
body.layout-tablet-landscape .toolbar #sampleButton,
body.layout-tablet-landscape .toolbar #gradeButton {
  display: none;
}

body.layout-tablet-portrait .toolbar select,
body.layout-tablet-landscape .toolbar select {
  min-height: 44px;
  font-size: 14px;
}

body.layout-tablet-portrait .workspace,
body.layout-tablet-landscape .workspace {
  width: 100%;
  min-width: 0;
  margin: 0;
}

body.layout-tablet-portrait .exercise-section > .section-title,
body.layout-tablet-landscape .exercise-section > .section-title {
  display: none !important;
  height: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

body.layout-tablet-portrait.tablet-portrait-edit-page,
body.layout-tablet-landscape.tablet-landscape-edit-page {
  display: grid;
  width: 100%;
  min-height: 0;
  height: var(--tablet-visual-height, 100dvh);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

body.layout-tablet-portrait.tablet-portrait-edit-page > .app-shell,
body.layout-tablet-landscape.tablet-landscape-edit-page > .app-shell {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .workspace,
body.layout-tablet-landscape.tablet-landscape-edit-page .workspace {
  display: grid;
  height: 100%;
  min-height: 0;
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: #fff;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .workspace {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

body.layout-tablet-landscape.tablet-landscape-edit-page .workspace {
  grid-template-rows: minmax(0, 1fr) auto auto;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .exercise-section,
body.layout-tablet-portrait.tablet-portrait-edit-page .exercise-body,
body.layout-tablet-portrait.tablet-portrait-edit-page .score-review-section,
body.layout-tablet-portrait.tablet-portrait-edit-page .content-grid,
body.layout-tablet-portrait.tablet-portrait-edit-page #issuePanel,
body.layout-tablet-landscape.tablet-landscape-edit-page .exercise-section,
body.layout-tablet-landscape.tablet-landscape-edit-page .exercise-body,
body.layout-tablet-landscape.tablet-landscape-edit-page .score-review-section,
body.layout-tablet-landscape.tablet-landscape-edit-page .content-grid,
body.layout-tablet-landscape.tablet-landscape-edit-page #issuePanel {
  display: contents;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .exercise-section > .section-title,
body.layout-tablet-portrait.tablet-portrait-edit-page .review-question-bar,
body.layout-tablet-portrait.tablet-portrait-edit-page .exercise-controls,
body.layout-tablet-portrait.tablet-portrait-edit-page .assist-tools,
body.layout-tablet-portrait.tablet-portrait-edit-page #gradingSummary,
body.layout-tablet-portrait.tablet-portrait-edit-page #basicJudgement,
body.layout-tablet-portrait.tablet-portrait-edit-page .technical-result-state,
body.layout-tablet-portrait.tablet-portrait-edit-page #currentErrorPanel,
body.layout-tablet-portrait.tablet-portrait-edit-page .exercise-load-notice,
body.layout-tablet-portrait.tablet-portrait-edit-page .result-stale-notice,
body.layout-tablet-landscape.tablet-landscape-edit-page .exercise-section > .section-title,
body.layout-tablet-landscape.tablet-landscape-edit-page .review-question-bar,
body.layout-tablet-landscape.tablet-landscape-edit-page .exercise-controls,
body.layout-tablet-landscape.tablet-landscape-edit-page .assist-tools,
body.layout-tablet-landscape.tablet-landscape-edit-page #gradingSummary,
body.layout-tablet-landscape.tablet-landscape-edit-page #basicJudgement,
body.layout-tablet-landscape.tablet-landscape-edit-page .technical-result-state,
body.layout-tablet-landscape.tablet-landscape-edit-page #currentErrorPanel,
body.layout-tablet-landscape.tablet-landscape-edit-page .exercise-load-notice,
body.layout-tablet-landscape.tablet-landscape-edit-page .result-stale-notice {
  display: none !important;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .exercise-meta {
  grid-row: 1;
  min-height: 44px;
  padding: 10px 16px;
}

body.layout-tablet-landscape.tablet-landscape-edit-page .exercise-meta {
  display: none;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .score-viewport,
body.layout-tablet-landscape.tablet-landscape-edit-page .score-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  touch-action: none;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .score-viewport {
  grid-row: 2;
}

body.layout-tablet-landscape.tablet-landscape-edit-page .score-viewport {
  grid-row: 1;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .score-content,
body.layout-tablet-landscape.tablet-landscape-edit-page .score-content {
  transform-origin: 0 0;
  will-change: transform;
  touch-action: none;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .phone-answer-toolbar,
body.layout-tablet-landscape.tablet-landscape-edit-page .phone-answer-toolbar {
  position: static;
  z-index: 30;
  width: 100%;
  min-height: 0;
  border-top: 1px solid var(--line);
  background: #fff;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .phone-answer-toolbar {
  grid-row: 3;
  display: grid;
  grid-template-columns: 0.75fr 0.8fr 1.15fr 1.2fr 1.1fr 0.65fr;
  gap: 8px;
  padding: 8px 12px;
}

body.layout-tablet-landscape.tablet-landscape-edit-page .phone-answer-toolbar {
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 16px;
  scrollbar-width: none;
}

body.layout-tablet-portrait.tablet-portrait-edit-page .phone-answer-toolbar button,
body.layout-tablet-landscape.tablet-landscape-edit-page .phone-answer-toolbar button {
  min-width: 0;
  height: 48px;
  min-height: 48px;
  padding: 0 10px;
  border-color: #cfd6dc;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}

body.layout-tablet-landscape.tablet-landscape-edit-page .phone-answer-toolbar button {
  min-width: 92px;
  height: 46px;
  min-height: 46px;
  flex: 0 0 auto;
}

body.layout-tablet-portrait.tablet-portrait-edit-page #issuePanel .phone-portrait-error-header,
body.layout-tablet-landscape.tablet-landscape-edit-page #issuePanel .phone-portrait-error-header {
  position: static;
  z-index: 20;
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  overflow: hidden;
  padding: 6px 12px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}

body.layout-tablet-portrait.tablet-portrait-edit-page #issuePanel .phone-portrait-error-header {
  grid-row: 4;
}

body.layout-tablet-landscape.tablet-landscape-edit-page #issuePanel .phone-portrait-error-header {
  grid-row: 3;
}

body.layout-tablet-portrait.tablet-portrait-edit-page #issuePanel .phone-portrait-error-header h2,
body.layout-tablet-landscape.tablet-landscape-edit-page #issuePanel .phone-portrait-error-header h2 {
  flex: 0 0 auto;
  font-size: 14px;
  white-space: nowrap;
}

body.layout-tablet-portrait.tablet-portrait-edit-page #issuePanel .issue-filters,
body.layout-tablet-landscape.tablet-landscape-edit-page #issuePanel .issue-filters {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 5px;
  overflow-x: auto;
}

body.layout-tablet-portrait.tablet-portrait-edit-page #issuePanel .issue-filter,
body.layout-tablet-landscape.tablet-landscape-edit-page #issuePanel .issue-filter {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 9px;
  font-size: 12px;
}

body.layout-tablet-portrait.tablet-portrait-edit-page #issuePanel #copyButton,
body.layout-tablet-landscape.tablet-landscape-edit-page #issuePanel #copyButton {
  display: none;
}

body.layout-tablet-portrait.tablet-portrait-edit-page #issuePanel .issue-list,
body.layout-tablet-landscape.tablet-landscape-edit-page #issuePanel .issue-list {
  display: none;
}

body.layout-tablet-portrait.tablet-edit-errors-open #issuePanel,
body.layout-tablet-landscape.tablet-edit-errors-open #issuePanel,
body.layout-tablet-portrait.phone-portrait-edit-errors-open #issuePanel {
  position: fixed;
  z-index: 35;
  inset: var(--tablet-topbar-height) 0 0;
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  -webkit-overflow-scrolling: touch;
}

body.layout-tablet-portrait.tablet-edit-errors-open #issuePanel .phone-portrait-error-header,
body.layout-tablet-landscape.tablet-edit-errors-open #issuePanel .phone-portrait-error-header,
body.layout-tablet-portrait.phone-portrait-edit-errors-open #issuePanel .phone-portrait-error-header {
  position: sticky;
  z-index: 2;
  top: 0;
}

body.layout-tablet-portrait.tablet-edit-errors-open #issuePanel .issue-list,
body.layout-tablet-landscape.tablet-edit-errors-open #issuePanel .issue-list,
body.layout-tablet-portrait.phone-portrait-edit-errors-open #issuePanel .issue-list {
  display: grid;
  height: auto;
  max-height: none;
  overflow: visible;
}

body.layout-tablet-portrait.tablet-result-page,
body.layout-tablet-landscape.tablet-result-page {
  display: block;
  width: 100%;
  min-height: 100dvh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

body.layout-tablet-portrait.tablet-result-page > .phone-landscape-topbar,
body.layout-tablet-landscape.tablet-result-page > .phone-landscape-topbar {
  position: sticky;
  top: 0;
}

body.layout-tablet-portrait.tablet-result-page .workspace,
body.layout-tablet-landscape.tablet-result-page .workspace {
  display: flex;
  width: 100%;
  min-height: 0;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: visible;
  background: #fff;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary,
body.layout-tablet-landscape.tablet-result-page #gradingSummary {
  order: 1;
  display: grid;
  width: 100%;
  grid-template-columns: minmax(130px, 1.15fr) repeat(5, minmax(0, 1fr));
  grid-template-rows: minmax(86px, auto);
  margin: 0;
  overflow: hidden;
  border-width: 0 0 1px;
  border-radius: 0;
  box-shadow: none;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .result-summary-row,
body.layout-tablet-landscape.tablet-result-page #gradingSummary .result-summary-row {
  display: contents;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .score-panel,
body.layout-tablet-landscape.tablet-result-page #gradingSummary .score-panel {
  display: flex;
  grid-row: 1;
  grid-column: 1;
  min-width: 0;
  min-height: 86px;
  align-items: flex-start;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1px;
  padding: 8px 12px 25px;
  border-right: 1px solid var(--line);
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .score-panel strong,
body.layout-tablet-landscape.tablet-result-page #gradingSummary .score-panel strong {
  font-size: 30px;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .domain-score-grid,
body.layout-tablet-landscape.tablet-result-page #gradingSummary .domain-score-grid {
  display: contents;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .domain-score,
body.layout-tablet-landscape.tablet-result-page #gradingSummary .domain-score {
  min-width: 0;
  min-height: 86px;
  padding: 7px 10px;
  border-width: 0 1px 0 0;
  border-radius: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .domain-score:nth-child(1),
body.layout-tablet-landscape.tablet-result-page #gradingSummary .domain-score:nth-child(1) {
  grid-row: 1;
  grid-column: 2;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .domain-score:nth-child(2),
body.layout-tablet-landscape.tablet-result-page #gradingSummary .domain-score:nth-child(2) {
  grid-row: 1;
  grid-column: 3;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .domain-score:nth-child(3),
body.layout-tablet-landscape.tablet-result-page #gradingSummary .domain-score:nth-child(3) {
  grid-row: 1;
  grid-column: 4;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .domain-score:nth-child(4),
body.layout-tablet-landscape.tablet-result-page #gradingSummary .domain-score:nth-child(4) {
  grid-row: 1;
  grid-column: 5;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .domain-score:nth-child(5),
body.layout-tablet-landscape.tablet-result-page #gradingSummary .domain-score:nth-child(5) {
  grid-row: 1;
  grid-column: 6;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .score-origin-line,
body.layout-tablet-landscape.tablet-result-page #gradingSummary .score-origin-line {
  z-index: 2;
  display: flex !important;
  grid-row: 1;
  grid-column: 1;
  min-width: 0;
  align-self: end;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 12px 6px;
  border: 0;
  background: transparent;
  font-size: 10px;
  line-height: 13px;
  pointer-events: none;
}

body.layout-tablet-portrait.tablet-result-page #gradingSummary .score-cap-reason,
body.layout-tablet-landscape.tablet-result-page #gradingSummary .score-cap-reason {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.layout-tablet-portrait.tablet-result-page .exercise-section,
body.layout-tablet-landscape.tablet-result-page .exercise-section {
  order: 2;
  min-height: 0;
  height: auto;
  margin: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.layout-tablet-portrait.tablet-result-page .exercise-section > .section-title,
body.layout-tablet-portrait.tablet-result-page .exercise-meta,
body.layout-tablet-portrait.tablet-result-page .review-question-bar,
body.layout-tablet-portrait.tablet-result-page .exercise-controls,
body.layout-tablet-portrait.tablet-result-page .assist-tools,
body.layout-tablet-portrait.tablet-result-page .phone-answer-toolbar,
body.layout-tablet-portrait.tablet-result-page #basicJudgement,
body.layout-tablet-landscape.tablet-result-page .exercise-section > .section-title,
body.layout-tablet-landscape.tablet-result-page .exercise-meta,
body.layout-tablet-landscape.tablet-result-page .review-question-bar,
body.layout-tablet-landscape.tablet-result-page .exercise-controls,
body.layout-tablet-landscape.tablet-result-page .assist-tools,
body.layout-tablet-landscape.tablet-result-page .phone-answer-toolbar,
body.layout-tablet-landscape.tablet-result-page #basicJudgement {
  display: none !important;
}

body.layout-tablet-portrait.tablet-result-page .exercise-body,
body.layout-tablet-portrait.tablet-result-page .score-review-section,
body.layout-tablet-landscape.tablet-result-page .exercise-body,
body.layout-tablet-landscape.tablet-result-page .score-review-section {
  display: block;
  width: 100%;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  box-shadow: none;
}

body.layout-tablet-portrait.tablet-result-page .result-score-viewport,
body.layout-tablet-portrait.tablet-result-page .review-score-viewport,
body.layout-tablet-landscape.tablet-result-page .result-score-viewport,
body.layout-tablet-landscape.tablet-result-page .review-score-viewport {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: none;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  touch-action: pan-y;
}

body.layout-tablet-portrait.tablet-result-page .result-score-viewport,
body.layout-tablet-portrait.tablet-result-page .review-score-viewport {
  padding: 10px 16px 8px;
}

body.layout-tablet-landscape.tablet-result-page .result-score-viewport,
body.layout-tablet-landscape.tablet-result-page .review-score-viewport {
  padding: 6px 16px;
}

body.layout-tablet-portrait.tablet-result-page .review-score-svg {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: none;
  margin: 0;
  transform: none !important;
  transform-origin: 0 0;
}

body.layout-tablet-landscape.tablet-result-page .review-score-svg {
  display: block;
  max-width: none;
  max-height: none;
  margin: 0;
  transform: none !important;
  transform-origin: 0 0;
}

body.layout-tablet-portrait.tablet-result-page .content-grid,
body.layout-tablet-landscape.tablet-result-page .content-grid {
  order: 3;
  display: block;
  width: 100%;
  overflow: visible;
}

body.layout-tablet-portrait.tablet-result-page #currentErrorPanel,
body.layout-tablet-landscape.tablet-result-page #currentErrorPanel,
body.layout-tablet-portrait.tablet-result-page #issuePanel,
body.layout-tablet-landscape.tablet-result-page #issuePanel {
  position: static;
  width: auto;
  min-height: 0;
  height: auto;
  margin: 10px 12px 0;
  overflow: visible;
  border-radius: 8px;
  box-shadow: none;
}

body.layout-tablet-portrait.tablet-result-page #currentErrorPanel[hidden],
body.layout-tablet-landscape.tablet-result-page #currentErrorPanel[hidden] {
  display: none !important;
}

body.layout-tablet-portrait.tablet-result-page #currentErrorPanel .current-error-header,
body.layout-tablet-landscape.tablet-result-page #currentErrorPanel .current-error-header,
body.layout-tablet-portrait.tablet-result-page #issuePanel .section-title,
body.layout-tablet-landscape.tablet-result-page #issuePanel .section-title {
  position: static;
  min-height: 46px;
  height: auto;
  padding: 7px 12px;
}

body.layout-tablet-portrait.tablet-result-page #currentErrorPanel .phone-inline-error-actions,
body.layout-tablet-landscape.tablet-result-page #currentErrorPanel .phone-inline-error-actions {
  display: flex;
  gap: 6px;
}

body.layout-tablet-portrait.tablet-result-page #currentErrorPanel .phone-inline-error-actions button,
body.layout-tablet-landscape.tablet-result-page #currentErrorPanel .phone-inline-error-actions button {
  min-height: 38px;
  padding: 0 11px;
  border-color: #cfd6dc;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

body.layout-tablet-portrait.tablet-result-page #currentErrorPanel .current-error-detail,
body.layout-tablet-landscape.tablet-result-page #currentErrorPanel .current-error-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px 10px;
}

body.layout-tablet-portrait.tablet-result-page #issuePanel .issue-list,
body.layout-tablet-landscape.tablet-result-page #issuePanel .issue-list {
  display: grid;
  height: auto;
  max-height: none;
  overflow: visible;
  gap: 8px;
  padding: 8px 10px 14px;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card {
  display: block;
  min-height: 0;
  margin: 0 0 8px;
  padding: 8px 12px;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-card-heading,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-card-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-location,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-location {
  font-size: 11px !important;
  line-height: 15px !important;
  white-space: nowrap;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-title,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-title {
  overflow: hidden;
  margin: 0;
  font-size: 14px !important;
  font-weight: 650;
  line-height: 19px !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-description,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-description {
  display: -webkit-box;
  overflow: hidden;
  margin: 2px 0 0;
  font-size: 12px !important;
  line-height: 17px !important;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-deduction,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-deduction {
  font-size: 13px !important;
  font-weight: 650;
  line-height: 18px !important;
  white-space: nowrap;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-tag,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-tag {
  font-size: 11px !important;
  line-height: 16px !important;
}

body.layout-tablet-portrait.tablet-result-page #issuePanel .issue-meta,
body.layout-tablet-portrait.tablet-result-page #issuePanel .issue-evidence,
body.layout-tablet-portrait.tablet-result-page #issuePanel .issue-related,
body.layout-tablet-portrait.tablet-result-page #issuePanel .foundation-related-issues,
body.layout-tablet-landscape.tablet-result-page #issuePanel .issue-meta,
body.layout-tablet-landscape.tablet-result-page #issuePanel .issue-evidence,
body.layout-tablet-landscape.tablet-result-page #issuePanel .issue-related,
body.layout-tablet-landscape.tablet-result-page #issuePanel .foundation-related-issues {
  display: none !important;
}

/* Tablet result cards use their own readable layout, never the phone compact grid. */
body.layout-tablet-portrait.tablet-result-page #currentErrorPanel .current-error-detail,
body.layout-tablet-portrait.tablet-result-page #issuePanel .issue-list,
body.layout-tablet-landscape.tablet-result-page #currentErrorPanel .current-error-detail,
body.layout-tablet-landscape.tablet-result-page #issuePanel .issue-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: auto;
  max-height: none;
  overflow: visible;
}

body.layout-tablet-portrait.tablet-result-page #currentErrorPanel .current-error-detail,
body.layout-tablet-portrait.tablet-result-page #issuePanel .issue-list {
  gap: 12px;
  padding: 12px 14px 16px;
}

body.layout-tablet-landscape.tablet-result-page #currentErrorPanel .current-error-detail,
body.layout-tablet-landscape.tablet-result-page #issuePanel .issue-list {
  gap: 10px;
  padding: 10px 12px 14px;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card {
  display: block;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 14px 18px;
}

body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card {
  display: block;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 12px 16px;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-card-heading,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-card-heading {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: start;
  gap: 0 12px;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-location,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-location {
  grid-row: 1;
  grid-column: 1;
  overflow: visible;
  white-space: normal;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-title,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-title {
  grid-row: 2;
  grid-column: 1 / -1;
  overflow: visible;
  width: 100%;
  text-overflow: clip;
  white-space: normal;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-deduction,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-deduction {
  grid-row: 1;
  grid-column: 2;
  white-space: nowrap;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-description,
body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-description {
  display: block;
  overflow: visible;
  width: 100%;
  max-width: none;
  white-space: normal;
  -webkit-line-clamp: initial;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-location {
  font-size: 13px !important;
  line-height: 19px !important;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-title {
  margin: 6px 0 0;
  font-size: 18px !important;
  font-weight: 650;
  line-height: 25px !important;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-description {
  margin: 6px 0 0;
  font-size: 15px !important;
  line-height: 23px !important;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-deduction {
  font-size: 17px !important;
  font-weight: 650;
  line-height: 24px !important;
}

body.layout-tablet-portrait.tablet-result-page .mobile-result-error-card .error-tag {
  font-size: 12px !important;
  line-height: 18px !important;
}

body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-location {
  font-size: 12px !important;
  line-height: 18px !important;
}

body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-title {
  margin: 5px 0 0;
  font-size: 17px !important;
  font-weight: 650;
  line-height: 24px !important;
}

body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-description {
  margin: 5px 0 0;
  font-size: 14px !important;
  line-height: 21px !important;
}

body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-deduction {
  font-size: 16px !important;
  font-weight: 650;
  line-height: 23px !important;
}

body.layout-tablet-landscape.tablet-result-page .mobile-result-error-card .error-tag {
  font-size: 12px !important;
  line-height: 18px !important;
}

/* The wrapper is layout-neutral everywhere except tablet portrait read-only results. */
.tablet-portrait-result-score-module {
  display: contents;
}

.score-zoom-control[hidden] {
  display: none !important;
}

body.layout-tablet-portrait.tablet-result-page .tablet-portrait-result-score-module {
  position: static;
  display: grid;
  width: 100%;
  max-height: 50dvh;
  grid-template-rows: minmax(0, 1fr) auto;
  margin: 0;
  padding: 0;
  overflow: hidden;
  transform: none;
  zoom: 1;
}

body.layout-tablet-portrait.tablet-result-page .score-horizontal-viewport {
  position: static;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 5px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  box-sizing: border-box;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  transform: none;
  zoom: 1;
}

body.layout-tablet-portrait.tablet-result-page .score-scaled-content {
  display: block;
  width: max-content;
  min-width: 0;
  height: auto;
  margin: 0;
  transform: none !important;
  transform-origin: left top;
  zoom: 1;
}

body.layout-tablet-portrait.tablet-result-page .score-zoom-control:not([hidden]) {
  display: flex;
}

body.layout-tablet-portrait.tablet-result-page .score-zoom-control {
  position: static;
  height: 42px;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
  box-sizing: border-box;
}

body.layout-tablet-portrait.tablet-result-page .score-zoom-control button {
  width: 38px;
  min-width: 38px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 19px;
  line-height: 28px;
}

body.layout-tablet-portrait.tablet-result-page .score-zoom-control input[type="range"] {
  width: min(360px, 62vw);
  margin: 0;
}

body.layout-tablet-portrait .mobile-sheet-layer:not([hidden]),
body.layout-tablet-landscape .mobile-sheet-layer:not([hidden]) {
  position: fixed;
  z-index: 900;
  inset: 0;
  display: block;
}

body.layout-tablet-portrait .mobile-sheet-backdrop,
body.layout-tablet-landscape .mobile-sheet-backdrop {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: rgba(20, 31, 43, 0.34);
}

body.layout-tablet-portrait .key-picker-overlay .key-picker-menu,
body.layout-tablet-landscape .key-picker-overlay .key-picker-menu {
  position: fixed;
  z-index: 1000;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  transform: translate(-50%, -50%);
  overscroll-behavior: contain;
}

body.layout-tablet-portrait .key-picker-overlay .key-picker-menu {
  width: min(560px, calc(100vw - 48px));
  max-width: 560px;
  max-height: min(72dvh, 620px);
}

body.layout-tablet-landscape .key-picker-overlay .key-picker-menu {
  width: min(620px, calc(100vw - 64px));
  max-width: 620px;
  max-height: min(76dvh, 520px);
}

body.layout-tablet-portrait .key-picker-grid,
body.layout-tablet-landscape .key-picker-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

body.layout-tablet-portrait .phone-bottom-panel,
body.layout-tablet-landscape .phone-bottom-panel {
  position: fixed;
  z-index: 1000;
  right: auto;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  display: block;
  width: min(640px, calc(100vw - 48px));
  max-height: min(72dvh, 560px);
  overflow-y: auto;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(20, 31, 43, 0.28);
  transform: translateX(-50%);
}

body.layout-tablet-portrait .phone-panel-backdrop,
body.layout-tablet-landscape .phone-panel-backdrop {
  position: fixed;
  z-index: 900;
  inset: 0;
  background: rgba(20, 31, 43, 0.34);
}

body.layout-tablet-portrait .phone-panel-heading,
body.layout-tablet-landscape .phone-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

body.layout-tablet-portrait .phone-choice-options,
body.layout-tablet-landscape .phone-choice-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

body.layout-tablet-portrait .phone-choice-options button,
body.layout-tablet-landscape .phone-choice-options button {
  min-height: 46px;
  border-color: #cfd6dc;
  background: #fff;
  color: var(--ink);
}
