:root {
  --bg: #f3f7f3;
  --panel: rgba(255, 255, 252, 0.96);
  --line: #d7e0d7;
  --text: #24332c;
  --muted: #64756c;
  --accent: #2f8a7c;
  --accent-soft: #daf2ec;
  --good: #2b7257;
  --good-soft: #e8f8f1;
  --warn: #b46c29;
  --danger: #bb6158;
  --danger-soft: #fff1ee;
  --danger-line: #efc1bb;
  --success-soft: #e7f7ef;
  --success-line: #a9d9c1;
  --reason-soft: #fff8dd;
  --reason-line: #ecd78e;
  --shadow: 0 18px 40px rgba(47, 77, 63, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 50%, rgba(47, 138, 124, 0.25), transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(14, 165, 233, 0.2), transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(255, 213, 135, 0.25), transparent 50%),
    linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
  background-attachment: fixed;
}

.app {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 100vh;
  flex: 1;
}

.sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-head h1,
.hero h2,
.panel h3 {
  margin: 0;
  font-weight: 700;
}

.sidebar-head p,
.hero p,
.panel-subtitle,
.meta-note {
  margin: 8px 0 0;
  color: #3b4d44;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
}

input[type="search"] {
  width: 100%;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  background: #fffdf9;
  font-size: 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: #ffffff;
}

.upload-form {
  margin-top: 18px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(47, 77, 63, 0.04);
  display: grid;
  gap: 16px;
}

.upload-form-head h2 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.upload-form-head p {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.file-field {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  background: #fffdf9;
  border: 2px dashed #c4d4cc;
  border-radius: 12px;
  transition: all 0.2s ease;
  text-align: center;
  cursor: pointer;
}

.file-field:hover, .file-field.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-field input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-field-icon {
  font-size: 24px;
  opacity: 0.8;
}

.file-field-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  pointer-events: none;
}

.file-field-subtext {
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}

.upload-actions,
.hero-side {
  display: grid;
  gap: 10px;
}

.document-fallback-link {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.58;
  cursor: pointer;
}

.document-fallback-link:hover {
  opacity: 0.9;
}

.document-fallback-link:disabled {
  cursor: wait;
  opacity: 0.42;
}

.smart-appendix-divider {
  margin: 54px 0 24px;
  padding: 18px 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(31, 82, 68, 0.08), rgba(31, 82, 68, 0.01));
}

.smart-appendix-divider span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.smart-appendix-divider strong {
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
}

.examples-list {
  overflow: auto;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.example-card {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.example-card:hover {
  background: var(--hover);
}

.example-card.active {
  background: white;
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.example-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
}

.example-card-header {
  display: flex;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
}

.example-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 52px;
  justify-content: flex-end;
  visibility: hidden;
}

.example-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.progress-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  width: 100%;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.status-text {
  font-size: 12px;
  color: var(--muted);
}
.status-text.new { color: var(--accent); font-weight: 500; }
.status-text.completed { color: var(--success); font-weight: 500; }

.example-subtitle {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.chips,
.hero-stats,
.warnings,
.files-block,
.parties-block {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff7f0;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
  transition: all 0.15s ease;
}

.chip:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

.chip.warn {
  background: #fff1e2;
  color: var(--warn);
}

.chip.good {
  background: #edf8ef;
  color: var(--good);
}

.chip.vector {
  background: #edf2ff;
  color: #3b5bdb;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.chip.rule {
  background: #f4f0ff;
  color: #6741d9;
  font-size: 11px;
}

.content {
  padding: 24px 28px 40px;
  height: 100vh;
  overflow-y: auto;
}

.global-busy {
  position: sticky;
  top: 18px;
  z-index: 20;
  margin: 0 0 18px;
  padding: 14px 18px;
  border-radius: 20px;
  border: 1px solid rgba(47, 138, 124, 0.18);
  background: rgba(255, 255, 252, 0.92);
  box-shadow: 0 16px 36px rgba(47, 77, 63, 0.12);
  display: flex;
  align-items: center;
  gap: 14px;
  backdrop-filter: blur(12px);
}

.global-busy-copy {
  display: grid;
  gap: 4px;
}

.global-busy-copy strong {
  font-size: 16px;
}

.global-busy-copy span {
  color: var(--muted);
  line-height: 1.45;
}

.global-busy-spinner,
.loading-spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 3px solid rgba(47, 138, 124, 0.16);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  flex: 0 0 auto;
}

/* Modal Styles */
.modal {
  border: none;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 30px;
  width: 90%;
  max-width: 1380px;
  color: var(--text);
  font-family: inherit;
}

.modal::backdrop {
  background: rgba(36, 51, 44, 0.4);
  backdrop-filter: blur(4px);
}

.modal h2 {
  margin: 0 0 16px 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.modal-fieldset {
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 20px;
  border-radius: 12px;
  background: #fffdf9;
}

.modal-fieldset legend {
  font-weight: 600;
  color: var(--muted);
  padding: 0 8px;
  font-size: 14px;
}

.modal-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.modal-label-compact {
  margin-bottom: 0;
}

.modal-label input[type="text"],
.modal-label textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  transition: all 0.2s;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}

.modal-label input[type="text"]:focus,
.modal-label textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.document-build-stack {
  position: relative;
}

.document-build-toolbar {
  align-items: center;
}

.document-build-trigger {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}

.document-format-picker {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: max-content;
  max-width: min(360px, calc(100vw - 56px));
  border: 1px solid rgba(47, 138, 124, 0.18);
  border-radius: 18px;
  padding: 10px;
  background: rgba(255, 255, 252, 0.98);
  box-shadow: 0 20px 38px rgba(47, 77, 63, 0.14);
  backdrop-filter: blur(12px);
}

.document-format-picker-actions {
  display: flex;
  gap: 10px;
}

.document-format-option {
  min-width: 142px;
  padding: 11px 16px;
  justify-content: center;
  white-space: nowrap;
}

.manual-clause-item {
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 16px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
}

.manual-clause-remove {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 4px 8px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}

.manual-clause-remove:hover {
  background: var(--danger);
  color: white;
}

.pdf-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.pdf-editor-column,
.pdf-preview-column {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.pdf-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pdf-items-list {
  display: grid;
  gap: 12px;
  max-height: 62vh;
  overflow: auto;
  padding-right: 4px;
}

.pdf-item-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfb 100%);
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.pdf-item-card .modal-label > .pdf-structured-editor,
.pdf-item-card .modal-label > .pdf-item-textarea {
  margin-top: 10px;
}

.pdf-item-card.disabled {
  opacity: 0.62;
  background: #f7f7f5;
}

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

.pdf-item-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.pdf-item-actions {
  display: flex;
  gap: 8px;
}

.pdf-item-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  align-items: flex-end;
}

.pdf-item-grid .modal-label {
  margin-bottom: 0;
}

