:root {
  --text: #162033;
  --muted: #65738a;
  --faint: #8a97aa;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #eef3f8;
  --line: #d8e1ec;
  --line-strong: #c2cedc;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #e6f5f2;
  --nav: #0c1424;
  --nav-soft: #152033;
  --nav-line: rgba(226, 232, 240, 0.14);
  --green: #0f766e;
  --gold: #a16207;
  --red: #b42318;
  --shadow: 0 22px 56px rgba(15, 23, 42, 0.09);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.07);
  --content-max: 1280px;
}

* {
  box-sizing: border-box;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, #f9fbfd 0%, var(--bg) 44%, #eef3f8 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.18;
  font-weight: 760;
}

h2 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.22;
  font-weight: 760;
}

h3 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.28;
  font-weight: 720;
}

h4 {
  margin-bottom: 0;
  font-size: 15px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.app-shell {
  --side-panel-width: 292px;
  --left-panel-width: var(--side-panel-width);
  --right-panel-width: var(--side-panel-width);
  display: grid;
  grid-template-columns: var(--left-panel-width) minmax(600px, 1fr) var(--right-panel-width);
  min-height: 100vh;
  transition: grid-template-columns 180ms ease;
}

.app-shell.nav-collapsed {
  --left-panel-width: 72px;
}

.app-shell.ai-collapsed {
  --right-panel-width: 144px;
}

body.foundation-bridge .app-shell {
  grid-template-columns: var(--left-panel-width) minmax(600px, 1fr);
}

body.foundation-bridge:not(.local-ai-debug) .ai-panel {
  display: none;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px 16px;
  color: #dbe7f3;
  background:
    linear-gradient(180deg, rgba(20, 184, 166, 0.08), transparent 24%),
    linear-gradient(180deg, #0d1728 0%, #0a1220 100%);
  border-right: 1px solid var(--nav-line);
  box-shadow: inset -1px 0 0 rgba(15, 23, 42, 0.28);
}

.side-nav .eyebrow {
  color: #8fa1b7;
}

.brand-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  align-items: center;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--nav-line);
}

.brand-mark {
  display: none;
  width: 48px;
  height: 48px;
  place-items: center;
  color: #ccfbf1;
  background: #0b2f2d;
  border: 1px solid rgba(45, 212, 191, 0.38);
  border-radius: 12px;
  font-size: 24px;
  font-weight: 800;
}

.brand-copy h1 {
  margin: 0;
  color: #f8fafc;
}

.brand-copy .eyebrow,
.brand-block .panel-toggle {
  display: none;
}

.panel-heading,
.section-heading,
.topbar,
.action-row,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.module-nav {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.nav-item {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  color: #dbe7f3;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--nav-line);
  border-radius: 10px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.nav-item:hover {
  transform: translateX(3px);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(45, 212, 191, 0.42);
}

.nav-item.active {
  color: #f8fafc;
  background:
    linear-gradient(90deg, rgba(20, 184, 166, 0.30), rgba(15, 118, 110, 0.18));
  border-color: rgba(45, 212, 191, 0.62);
  box-shadow: inset 3px 0 0 #2dd4bf;
}

.nav-item strong {
  display: block;
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.35;
}

.growth-panel,
.connector-card,
.law-box {
  margin-top: 16px;
  padding: 15px;
  border-radius: 12px;
}

.growth-panel {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--nav-line);
  border-radius: 10px;
}

.growth-panel p {
  margin-bottom: 14px;
  color: #aab8ca;
  font-size: 13px;
  line-height: 1.72;
}

.growth-panel .panel-heading strong {
  color: #ccfbf1;
}

.workbench {
  min-width: 0;
  overflow: auto;
  padding: 26px 28px;
  background:
    radial-gradient(circle at 24px 24px, rgba(15, 118, 110, 0.05), transparent 280px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.50), rgba(239, 246, 255, 0.42));
}

