:root {
  color-scheme: light;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-tint: #eef2ff;
  --ink: #142033;
  --muted: #66748a;
  --line: #d9e1ec;
  --line-strong: #a9b6c8;
  --navy: #111827;
  --navy-soft: #24304a;
  --teal: #2563eb;
  --teal-deep: #1d4ed8;
  --teal-bright: #38bdf8;
  --indigo: #4f46e5;
  --amber: #b45309;
  --rose: #be123c;
  --green: #166534;
  --accent: #2563eb;
  --accent-deep: #1d4ed8;
  --accent-soft: #eaf1ff;
  --shadow: 0 22px 48px rgba(20, 32, 51, 0.13);
  --shadow-soft: 0 12px 26px rgba(20, 32, 51, 0.08);
  --shadow-tight: 0 7px 18px rgba(20, 32, 51, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #f7f9fd 0, #ffffff 320px, var(--bg) 100%);
  color: var(--ink);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1522;
  --surface: #111c2d;
  --surface-alt: #162235;
  --surface-tint: #17203a;
  --ink: #edf4ff;
  --muted: #9fb0c6;
  --line: #2a3950;
  --line-strong: #53657d;
  --navy: #0f1a2b;
  --navy-soft: #172842;
  --teal: #93c5fd;
  --teal-deep: #bfdbfe;
  --teal-bright: #fbbf24;
  --indigo: #a5b4fc;
  --amber: #fbbf24;
  --rose: #fb7185;
  --green: #86efac;
  --accent: #93c5fd;
  --accent-deep: #dbeafe;
  --accent-soft: #172554;
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 12px 26px rgba(0, 0, 0, 0.26);
  --shadow-tight: 0 7px 18px rgba(0, 0, 0, 0.24);
  background:
    linear-gradient(180deg, #111827 0, #101827 330px, var(--bg) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  isolation: isolate;
  min-height: 100vh;
  padding: 22px;
  position: relative;
}

.app-shell::before {
  content: "";
  display: none;
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: -1;
}

body[data-theme="dark"] .app-shell::before {
  display: none;
}

.topbar {
  align-items: center;
  background: linear-gradient(135deg, #111827, #1f2937 62%, #263244);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  box-shadow: 0 20px 42px rgba(17, 24, 39, 0.2);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 18px;
  max-width: 1560px;
  min-height: 92px;
  padding: 18px 22px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 15px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(20, 32, 51, 0.06), 0 10px 22px rgba(0, 0, 0, 0.14);
  display: flex;
  flex: 0 0 56px;
  gap: 4px;
  height: 56px;
  justify-content: center;
  width: 56px;
}

.brand-stroke {
  border-radius: 999px;
  display: block;
  width: 6px;
}

.brand-stroke-one {
  background: #2563eb;
  height: 20px;
}

.brand-stroke-two {
  background: #4f46e5;
  height: 30px;
}

.brand-stroke-three {
  background: #f59e0b;
  height: 40px;
}

.brand h1,
.draft-toolbar h2 {
  letter-spacing: 0;
  line-height: 1.1;
  margin: 0;
}

.brand h1 {
  color: #ffffff;
  font-family: Georgia, "Times New Roman", ui-serif, serif;
  font-size: 1.46rem;
  font-weight: 700;
}

.brand p,
.draft-toolbar p {
  color: var(--muted);
  margin: 5px 0 0;
}

.topbar .brand p {
  color: rgba(237, 244, 255, 0.82);
  font-size: 0.98rem;
}

.topbar .tool-button,
.topbar .icon-button {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.38);
  color: #122033;
  box-shadow: 0 1px 0 rgba(20, 32, 51, 0.08);
}

.topbar .tool-button:hover,
.topbar .icon-button:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  color: var(--accent-deep);
}

.top-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.top-action-group {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.editor-console {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e6d19b;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 auto 16px;
  max-width: 1560px;
  overflow: hidden;
}

.editor-console-head {
  align-items: center;
  background: linear-gradient(180deg, #fffaf0, #ffffff);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 1fr) auto 40px;
  min-height: 76px;
  padding: 14px 16px;
}

.editor-kicker {
  color: #8a5b0a;
  display: block;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.editor-console h2,
.editor-inspector h3 {
  letter-spacing: 0;
  margin: 3px 0 0;
}

.editor-console h2 {
  font-size: 1.15rem;
}

.editor-inspector h3 {
  font-size: 1rem;
}

.editor-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.editor-metrics span {
  background: #fff8e5;
  border: 1px solid #ead9a9;
  border-radius: 999px;
  color: #76500d;
  font-size: 0.75rem;
  min-height: 28px;
  padding: 5px 9px;
}

.editor-metrics strong {
  color: #4d350d;
}

.editor-console-body {
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 610px;
}

.editor-inbox {
  border-right: 1px solid var(--line);
  min-width: 0;
  padding: 12px;
}

.editor-filters {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 115px;
  margin-bottom: 10px;
}

.search-field {
  position: relative;
}

.search-field svg {
  color: var(--muted);
  height: 16px;
  left: 10px;
  pointer-events: none;
  position: absolute;
  top: 12px;
  width: 16px;
}

.search-field input {
  padding-left: 33px;
}

.editor-submission-list {
  display: grid;
  gap: 7px;
  max-height: 540px;
  overflow-y: auto;
  padding-right: 2px;
}

.editor-submission-row {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 9px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  min-height: 58px;
  padding: 8px;
  text-align: left;
  width: 100%;
  box-shadow: 0 1px 0 rgba(20, 32, 51, 0.03);
}

.editor-submission-row:hover,
.editor-submission-row.is-selected {
  background: #fffbef;
  border-color: #d6b756;
}

.submission-type {
  align-items: center;
  background: #fff4c7;
  border-radius: 7px;
  color: #68460b;
  display: inline-flex;
  font-size: 0.66rem;
  font-weight: 850;
  height: 36px;
  justify-content: center;
  width: 38px;
}

.submission-summary {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.submission-summary strong,
.submission-summary small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.submission-summary strong {
  font-size: 0.8rem;
}

.submission-summary small {
  color: var(--muted);
  font-size: 0.68rem;
}

.submission-score {
  color: #76500d;
  font-size: 0.76rem;
  font-weight: 850;
}

.editor-inspector {
  min-width: 0;
  padding: 16px;
}

.editor-empty {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  min-height: 560px;
  text-align: center;
}

.editor-empty svg {
  color: #b7791f;
  height: 42px;
  width: 42px;
}

.editor-empty strong {
  color: var(--ink);
}

.editor-empty span {
  font-size: 0.84rem;
}

.editor-form {
  display: grid;
  gap: 11px;
}

.editor-inspector-head {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.editor-score-block {
  text-align: right;
}

.editor-score-block strong,
.editor-score-block span {
  display: block;
}

.editor-score-block strong {
  color: #76500d;
  font-size: 1.1rem;
}

.editor-score-block span,
.editor-status {
  color: var(--muted);
  font-size: 0.72rem;
}

.editor-field-grid {
  display: grid;
  gap: 9px;
  grid-template-columns: 1fr 1fr;
}

.editor-field,
.editor-field-grid label {
  display: block;
}

.editor-field > span,
.editor-field-grid label > span {
  color: var(--muted);
  display: block;
  font-size: 0.75rem;
  font-weight: 750;
  margin-bottom: 5px;
}

.editor-prompt {
  min-height: 68px;
  padding: 9px 10px;
}

.editor-record-text {
  min-height: 290px;
  padding: 12px;
}

.editor-original-row {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  padding: 9px 10px;
}

.editor-original-row > svg {
  color: #b7791f;
  height: 24px;
  width: 24px;
}

.editor-original-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.editor-original-row strong,
.editor-original-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-original-row strong {
  font-size: 0.8rem;
}

.editor-original-row span {
  color: var(--muted);
  font-size: 0.7rem;
}

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

.editor-form-actions .primary-action,
.editor-form-actions .secondary-action {
  min-width: 0;
}

.editor-status {
  margin: 0;
}

.editor-badge {
  align-items: center;
  background: #fff3d6;
  border: 1px solid #d9a72a;
  border-radius: 999px;
  color: #6f4300;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  gap: 6px;
  min-height: 32px;
  padding: 5px 9px;
}

.editor-badge svg {
  height: 15px;
  width: 15px;
}

.usage-badge {
  align-items: center;
  background: #eef8f5;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 999px;
  color: var(--accent-deep);
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  gap: 6px;
  min-height: 32px;
  padding: 5px 9px;
}

.usage-badge svg {
  height: 15px;
  width: 15px;
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: 316px minmax(430px, 1fr) 410px;
  margin: 0 auto;
  max-width: 1560px;
}

.setup-panel,
.draft-panel,
.results-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(217, 225, 236, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  min-width: 0;
  overflow: hidden;
}

.setup-panel,
.results-panel {
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 18px;
}

.setup-panel,
.results-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.results-panel:focus {
  outline: 3px solid rgba(20, 122, 108, 0.34);
  outline-offset: 3px;
}

.draft-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px;
}

.panel-section {
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.setup-panel .panel-section,
.results-panel .panel-section,
.results-panel .score-section {
  border: 1px solid rgba(217, 225, 236, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.setup-panel .panel-section,
.results-panel .panel-section {
  background: rgba(255, 255, 255, 0.96);
}

.account-section {
  background: linear-gradient(180deg, #f4fbf9, #ffffff);
  position: relative;
}

.account-section.is-premium {
  background: linear-gradient(135deg, #f5f9ff 0%, #ffffff 48%, #eef7ff 100%);
  border-color: rgba(29, 78, 216, 0.28);
  box-shadow: 0 18px 38px rgba(29, 78, 216, 0.1);
}

.account-section.is-premium::before {
  background: linear-gradient(90deg, #1d4ed8, #38bdf8, #64748b);
  content: "";
  height: 4px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.account-section.is-premium .section-heading {
  padding-top: 2px;
}

.account-section.is-premium .small-metric {
  background: #eff6ff;
  border-color: rgba(29, 78, 216, 0.24);
  color: #1d4ed8;
}

.account-profile {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 44px 1fr;
  margin-bottom: 10px;
  min-width: 0;
}

.account-avatar {
  align-items: center;
  background: linear-gradient(135deg, #e7f0ff, #fff4d8);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 10px;
  color: var(--accent);
  display: inline-flex;
  height: 44px;
  justify-content: center;
  position: relative;
  width: 44px;
}

.account-section.is-premium .account-avatar {
  background: linear-gradient(135deg, #dbeafe, #f8fafc);
  border-color: rgba(29, 78, 216, 0.24);
  box-shadow: 0 10px 20px rgba(29, 78, 216, 0.14);
  color: #1d4ed8;
}

.account-avatar svg {
  height: 21px;
  width: 21px;
}

.account-profile strong,
.account-profile span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.account-profile strong {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.2;
}

.account-profile span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 2px;
}

.account-plan-badge {
  margin: 0 0 10px;
  width: 100%;
}

.account-plan-badge.is-premium {
  background: #eff6ff;
  border-color: rgba(29, 78, 216, 0.24);
  color: #1d4ed8;
  justify-content: center;
}

body.has-premium-account #accountToggleBtn {
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
  border-color: rgba(29, 78, 216, 0.34);
  color: #1d4ed8;
}

body.has-premium-account .topbar #accountToggleBtn {
  color: #1d4ed8;
}

body.has-premium-account #accountToggleBtn svg {
  color: #2563eb;
}

.plan-comparison {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin: 0 0 10px;
}

.plan-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
}

.plan-card span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.plan-card strong {
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.2;
}

.plan-card small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.plan-card.is-current {
  border-color: rgba(37, 99, 235, 0.34);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.06);
}

.plan-card-premium {
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
  border-color: rgba(29, 78, 216, 0.22);
}

.plan-card-premium span {
  color: #1d4ed8;
}

.plan-card-premium.is-current {
  border-color: rgba(29, 78, 216, 0.4);
  box-shadow: 0 10px 20px rgba(29, 78, 216, 0.1), inset 0 0 0 1px rgba(56, 189, 248, 0.14);
}

.coach-plan-hint {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.42;
  margin: 0 0 10px;
}

.account-copy {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0 0 10px;
}

.account-signin-fields {
  margin-top: 8px;
}

.account-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.account-actions .primary-action,
.account-actions .secondary-action {
  min-width: 0;
  width: 100%;
}

.subject-section {
  background: linear-gradient(180deg, var(--surface-tint), #ffffff);
}

.panel-section:last-child {
  border-bottom: 0;
}

.setup-panel .panel-section:last-child,
.results-panel .panel-section:last-child {
  border-bottom: 1px solid rgba(217, 225, 236, 0.95);
}

.panel-section.compact {
  padding: 13px 14px;
}

.section-heading,
.score-head {
  align-items: center;
  display: flex;
  font-size: 0.76rem;
  font-weight: 850;
  justify-content: space-between;
  letter-spacing: 0;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.status-dot,
.small-metric,
.confidence-pill {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 700;
  min-height: 24px;
  padding: 3px 8px;
  text-transform: none;
  white-space: nowrap;
}

.status-dot.is-dirty {
  background: #fff7ed;
  border-color: #fed7aa;
  color: var(--amber);
}

.segmented {
  background: #eef3f7;
  border: 1px solid #dce5ef;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
}

.segment,
.tool-button,
.icon-button,
.primary-action,
.secondary-action,
.mode-action,
.coach-chips button {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  font-weight: 750;
  gap: 8px;
  justify-content: center;
  letter-spacing: 0;
  min-height: 40px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.segment {
  background: transparent;
  border-color: transparent;
  color: var(--ink);
  min-width: 0;
  min-height: 38px;
  padding: 7px 9px;
  --segment-color: var(--accent);
}

.segment svg {
  color: var(--segment-color);
}

.segment span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment.is-active {
  background: var(--segment-color);
  border-color: var(--segment-color);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.segment.is-active svg {
  color: #ffffff;
}

.segment:hover,
.tool-button:hover,
.icon-button:hover,
.secondary-action:hover,
.mode-action:hover,
.coach-chips button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.tool-button,
.icon-button {
  background: var(--surface);
  color: var(--ink);
}

.tool-button {
  padding: 8px 12px;
}

.icon-button {
  aspect-ratio: 1;
  padding: 0;
  width: 40px;
}

.segment svg,
.tool-button svg,
.icon-button svg,
.primary-action svg,
.secondary-action svg,
.mode-action svg {
  flex: 0 0 18px;
  height: 18px;
  width: 18px;
}

.field-label {
  color: var(--muted);
  display: block;
  font-size: 0.8rem;
  font-weight: 750;
  margin: 12px 0 6px;
}

.field-label span {
  color: #929bad;
  font-weight: 600;
}

.field-label:first-child {
  margin-top: 0;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  width: 100%;
  box-shadow: inset 0 1px 0 rgba(20, 32, 51, 0.02);
}

input,
select {
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  line-height: 1.5;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input:read-only,
textarea:read-only,
select:disabled {
  background: #f8fafc;
  color: #475569;
}

.prompt-box {
  min-height: 86px;
  padding: 10px;
}

.dropzone {
  align-items: center;
  background:
    linear-gradient(180deg, #ffffff, #f7fbfa);
  border: 1px dashed color-mix(in srgb, var(--accent) 34%, var(--line-strong));
  border-radius: 8px;
  color: var(--accent-deep);
  display: flex;
  gap: 12px;
  min-height: 92px;
  padding: 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.dropzone:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.dropzone.is-disabled {
  background: #f2f5f8;
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.78;
}

.dropzone.is-disabled .upload-icon {
  background: #e6ebf1;
  color: var(--muted);
}

.dropzone.is-disabled:hover {
  background: #f2f5f8;
  border-color: var(--line);
  color: var(--muted);
}

.upload-icon {
  align-items: center;
  background: #dff3ef;
  border-radius: 8px;
  color: var(--accent-deep);
  display: inline-flex;
  flex: 0 0 44px;
  height: 44px;
  justify-content: center;
}

.upload-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.upload-copy strong {
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.25;
}

.upload-copy small {
  color: var(--muted);
  font-size: 0.73rem;
}

.paste-action {
  align-items: center;
  background: #ffffff;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 8px;
  color: var(--accent-deep);
  display: grid;
  font-weight: 750;
  gap: 8px;
  grid-template-columns: 20px 1fr 18px;
  min-height: 48px;
  padding: 9px 11px;
  text-align: left;
  width: 100%;
  box-shadow: var(--shadow-tight);
}

.paste-action:hover {
  border-color: var(--accent);
}

.paste-action svg {
  height: 18px;
  width: 18px;
}

.source-divider {
  align-items: center;
  color: #929bad;
  display: flex;
  font-size: 0.72rem;
  gap: 8px;
  margin: 9px 0;
  text-transform: uppercase;
}

.source-divider::before,
.source-divider::after {
  background: var(--line);
  content: "";
  flex: 1;
  height: 1px;
}

.dropzone.is-dragging {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.draft-toolbar {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 4px 4px 14px;
}

.draft-toolbar h2 {
  font-size: 1.3rem;
}

.draft-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.draft-stats span {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  min-height: 28px;
  padding: 5px 9px;
}

.draft-stats strong {
  color: var(--ink);
}

.auth-notice {
  align-items: center;
  background: #fff7e8;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #7a3d08;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 0 12px;
  padding: 12px;
}

.auth-notice strong,
.auth-notice span {
  display: block;
}

.auth-notice strong {
  color: #7a3d08;
  font-size: 0.9rem;
}

.auth-notice span {
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: 2px;
}

.auth-notice .secondary-action {
  background: #ffffff;
  border-color: #fed7aa;
  color: #7a3d08;
  flex: 0 0 auto;
  min-width: 112px;
}

.draft-input {
  flex: 1;
  min-height: clamp(280px, 38vh, 430px);
  overflow: auto;
  padding: 20px;
  resize: vertical;
  background: #ffffff;
  border-color: #cfd7e3;
  box-shadow: inset 0 1px 2px rgba(20, 32, 51, 0.04);
}

.paste-surface {
  display: flex;
  flex: 1;
  min-height: clamp(280px, 38vh, 430px);
}

.document-surface {
  background: #f7fafc;
  border: 1px solid #ccd8e5;
  border-radius: 8px;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: clamp(320px, 42vh, 470px);
  overflow: hidden;
}

.document-bar {
  align-items: center;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 44px minmax(0, 1fr) auto 40px;
  min-height: 64px;
  padding: 10px;
}

.document-type {
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: 7px;
  color: var(--accent-deep);
  display: inline-flex;
  font-size: 0.68rem;
  font-weight: 850;
  height: 40px;
  justify-content: center;
  width: 44px;
}

.document-identity {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.document-identity strong,
.document-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-identity strong {
  font-size: 0.88rem;
}

.document-identity small {
  color: var(--muted);
  font-size: 0.73rem;
}

.document-preview {
  background: #ffffff;
  border: 0;
  flex: 1;
  min-height: clamp(240px, 34vh, 390px);
  width: 100%;
}

.document-placeholder {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  min-height: clamp(240px, 34vh, 390px);
  padding: 24px;
  text-align: center;
}

.document-placeholder svg {
  color: var(--accent);
  height: 44px;
  width: 44px;
}

.document-placeholder strong {
  color: var(--ink);
}

.document-placeholder span {
  font-size: 0.84rem;
}

.action-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 14px;
}

.primary-action {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  min-width: 150px;
  padding: 10px 16px;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.16);
}

.primary-action:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}

.secondary-action {
  background: #fff;
  color: var(--ink);
  min-width: 140px;
  padding: 10px 14px;
  box-shadow: 0 1px 0 rgba(20, 32, 51, 0.04);
}

.mode-action {
  background: #ffffff;
  color: var(--ink);
  min-width: 138px;
  padding: 10px 14px;
  box-shadow: 0 1px 0 rgba(20, 32, 51, 0.04);
}

.mode-action.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

.mode-action[data-review-mode="ai"].is-active {
  background: #4f46e5;
  border-color: #4f46e5;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.18);
}

.mode-action[data-review-mode="integrity"].is-active {
  background: #b45309;
  border-color: #b45309;
  box-shadow: 0 10px 20px rgba(180, 83, 9, 0.2);
}

.score-section {
  background: linear-gradient(180deg, var(--navy), #23304a);
  border-bottom: 1px solid #2f3d59;
  color: #ffffff;
  padding: 16px;
}

.score-display {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 128px 1fr;
}

.score-ring {
  display: grid;
  height: 124px;
  place-items: center;
  position: relative;
  width: 124px;
}

.score-gauge {
  height: 124px;
  inset: 0;
  position: absolute;
  transform: rotate(-90deg);
  width: 124px;
}

.score-gauge-track,
.score-gauge-value {
  fill: none;
  stroke-linecap: round;
  stroke-width: 18;
}

.score-gauge-track {
  stroke: rgba(255, 255, 255, 0.16);
}

.score-gauge-value {
  stroke: var(--accent);
  stroke-dasharray: var(--score) 100;
  stroke-dashoffset: 0;
  transition: stroke-dasharray 760ms cubic-bezier(0.22, 1, 0.36, 1);
}

.score-ring.is-ai .score-gauge-value {
  stroke: #7c3aed;
}

.score-ring.is-risk .score-gauge-value {
  stroke: #f59e0b;
}

.score-ring span,
.score-ring small {
  align-self: center;
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.score-ring span {
  font-size: 1.8rem;
  font-weight: 850;
  transform: translateY(-9px);
}

.score-ring small {
  color: #b9c9dd;
  font-weight: 700;
  transform: translateY(17px);
}

.band-block {
  min-width: 0;
}

.band-block span {
  color: #9fb2cc;
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.band-block strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1.2;
  margin: 3px 0;
}

.band-block small {
  color: #b9c9dd;
  display: block;
  line-height: 1.35;
}

.score-section .score-head span:first-child {
  color: #dce9f7;
}

.score-section .confidence-pill {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #dce9f7;
}

.criteria-list,
.feedback-list,
.chat-log {
  display: grid;
  gap: 9px;
}

.criterion-row {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  box-shadow: 0 1px 0 rgba(20, 32, 51, 0.03);
}

.criterion-top {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.criterion-name {
  font-weight: 800;
  min-width: 0;
}

.criterion-score {
  color: var(--accent-deep);
  flex: 0 0 auto;
  font-weight: 850;
}

.bar-track {
  background: #e8eef5;
  border-radius: 999px;
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
}

.bar-track span {
  background: var(--accent);
  border-radius: inherit;
  display: block;
  height: 100%;
  width: var(--width);
}

.criterion-row p,
.feedback-item p {
  color: var(--muted);
  line-height: 1.45;
  margin: 8px 0 0;
}

.criterion-evidence,
.feedback-reference {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #475569;
  font-size: 0.76rem;
  line-height: 1.4;
  margin-top: 9px;
  padding: 8px 9px;
}

.criterion-evidence {
  display: grid;
  gap: 4px;
  grid-template-columns: 34px minmax(0, 1fr);
}

.criterion-evidence strong {
  color: var(--accent-deep);
  font-size: 0.72rem;
}

.criterion-evidence span {
  min-width: 0;
}

.feedback-item {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 11px;
  box-shadow: 0 1px 0 rgba(20, 32, 51, 0.03);
}

.feedback-item.warning {
  border-color: var(--amber);
}

.feedback-item.risk {
  border-color: var(--rose);
}

.feedback-item strong {
  display: block;
  font-size: 0.9rem;
}

.empty-state {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 12px;
}

.calibration-grid {
  display: grid;
  gap: 9px;
  grid-template-columns: 1fr 1fr;
}

.calibration-grid label span,
.calibration-prompt > span {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
  font-weight: 750;
  margin-bottom: 5px;
}

.calibration-section {
  background: #fffdf7;
  border-left: 3px solid #d9a72a;
}

.calibration-prompt {
  display: block;
  margin-top: 9px;
}

.calibration-prompt small {
  font-weight: 600;
}

.calibration-upload {
  align-items: center;
  background: #ffffff;
  border: 1px dashed #c49a32;
  border-radius: 8px;
  color: #6f4300;
  display: flex;
  font-size: 0.82rem;
  font-weight: 750;
  gap: 8px;
  margin-top: 10px;
  min-height: 43px;
  padding: 9px 10px;
}

.calibration-upload:hover {
  background: #fff7df;
}

.calibration-upload svg {
  flex: 0 0 18px;
  height: 18px;
  width: 18px;
}

.calibration-upload span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calibration-add {
  margin-top: 9px;
  width: 100%;
}

.calibration-status {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 8px 0 10px;
}

.calibration-list {
  display: grid;
  gap: 7px;
}

.calibration-record {
  align-items: center;
  background: #ffffff;
  border: 1px solid #ead9a9;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 32px;
  padding: 8px;
}

.calibration-record > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.calibration-record strong,
.calibration-record small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calibration-record strong {
  font-size: 0.8rem;
}

.calibration-record small {
  color: var(--muted);
  font-size: 0.68rem;
}

.calibration-record .icon-button {
  min-height: 32px;
  width: 32px;
}

.calibration-actions {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.calibration-actions .secondary-action {
  min-height: 36px;
  min-width: 0;
  padding: 7px 9px;
}

.danger-action {
  color: var(--rose);
}

.coach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.coach-chips button {
  background: #fff;
  color: var(--ink);
  font-size: 0.78rem;
  min-height: 32px;
  padding: 6px 9px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(480px, calc(100vh - 240px));
  overflow: auto;
  padding-right: 2px;
}

.chat-row {
  align-items: flex-end;
  display: flex;
  gap: 8px;
}

.chat-row.user {
  justify-content: flex-end;
}

.chat-row.user .chat-avatar {
  order: 2;
}

.chat-avatar {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 30px;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.chat-avatar svg {
  height: 16px;
  width: 16px;
}

.coach-avatar {
  background: #111827;
  border-color: #26344f;
  color: #dbeafe;
}

.user-avatar {
  background: #eef2ff;
  border-color: #d9e0ff;
  color: #3646a3;
}

.chat-message {
  border-radius: 14px;
  line-height: 1.45;
  max-width: min(76%, 520px);
  padding: 10px 11px;
  white-space: pre-wrap;
}

.chat-message.assistant {
  background: #f8fbff;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  border-bottom-left-radius: 5px;
}

.chat-message.user {
  background: #122033;
  border: 1px solid #122033;
  border-bottom-right-radius: 5px;
  color: #ffffff;
}

.chat-form {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 40px;
  margin-top: 10px;
}

.chat-form input {
  min-width: 0;
}

.site-footer {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.78rem;
  gap: 10px;
  justify-content: space-between;
  line-height: 1.4;
  margin: 18px auto 0;
  max-width: 1560px;
  padding: 0 4px 4px;
}

.footer-identity {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.footer-identity span {
  color: var(--ink);
  font-weight: 800;
}

.footer-identity nav {
  display: flex;
  gap: 12px;
}

.footer-identity a,
.legal-back {
  color: var(--accent-deep);
  font-weight: 800;
  text-decoration: none;
}

.footer-identity a:hover,
.legal-back:hover {
  text-decoration: underline;
}

.feedback-dialog {
  background: transparent;
  border: 0;
  max-width: min(560px, calc(100vw - 28px));
  padding: 0;
  width: 100%;
}

.feedback-dialog::backdrop {
  background: rgba(13, 21, 34, 0.46);
  backdrop-filter: blur(6px);
}

.feedback-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  padding: 16px;
}

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

.feedback-head h2 {
  font-size: 1.18rem;
  margin: 2px 0 0;
}

.feedback-copy,
.feedback-status {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  margin: 0;
}

.feedback-form label {
  color: var(--ink);
  display: grid;
  font-size: 0.82rem;
  font-weight: 750;
  gap: 6px;
}

.feedback-form small {
  color: var(--muted);
  font-weight: 650;
}

.feedback-form textarea {
  min-height: 128px;
  resize: vertical;
}

#feedbackWebsite {
  display: none;
}

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

.legal-shell {
  margin: 0 auto;
  max-width: 900px;
  padding: 32px 18px 56px;
}

.legal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  margin-top: 18px;
  padding: 28px;
}

.legal-kicker {
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.legal-card h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
  margin: 0 0 12px;
}

.legal-card h2 {
  font-size: 1.05rem;
  margin: 24px 0 8px;
}

.legal-card p {
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 12px;
}

body[data-theme="dark"] .draft-panel,
body[data-theme="dark"] .editor-console,
body[data-theme="dark"] .legal-card {
  background: rgba(17, 28, 45, 0.96);
  border-color: rgba(42, 57, 80, 0.95);
}

body[data-theme="dark"] .setup-panel,
body[data-theme="dark"] .results-panel {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

body[data-theme="dark"] .setup-panel .panel-section,
body[data-theme="dark"] .results-panel .panel-section {
  background: rgba(17, 28, 45, 0.96);
  border-color: rgba(42, 57, 80, 0.95);
}

body[data-theme="dark"] .setup-panel .panel-section:last-child,
body[data-theme="dark"] .results-panel .panel-section:last-child {
  border-bottom-color: rgba(42, 57, 80, 0.95);
}

body[data-theme="dark"] .topbar {
  background: linear-gradient(135deg, #0b1120, #172033 62%, #253149);
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .editor-console-head,
body[data-theme="dark"] .account-section,
body[data-theme="dark"] .subject-section,
body[data-theme="dark"] .document-bar {
  background: linear-gradient(180deg, #162235, #111c2d);
}

body[data-theme="dark"] .editor-console {
  border-color: #5e4a1d;
}

body[data-theme="dark"] .editor-metrics span,
body[data-theme="dark"] .editor-badge,
body[data-theme="dark"] .calibration-section {
  background: #211b10;
  border-color: #6b5521;
  color: #f6d783;
}

body[data-theme="dark"] .editor-metrics strong,
body[data-theme="dark"] .editor-score-block strong,
body[data-theme="dark"] .submission-score {
  color: #f8d787;
}

body[data-theme="dark"] .account-avatar {
  background: linear-gradient(135deg, #172235, #2d2412);
  border-color: rgba(165, 180, 252, 0.22);
  color: #a5b4fc;
}

body[data-theme="dark"] .account-section.is-premium {
  background: linear-gradient(135deg, #0f1f3d 0%, #111827 50%, #0f2836 100%);
  border-color: rgba(96, 165, 250, 0.32);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.32);
}

body[data-theme="dark"] .account-section.is-premium .small-metric {
  background: #10233f;
  border-color: rgba(96, 165, 250, 0.32);
  color: #bfdbfe;
}

body[data-theme="dark"] .account-section.is-premium .account-avatar {
  background: linear-gradient(135deg, #10233f, #1e3a5f);
  border-color: rgba(96, 165, 250, 0.34);
  color: #bfdbfe;
}

body[data-theme="dark"] .plan-card {
  background: #111827;
  border-color: rgba(42, 57, 80, 0.95);
}

body[data-theme="dark"] .plan-card-premium {
  background: linear-gradient(135deg, #10233f, #111827);
  border-color: rgba(96, 165, 250, 0.28);
}

body[data-theme="dark"] .plan-card-premium span {
  color: #bfdbfe;
}

body[data-theme="dark"] .plan-card-premium.is-current {
  border-color: rgba(96, 165, 250, 0.48);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(56, 189, 248, 0.14);
}

body[data-theme="dark"] .segmented,
body[data-theme="dark"] .empty-state,
body[data-theme="dark"] .editor-original-row,
body[data-theme="dark"] .document-surface,
body[data-theme="dark"] .criterion-evidence,
body[data-theme="dark"] .feedback-reference {
  background: var(--surface-alt);
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .editor-submission-row,
body[data-theme="dark"] .criterion-row,
body[data-theme="dark"] .feedback-item,
body[data-theme="dark"] .draft-stats span,
body[data-theme="dark"] .status-dot,
body[data-theme="dark"] .small-metric,
body[data-theme="dark"] .confidence-pill,
body[data-theme="dark"] .tool-button,
body[data-theme="dark"] .icon-button,
body[data-theme="dark"] .secondary-action,
body[data-theme="dark"] .mode-action,
body[data-theme="dark"] .paste-action,
body[data-theme="dark"] .coach-chips button,
body[data-theme="dark"] .calibration-record,
body[data-theme="dark"] .calibration-upload {
  background: #111827;
  border-color: var(--line);
  color: var(--ink);
}

body[data-theme="dark"] input:read-only,
body[data-theme="dark"] textarea:read-only,
body[data-theme="dark"] select:disabled {
  background: #172235;
  color: #b6c4d8;
}

body[data-theme="dark"] .mode-action.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #08111f;
}

body[data-theme="dark"] .mode-action[data-review-mode="ai"].is-active {
  background: #a5b4fc;
  border-color: #a5b4fc;
}

body[data-theme="dark"] .mode-action[data-review-mode="integrity"].is-active {
  background: #fbbf24;
  border-color: #fbbf24;
}

body[data-theme="dark"] .auth-notice {
  background: #2b1f10;
  border-color: #7c4a14;
  color: #f8d787;
}

body[data-theme="dark"] .auth-notice strong,
body[data-theme="dark"] .auth-notice .secondary-action {
  color: #f8d787;
}

body[data-theme="dark"] .auth-notice .secondary-action {
  background: #111827;
  border-color: #7c4a14;
}

body[data-theme="dark"] .dropzone {
  background: linear-gradient(180deg, #122335, #172554);
  box-shadow: none;
}

body[data-theme="dark"] .dropzone:hover,
body[data-theme="dark"] .dropzone.is-dragging {
  background: var(--accent-soft);
}

body[data-theme="dark"] .dropzone.is-disabled,
body[data-theme="dark"] .dropzone.is-disabled:hover {
  background: #172235;
  border-color: var(--line);
  color: var(--muted);
}

body[data-theme="dark"] .dropzone.is-disabled .upload-icon {
  background: #202c40;
  color: var(--muted);
}

body[data-theme="dark"] .upload-icon,
body[data-theme="dark"] .usage-badge,
body[data-theme="dark"] .chat-message.assistant {
  background: #172554;
  border-color: #28427c;
  color: #dbeafe;
}

body[data-theme="dark"] .account-plan-badge.is-premium,
body[data-theme="dark"].has-premium-account #accountToggleBtn {
  background: linear-gradient(135deg, #10233f, #111827);
  border-color: rgba(96, 165, 250, 0.5);
  color: #bfdbfe;
}

body[data-theme="dark"].has-premium-account #accountToggleBtn svg {
  color: #93c5fd;
}

body[data-theme="dark"] .chat-message.user {
  background: #e8edff;
  border-color: #e8edff;
  color: #111827;
}

body[data-theme="dark"] .user-avatar {
  background: #1a2440;
  border-color: #33446b;
  color: #e8edff;
}

.chat-message.is-thinking {
  color: var(--muted);
  font-style: italic;
}

.typing-dots {
  align-items: center;
  display: inline-flex;
  gap: 4px;
  min-height: 20px;
}

.typing-dots span {
  animation: typingPulse 1s infinite ease-in-out;
  background: currentColor;
  border-radius: 999px;
  display: block;
  height: 6px;
  opacity: 0.45;
  width: 6px;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes typingPulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-3px);
    opacity: 0.9;
  }
}

body[data-theme="dark"] .document-preview {
  background: #ffffff;
}

body[data-theme="dark"] .editor-submission-row:hover,
body[data-theme="dark"] .editor-submission-row.is-selected {
  background: #211b10;
  border-color: #8b6f2b;
}

body[data-theme="dark"] .submission-type {
  background: #3b2d12;
  color: #f8d787;
}

body[data-theme="dark"] .score-section {
  background: linear-gradient(180deg, #0b1320, #102035);
  border-color: #20324d;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1240px) {
  .editor-console-body {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .workspace {
    grid-template-columns: 280px minmax(360px, 1fr);
  }

  .setup-panel {
    position: static;
  }

  .results-panel {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .draft-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 12px;
    min-height: 0;
    padding: 14px;
  }

  .brand {
    gap: 11px;
  }

  .brand-mark {
    flex-basis: 44px;
    height: 44px;
    width: 44px;
  }

  .brand-stroke-one {
    height: 17px;
  }

  .brand-stroke-two {
    height: 25px;
  }

  .brand-stroke-three {
    height: 33px;
  }

  .brand h1 {
    font-size: 1.24rem;
  }

  .topbar .brand p {
    font-size: 0.88rem;
  }

  .top-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .top-action-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
  }

  .topbar .tool-button,
  .topbar .icon-button {
    min-width: 0;
    width: 100%;
  }

  .editor-console-head {
    align-items: start;
    grid-template-columns: 1fr 40px;
  }

  .editor-metrics {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .editor-console-body {
    grid-template-columns: 1fr;
  }

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

  .editor-submission-list {
    max-height: 280px;
  }

  .editor-empty {
    min-height: 300px;
  }

  .top-actions,
  .draft-stats {
    justify-content: flex-start;
  }

  .workspace,
  .results-panel {
    grid-template-columns: 1fr;
  }

  .setup-panel,
  .results-panel {
    position: static;
  }

  .draft-panel {
    min-height: auto;
  }

  .draft-input {
    min-height: clamp(220px, 42vh, 340px);
  }

  .paste-surface,
  .document-surface {
    min-height: clamp(220px, 42vh, 360px);
  }

  .document-preview,
  .document-placeholder {
    min-height: clamp(180px, 32vh, 300px);
  }

  .calibration-grid,
  .score-display {
    grid-template-columns: 1fr;
  }

  .score-ring {
    height: 116px;
    width: 116px;
  }

  .score-gauge {
    height: 116px;
    width: 116px;
  }
}

@media (max-width: 520px) {
  .segmented {
    grid-template-columns: 1fr;
  }

  .plan-comparison {
    grid-template-columns: 1fr;
  }

  .auth-notice {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-filters,
  .editor-field-grid {
    grid-template-columns: 1fr;
  }

  .editor-inspector-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-score-block {
    text-align: left;
  }

  .editor-original-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .editor-original-row .secondary-action {
    grid-column: 1 / -1;
  }

  .tool-button span,
  .primary-action span,
  .secondary-action span,
  .mode-action span {
    white-space: normal;
  }

  .primary-action,
  .secondary-action,
  .mode-action {
    justify-content: center;
    width: 100%;
  }

  .document-bar {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .document-bar .tool-button {
    display: none;
  }

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