.modal-label select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  background: #fff;
}

.modal-label select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pdf-preview-document {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 24px;
  min-height: 320px;
  max-height: 56vh;
  overflow: auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.pdf-preview-title {
  margin: 0 0 10px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
}

.pdf-preview-subtitle,
.pdf-preview-cityline {
  margin: 0 0 8px;
  text-align: center;
  font-size: 14px;
}

.pdf-preview-paragraph {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
}

.pdf-preview-table {
  display: grid;
  gap: 12px;
}

.pdf-preview-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fcfdfc;
}

.pdf-preview-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #eef8f5;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.pdf-preview-row-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.pdf-preview-cell {
  padding: 12px;
  border-right: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow: hidden;
}

.pdf-preview-cell:last-child {
  border-right: none;
}

.pdf-preview-cell-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pdf-preview-frame {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.pdf-preview-empty {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 24px 18px;
  text-align: center;
  color: var(--muted);
  background: #fafcf9;
}

.pdf-preview-empty.compact {
  padding: 14px 12px;
  border-radius: 12px;
}

.pdf-preview-rich {
  overflow-x: auto;
}

.pdf-preview-rich table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
}

.pdf-preview-rich th,
.pdf-preview-rich td {
  border: 1px solid rgba(47, 138, 124, 0.22);
  padding: 8px 10px;
  vertical-align: top;
  white-space: normal;
}

.pdf-preview-rich p:last-child,
.pdf-preview-rich ul:last-child,
.pdf-preview-rich ol:last-child {
  margin-bottom: 0;
}

.pdf-structured-editor {
  display: grid;
  gap: 10px;
}

.pdf-structured-preview {
  border: 1px solid rgba(47, 138, 124, 0.22);
  border-radius: 14px;
  background: #fbfffd;
  padding: 12px;
  overflow-x: auto;
}

.pdf-structured-preview table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.pdf-structured-preview th,
.pdf-structured-preview td {
  border: 1px solid rgba(47, 138, 124, 0.22);
  padding: 9px 10px;
  vertical-align: top;
  min-width: 52px;
}

.pdf-structured-preview .structured-edit-node {
  outline: none;
}

.pdf-structured-preview .structured-edit-node:focus {
  box-shadow: inset 0 0 0 2px rgba(47, 138, 124, 0.18);
  background: rgba(47, 138, 124, 0.06);
}

.global-busy-spinner {
  width: 22px;
  height: 22px;
}

.loading-placeholder {
  display: grid;
  gap: 14px;
  border-radius: 22px;
  border: 1px solid rgba(47, 138, 124, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 252, 0.98) 0%, rgba(243, 249, 245, 0.96) 100%);
  padding: 18px 20px;
  box-shadow: 0 10px 24px rgba(47, 77, 63, 0.08);
  text-align: left;
}

.loading-placeholder.compact {
  border-radius: 18px;
  padding: 14px 16px;
}

.loading-placeholder-head {
  display: flex;
  align-items: start;
  gap: 12px;
}

.loading-placeholder-copy {
  display: grid;
  gap: 4px;
}

.loading-placeholder-copy strong {
  font-size: 16px;
}

.loading-placeholder-copy span {
  color: var(--muted);
  line-height: 1.5;
}

.loading-skeleton {
  display: grid;
  gap: 10px;
}

.loading-skeleton-line {
  display: block;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(221, 232, 223, 0.85) 0%,
    rgba(247, 251, 248, 0.98) 50%,
    rgba(221, 232, 223, 0.85) 100%
  );
  background-size: 220% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.loading-skeleton-line.medium {
  width: 78%;
}

.loading-skeleton-line.short {
  width: 58%;
}

.panel-loader-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(47, 138, 124, 0.12);
  background: rgba(248, 251, 249, 0.92);
  color: var(--muted);
  line-height: 1.45;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
  margin-bottom: 20px;
  padding: 24px 26px;
  border: 1px solid rgba(215, 224, 215, 0.95);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 252, 0.98) 0%, rgba(237, 248, 243, 0.96) 100%);
  box-shadow: var(--shadow);
}

.hero-main {
  display: grid;
  gap: 10px;
  max-width: 820px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #1e5a51;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero-side {
  justify-items: end;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.05);
}

.workflow-panel {
  margin-bottom: 18px;
  background:
    linear-gradient(135deg, rgba(218, 242, 236, 0.9) 0%, rgba(255, 255, 252, 0.96) 52%, rgba(255, 248, 221, 0.82) 100%);
}

.workflow-head {
  align-items: center;
}

.workflow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.workflow-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(47, 138, 124, 0.12);
  font-size: 15px;
  line-height: 1.5;
}

.workflow-step strong {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
}

.emphasis-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 252, 0.98) 0%, rgba(247, 251, 248, 0.96) 100%);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

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

.toolbar input[type="search"] {
  margin-top: 0;
  width: 320px;
}

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

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(248, 251, 249, 0.95);
  border: 1px solid rgba(215, 224, 215, 0.9);
}

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

.jump-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.jump-list-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.jump-link {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(47, 138, 124, 0.25);
  background: linear-gradient(180deg, #ffffff 0%, #eef8f5 100%);
  color: #1f5d53;
  border-radius: 999px;
  padding: 10px 15px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(47, 138, 124, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.jump-link:hover {
  background: linear-gradient(180deg, #ffffff 0%, #daf2ec 100%);
  border-color: var(--accent);
  box-shadow: 0 10px 20px rgba(47, 138, 124, 0.14);
  transform: translateY(-1px);
}

.jump-link:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(47, 138, 124, 0.15),
    0 10px 20px rgba(47, 138, 124, 0.14);
}

.accent-button {
  border: 1px solid var(--accent);
  background: linear-gradient(180deg, #42a08f 0%, #2f8a7c 100%);
  color: #f9fffd;
  border-radius: 14px;
  padding: 13px 18px;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(47, 138, 124, 0.2);
  font-weight: 700;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, box-shadow;
}

.accent-button:hover {
  background: linear-gradient(180deg, #4cb09e 0%, #369b8b 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(47, 138, 124, 0.3);
}

.accent-button:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 2px 6px rgba(47, 138, 124, 0.2);
}

.accent-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft), 0 4px 12px rgba(47, 138, 124, 0.2);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff9f2;
  color: var(--text);
  border-radius: 14px;
  padding: 13px 18px;
  font: inherit;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, box-shadow;
}

.secondary-button:hover {
  background: #ffffff;
  border-color: #c9d5c9;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
}

.secondary-button:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.secondary-button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.download-button-primary {
  min-width: 240px;
  box-shadow: 0 10px 24px rgba(24, 102, 89, 0.28);
}

.download-button-primary:hover {
  box-shadow: 0 14px 28px rgba(24, 102, 89, 0.34);
}

.hidden-link {
  display: none;
}

.accent-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.inline-status {
  min-height: 34px;
  display: flex;
  align-items: center;
  width: 100%;
}

.status-banner {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 20px;
  background: #fffaf5;
  border: 1px solid #f1d4b2;
  box-shadow: 0 8px 24px rgba(180, 108, 41, 0.12);
}

.status-banner.warn {
  background: linear-gradient(180deg, #fff8f1 0%, #fff3e5 100%);
  border-color: #efc999;
}

.status-banner-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: var(--warn);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(180, 108, 41, 0.18);
}

.status-banner-copy {
  display: grid;
  gap: 6px;
}

.status-banner-copy strong {
  font-size: 18px;
  line-height: 1.2;
  color: #8a4f16;
}

.status-banner-copy span {
  font-size: 16px;
  line-height: 1.45;
  color: #9a5b21;
}
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.panel-grid-single {
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
}

.panel-wide {
  width: 100%;
}

.meta-grid {
  display: grid;
  gap: 18px;
}

.meta-section {
  border: 1px solid rgba(154, 186, 172, 0.3);
  border-radius: 22px;
  padding: 20px 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 252, 248, 0.92));
  box-shadow: 0 14px 30px rgba(41, 77, 63, 0.06);
}