.workbench > * {
  width: min(100%, var(--content-max));
  margin-left: auto;
  margin-right: auto;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 22px;
  align-items: start;
  padding: 22px 24px 20px;
  background:
    linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.topbar-copy {
  min-width: 0;
}

.topbar-lead {
  max-width: 650px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.status-rail {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 8px;
  margin: 2px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}

.status-item {
  display: inline-flex;
  min-width: 0;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.status-item dt {
  display: flex;
  gap: 7px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-item dt::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--accent);
  border-radius: 999px;
}

.status-item dd {
  margin: 0;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}

.status-item small {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
  white-space: nowrap;
}

.primary-btn {
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.22);
}

.secondary-btn {
  padding: 0 18px;
  color: var(--text);
  background: var(--surface);
  border-color: var(--line-strong);
}

.ghost-btn {
  padding: 0 16px;
  color: var(--accent-dark);
  background: transparent;
  border-color: var(--line);
}

.icon-btn {
  display: inline-grid;
  width: 40px;
  padding: 0;
  place-items: center;
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
  font-size: 20px;
}

.panel-toggle {
  flex: 0 0 auto;
}

.side-nav .icon-btn {
  color: #dbe7f3;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--nav-line);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.primary-btn:active,
.secondary-btn:active,
.ghost-btn:active,
.icon-btn:active,
.nav-item:active,
.table-action:active,
.suggestions button:active {
  transform: translateY(1px);
}

.app-shell.nav-collapsed .side-nav {
  overflow: hidden;
  padding: 18px 10px;
}

.app-shell.nav-collapsed .brand-block {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 10px;
}

.app-shell.nav-collapsed .module-nav,
.app-shell.nav-collapsed .growth-panel {
  display: none;
}

.app-shell.nav-collapsed .brand-copy {
  display: block;
}

.app-shell.nav-collapsed .brand-mark {
  width: 42px;
  height: 42px;
  font-size: 21px;
}

.app-shell.ai-collapsed .ai-panel {
  overflow: hidden;
  padding: 18px 8px;
  background:
    linear-gradient(180deg, rgba(20, 184, 166, 0.08), transparent 28%),
    linear-gradient(180deg, #0d1728 0%, #0a1220 100%);
  border-left-color: rgba(226, 232, 240, 0.14);
  box-shadow: inset 1px 0 0 rgba(15, 23, 42, 0.28);
}

.app-shell.ai-collapsed .ai-panel header {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom-color: rgba(226, 232, 240, 0.14);
}

.app-shell.ai-collapsed .ai-panel .icon-btn {
  width: 144px;
  min-height: 144px;
  padding: 0;
  color: transparent;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.app-shell.ai-collapsed .ai-panel::after {
  display: none;
  content: "";
}

.panel-toggle-arrow {
  line-height: 1;
}

.panel-toggle .performance-cat-face {
  display: none;
}

.app-shell.ai-collapsed .panel-toggle-arrow {
  display: none;
}

.app-shell.ai-collapsed .panel-toggle .performance-cat-face {
  display: block;
}

.app-shell.ai-collapsed .panel-toggle:hover .performance-cat-face {
  filter: drop-shadow(0 10px 18px rgba(29, 144, 240, 0.16));
  transform: translateY(-1px);
}

.app-shell.ai-collapsed .panel-toggle:active .performance-cat-face {
  transform: scale(0.96);
}

.performance-cat-face {
  --performance-cat-size: 92px;
  --performance-cat-image-scale: 1.78;
  --performance-cat-image-y: 6.8%;
  --eye-x: 0px;
  --eye-y: 0px;
  position: relative;
  z-index: 0;
  display: block;
  width: var(--performance-cat-size);
  height: var(--performance-cat-size);
  overflow: visible;
  background: transparent;
  transform-origin: center;
  transition:
    filter 160ms ease,
    transform 120ms ease;
}

.performance-cat-face::before {
  position: absolute;
  inset: -10%;
  z-index: -1;
  border-radius: 50%;
  opacity: 0;
  box-shadow:
    0 0 calc(var(--performance-cat-size) * 0.16) rgba(63, 171, 255, 0.22),
    0 0 calc(var(--performance-cat-size) * 0.28) rgba(63, 171, 255, 0.12);
  content: "";
  pointer-events: none;
}

.app-shell.ai-answering.ai-collapsed .performance-cat-face::before {
  animation: performance-cat-answering-glow 1.7s ease-in-out infinite;
}

.performance-cat-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  transform: translateY(var(--performance-cat-image-y)) scale(var(--performance-cat-image-scale));
  transform-origin: center;
}

.performance-cat-eye {
  position: absolute;
  z-index: 2;
  top: 48.5%;
  width: calc(var(--performance-cat-size) * 0.125);
  height: calc(var(--performance-cat-size) * 0.125);
  border: 1px solid rgba(16, 24, 39, 0.82);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 54%, #fff 0 58%, #eef6ff 59% 75%, #cfdff3 100%);
  box-shadow:
    0 calc(var(--performance-cat-size) * 0.008) 0 rgba(64, 92, 128, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

.performance-cat-eye::after {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  content: "";
}

.performance-cat-pupil {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 68%;
  height: 68%;
  pointer-events: none;
  transform: translate(calc(-50% + var(--eye-x)), calc(-50% + var(--eye-y)));
  /* 瞳孔由脚本逐帧定位，取消过渡可避免眨眼后跟随动作发黏。 */
  transition: none;
  will-change: transform;
}

.performance-cat-pupil::before,
.performance-cat-pupil::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.performance-cat-pupil::before {
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 27%, #fff 0 14%, rgba(255, 255, 255, 0) 15%),
    radial-gradient(circle at 50% 58%, #152035 0 30%, #6681ad 31% 64%, #2e456d 65% 100%);
  box-shadow:
    0 0 0 1px rgba(13, 21, 35, 0.76),
    inset calc(var(--performance-cat-size) * -0.012) calc(var(--performance-cat-size) * -0.016) calc(var(--performance-cat-size) * 0.026) rgba(10, 18, 32, 0.32);
  transform: translateX(0);
}

.performance-cat-pupil::after {
  top: 16%;
  left: 18%;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
}

.app-shell.ai-answering.ai-collapsed .performance-cat-pupil::before {
  animation: performance-cat-answering-pupil 1.25s ease-in-out infinite;
}

.performance-cat-eye::after {
  z-index: 3;
  top: calc(var(--performance-cat-size) * -0.008);
  right: calc(var(--performance-cat-size) * -0.008);
  bottom: calc(var(--performance-cat-size) * -0.008);
  left: calc(var(--performance-cat-size) * -0.008);
  width: auto;
  height: auto;
  border-radius: 50%;
  background:
    linear-gradient(to bottom, #fff 0 40%, #fafdff 41% 44%, #35aefe 45% 56%, #fafdff 57% 60%, #fff 61% 100%);
  transform: scaleY(0);
  transform-origin: center;
  animation: performance-cat-blink 5s ease-in-out infinite;
}

.performance-cat-eye.left {
  left: 26.2%;
}

.performance-cat-eye.right {
  right: 26.2%;
}

.performance-cat-message-dot {
  position: absolute;
  top: -7%;
  right: -10%;
  z-index: 3;
  width: calc(var(--performance-cat-size) * 0.16);
  height: calc(var(--performance-cat-size) * 0.16);
  min-width: 7px;
  min-height: 7px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 3px 8px rgba(238, 45, 42, 0.28);
  opacity: 0;
  transform: scale(0.45);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.app-shell.ai-has-unread.ai-collapsed .performance-cat-message-dot {
  opacity: 1;
  transform: scale(1);
}

.app-shell.ai-collapsed .ai-copy,
.app-shell.ai-collapsed .model-pill,
.app-shell.ai-collapsed .assistant-context,
.app-shell.ai-collapsed .chat-log,
.app-shell.ai-collapsed .suggestions,
.app-shell.ai-collapsed .chat-form,
.app-shell.ai-collapsed .connector-card {
  display: none;
}

.subproject-board,
.evidence-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.subproject-board {
  margin-top: 18px;
  margin-bottom: 18px;
  padding: 20px 22px;
}

.section-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.workflow-table-wrap {
  overflow: auto;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.workflow-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.workflow-table th,
.workflow-table td {
  padding: 9px 7px;
  border: 1px solid var(--line);
  vertical-align: middle;
  word-break: break-word;
}

.workflow-table th {
  color: #334155;
  background: var(--surface-strong);
  font-weight: 800;
  text-align: left;
}

.workflow-table tr {
  background: var(--surface);
}

.workflow-table tr.active {
  background: #fbfdff;
}

.workflow-table td.readonly-cell {
  background: #f8fbfd;
}

.table-action,
.table-info {
  display: grid;
  gap: 7px;
  align-content: center;
  width: 100%;
  min-height: 66px;
  padding: 10px;
  color: var(--text);
  text-align: left;
  border-radius: 12px;
}

.table-action {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.table-info {
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.table-action:hover {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
}

.table-action strong,
.table-info strong {
  display: block;
  color: inherit;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.table-flow-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.table-flow-status {
  margin-top: 6px;
  font-size: 14px !important;
  font-weight: 800;
}

.table-flow-status.waiting {
  color: #0f766e;
}

.table-flow-status.pending {
  color: #1d4ed8;
}

.table-flow-status.success {
  color: #047857;
}

.table-flow-status.withdrawn {
  color: #b91c1c;
}

.evidence-panel {
  min-width: 0;
  padding: 22px;
}

.evidence-panel {
  margin-top: 18px;
  margin-bottom: 22px;
}

.evidence-launcher {
  display: grid;
  gap: 18px;
}

.status-pill,
.score-badge,
.model-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.info-table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.info-table th,
.info-table td {
  padding: 11px;
  border: 1px solid var(--line);
  vertical-align: top;
  word-break: break-word;
}

.info-table th {
  width: 118px;
  color: #334155;
  background: var(--surface-strong);
  text-align: left;
}

.action-row {
  margin-top: 20px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

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

.evidence-intel-grid article,
.evidence-window-summary section {
  min-width: 0;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.evidence-intel-grid span,
.evidence-window-summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.evidence-intel-grid strong,
.evidence-window-summary strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.evidence-action-strip {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.evidence-action-strip p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.evidence-window-summary {
  display: grid;
  grid-template-columns: 0.75fr 1fr 1.45fr;
  gap: 10px;
  margin: 16px 0;
}

.evidence-window-list {
  display: grid;
  gap: 10px;
}

.evidence-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(220px, 1fr) minmax(260px, 1.2fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.evidence-row.ready {
  background: rgba(15, 118, 110, 0.05);
  border-color: rgba(15, 118, 110, 0.22);
}

.evidence-row.attention {
  background: rgba(161, 98, 7, 0.06);
  border-color: rgba(161, 98, 7, 0.20);
}

.evidence-row strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.evidence-row p,
.evidence-row small {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.evidence-state {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.evidence-row.attention .evidence-state {
  color: var(--gold);
  background: #fef3c7;
}

.evidence-law-box {
  margin-top: 14px;
}

.law-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
  margin-top: 12px;
  padding: 14px;
  color: var(--text);
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.law-title {
  font-weight: 800;
  line-height: 1.5;
}

.law-box ul {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 10px;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.law-box li {
  min-width: 0;
  padding-left: 12px;
  border-left: 3px solid rgba(15, 118, 110, 0.24);
}

.ai-panel {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto auto;
  height: 100vh;
  padding: 22px 16px;
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-left: 1px solid var(--line);
}

.ai-panel header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.ai-panel h2 {
  font-size: 20px;
  white-space: nowrap;
}

.assistant-context {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 14px 0;
}

.assistant-context div {
  min-height: 80px;
  padding: 13px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.assistant-context span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.assistant-context strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.chat-log {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.message {
  max-width: 92%;
  margin-bottom: 10px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  line-height: 1.6;
  font-size: 14px;
}

.message.assistant {
  color: var(--text);
  background: var(--surface-soft);
}

.message.user {
  margin-left: auto;
  color: #ffffff;
  background: var(--nav);
  border-color: var(--nav);
}

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

.suggestions button {
  min-height: 36px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid rgba(15, 118, 110, 0.20);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.chat-form textarea {
  width: 100%;
  resize: none;
  padding: 12px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  line-height: 1.45;
}

.connector-card {
  margin-bottom: 0;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.connector-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.template-dialog,
.subproject-dialog,
.evidence-dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.template-dialog {
  width: min(720px, calc(100vw - 40px));
}

.subproject-dialog {
  position: fixed;
  inset: 20px 20px auto auto;
  width: min(1180px, calc(100vw - 40px));
  height: calc(100vh - 40px);
  min-width: min(760px, calc(100vw - 40px));
  min-height: 560px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  margin: 0;
  overflow: hidden;
  padding: 18px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  resize: both;
}

.subproject-dialog[open] {
  display: grid;
}

.subproject-dialog.maximized {
  inset: 16px;
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  max-width: none;
  max-height: none;
  resize: none;
}

.subproject-resize-handle {
  position: absolute;
  top: 0;
  z-index: 4;
  width: 10px;
  height: 100%;
  cursor: ew-resize;
}

.subproject-resize-handle.left {
  left: -2px;
}

.subproject-resize-handle.right {
  right: -2px;
}

.subproject-dialog.maximized .subproject-resize-handle {
  display: none;
}

.evidence-dialog {
  width: min(1040px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.template-dialog::backdrop,
.subproject-dialog::backdrop,
.evidence-dialog::backdrop,
.signature-flow-dialog::backdrop,
.signature-viewer-dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.signature-flow-dialog {
  position: fixed;
  inset: 28px auto auto 50%;
  width: min(860px, calc(100vw - 48px));
  max-height: calc(100vh - 56px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 26px 80px rgba(15, 23, 42, 0.24);
  transform: translateX(-50%);
}

.signature-flow-dialog[open] {
  display: block;
}

.signature-flow-dialog.maximized {
  inset: 0;
  width: 100vw;
  max-height: none;
  height: 100vh;
  border: 0;
  border-radius: 0;
  transform: none;
}

.signature-flow-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: min(520px, calc(100vh - 56px));
  min-height: 0;
}

.signature-flow-dialog.maximized .signature-flow-shell {
  height: 100vh;
}

.signature-flow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.signature-flow-heading {
  min-width: 0;
}

.signature-flow-heading h3 {
  margin: 0;
  font-size: 20px;
}

.signature-flow-content {
  display: grid;
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 20px;
  background: #f8fafc;
}

.signature-flow-section {
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.signature-flow-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.signature-flow-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.signature-flow-table th,
.signature-flow-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.signature-flow-table th {
  color: #111827;
  background: #f3f6fa;
  white-space: nowrap;
}

.signature-flow-table th:nth-child(1),
.signature-flow-table td:nth-child(1) {
  width: 32%;
}

.signature-flow-table th:nth-child(2),
.signature-flow-table td:nth-child(2) {
  width: 18%;
}

.signature-flow-table th:nth-child(3),
.signature-flow-table td:nth-child(3) {
  width: 50%;
}

.signature-flow-table tr:last-child td {
  border-bottom: 0;
}

.signature-flow-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  background: #ffffff;
  border-top: 1px solid var(--line);
}

.signature-viewer-dialog {
  position: fixed;
  inset: 16px;
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
}

.signature-viewer-dialog[open] {
  display: block;
}

.signature-viewer-dialog.maximized {
  inset: 0;
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.signature-viewer-shell {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.signature-viewer-dialog.pdf-native-mode .signature-viewer-shell {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.signature-viewer-head {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.signature-viewer-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 12px;
  align-items: baseline;
  min-width: 0;
}

.signature-viewer-heading .eyebrow {
  grid-column: 1 / -1;
  margin: 0;
}

.signature-viewer-heading h3 {
  font-size: 18px;
}

.signature-viewer-file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signature-viewer-toolbar {
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 7px 12px;
  overflow-x: auto;
  color: #e5edf5;
  background: #27313d;
  border-bottom: 1px solid #111827;
  scrollbar-width: thin;
}

.signature-viewer-dialog.pdf-native-mode .signature-viewer-toolbar {
  justify-content: flex-end;
}

.signature-viewer-dialog.pdf-native-mode .signature-viewer-toolbar .signature-viewer-tool-group:not(.signature-viewer-file-tools),
.signature-viewer-dialog.pdf-native-mode .signature-viewer-search,
.signature-viewer-dialog.pdf-native-mode .signature-viewer-thumbnails {
  display: none;
}

.signature-viewer-tool-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.signature-viewer-tool-group + .signature-viewer-tool-group {
  padding-left: 10px;
  border-left: 1px solid rgba(226, 232, 240, 0.18);
}

.signature-viewer-toolbar-spacer {
  flex: 1 1 auto;
  min-width: 12px;
}

.signature-viewer-tool,
.signature-viewer-text-tool {
  display: inline-grid;
  place-items: center;
  height: 32px;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  line-height: 1;
}

.signature-viewer-tool {
  width: 32px;
  padding: 0;
  font-size: 20px;
}

.signature-viewer-text-tool {
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.signature-viewer-tool:hover,
.signature-viewer-text-tool:hover,
.signature-viewer-tool[aria-pressed="true"] {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.14);
}

.signature-viewer-tool:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

.signature-viewer-page-field input,
.signature-viewer-zoom-field select {
  height: 30px;
  color: #f8fafc;
  background: #3b4653;
  border: 1px solid rgba(226, 232, 240, 0.2);
  border-radius: 4px;
}

.signature-viewer-page-field input {
  width: 48px;
  padding: 0 6px;
  text-align: center;
}

.signature-viewer-page-field input::-webkit-inner-spin-button,
.signature-viewer-page-field input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.signature-viewer-page-total {
  min-width: 32px;
  color: #cbd5e1;
  font-size: 12px;
}

.signature-viewer-zoom-field select {
  min-width: 108px;
  padding: 0 26px 0 8px;
  font-size: 12px;
}

.signature-viewer-search {
  grid-row: 3;
  display: grid;
  grid-template-columns: auto minmax(180px, 420px) auto auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.signature-viewer-search label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.signature-viewer-search input {
  height: 34px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.signature-viewer-search span {
  min-width: 44px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.signature-viewer-search .signature-viewer-tool {
  color: var(--text);
  border-color: var(--line);
}

.signature-viewer-search .signature-viewer-tool:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: rgba(15, 118, 110, 0.3);
}

.signature-viewer-body {
  grid-row: 4;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.signature-viewer-dialog.pdf-native-mode .signature-viewer-body {
  grid-row: 3;
  grid-template-columns: minmax(0, 1fr);
}

.signature-viewer-dialog.thumbnails-hidden .signature-viewer-body {
  grid-template-columns: minmax(0, 1fr);
}

.signature-viewer-dialog.thumbnails-hidden .signature-viewer-thumbnails {
  display: none;
}

.signature-viewer-thumbnails {
  min-width: 0;
  padding: 14px 12px;
  overflow: auto;
  background: #202a35;
  border-right: 1px solid #111827;
}

.signature-viewer-thumbnail {
  display: grid;
  gap: 7px;
  width: 100%;
  margin: 0 0 14px;
  padding: 7px;
  color: #cbd5e1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  text-align: left;
}

.signature-viewer-thumbnail:hover,
.signature-viewer-thumbnail.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(45, 212, 191, 0.72);
}

.signature-viewer-thumbnail-sheet {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1.414;
  overflow: hidden;
  color: #64748b;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

.signature-viewer-thumbnail span:last-child {
  font-size: 11px;
  text-align: center;
}

.signature-viewer-viewport {
  min-width: 0;
  min-height: 0;
  padding: 24px 36px 40px;
  overflow: auto;
  background: #343d47;
  outline: none;
}

.signature-viewer-dialog.pdf-native-mode .signature-viewer-viewport {
  padding: 0;
  overflow: hidden;
}

.signature-viewer-canvas {
  display: grid;
  place-items: start center;
  min-width: max-content;
  min-height: 100%;
}

.signature-viewer-dialog.pdf-native-mode .signature-viewer-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
}

.signature-viewer-page-frame {
  position: relative;
  flex: 0 0 auto;
}

.signature-viewer-page {
  position: absolute;
  inset: 0 auto auto 0;
  display: none;
  width: 760px;
  min-height: 1075px;
  padding: 76px 72px;
  overflow: hidden;
  color: #303846;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  transform-origin: 0 0;
}

.signature-viewer-page.is-active {
  display: block;
}

.signature-viewer-page.is-pdf {
  padding: 0;
  background: #525b65;
}

.signature-viewer-page.is-message {
  display: block;
}

.signature-viewer-pdf-frame {
  width: 100%;
  height: 1075px;
  border: 0;
  background: #ffffff;
}

.signature-viewer-pdf-native {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 640px;
  border: 0;
  background: #343d47;
}

.signature-viewer-native-message {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 32px;
  color: #e5edf5;
  background: #343d47;
  font-size: 15px;
}

.signature-viewer-native-message.is-error {
  gap: 10px;
  color: #b42318;
  background: #ffffff;
  text-align: center;
}

.signature-viewer-message {
  display: grid;
  align-content: center;
  min-height: 900px;
  gap: 14px;
  color: #475467;
  text-align: center;
}

.signature-viewer-message strong {
  color: #b42318;
  font-size: 26px;
}

.signature-viewer-message p {
  margin: 0;
  font-size: 15px;
}

.signature-viewer-notice {
  display: grid;
  align-content: center;
  min-height: 900px;
  padding: 40px 48px;
  color: #667085;
  font-size: 18px;
  line-height: 2.05;
}

.signature-viewer-notice h2 {
  margin: 0 0 24px;
  color: #f59e0b;
  font-size: 26px;
  font-weight: 500;
  text-align: center;
}

.signature-viewer-notice p {
  margin: 0 0 22px;
  text-indent: 2em;
}

.signature-viewer-document {
  font-size: 15px;
  line-height: 1.85;
}

.signature-viewer-document h2 {
  margin: 0 0 26px;
  color: #111827;
  font-size: 24px;
  text-align: center;
}

.signature-viewer-document-line {
  min-height: 1.85em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.signature-viewer-page mark {
  padding: 0 2px;
  color: inherit;
  background: #fde68a;
  border-radius: 2px;
}

.dialog-head {
  flex: 0 0 auto;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.subproject-dialog .dialog-head {
  cursor: move;
  user-select: none;
}

.dialog-window-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dialog-window-controls button {
  cursor: pointer;
}

.document-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  margin: 16px 0;
  min-height: 0;
  overflow: hidden;
}

.subproject-dialog.signature-manage-mode .document-workspace {
  grid-template-columns: minmax(0, 1fr);
}

.subproject-dialog.signature-manage-mode .document-preview-panel {
  display: none;
}

.subproject-dialog.signature-manage-mode .variable-panel {
  max-width: none;
}

.subproject-dialog.feedback-mode .document-workspace {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.subproject-dialog.communication-mode .document-workspace {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.subproject-dialog.feedback-mode .document-preview-panel,
.subproject-dialog.feedback-mode .variable-panel,
.subproject-dialog.communication-mode .document-preview-panel,
.subproject-dialog.communication-mode .variable-panel {
  background: #f8fafc;
}

.subproject-dialog.communication-mode .document-preview-panel {
  height: auto;
}

.subproject-dialog.communication-mode .document-page {
  min-height: auto;
  max-width: none;
  padding: 24px;
}

.subproject-dialog.feedback-mode .document-preview-panel {
  height: auto;
}

.subproject-dialog.feedback-mode .document-page {
  min-height: auto;
  max-width: none;
  padding: 24px;
}

.feedback-empty-state,
.feedback-summary-panel,
.communication-upload-state,
.communication-file-state {
  display: grid;
  gap: 18px;
  min-height: 100%;
  padding: 18px;
}

.feedback-empty-state {
  align-content: center;
  color: var(--muted);
  text-align: center;
}

.feedback-empty-state span,
.feedback-summary-head span,
.communication-upload-state span,
.communication-file-head span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.feedback-empty-state h2,
.feedback-summary-head h2,
.communication-upload-state h2,
.communication-file-head h2 {
  margin: 0;
  color: #111827;
  font-size: 24px;
}

.feedback-empty-state p {
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.8;
}

.feedback-empty-next {
  justify-self: center;
  max-width: 560px;
  padding: 12px 16px;
  color: #0f5fd6;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-weight: 700;
}

.communication-upload-state {
  align-content: center;
  color: var(--muted);
  text-align: center;
}

.communication-upload-state p {
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.8;
}

.communication-upload-box,
.communication-file-card {
  justify-self: stretch;
  padding: 18px;
  background: #ffffff;
  border: 1px dashed #8ddfd3;
  border-radius: 8px;
}

.communication-upload-box {
  display: grid;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
  color: var(--accent-dark);
}

.communication-upload-box small {
  color: var(--muted);
  line-height: 1.6;
}

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

.communication-file-card {
  border-style: solid;
  border-color: var(--line);
}

.communication-file-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.communication-file-card dl div {
  display: grid;
  gap: 4px;
}

.communication-file-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.communication-file-card dd {
  margin: 0;
  color: #111827;
  overflow-wrap: anywhere;
}

.communication-preview-text pre {
  max-height: 220px;
}

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

.feedback-status {
  flex: 0 0 auto;
  padding: 6px 10px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid #99f6e4;
  border-radius: 999px;
  font-size: 12px;
}

.feedback-dissent-table-wrap {
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.feedback-dissent-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}

.feedback-dissent-table th,
.feedback-dissent-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.feedback-dissent-table th {
  color: #111827;
  background: #f3f6fa;
  white-space: nowrap;
}

.feedback-dissent-table tr:last-child td {
  border-bottom: 0;
}

.feedback-opinion-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.feedback-opinion-box h3,
.feedback-side-card h4 {
  margin: 0;
  color: #111827;
  font-size: 15px;
}

.feedback-opinion-box pre {
  max-height: 280px;
  margin: 0;
  overflow: auto;
  color: #334155;
  font: inherit;
  line-height: 1.75;
  white-space: pre-wrap;
}

.feedback-side-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.feedback-side-card dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.feedback-side-card dl div {
  display: grid;
  gap: 4px;
}

.feedback-side-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.feedback-side-card dd {
  margin: 0;
  color: #111827;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.feedback-button-data {
  display: grid;
  gap: 8px;
}

.feedback-button-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.feedback-button-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.feedback-button-row strong {
  color: #111827;
}

.feedback-button-row small {
  color: var(--muted);
  line-height: 1.5;
}

.feedback-button-row.disabled {
  opacity: 0.68;
}

.document-preview-panel {
  min-height: 0;
  height: 100%;
  overflow: auto;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.document-page {
  min-height: 760px;
  max-width: 760px;
  margin: 0 auto;
  padding: 36px 42px;
  color: #111827;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.08);
}

.document-page h2 {
  margin: 0 0 24px;
  font-size: 24px;
  text-align: center;
}

.document-page p {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.75;
}

.document-space {
  height: 12px;
}

.variable-panel {
  position: static;
  align-self: start;
  height: 100%;
  max-height: none;
  overflow: auto;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}

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

.variable-panel-head span,
.variable-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.variable-panel-head strong {
  color: var(--accent-dark);
  font-size: 12px;
}

.variable-form {
  display: grid;
  gap: 10px;
}

.variable-form label {
  display: grid;
  gap: 6px;
}

.variable-form input,
.variable-form select,
.variable-form textarea {
  width: 100%;
  padding: 10px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  line-height: 1.45;
}

.variable-form textarea {
  resize: vertical;
}

.signature-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.signature-status-pill.pending {
  color: #0f5fd6;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.signature-status-pill.success {
  color: #047857;
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.signature-status-pill.withdrawn {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.signature-table-wrap {
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.signature-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 12px;
}

.signature-table th {
  padding: 12px 10px;
  color: #111827;
  background: #f3f6fa;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.signature-table td {
  padding: 14px 10px;
  color: #4b5563;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

.signature-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 999px;
  vertical-align: middle;
}

.signature-dot.pending {
  background: #2f80ed;
}

.signature-dot.success {
  background: #31c754;
}

.signature-dot.withdrawn {
  background: #ef4444;
}

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

.signature-actions button {
  padding: 0;
  color: #1677ff;
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.signature-actions button:hover {
  color: #0f5fd6;
}

.signature-action-static {
  color: var(--muted);
  font-size: 12px;
}

.signature-flow-line {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.template-content {
  max-height: 58vh;
  overflow: auto;
  margin: 16px 0;
  padding: 18px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.custom-template-box {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.template-file-picker {
  display: grid;
  place-items: center;
  min-height: 96px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px dashed rgba(15, 118, 110, 0.45);
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
}

.template-file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.template-status {
  color: var(--muted);
  font-size: 13px;
}

.dialog-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

body:has(.subproject-dialog[open]),
body:has(.signature-viewer-dialog[open]) {
  overflow: hidden;
}

.toast {
  position: fixed;
  right: 382px;
  bottom: 20px;
  z-index: 10;
  max-width: 360px;
  padding: 12px 14px;
  color: #ffffff;
  background: var(--nav);
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes performance-cat-blink {
  0%,
  88%,
  92%,
  96%,
  100% {
    transform: scaleY(0);
  }

  90% {
    transform: scaleY(1);
  }

  94% {
    transform: scaleY(0.72);
  }
}

@keyframes performance-cat-answering-pupil {
  0%,
  100% {
    transform: translateX(calc(var(--performance-cat-size) * -0.012));
  }

  50% {
    transform: translateX(calc(var(--performance-cat-size) * 0.014));
  }
}

@keyframes performance-cat-answering-glow {
  0%,
  100% {
    opacity: 0.18;
  }

  50% {
    opacity: 0.42;
  }
}

@media (max-width: 1260px) {
  .app-shell {
    --side-panel-width: 250px;
    grid-template-columns: var(--left-panel-width) minmax(520px, 1fr) var(--right-panel-width);
  }

  .app-shell.nav-collapsed {
    --left-panel-width: 72px;
  }

  .app-shell.ai-collapsed {
    --right-panel-width: 144px;
  }

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

  .evidence-window-summary,
  .evidence-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .side-nav,
  .ai-panel {
    position: static;
    height: auto;
    border-width: 0 0 1px;
  }

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

  .workbench {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .dialog-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .primary-btn {
    flex: 1;
  }

  .evidence-intel-grid {
    grid-template-columns: 1fr;
  }

  .evidence-action-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-panel {
    display: block;
  }

  .chat-log {
    max-height: 420px;
  }

  .toast {
    right: 18px;
    left: 18px;
  }
}

@media (max-width: 620px) {
  .module-nav,
  .assistant-context,
  .suggestions,
  .chat-form {
    grid-template-columns: 1fr;
  }

  .brand-block {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    font-size: 21px;
  }

  h1 {
    font-size: 19px;
  }

  h2 {
    font-size: 21px;
  }

  h3 {
    font-size: 18px;
  }

  .workbench,
  .side-nav,
  .ai-panel {
    padding: 14px;
  }

  .topbar,
  .subproject-board,
  .evidence-panel {
    border-radius: 14px;
  }

  .law-box,
  .law-box ul {
    grid-template-columns: 1fr;
  }

  .action-row,
  .dialog-actions,
  .evidence-action-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .subproject-dialog.feedback-mode .document-workspace {
    grid-template-columns: 1fr;
  }

  .subproject-dialog.communication-mode .document-workspace {
    grid-template-columns: 1fr;
  }

  .document-preview-panel {
    min-height: auto;
    padding: 10px;
  }

  .document-page {
    min-height: 560px;
    padding: 24px 18px;
  }

  .variable-panel {
    position: static;
    max-height: none;
  }

  .feedback-summary-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .subproject-dialog .dialog-head {
    align-items: center;
    flex-direction: row;
  }

  .feedback-empty-state,
  .feedback-summary-panel {
    padding: 12px;
  }

  .subproject-dialog.feedback-mode .document-page {
    padding: 16px 12px;
  }

  .subproject-dialog.communication-mode .document-page {
    padding: 16px 12px;
  }

  .communication-file-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .communication-file-card dl {
    grid-template-columns: 1fr;
  }

  .feedback-dissent-table {
    min-width: 0;
  }

  .feedback-dissent-table thead {
    display: none;
  }

  .feedback-dissent-table,
  .feedback-dissent-table tbody,
  .feedback-dissent-table tr,
  .feedback-dissent-table td {
    display: block;
  }

  .feedback-dissent-table tr {
    padding: 10px;
  }

  .feedback-dissent-table td {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 8px;
    padding: 7px 0;
    border-bottom: 0;
  }

  .feedback-dissent-table td::before {
    color: var(--muted);
    font-weight: 800;
    content: attr(data-label);
  }

  .evidence-dialog {
    width: calc(100vw - 28px);
    max-height: calc(100vh - 28px);
  }

  .evidence-dialog .dialog-head {
    align-items: center;
    flex-direction: row;
  }

  .signature-flow-dialog {
    inset: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    transform: none;
  }

  .signature-flow-shell {
    height: calc(100vh - 16px);
  }

  .signature-flow-head {
    align-items: center;
    min-height: 60px;
    padding: 10px 12px;
  }

  .signature-flow-heading h3 {
    font-size: 17px;
  }

  .signature-flow-content {
    padding: 12px;
  }

  .signature-flow-actions {
    padding: 12px;
  }

  .signature-viewer-dialog {
    inset: 8px;
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }

  .signature-viewer-head {
    align-items: center;
    min-height: 58px;
    padding: 8px 10px;
  }

  .signature-viewer-heading {
    display: block;
  }

  .signature-viewer-heading .eyebrow,
  .signature-viewer-file-name {
    display: none;
  }

  .signature-viewer-heading h3 {
    font-size: 16px;
  }

  .signature-viewer-toolbar {
    gap: 6px;
    padding: 6px 8px;
  }

  .signature-viewer-file-tools {
    padding-right: 6px;
  }

  .signature-viewer-search {
    grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  }

  .signature-viewer-search label {
    display: none;
  }

  .signature-viewer-body {
    grid-template-columns: 102px minmax(0, 1fr);
  }

  .signature-viewer-thumbnails {
    padding: 10px 8px;
  }

  .signature-viewer-viewport {
    padding: 14px 16px 28px;
  }

  .action-row button,
  .dialog-actions button,
  .signature-flow-actions button,
  .evidence-action-strip button,
  .chat-form button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
