:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --surface: #f8faf9;
  --surface-strong: #eef3f1;
  --ink: #18211d;
  --muted: #66736e;
  --line: #d9e1dd;
  --line-strong: #bdcbc5;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e6f4f1;
  --blue: #1d4ed8;
  --blue-strong: #1e40af;
  --violet: #6d28d9;
  --violet-strong: #5b21b6;
  --danger: #b42318;
  --warn: #b54708;
  --low: #276749;
  --shadow: 0 16px 40px rgba(24, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.hidden {
  display: none !important;
}

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

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.app-title,
.header-actions,
.brand,
.result-head,
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title {
  min-width: 0;
}

.app-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid #b8ddd6;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.header-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

h2 {
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  line-height: 1.35;
}

.app-title p,
.pane-head p,
.result-head p,
.notice,
.upload-box small,
.issue-meta,
.issue-detail {
  color: var(--muted);
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.offline {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid #b8ddd6;
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.session-user {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  max-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--surface);
  color: var(--muted);
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-body {
  min-height: 100vh;
  background: #edf2f0;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(320px, 1.18fr);
  min-height: 100vh;
}

.login-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 42px;
  background: #143d37;
  color: #fff;
}

.login-brand .app-mark {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.login-brand p {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.72);
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card {
  display: grid;
  width: min(100%, 420px);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card-head {
  display: grid;
  gap: 2px;
}

.login-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.login-field input:focus {
  border-color: var(--accent);
}

.login-card .primary-action {
  width: 100%;
}

.login-status {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(560px, 1.45fr);
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
}

.input-pane,
.result-pane {
  min-height: calc(100vh - 128px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.input-pane {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.result-pane {
  padding: 18px;
  overflow: auto;
}

.pane-head,
.result-head {
  justify-content: space-between;
  gap: 14px;
}

.upload-box {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-box:hover {
  border-color: var(--accent);
  background: #fbfdfc;
}

.upload-box input {
  display: none;
}

.upload-symbol {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #b8ddd6;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

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

.upload-copy > span {
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-cta {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.stance-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.stance-selector legend {
  grid-column: 1 / -1;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stance-selector label {
  min-width: 0;
}

.stance-selector input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.stance-selector span {
  display: block;
  min-height: 40px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.stance-selector input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.18);
}

.actions {
  margin: 0 0 14px;
  justify-content: flex-start;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

button[data-icon]::before {
  content: attr(data-icon);
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  font-size: 15px;
  line-height: 1;
}

button:hover {
  background: var(--accent-strong);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.16);
  outline-offset: 2px;
}

button.compact {
  min-width: 36px;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 14px;
}

button.primary-action {
  min-width: 154px;
  background: var(--accent);
}

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

button.secondary:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

button.docx-export {
  background: var(--blue);
  color: #fff;
}

button.docx-export:hover {
  background: var(--blue-strong);
}

button.review-export {
  background: var(--violet);
  color: #fff;
}

button.review-export:hover {
  background: var(--violet-strong);
}

button.save-project {
  background: var(--accent);
  color: #fff;
}

button.save-project:hover {
  background: var(--accent-strong);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.preview-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  align-items: end;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.preview-meta {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.preview-meta span:first-child {
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-controls {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  background: #fff;
}

.search-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.search-field input {
  width: 112px;
  min-height: 32px;
  border: 0;
  padding: 0;
  outline: none;
  background: transparent;
}

.preview-count,
#previewZoom {
  min-width: 42px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

textarea {
  flex: 1;
  min-height: 430px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  line-height: 1.7;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.document-preview {
  --preview-zoom: 1;
  display: grid;
  flex: 1;
  align-content: start;
  justify-items: center;
  gap: 18px;
  min-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #e9eeeb;
}

.document-page {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: min(100%, calc(440px * var(--preview-zoom)));
  min-height: calc(622px * var(--preview-zoom));
  border: 1px solid #cbd5d1;
  background: #fff;
  box-shadow: 0 10px 24px rgba(23, 33, 29, 0.12);
  padding: calc(38px * var(--preview-zoom)) calc(34px * var(--preview-zoom)) calc(24px * var(--preview-zoom));
}

.page-content {
  display: grid;
  gap: 10px;
}

.document-page p {
  margin: 0;
  color: #1d2723;
  font-size: calc(14px * var(--preview-zoom));
  line-height: 1.85;
  text-align: justify;
}

.document-page .doc-heading {
  margin-bottom: 8px;
  text-align: center;
  font-size: calc(20px * var(--preview-zoom));
  font-weight: 800;
}

.document-page mark {
  padding: 1px 2px;
  background: #fde68a;
  color: inherit;
}

.document-page mark.current-hit {
  background: #f97316;
  color: #fff;
}

.focused-paragraph {
  outline: 2px solid var(--danger);
  outline-offset: 4px;
  background: #fff1f0;
}

.pdf-preview-shell {
  display: grid;
  gap: 14px;
  width: min(100%, calc(560px * var(--preview-zoom)));
}

.pdf-frame {
  width: 100%;
  height: calc(680px * var(--preview-zoom));
  border: 1px solid #cbd5d1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(23, 33, 29, 0.12);
}

.pdf-text-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pdf-text-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.pdf-text-content {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
}

.pdf-text-content p {
  margin: 0;
  line-height: 1.7;
}

.page-footer {
  margin-top: 28px;
  color: #7a8681;
  font-size: 12px;
  text-align: center;
}

.notice {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.compatibility-notice {
  margin: -2px 0 14px;
  border: 1px solid #f2c08b;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff7ed;
  color: #8a4b12;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.compatibility-notice.is-ok {
  border-color: #b8ddd6;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

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

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 12px;
}

.overview div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.overview strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.1;
}

.overview span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.summary {
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  padding: 14px;
  background: var(--accent-soft);
  line-height: 1.6;
}

.issue-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.issue-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface);
  color: var(--text);
  min-height: 42px;
}

.issue-filter:hover,
.issue-filter.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.issue-filter span,
.issue-filter strong {
  display: block;
}

.issue-filter strong {
  border-radius: 999px;
  min-width: 26px;
  padding: 2px 7px;
  background: #fff;
  text-align: center;
}

.issue-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
}

.issue-pagination + .issues {
  margin-top: 12px;
}

.issues + .issue-pagination {
  margin-top: 12px;
}

.issue-page-info {
  display: grid;
  gap: 3px;
  min-width: 170px;
}

.issue-page-info strong {
  font-size: 14px;
}

.issue-page-info span {
  color: var(--muted);
  font-size: 12px;
}

.issue-page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.issue-page-actions .page-number {
  min-width: 34px;
}

.issue-page-actions .page-number.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.issue-page-gap {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-weight: 800;
}

.issues {
  display: grid;
  gap: 18px;
  margin-top: 14px;
}

.empty-issues {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.issue-group {
  display: grid;
  gap: 10px;
}

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

.issue-group-title span {
  font-size: 17px;
  font-weight: 800;
}

.issue-group-title small {
  color: var(--muted);
}

.issue-group-list {
  display: grid;
  gap: 12px;
}

.issue {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.issue-ignored {
  background: var(--surface);
  opacity: 0.72;
}

.issue-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.issue h3 {
  font-size: 18px;
}

.badges {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.action-add {
  color: #075985;
  background: #e0f2fe;
}

.action-edit {
  color: #854d0e;
  background: #fef3c7;
}

.action-delete {
  color: var(--danger);
  background: #fee4e2;
}

.sev-high {
  color: var(--danger);
  background: #fef3f2;
}

.sev-mid {
  color: var(--warn);
  background: #fff4e5;
}

.sev-low {
  color: var(--low);
  background: #edf7ed;
}

.issue-meta {
  margin-top: 6px;
  font-size: 13px;
}

.issue-decision {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.issue-buttons {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.issue-decision button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 13px;
}

.decision-state {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.decision-state.accepted {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.decision-state.ignored {
  color: #4b5563;
  background: #e5e7eb;
}

.issue-detail {
  margin-top: 12px;
  line-height: 1.65;
}

.issue-section {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  line-height: 1.7;
}

.issue-section strong {
  display: block;
  margin-bottom: 6px;
}

.issue-section p {
  margin: 0;
  white-space: pre-wrap;
}

.issue-section.revised {
  border-color: #a7d7cd;
  background: var(--accent-soft);
}

.original-text {
  color: #2c3531;
}

.red-mark {
  border-bottom: 2px solid var(--danger);
  background: #fee4e2;
  color: var(--danger);
  font-weight: 800;
}

.delete-line {
  color: var(--danger);
  text-decoration-line: line-through;
  text-decoration-color: var(--danger);
  text-decoration-thickness: 2px;
}

.sample {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  line-height: 1.65;
  white-space: pre-wrap;
}

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

.excerpt {
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px;
}

.rule-panel,
.project-panel,
.template-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.rule-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: rgba(23, 33, 29, 0.38);
  box-shadow: none;
}

.rule-backdrop:hover {
  background: rgba(23, 33, 29, 0.38);
}

.rule-drawer,
.project-drawer,
.template-drawer {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-left: 1px solid var(--line);
  padding: 18px;
  background: #fff;
  box-shadow: -12px 0 30px rgba(23, 33, 29, 0.16);
}

.rule-drawer {
  width: min(760px, 96vw);
}

.project-drawer {
  width: min(680px, 96vw);
}

.template-drawer {
  width: min(820px, 96vw);
}

.template-drawer .rule-head {
  align-items: flex-start;
  flex-direction: row;
}

.template-drawer .rule-head .compact {
  width: auto;
  flex: 0 0 auto;
}

.rule-head,
.rule-savebar,
.rule-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rule-head p,
.rule-savebar span,
.rule-item p,
.rule-grid span {
  color: var(--muted);
}

.rule-version {
  margin-top: 3px;
  font-size: 12px;
}

.rules-update-notice {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.rules-update-notice.is-warning {
  border-color: #f2c08b;
  background: #fff7ed;
  color: #8a4b12;
}

.rules-update-notice.is-ok {
  border-color: #b8ddd6;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.rule-tools {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 8px;
  margin: 14px 0;
}

.project-tools {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  margin: 14px 0;
}

.template-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 138px 112px 124px;
  gap: 8px;
  margin: 14px 0;
}

.template-tools #templateTypeFilter {
  display: none;
}

.template-panel.is-category-view .template-tools {
  display: none;
}

.rule-tools input,
.rule-tools select,
.project-tools input,
.template-tools input,
.template-tools select,
.rule-grid input,
.rule-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
  outline: none;
}

.rule-grid textarea {
  min-height: 58px;
  resize: vertical;
  line-height: 1.5;
}

.rule-tools input:focus,
.rule-tools select:focus,
.project-tools input:focus,
.template-tools input:focus,
.template-tools select:focus,
.rule-grid input:focus,
.rule-grid textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.rules-list,
.projects-list,
.templates-list {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
}

.rule-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.rule-disabled {
  opacity: 0.7;
  background: #f3f4f6;
}

.rule-item h3 {
  font-size: 17px;
}

.rule-item p {
  margin-top: 4px;
  font-size: 13px;
}

.rule-toggle {
  display: grid;
  flex: 0 0 54px;
  justify-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 800;
}

.rule-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.rule-grid {
  display: grid;
  grid-template-columns: 100px 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.rule-grid label:last-child {
  grid-column: 1 / -1;
}

.rule-grid span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 800;
}

.rule-item details {
  margin-top: 10px;
}

.rule-item summary {
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

.rule-item pre {
  max-height: 180px;
  overflow: auto;
  border-radius: 8px;
  padding: 10px;
  background: #f1f5f3;
  color: #27322e;
  font-size: 12px;
  line-height: 1.5;
}

.rule-savebar {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.project-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.project-item h3 {
  font-size: 17px;
}

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

.project-meta,
.project-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.project-meta {
  margin-top: 10px;
}

.project-meta span {
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--surface-strong);
  color: #33423d;
  font-size: 12px;
  font-weight: 800;
}

.project-actions {
  justify-content: flex-end;
}

.project-actions button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 13px;
}

.template-viewbar {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin: 0 0 12px;
  background: var(--surface);
}

.template-viewbar h3 {
  font-size: 16px;
}

.template-viewbar p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

.template-category-card {
  display: grid;
  width: 100%;
  min-height: 132px;
  align-content: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  white-space: normal;
}

.template-category-card:hover {
  border-color: var(--accent);
  background: #fbfdfc;
}

.template-category-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.template-category-top h3 {
  font-size: 17px;
}

.template-category-top strong {
  min-width: 38px;
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: center;
  font-size: 13px;
}

.template-category-card p,
.template-category-card small {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
}

.template-category-card p {
  -webkit-line-clamp: 1;
}

.template-category-card small {
  -webkit-line-clamp: 2;
}

.template-contract-list {
  gap: 10px;
}

.template-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.template-card:hover {
  border-color: var(--accent);
  background: #fbfdfc;
}

.template-card-main {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.template-card h3 {
  display: -webkit-box;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.template-card p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.template-card .template-brief {
  color: #33423d;
  -webkit-line-clamp: 2;
}

.template-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.template-meta span {
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--surface-strong);
  color: #33423d;
  font-size: 12px;
  font-weight: 800;
}

.template-card-actions {
  display: flex;
  justify-content: flex-end;
}

.template-card-actions button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 13px;
}

.template-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-top: 12px;
  background: var(--surface);
}

.template-page-info {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.template-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-page-actions span {
  min-width: 54px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.empty-projects {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  color: var(--muted);
}

.site-credit {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  max-width: 1440px;
  margin: 8px auto 0;
  color: rgba(100, 113, 108, 0.82);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}

.site-credit a {
  color: #8a5b00;
  font-weight: 800;
  text-decoration: none;
}

.site-credit a:hover {
  color: #6d4600;
  text-decoration: underline;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(320px, 0.95fr) minmax(460px, 1.2fr);
  }

  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

  .export-actions {
    justify-content: flex-start;
  }
}

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

  .login-brand {
    padding: 24px;
  }

  .login-panel {
    align-items: start;
    padding: 18px;
  }

  .app-shell {
    padding: 10px;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 10px;
  }

  .header-actions {
    justify-content: flex-start;
  }

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

  .input-pane,
  .result-pane {
    min-height: auto;
  }

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

  .preview-toolbar,
  .issue-pagination,
  .rule-head,
  .rule-savebar,
  .project-item,
  .issue-decision {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .preview-controls,
  .issue-page-actions,
  .project-actions,
  .issue-buttons {
    justify-content: flex-start;
  }

  .search-field {
    width: 100%;
  }

  .search-field input {
    width: 100%;
  }

  .issue-decision button {
    width: 100%;
  }

  .rule-tools,
  .project-tools,
  .template-tools,
  .rule-grid {
    grid-template-columns: 1fr;
  }

  .rule-grid label:last-child {
    grid-column: auto;
  }

  .project-item {
    grid-template-columns: 1fr;
  }

  .template-category-grid,
  .template-card {
    grid-template-columns: 1fr;
  }

  .template-viewbar,
  .template-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .template-card-actions,
  .template-page-actions {
    justify-content: flex-start;
  }

  .document-page {
    width: 100%;
    min-height: 560px;
    padding: 28px 22px 20px;
  }
}

@media (max-width: 560px) {
  .upload-box {
    grid-template-columns: auto 1fr;
  }

  .upload-cta {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .stance-selector,
  .issue-filters,
  .overview {
    grid-template-columns: 1fr;
  }

  .actions,
  .export-actions {
    width: 100%;
  }

  .actions button,
  .export-actions button {
    width: 100%;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .header-actions button {
    width: 100%;
  }

  .header-actions .offline {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .header-actions .session-user {
    max-width: none;
  }

  .login-card {
    padding: 20px;
  }
}