.meta-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.meta-section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.meta-section-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.meta-section-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 20px;
}

.meta-item {
  min-width: 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(208, 226, 218, 0.9);
}

.meta-item.meta-item-wide {
  grid-column: 1 / -1;
}

.panel-wide .meta-section:first-child .meta-item.meta-item-wide,
.panel-wide .meta-section:nth-child(2) .meta-item.meta-item-wide {
  grid-column: span 2;
}

.meta-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.meta-value {
  font-weight: 600;
  font-size: 18px;
  line-height: 1.45;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.meta-value .chip {
  margin-top: 2px;
}

.meta-risk-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-risk-list .chip {
  background: #fff6da;
  border-color: #f1d58a;
  color: #8a6110;
}

.meta-error-box {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(237, 182, 146, 0.7);
  background: rgba(255, 244, 236, 0.92);
}

.meta-error-box .meta-value {
  font-size: 16px;
  color: #9b4b20;
}

@media (max-width: 980px) {
  .meta-section-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-wide .meta-section:first-child .meta-item.meta-item-wide,
  .panel-wide .meta-section:nth-child(2) .meta-item.meta-item-wide {
    grid-column: 1 / -1;
  }
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 300px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 24px;
  background: rgba(255, 252, 247, 0.6);
}

.empty-state.compact {
  min-height: 160px;
}

.hidden {
  display: none;
}

.clauses-list,
.classification-list,
.reason-list {
  display: grid;
  gap: 12px;
}

.clause-card,
.classification-card,
.reason-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: #fffdfa;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.clause-card:hover,
.classification-card:hover,
.reason-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(47, 77, 63, 0.05);
  border-color: #c9d5c9;
}

.clause-card:active,
.classification-card:active,
.reason-card:active {
  transform: translateY(0) scale(0.99);
  box-shadow: 0 2px 8px rgba(47, 77, 63, 0.05);
  transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

:root {
  --doc-font-size: 18px;
}

/* Smart Document UI */
.smart-document-page {
  position: relative;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  padding: 60px 80px;
  font-family: "Times New Roman", "Georgia", serif;
  color: #000000;
  width: 100%;
  max-width: 26cm;
  margin: 40px auto;
  line-height: 1.3;
}

.smart-clause-num {
  font-weight: bold;
  margin-right: 8px;
  color: #000000;
  font-family: var(--font-family);
}

.smart-icon-btn.reranker-change-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: -3px 8px -3px -34px;
  padding: 0;
  vertical-align: middle;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.92);
  text-indent: 0;
  cursor: pointer;
  box-shadow: 0 3px 9px rgba(35, 55, 47, 0.12);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.reranker-change-indicator:hover,
.reranker-change-indicator[aria-expanded="true"] {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(35, 55, 47, 0.18);
}

.reranker-change-indicator.is-up {
  color: #b53a2d;
  background: #fff0ec;
}

.reranker-change-indicator.is-down {
  color: #18735f;
  background: #eaf8f2;
}

.reranker-change-indicator.is-locked {
  opacity: 0.58;
  cursor: default;
}

.reranker-change-indicator.is-locked:hover,
.reranker-change-indicator.is-locked[aria-expanded="true"] {
  transform: none;
  box-shadow: 0 3px 9px rgba(35, 55, 47, 0.12);
}

.reranker-assessment-menu {
  position: fixed;
  z-index: 2700;
  width: min(330px, calc(100vw - 24px));
  padding: 14px;
  border: 1px solid rgba(47, 138, 124, 0.28);
  border-radius: 18px;
  background: rgba(255, 255, 252, 0.98);
  box-shadow: 0 22px 50px rgba(30, 52, 43, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--font-family);
  color: var(--text);
}

.reranker-assessment-menu.hidden {
  display: none;
}

.reranker-assessment-menu-head {
  display: grid;
  gap: 4px;
  padding: 2px 2px 11px;
  border-bottom: 1px solid rgba(154, 186, 172, 0.34);
}

.reranker-assessment-menu-head strong {
  font-size: 14px;
  line-height: 1.35;
}

.reranker-assessment-menu-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reranker-assessment-menu-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 12px;
}

.reranker-assessment-menu-actions button {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid rgba(154, 186, 172, 0.42);
  border-radius: 12px;
  background: #f7faf8;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}

.reranker-assessment-menu-actions button:hover {
  transform: translateY(-1px);
  border-color: rgba(47, 138, 124, 0.62);
  background: #edf7f2;
}

.reranker-assessment-menu-actions button.is-correct {
  color: #17634f;
  background: #e9f7f0;
}

.reranker-assessment-menu-actions button.is-correction {
  color: #96372d;
  background: #fff0ec;
  border-color: rgba(181, 58, 45, 0.25);
}

.reranker-assessment-menu-actions button:disabled {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

.reranker-assessment-menu > p {
  margin: 11px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

@media (max-width: 560px) {
  .reranker-assessment-menu-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

.smart-clause-wrapper {
  position: relative;
  margin-bottom: 12px;
}

.smart-clause {
  font-size: var(--doc-font-size);
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.2s ease;
  position: relative;
  text-align: justify;
  text-indent: 1.25cm;
  margin-bottom: 0;
  line-height: 1.3;
}

.smart-clause:hover {
  background: #f9fbf9;
}

.smart-clause-danger {
  background: rgba(220, 53, 69, 0.1) !important;
}

.smart-clause-warning {
  background: rgba(255, 193, 7, 0.15) !important;
}

.smart-clause-muted {
  background: linear-gradient(90deg, rgba(112, 132, 123, 0.12), rgba(112, 132, 123, 0.045)) !important;
  color: #56635e;
  border-left-color: #87958f !important;
}

.smart-clause-manual {
  background: rgba(139, 92, 246, 0.12) !important;
  outline: 2px solid rgba(139, 92, 246, 0.9) !important;
  outline-offset: -2px;
}

.smart-clause-checked {
  outline: 2px solid #28a745 !important;
  outline-offset: -2px;
  background: rgba(40, 167, 69, 0.05) !important;
}

/* Global Modal Editor */
.smart-global-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
}
.smart-global-modal {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 1200px;
    max-width: 95vw;
    max-height: 90vh;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 2001;
    flex-direction: column;
    overflow: hidden;
}
.smart-global-backdrop.visible, .smart-global-modal.visible {
    display: flex;
}
.smart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
    background: #fdfdfd;
}
.smart-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.smart-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
    text-indent: 0;
}

/* Context Menu Tools */
.smart-clause-tools {
  position: absolute;
  top: -2px;
  right: -52px;
  margin: -18px -20px -18px -34px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px 18px 34px;
  border-radius: 26px;
}

.smart-clause-wrapper:hover .smart-clause-tools,
.smart-clause-tools.active {
  opacity: 1;
  pointer-events: auto;
}

/* Clause Status Indicator */
.clause-status-icon {
  position: absolute;
  left: -24px;
  top: 8px;
  font-size: 14px;
  width: 16px;
  text-align: center;
  z-index: 2;
  user-select: none;
}

/* Status Menu Dropdown */
.status-menu-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.status-dropdown {
  position: absolute;
  top: 0;
  right: 100%; /* pop out to the left of the button to avoid horizontal scroll */
  margin-right: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 4px 0;
  min-width: 170px;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.status-dropdown.hidden {
  display: none !important;
}

.status-dropdown-btn {
  background: none;
  border: none;
  padding: 8px 12px;
  text-align: left;
  font-family: var(--font-family);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}

.status-dropdown-btn:hover {
  background: var(--surface-bg);
}



.smart-icon-btn {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  transition: all 0.2s;
  position: relative;
}

.smart-icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.smart-icon-btn::before {
  content: "";
  position: absolute;
  inset: -8px;
}

/* Bookmark line */
.bookmark-line {
  height: 2px;
  background: var(--accent);
  margin: 20px 0;
  position: relative;
  display: none;
}
.bookmark-line.visible {
  display: block;
}
.bookmark-line::after {
  content: "Остановились здесь";
  position: absolute;
  right: 0;
  top: -20px;
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-family);
}

.smart-inline-editor {
  margin-top: 10px;
  margin-bottom: 20px;
  padding-left: 20px;
  border-left: 3px solid var(--accent);
  display: none;
  font-family: var(--font-family); /* Switch back to app sans-serif for editor */
}
.smart-inline-editor.visible {
  display: block;
}

.reranker-log-panel {
  padding: 0;
  overflow: hidden;
  border-color: rgba(48, 99, 83, 0.22);
  background:
    radial-gradient(circle at 92% -20%, rgba(220, 190, 98, 0.2), transparent 42%),
    linear-gradient(145deg, #f8fbf7, #fffdf7);
}

.reranker-log-shell > summary,
.reranker-log-entry > summary {
  list-style: none;
  cursor: pointer;
}

.reranker-log-shell > summary::-webkit-details-marker,
.reranker-log-entry > summary::-webkit-details-marker {
  display: none;
}

.reranker-log-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 26px;
}

.reranker-log-summary > span:first-child {
  display: grid;
  gap: 4px;
}

.reranker-log-summary strong {
  font-size: 17px;
  color: #243c34;
}

.reranker-log-summary small {
  color: var(--muted);
  font-size: 13px;
}

.reranker-log-summary-stats {
  padding: 7px 12px;
  border: 1px solid rgba(48, 99, 83, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: #355e50;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.reranker-log-content {
  padding: 0 26px 26px;
  border-top: 1px solid rgba(48, 99, 83, 0.12);
}

.reranker-log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0;
}

.reranker-log-meta span,
.reranker-signals span {
  padding: 6px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(48, 99, 83, 0.14);
  color: #4e625b;
  font-size: 12px;
}

.reranker-log-entries {
  display: grid;
  gap: 10px;
}

.reranker-log-entry {
  border: 1px solid rgba(48, 99, 83, 0.15);
  border-left: 4px solid #83968f;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  overflow: hidden;
}

.reranker-log-entry.reranker-log-high {
  border-left-color: #c83e4d;
}

.reranker-log-entry.reranker-log-medium {
  border-left-color: #d3a016;
}

.reranker-log-entry.reranker-log-low {
  border-left-color: #779087;
}

.reranker-log-entry > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.reranker-entry-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #273d35;
  font-weight: 750;
}

.reranker-entry-score {
  color: #60736c;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.reranker-level-badge {
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf2ef;
  color: #4f665d;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.reranker-log-high .reranker-level-badge {
  color: #9f1d2d;
  background: #ffe7e9;
}

.reranker-log-medium .reranker-level-badge {
  color: #785500;
  background: #fff3c4;
}

.reranker-log-body {
  padding: 16px;
  border-top: 1px solid rgba(48, 99, 83, 0.12);
}

.reranker-decision {
  margin: 0 0 12px;
  color: #344f46;
  line-height: 1.5;
}

.reranker-formula {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #243c34;
  color: #f7fbf8;
  font-variant-numeric: tabular-nums;
}

.reranker-formula span {
  color: #b9cec5;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.reranker-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.reranker-metrics > div {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid rgba(48, 99, 83, 0.12);
  border-radius: 10px;
  background: #fbfcfa;
}

.reranker-metrics span {
  color: var(--muted);
  font-size: 11px;
}

.reranker-metrics strong {
  color: #263e35;
  font-size: 16px;
}

.reranker-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.reranker-signals .positive {
  color: #236b4c;
  background: #e8f6ee;
}

.reranker-signals .negative {
  color: #9f1d2d;
  background: #fff0f1;
}

.reranker-code-line {
  color: #64766f;
  font-size: 12px;
}

.reranker-code-line code,
.reranker-neighbor code {
  color: #3d5c50;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.reranker-log-body h4 {
  margin: 18px 0 8px;
  color: #304a40;
  font-size: 13px;
}

.reranker-neighbors {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reranker-neighbor {
  padding: 10px 12px;
  border-left: 3px solid #4a9b77;
  border-radius: 8px;
  background: #f5faf7;
}

.reranker-neighbor-negative {
  border-left-color: #ce5a67;
  background: #fff7f7;
}

.reranker-neighbor.is-rejected {
  background: #f5f7f6;
  border-color: #d8dfdc;
  opacity: 0.82;
}

.reranker-neighbor.is-compatible {
  box-shadow: inset 3px 0 0 #2f7d5b;
}

.reranker-assessment-actions,
.reranker-evidence-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
}

.reranker-assessment-actions > span {
  color: #5d6b65;
  font-size: 12px;
  font-weight: 700;
  margin-right: 2px;
}

.reranker-assessment-actions button,
.reranker-evidence-actions button {
  border: 1px solid #c7d3ce;
  border-radius: 999px;
  background: #fff;
  color: #33463e;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  padding: 6px 10px;
}

.reranker-assessment-actions button:hover,
.reranker-evidence-actions button:hover {
  border-color: #587a6b;
  background: #edf4f1;
}

.reranker-assessment-actions button.is-safety {
  border-color: #d0a326;
  color: #755600;
  background: #fff8dc;
}

.reranker-assessment-actions button.is-saved,
.reranker-evidence-actions button.is-saved {
  border-color: #5a8c73;
  color: #1f6245;
  background: #e8f4ed;
}

.reranker-neighbor-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #4f665d;
  font-size: 12px;
}

.reranker-neighbor p {
  margin: 5px 0;
  color: #354b43;
  font-size: 13px;
  line-height: 1.45;
}

.reranker-neighbor-empty {
  color: var(--muted);
  font-size: 13px;
}

.reranker-log-fallback {
  display: grid;
  gap: 5px;
  padding: 20px 24px;
  color: #7c4d11;
  background: #fff7e3;
}

@media (max-width: 760px) {
  .reranker-log-summary,
  .reranker-log-content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .reranker-log-summary,
  .reranker-log-entry > summary {
    align-items: flex-start;
  }

  .reranker-log-entry > summary {
    grid-template-columns: 1fr auto;
  }

  .reranker-entry-title {
    grid-column: 1 / -1;
    white-space: normal;
  }

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



.review-compare-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 252, 0.98) 0%, rgba(249, 252, 249, 0.98) 100%);
  box-shadow: 0 14px 28px rgba(47, 77, 63, 0.08);
  transition: all 0.2s ease;
}

.review-compare-card:hover {
  box-shadow: 0 20px 36px rgba(47, 77, 63, 0.12);
  transform: translateY(-1px);
}

.review-compare-card.is-focused {
  box-shadow:
    0 0 0 4px rgba(47, 138, 124, 0.18),
    0 20px 36px rgba(47, 77, 63, 0.12);
}

.review-compare-card.state-keep {
  border-color: var(--success-line);
}

.review-compare-card.state-manual {
  border-color: var(--reason-line);
}

.review-compare-card.state-reject {
  border-color: var(--danger-line);
}

.review-compare-card.risk-high {
  border-left: 5px solid #dc3545;
  background: linear-gradient(90deg, rgba(220, 53, 69, 0.055), #fffdfa 18%);
}

.review-compare-card.risk-medium {
  border-left: 5px solid #e0a800;
  background: linear-gradient(90deg, rgba(255, 193, 7, 0.09), #fffdfa 18%);
}

.review-compare-card.risk-low {
  border-left: 5px solid #87958f;
  background: linear-gradient(90deg, rgba(112, 132, 123, 0.08), #fffdfa 18%);
}

.risk-level-label {
  width: fit-content;
  margin: 6px 0 8px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.risk-level-high {
  color: #9f1d2d;
  background: #ffe7e9;
  border: 1px solid #f2aeb6;
}

.risk-level-medium {
  color: #785500;
  background: #fff3c4;
  border: 1px solid #e8c85f;
}

.risk-level-low {
  color: #53645d;
  background: #edf1ef;
  border: 1px solid #cbd5d1;
}

.review-compare-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 16px;
}

.review-compare-heading {
  display: grid;
  gap: 6px;
}

.review-compare-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.collapse-toggle {
  min-width: 132px;
}

.review-kicker {
  color: #1e5a51;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  background: #daf2ec;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-block;
}

.review-card-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #1a241f;
  line-height: 1.3;
}

.review-card-body {
  display: grid;
  gap: 18px;
}

.review-compare-card.is-collapsed .review-card-body {
  display: none;
}

.review-compare-card.is-collapsed .review-compare-top {
  margin-bottom: 0;
}

.review-compare-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) 52px minmax(0, 1.15fr);
  gap: 18px;
  align-items: stretch;
}

.compare-pane {
  border-radius: 24px;
  padding: 18px;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.current-pane {
  background: var(--danger-soft);
  border-color: var(--danger-line);
}

.proposed-pane {
  background: var(--success-soft);
  border-color: var(--success-line);
}

.compare-transfer-column {
  display: flex;
  align-items: center;
  justify-content: center;
}

.compare-transfer-button {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.2);
  background: linear-gradient(180deg, #ffffff 0%, #f3f8ff 100%);
  color: #2563eb;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.compare-transfer-button:hover {
  transform: translateX(1px);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.18);
  background: linear-gradient(180deg, #ffffff 0%, #eaf2ff 100%);
}

.compare-transfer-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

.compare-transfer-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  background: #f1f5f9;
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: none;
  transform: none;
}

.compare-pane-head,
.safe-redaction-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.safe-redaction-head {
  margin-bottom: 8px;
}

.compare-label {
  font-size: 18px;
  font-weight: 800;
}

.compare-caption {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: right;
  max-width: 260px;
}

.compare-chip-row {
  margin-top: -2px;
}

.compare-text,
.clause-text,
.reason-text {
  white-space: pre-wrap;
  line-height: 1.6;
}

.compare-text.rich-markup {
  white-space: normal;
  overflow-x: auto;
}

.compare-text.rich-markup p {
  margin-top: 0;
  margin-bottom: 8px;
}

.compare-text.rich-markup p:last-child {
  margin-bottom: 0;
}

.compare-text.rich-markup table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.76);
  border-radius: 16px;
  overflow: hidden;
}

.compare-text.rich-markup th,
.compare-text.rich-markup td {
  border: 1px solid var(--danger-line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.compare-text.rich-markup th {
  background: rgba(255, 255, 255, 0.92);
  font-weight: 700;
}

.suggested-preview {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.suggested-preview-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--success-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.suggested-preview .compare-text.rich-markup table th,
.suggested-preview .compare-text.rich-markup table td {
  border-color: var(--success-line);
}

.suggested-preview-content {
  border-radius: 18px;
}

.structured-edit-node {
  cursor: text;
  transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.structured-edit-node:hover {
  background: rgba(14, 165, 233, 0.06);
}

.diff-remove-cell {
  background: rgba(239, 68, 68, 0.12);
  box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.18);
}

.diff-add-cell {
  background: rgba(16, 185, 129, 0.12);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.18);
}

.structured-edit-node:focus {
  outline: none;
  background: rgba(16, 185, 129, 0.10);
  box-shadow: inset 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.editable-structured-table td,
.editable-structured-table th {
  min-width: 56px;
}

.structured-editor-toggle {
  display: grid;
  gap: 10px;
}

.structured-editor-toggle summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--success-line);
  background: rgba(255, 255, 255, 0.88);
  color: var(--success-strong);
  font-size: 14px;
  font-weight: 700;
}

.structured-editor-toggle summary::-webkit-details-marker {
  display: none;
}

.structured-editor-toggle[open] summary {
  background: rgba(255, 255, 255, 0.96);
}

.structured-editor-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.hidden-textarea-holder {
  display: block;
}

.diff-remove {
  background-color: #fdd8d8;
  color: #a40000;
  border-radius: 2px;
  padding: 0 1px;
}

.diff-add {
  background-color: #d1f3d8;
  color: #0b6623;
  border-radius: 2px;
  padding: 0 1px;
}

.redaction-viewer {
  white-space: pre-wrap;
  overflow-y: auto;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}

.reason-summary {
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--reason-soft);
  border: 1px solid var(--reason-line);
  display: grid;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.reason-summary-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--warn);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.reason-summary-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
}

.reason-summary-text,
.reason-summary-note {
  line-height: 1.58;
  color: var(--text);
}

.vector-ref {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(59, 91, 219, 0.07);
  border: 1px solid rgba(59, 91, 219, 0.18);
  font-size: 12px;
  color: #3b5bdb;
}

.vector-ref--rule {
  background: rgba(103, 65, 217, 0.07);
  border-color: rgba(103, 65, 217, 0.18);
  color: #6741d9;
}

.vector-ref-icon {
  font-size: 14px;
  line-height: 1.2;
  flex-shrink: 0;
  margin-top: 1px;
}

.vector-ref-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
}

.vector-ref-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  opacity: 0.75;
}

.vector-ref-ids {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 12px;
}

.vector-ref-meta {
  font-size: 11px;
  opacity: 0.55;
  font-family: ui-monospace, "SF Mono", monospace;
}

.vector-ref-score {
  margin-left: auto;
  font-weight: 700;
  font-size: 12px;
  opacity: 0.85;
}

.proposal-empty {
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px dashed var(--success-line);
  color: var(--muted);
  line-height: 1.6;
}

.safe-redaction-note {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.reason-switcher {
  display: grid;
  gap: 10px;
}

.reason-switcher-toggle {
  appearance: none;
  -webkit-appearance: none;
  min-width: 210px;
  justify-content: space-between;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.reason-switcher-chevron {
  font-size: 15px;
  line-height: 1;
}

.reason-switcher-list {
  display: grid;
  gap: 8px;
  min-width: min(420px, 100%);
}

.reason-option {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(236, 215, 142, 0.9);
  background: linear-gradient(180deg, #fffef7 0%, #fff8dd 100%);
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  display: grid;
  gap: 6px;
  text-align: left;
  font: inherit;
  color: var(--text);
  box-shadow: 0 6px 14px rgba(180, 108, 41, 0.08);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.reason-option:hover {
  transform: translateY(-1px);
  border-color: var(--warn);
  box-shadow: 0 8px 18px rgba(180, 108, 41, 0.12);
}

.reason-option:focus-visible {
  outline: none;
  border-color: var(--warn);
  box-shadow:
    0 0 0 3px rgba(180, 108, 41, 0.12),
    0 8px 18px rgba(180, 108, 41, 0.12);
}

.reason-option-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.reason-option-meta {
  font-size: 13px;
  color: var(--muted);
}

.reason-option-note {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.82;
}

.clause-head,
.reason-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 10px;
}

.clause-number {
  font-weight: 700;
  color: var(--accent);
}

.clause-text,
.reason-text {
  white-space: pre-wrap;
  line-height: 1.55;
}

.reason-list {
  margin-top: 14px;
}

.raw-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
  max-height: 420px;
  overflow: auto;
  font-family: "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  background: #fffdfa;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
}

.compact-button {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.review-bottom-tab {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(255, 255, 255, 0.86);
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--line);
}

.safe-redaction-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--good);
}

.redaction-textarea {
  width: 100%;
  flex-grow: 1;
  min-height: 340px;
  resize: vertical;
  border: 1px solid rgba(47, 106, 59, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  padding: 18px 20px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.8;
  letter-spacing: 0.01em;
  color: inherit;
  box-shadow: inset 0 1px 2px rgba(75, 48, 24, 0.06);
}

.redaction-textarea:focus {
  outline: none;
  border-color: rgba(167, 72, 45, 0.55);
  box-shadow:
    0 0 0 3px rgba(167, 72, 45, 0.12),
    inset 0 1px 2px rgba(75, 48, 24, 0.06);
}

.redaction-textarea[readonly] {
  background: rgba(255, 255, 255, 0.78);
  cursor: default;
}

.redaction-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.feedback-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.decision-button {
  min-height: 52px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.disabled-button-hint {
  position: relative;
  display: inline-flex;
  width: 100%;
}

.disabled-button-hint .decision-button {
  width: 100%;
}

.disabled-button-hint[data-disabled-hint]:hover::after,
.disabled-button-hint[data-disabled-hint]:focus-within::after {
  content: attr(data-disabled-hint);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 210px;
  max-width: min(280px, 90vw);
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(32, 41, 37, 0.94);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 10px 26px rgba(22, 27, 25, 0.18);
  z-index: 30;
  pointer-events: none;
}

.disabled-button-hint[data-disabled-hint]:hover::before,
.disabled-button-hint[data-disabled-hint]:focus-within::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(32, 41, 37, 0.94) transparent transparent transparent;
  z-index: 30;
  pointer-events: none;
}

.decision-button.is-active {
  border-width: 2px;
}

.decision-button.is-loading {
  position: relative;
}

.decision-button .button-spinner {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.redaction-progress-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(47, 138, 124, 0.16);
  background: rgba(236, 247, 243, 0.9);
  color: #2a655d;
  font-size: 14px;
  line-height: 1.45;
}

.redaction-progress-note .button-spinner {
  color: var(--accent);
}

.decision-button.decision-keep.is-active {
  background: #edf9f2;
  border-color: var(--good);
  color: var(--good);
}

.decision-button.decision-manual.is-active {
  background: #fff9e7;
  border-color: var(--warn);
  color: #8d541a;
}

.decision-button.decision-reject.is-active {
  background: #fff0ed;
  border-color: var(--danger);
  color: var(--danger);
}

.decision-button.decision-feedback-like.is-active {
  background: #edf9f2;
  border-color: var(--good);
  color: var(--good);
}

.decision-button.decision-feedback-dislike.is-active {
  background: #fff0ed;
  border-color: var(--danger);
  color: var(--danger);
}

.missing-number-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: -2px;
}

.missing-number-choice {
  appearance: none;
  border: 1px solid rgba(47, 138, 124, 0.22);
  background: rgba(236, 247, 243, 0.88);
  color: #255d55;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.missing-number-choice:hover {
  border-color: rgba(47, 138, 124, 0.45);
  background: rgba(225, 243, 238, 0.98);
}

.missing-number-choice.is-active {
  background: #2f8a7c;
  color: #fff;
  border-color: #2f8a7c;
  box-shadow: 0 8px 18px rgba(47, 138, 124, 0.22);
}

.empty-state .loading-placeholder {
  width: min(720px, 100%);
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --- Tooltips --- */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  padding: 6px 12px;
  background-color: #1e293b;
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  border-radius: 6px;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  animation: fadeIn 0.2s forwards;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  font-weight: 500;
}

[data-tooltip]:hover::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 2px;
  border-width: 6px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  animation: fadeIn 0.2s forwards;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -20% 0;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .hero,
  .panel-head,
  .section-toolbar,
  .toolbar,
  .clause-head,
  .reason-head,
  .safe-redaction-head,
  .review-compare-top,
  .compare-pane-head,
  .workflow-head {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar input[type="search"] {
    width: 100%;
  }

  .hero-side {
    justify-items: stretch;
  }

  .hero-actions,
  .section-toolbar-actions,
  .global-busy {
    justify-content: stretch;
  }

  .review-compare-tools {
    justify-content: stretch;
  }

  .workflow-steps,
  .review-compare-grid,
  .redaction-actions {
    grid-template-columns: 1fr;
  }

  .compare-transfer-column {
    order: 2;
    padding: 2px 0;
  }

  .compare-transfer-button {
    transform: rotate(90deg);
  }

  .compare-transfer-button:hover {
    transform: rotate(90deg) translateX(1px);
  }

  .pdf-editor-layout,
  .pdf-item-grid,
  .pdf-preview-row-grid {
    grid-template-columns: 1fr;
  }

  .document-format-picker {
    width: min(100%, 320px);
    max-width: calc(100vw - 56px);
  }

  .document-format-picker-actions {
    flex-direction: column;
  }

  .pdf-editor-toolbar,
  .pdf-item-head,
  .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .modal {
    width: 96%;
    padding: 18px;
  }

  .reason-switcher-toggle,
  .collapse-toggle,
  .jump-link {
    width: 100%;
    justify-content: space-between;
  }

  .reason-switcher-list {
    min-width: 0;
  }

  .compare-caption {
    max-width: none;
    text-align: left;
  }
}

/* Missing Clause Modal */
/* --- PREMIUM MODAL DESIGN --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    background: linear-gradient(145deg, rgba(255,255,255,1) 0%, rgba(248,250,252,1) 100%);
    width: 520px;
    max-width: 90vw;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.5) inset;
    transform: translateY(40px) scale(0.95);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    position: relative;
}
.modal-overlay.visible .modal-content {
    transform: translateY(0) scale(1);
}
.modal-header {
    padding: 24px 32px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}
.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}
.modal-close {
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
}
.modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: rotate(90deg);
}

/* Beautiful form controls */
.smart-editor {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid transparent;
    border-radius: 16px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 15px;
    color: #0f172a;
    background-color: #f8fafc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02) inset, 0 0 0 1px #e2e8f0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    resize: vertical;
}

.smart-editor:focus {
    outline: none;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15) inset, 0 0 0 2px #0ea5e9;
}

.smart-editor::placeholder {
    color: #94a3b8;
}

.smart-editor[readonly] {
    color: #334155;
    background-color: #eef4fb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02) inset, 0 0 0 1px #d7e3f0;
    cursor: default;
}

select.smart-editor {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%230ea5e9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
    cursor: pointer;
}

/* Premium FAB */
.premium-fab {
    position: fixed;
    bottom: 110px;
    right: 30px;
    border-radius: 50px;
    padding: 16px 28px;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.01em;
    border: none;
    box-shadow: 0 10px 25px -5px rgba(2, 132, 199, 0.4), 0 0 0 1px rgba(255,255,255,0.2) inset;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(4px);
}
.premium-fab:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 30px -10px rgba(2, 132, 199, 0.5), 0 0 0 1px rgba(255,255,255,0.3) inset;
    background: linear-gradient(135deg, #38bdf8 0%, #0369a1 100%);
}
.premium-fab:active {
    transform: translateY(2px) scale(0.98);
}
.premium-fab svg {
    margin-right: 10px;
    transition: transform 0.3s ease;
}
.premium-fab:hover svg {
    transform: rotate(180deg);
}

.premium-btn-submit {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    background: #0f172a;
    color: white;
    font-weight: 600;
    font-size: 16px;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}
.premium-btn-submit:hover {
    background: #1e293b;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.3);
}

.premium-btn-submit:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.2);
    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.smart-clause-info {
  background: rgba(13, 110, 253, 0.1) !important;
}

/* Auth and Profile Screens */
.auth-container, .profile-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(circle at top left, rgba(47, 138, 124, 0.16), transparent 24%),
              radial-gradient(circle at top right, rgba(255, 213, 135, 0.18), transparent 26%),
              linear-gradient(180deg, #f8fbf8 0%, #eef5ef 100%);
}

.help-screen {
  align-items: flex-start;
}

.help-layout {
  width: 100%;
  max-width: 980px;
  display: grid;
  gap: 20px;
}

.help-header-card,
.help-article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.06);
}

.help-header-card {
  padding: 28px 32px;
}

.help-eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(47, 138, 124, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.help-header-card h2 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.15;
  color: var(--text);
}

.help-header-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
}

.help-article {
  padding: 32px;
  overflow: hidden;
}

.help-article h1,
.help-article h2,
.help-article h3 {
  color: var(--text);
  line-height: 1.2;
}

.help-article h1 {
  font-size: 32px;
  margin: 0 0 20px;
}

.help-article h2 {
  font-size: 24px;
  margin: 30px 0 14px;
}

.help-article h3 {
  font-size: 18px;
  margin: 22px 0 10px;
}

.help-article p,
.help-article li {
  color: var(--text);
  line-height: 1.75;
  font-size: 16px;
}

.help-article ul,
.help-article ol {
  padding-left: 22px;
}

.help-article code {
  background: rgba(15, 23, 42, 0.06);
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 0.95em;
}

.help-article hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

.help-article blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  background: rgba(47, 138, 124, 0.08);
  border-radius: 0 14px 14px 0;
}

.help-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  overflow: hidden;
  border-radius: 16px;
}

.help-article th,
.help-article td {
  border: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

.help-article th {
  background: rgba(47, 138, 124, 0.08);
  font-weight: 700;
}

.help-article img {
  display: block;
  max-width: 100%;
  margin: 18px auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 14px 30px rgba(0,0,0,0.08);
}

.auth-box, .profile-box {
  background: var(--panel);
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--line);
}

.auth-box h2, .profile-box h2 {
  margin-top: 0;
  margin-bottom: 30px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.auth-loading-box {
  text-align: center;
  max-width: 460px;
}

.auth-loading-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(47, 138, 124, 0.1);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-loading-badge::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 rgba(47, 138, 124, 0.35);
  animation: authPulse 1.5s infinite;
}

.auth-loading-title {
  margin: 20px 0 10px;
  font-size: 28px;
  line-height: 1.2;
  color: var(--text);
}

.auth-loading-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 15px;
}

.auth-loading-steps {
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
  text-align: left;
}

.auth-loading-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(248, 251, 248, 0.92) 100%);
  border: 1px solid var(--line);
  color: var(--text);
}

.auth-loading-step::before {
  content: "";
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(47, 138, 124, 0.35);
  animation: authPulse 1.5s infinite;
}

@keyframes authPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(47, 138, 124, 0.35);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(47, 138, 124, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(47, 138, 124, 0);
  }
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--muted);
  font-size: 14px;
}

.input-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
  background: #fff;
}

.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin-top: 16px;
  text-align: center;
  min-height: 20px;
}

.system-inline-error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, white);
  border: 1px solid color-mix(in srgb, var(--danger) 20%, white);
  border-radius: 12px;
  padding: 12px 14px;
  line-height: 1.5;
}

.system-state-card {
  max-width: 720px;
  margin: 48px auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 18px;
}

.system-state-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 14%, white);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
}

.system-state-copy h3 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.15;
  color: var(--text-primary);
}

.system-state-copy p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.65;
  font-size: 16px;
}

.system-state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.profile-info {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.profile-info p {
  margin: 12px 0;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.profile-info p:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.profile-info strong {
  color: var(--muted);
}

/* Global Nav Layout */
.main-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.global-nav {
  position: relative;
  z-index: 100;
  width: 64px;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 16px;
  flex-shrink: 0;
}

.nav-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-btn:active {
  transform: scale(0.9);
  transition: all 0.1s;
}

.nav-btn::after {
  content: attr(data-title);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 10px;
  background: #1e293b;
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--line);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  transition-delay: 0s;
  z-index: 110;
}

.nav-btn:hover::after,
.nav-btn:focus-visible::after {
  opacity: 1;
  transition-delay: 0.35s;
}

.nav-btn:hover {
  background: rgba(47, 138, 124, 0.08);
  color: var(--accent);
}

.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.example-card:hover .example-actions {
  visibility: visible;
}
.example-actions .action-btn {
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.6;
  font-size: 14px;
}
.example-actions .action-btn:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.05);
}


/* Chat Drawer Styles */
.chat-drawer {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
  display: flex;
  flex-direction: column;
}

.chat-drawer.open {
  right: 0;
}

.chat-header {
  padding: 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
}

.chat-header h3 {
  margin: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-chat-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
}

.close-chat-btn:hover {
  color: var(--text);
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f9fafb;
}

.chat-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.clause-chat-menu {
  position: fixed;
  z-index: 2600;
  min-width: 260px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(42, 157, 143, 0.22);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.clause-chat-menu.hidden {
  display: none;
}

.clause-chat-menu-item {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.clause-chat-menu-item:hover {
  background: rgba(42, 157, 143, 0.12);
  color: var(--accent-strong);
}

.clause-chat-menu-item:active {
  transform: translateY(1px);
}

.chat-input-area {
  padding: 20px;
  border-top: 1px solid var(--line);
  background: #fff;
  display: flex;
  gap: 10px;
}

.chat-input-area input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  outline: none;
  font-family: inherit;
}

.chat-input-area input:focus {
  border-color: var(--accent);
}

.chat-send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.chat-send-btn:hover {
  opacity: 0.9;
}

.chat-send-btn:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
}

.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.2);
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.chat-overlay.visible {
  display: block;
  opacity: 1;
}

/* Floating button to open chat */
.open-chat-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.3);
  cursor: pointer;
  z-index: 9998;
  transition: transform 0.2s;
}

.open-chat-fab:hover {
  transform: scale(1.05);
}

.chat-clause-link {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-clause-link:hover {
  color: var(--primary-hover);
  text-decoration-style: solid;
}

/* Inline Premium Button */
.inline-premium-btn {
    border-radius: 50px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.01em;
    border: none;
    box-shadow: 0 4px 15px -3px rgba(2, 132, 199, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.inline-premium-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(2, 132, 199, 0.5);
}

.inline-premium-btn:active {
    transform: translateY(0);
}

/* Jump Top Pill */
.jump-top-pill {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 9999;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.jump-top-pill:hover {
    background: var(--surface-hover);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

/* Markdown Table Styles */
.clause-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.4;
}
.clause-text table th,
.clause-text table td {
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.clause-text table th {
  background-color: var(--surface-bg);
  font-weight: 600;
}
.clause-text p {
  margin-top: 0;
  margin-bottom: 8px;
}
.clause-text p:last-child {
  margin-bottom: 0;
}

.smart-clause table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.4;
}
.smart-clause table th,
.smart-clause table td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.smart-clause table th {
  background-color: var(--bg);
  font-weight: 600;
}
.smart-clause p {
  margin-top: 0;
  margin-bottom: 8px;
}
.smart-clause p:last-of-type {
  margin-bottom: 0;
}

/* Custom Combobox Dropdown */
.custom-combobox-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-top: 4px;
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}
.custom-combobox-item {
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--line);
}
.custom-combobox-item:last-child {
  border-bottom: none;
}
.custom-combobox-item:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.custom-combobox-dropdown.hidden {
  display: none;
}

/* Sharing & Read-only Mode */
.mode-readonly .clause-edit-btn,
.mode-readonly .clause-action-btn,
.mode-readonly .missing-clause-add-btn,
.mode-readonly .inline-edit-toolbar,
.mode-readonly .redaction-actions,
.mode-readonly .document-build-trigger,
.mode-readonly #openShareModalBtn {
  display: none !important;
}

.mode-readonly input,
.mode-readonly textarea,
.mode-readonly select {
  pointer-events: none;
}

.author-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
}

/* Document Section Accordions */
.accordion-section {
  margin-bottom: 16px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.accordion-header {
  padding: 12px 16px;
  background: #f8f9fa;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background-color 0.2s ease;
}
.accordion-header:hover {
  background: #f1f3f5;
}
.accordion-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #2b3035;
}
.accordion-icon {
  font-size: 12px;
  color: #6c757d;
  transition: transform 0.2s ease;
}
.accordion-content {
  display: none;
  padding: 16px;
  background: #fff;
}
.accordion-section.open .accordion-content {
  display: block;
}
.accordion-section.open .accordion-header {
  border-bottom: 1px solid #e9ecef;
}
.accordion-section.open .accordion-icon {
  transform: rotate(180deg);
}
