:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #12161d;
  --panel-strong: #171d26;
  --line: #27313f;
  --line-soft: #1d2531;
  --text: #f4f7fb;
  --muted: #9ba8b8;
  --accent: #29d3a2;
  --accent-strong: #14b889;
  --danger: #ff5d5d;
  --warning: #f6bf4f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 18% 12%, rgba(41, 211, 162, 0.14), transparent 26rem), var(--bg);
  color: var(--text);
}

body.review-body {
  height: 100vh;
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
}

.review-shell-layout {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.review-shell {
  width: min(1320px, calc(100% - 32px));
}

.site-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(41, 211, 162, 0.45);
  border-radius: 8px;
  background: rgba(41, 211, 162, 0.12);
  color: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.muted,
.limit,
.label,
.file-meta,
.panel-head span:last-child {
  color: var(--muted);
}

.header-links {
  display: flex;
  justify-self: center;
  gap: 10px;
}

.header-links a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--muted);
}

.header-auth {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--muted);
}

.header-account {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
  min-width: 0;
}

.header-user {
  max-width: 230px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-links a:hover,
.header-links a:focus-visible,
.header-links a.active-nav,
.header-auth:hover,
.header-auth:focus-visible {
  border-color: rgba(41, 211, 162, 0.5);
  color: var(--text);
}

.header-links a.active-nav {
  background: rgba(41, 211, 162, 0.12);
  color: var(--accent);
}

.disabled-link {
  pointer-events: none;
  opacity: 0.55;
}

.hero {
  display: grid;
  grid-template-columns: minmax(440px, 0.9fr) minmax(420px, 1.1fr);
  gap: 36px;
  align-items: center;
  min-height: calc(100vh - 82px);
  padding-top: 16px;
  padding-bottom: 16px;
}

.home-paired-list {
  max-height: 460px;
}

.hero-left {
  display: grid;
  gap: 22px;
}

.hero-copy {
  max-width: 620px;
}

.eyebrow,
.label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 14px 0 18px;
  font-size: clamp(2.55rem, 5.3vw, 5.2rem);
  line-height: 1;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
}

.workspace,
.panel,
dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 22, 29, 0.92);
  box-shadow: var(--shadow);
}

.workspace {
  padding: 20px;
}

.compact-workspace {
  border: 0;
  border-radius: 0;
  padding: 16px 18px;
  background: #10151d;
  box-shadow: none;
}

.visual-preview {
  min-width: 0;
}

.preview-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  border: 1px solid rgba(41, 211, 162, 0.45);
  border-radius: 8px;
  padding: 0 22px;
  background: var(--accent);
  color: #04110d;
  font-size: 1.02rem;
  font-weight: 850;
  box-shadow: 0 18px 50px rgba(41, 211, 162, 0.18);
}

.hero-cta {
  justify-self: start;
  margin-top: 4px;
}

.preview-cta-arrow {
  font-size: 1.18rem;
  line-height: 1;
}

.preview-cta:hover {
  background: #3ee2b3;
}

.preview-window {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e1218;
  box-shadow: var(--shadow);
}

.preview-window::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(41, 211, 162, 0.12), transparent 34%), radial-gradient(circle at 80% 10%, rgba(255, 93, 93, 0.12), transparent 20rem);
  pointer-events: none;
}

.window-bar {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #151b24;
}

.window-bar span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6a7484;
}

.window-bar span:first-child {
  background: var(--danger);
}

.window-bar span:nth-child(2) {
  background: var(--warning);
}

.window-bar span:nth-child(3) {
  background: var(--accent);
}

.review-file {
  position: relative;
  padding: 18px 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.8;
}

.file-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  min-height: 34px;
  padding: 0 20px 0 0;
  color: #dce5ef;
}

.line-no {
  user-select: none;
  color: #697688;
  text-align: right;
}

.file-row.issue {
  border-left: 3px solid transparent;
}

.file-row.issue.medium {
  border-color: var(--warning);
  background: rgba(246, 191, 79, 0.08);
}

.file-row.issue.high {
  border-color: var(--danger);
  background: rgba(255, 93, 93, 0.09);
}

.file-row.issue span:last-child {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

.file-row.issue.medium span:last-child {
  text-decoration-color: var(--warning);
}

.file-row.issue.high span:last-child {
  text-decoration-color: var(--danger);
}

.review-note {
  position: relative;
  display: grid;
  gap: 4px;
  margin: 0 18px 18px;
  border: 1px solid rgba(255, 93, 93, 0.3);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 93, 93, 0.1);
}

.review-note span {
  color: var(--muted);
}

.toolbar,
.actions,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.compact-toolbar {
  align-items: flex-end;
}

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

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 180px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment.active {
  background: var(--accent);
  color: #04110d;
  font-weight: 800;
}

.upload-zone {
  display: grid;
  min-height: 172px;
  margin: 22px 0 14px;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 1px dashed #3d4a5d;
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.compact-drop {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 0;
  place-items: unset;
  align-content: unset;
  justify-content: center;
  gap: 10px;
  border: 0;
  background: transparent;
}

.compact-drop .upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  padding: 0 18px;
  line-height: 1;
}

.compact-drop span {
  display: inline-flex;
  align-items: center;
  height: 44px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  white-space: nowrap;
}

.upload-zone.dragging {
  border-color: var(--accent);
  background: rgba(41, 211, 162, 0.1);
  transform: translateY(-1px);
}

.upload-zone strong {
  color: var(--text);
  font-size: 1.25rem;
}

.upload-button,
.primary-action,
.dialog-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  background: #0f1319;
  color: var(--text);
  cursor: pointer;
}

.primary-action {
  border-color: transparent;
  background: var(--accent);
  color: #04110d;
  font-weight: 800;
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.progress-wrap {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #202936;
  opacity: 0;
}

.progress-wrap.active {
  opacity: 1;
}

.progress-bar {
  width: 35%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: loading 1s ease-in-out infinite;
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  margin: 14px 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  outline: none;
  background: #0f1319;
  color: var(--text);
  line-height: 1.55;
}

textarea:focus {
  border-color: rgba(41, 211, 162, 0.72);
}

.contract-input {
  display: block;
  min-height: 100%;
  max-height: 100%;
  overflow: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  background: #0d1117;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
  outline: none;
}

.contract-input:focus {
  border-color: var(--line);
  box-shadow: inset 0 0 0 1px rgba(41, 211, 162, 0.24);
}

.contract-input:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.review-topbar {
  display: grid;
  grid-template-columns: 190px minmax(320px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 4px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(18, 22, 29, 0.92);
  box-shadow: 0 16px 52px rgba(0, 0, 0, 0.28);
}

.review-progress {
  margin-bottom: 10px;
}

.review-meta {
  min-height: 22px;
  margin-bottom: 12px;
}

.account-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(18, 22, 29, 0.78);
  color: var(--muted);
  font-size: 0.92rem;
}

.account-strip strong {
  color: var(--text);
}

.account-strip a,
.upgrade-callout a {
  color: var(--accent);
  font-weight: 800;
}

.paired-review {
  min-height: 0;
  padding-bottom: 0;
}

.review-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.review-page {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-height: 0;
  height: 100%;
  padding-bottom: 12px;
  overflow: hidden;
}

.paired-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  height: 100%;
}

.hidden {
  display: none;
}

.panel {
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 29, 38, 0.8);
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-left: 0;
  min-width: 0;
}

.panel-actions .primary-action {
  height: 44px;
  min-height: 44px;
}

.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #0f1319;
  color: var(--muted);
  cursor: pointer;
}

.secondary-action:hover,
.secondary-action:focus-visible {
  border-color: rgba(41, 211, 162, 0.45);
  color: var(--text);
}

.pair-header,
.review-pair {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.8fr);
  column-gap: 50px;
}

.pair-header {
  border-bottom: 1px solid var(--line);
  background: #0f141b;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pair-header span {
  padding: 12px 16px;
}

.pair-header span:first-child,
.pair-source {
  border-right: 0;
}

.pair-header small {
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: none;
}

.paired-list {
  position: relative;
  max-height: none;
  height: 100%;
  overflow: hidden;
  background: #0d1117;
  padding: 0;
  font-size: 14px;
}

.paired-list.is-streaming,
.paired-list.is-preparing-merge {
  overflow: hidden;
}

.paired-list.is-merging,
.paired-list.is-merged {
  overflow: auto;
}

.stream-overlay {
  position: absolute;
  top: 0;
  right: 0;
  width: calc((100% - 22px) * 2 / 3);
  height: 100%;
  overflow-y: auto; /* 明确指定垂直滚动 */
  overflow-x: hidden;
  z-index: 3;
  border-left: 1px solid rgba(39, 49, 63, 0.72);
  background: rgba(13, 17, 23, 0.98);
  box-shadow: -18px 0 44px rgba(0, 0, 0, 0.18);
  animation: stream-panel-in 280ms ease both;
  scroll-behavior: smooth; /* 平滑滚动 */
}

.stream-overlay.merge-out {
  animation: stream-panel-out 850ms ease both;
}

.streaming-inline {
  padding: 0;
}

.stream-loading {
  display: flex;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.stream-loading span {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(41, 211, 162, 0.24);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 820ms linear infinite;
}

.stream-loading strong {
  color: var(--text);
  font-size: 0.95rem;
}

.streaming-inline.merge-out {
  animation: stream-panel-out 850ms ease both;
}

.review-pair {
  position: relative;
  margin: 0;
  /* border-bottom: 1px solid rgba(39, 49, 63, 0.5); */
}

.input-pair {
  height: 100%;
  min-height: 100%;
  align-items: stretch;
  overflow: hidden;
}

.pair-source,
.pair-analysis {
  min-width: 0;
  padding: 12px 16px;
}

.pair-source {
  overflow: visible;
  position: relative;
  z-index: 3;
}

.pair-analysis {
  display: grid;
  align-content: start;
  gap: 10px;
  position: relative;
  z-index: 4;
  overflow: auto;
}

.input-pair .pair-source,
.input-pair .pair-analysis {
  padding: 0;
}

.input-pair .pair-source {
  border-right: 1px solid var(--line);
  overflow: auto;
}

.input-pair .pair-source,
.input-pair .pair-analysis {
  display: flex;
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

.input-pair .pair-analysis {
  overflow: auto;
}

.input-pair .contract-input,
.input-pair .empty-report,
.input-pair .streaming-inline {
  flex: 1;
  min-height: 100%;
  max-height: none;
  overflow: visible;
}


.merged-fallback .pair-analysis {
  max-height: none;
  overflow: visible;
}

.source-context,
.contract-input {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92rem;
  line-height: 1.5;
  /* white-space: pre-wrap; */
  text-indent: 0;
  text-align: justify;
  text-align-last: left;
  hyphens: auto;
}

.source-context {
  color: #dce5ef;
  width: 100%;
  border-radius: 8px;
  padding: 0;
  position: relative;
  z-index: 1;
}

.source-context.risky {
  padding: 0;
  border: 0;
}

.unmatched-pair .pair-source {
  display: flex;
  align-items: flex-start;
}

.unmatched-source {
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.4;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(15, 20, 27, 0.62);
}

.review-pair.high .analysis-card {
  background: #101721;
}

.review-pair.medium .analysis-card {
  background: #101721;
}

.connection-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

.connection-path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  opacity: 0.72;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: connection-draw 900ms ease forwards;
}

.paired-list.connections-drawn .connection-path {
  stroke-dashoffset: 0;
  animation: none;
}

.connection-path.high {
  stroke: rgba(255, 93, 93, 0.78);
}

.connection-path.medium {
  stroke: rgba(246, 191, 79, 0.78);
}

.connection-path.suggestion {
  stroke: rgba(41, 211, 162, 0.82);
  stroke-width: 2.25;
  opacity: 0.82;
}

.streaming-report {
  padding: 16px;
  color: #d9e1ec;
  line-height: 1.62;
  width: 100%;
}

.risk-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #101721;
  color: #dce5ef;
  font-weight: 700;
}

.analysis-item {
  display: grid;
  gap: 8px;
}

.analysis-card {
  border: 1px solid rgba(39, 49, 63, 0.82);
  border-radius: 8px;
  padding: 12px 14px;
  background: #101721;
  position: relative;
  z-index: 1;
}

.analysis-card.high {
  border-color: rgba(255, 93, 93, 0.24);
  box-shadow: inset 3px 0 0 rgba(255, 93, 93, 0.72);
}

.analysis-card.medium {
  box-shadow: inset 3px 0 0 rgba(246, 191, 79, 0.74);
}

.analysis-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.analysis-title h3 {
  margin: 0;
  border: 0;
  padding: 0;
  font-size: 0.94rem;
  line-height: 1.28;
}

.mini-label {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.severity-label.high {
  color: var(--danger);
}

.severity-label.medium {
  color: var(--warning);
}

.suggestion-box {
  border: 1px solid rgba(41, 211, 162, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(41, 211, 162, 0.11), rgba(20, 29, 31, 0.92));
  box-shadow: inset 3px 0 0 rgba(41, 211, 162, 0.78);
}

.analysis-card p,
.suggestion-box p {
  margin: 5px 0 0;
  line-height: 1.48;
}

.analysis-empty {
  min-height: 1.7em;
}

.empty-report {
  padding: 22px;
  color: var(--muted);
  line-height: 1.7;
}

.paired-list .empty-report {
  display: flex;
}

.empty-report.error {
  color: var(--danger);
}

.upgrade-callout {
  border: 1px solid rgba(246, 191, 79, 0.3);
  border-radius: 8px;
  padding: 16px;
  background: rgba(246, 191, 79, 0.09);
  color: #f2dfb8;
}

.risk-underline {
  border-radius: 2px;
  padding: 1px 3px;
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.source-mark {
  position: relative;
  cursor: help;
  border-radius: 4px;
}

.risk-underline.high {
  background: rgba(255, 93, 93, 0.24);
  text-decoration-color: var(--danger);
}

.risk-underline.medium {
  background: rgba(246, 191, 79, 0.26);
  text-decoration-color: var(--warning);
}

.paired-list.is-merging .review-pair.high,
.paired-list.is-merging .review-pair.medium {
  animation: merge-row-enter 2400ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--merge-index, 0) * 70ms);
}

.paired-list.is-merging .review-pair.high .analysis-card,
.paired-list.is-merging .review-pair.medium .analysis-card {
  animation: merge-block-enter 2400ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--merge-index, 0) * 70ms);
}

.paired-list.is-preparing-merge .streaming-report {
  animation: preparing-merge 850ms ease both;
}

@keyframes stream-panel-in {
  0% {
    opacity: 0;
    transform: translateX(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes stream-panel-out {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-22px) scale(0.985);
  }
}

@keyframes merge-row-enter {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  45% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes merge-block-enter {
  0% {
    clip-path: inset(0 50% 0 50%);
    opacity: 0.1;
  }
  55% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
  100% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

@keyframes connection-draw {
  0% {
    stroke-dashoffset: 1;
    opacity: 0;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0.72;
  }
}

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

@keyframes preparing-merge {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0.24;
    transform: translateX(-10px);
  }
}

.markdown h2,
.markdown h3 {
  letter-spacing: 0;
}

.markdown h2 {
  margin-top: 0;
}

.markdown h3 {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.markdown strong {
  color: var(--text);
}

dialog {
  max-width: 460px;
  color: var(--text);
  padding: 22px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.page-shell {
  width: min(1320px, calc(100% - 32px));
}

.page-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.42fr) minmax(0, 0.58fr);
  gap: 18px;
  padding-bottom: 42px;
}

.page-panel {
  min-height: 520px;
}

.history-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 12px;
}

.history-item {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 12px;
  background: #0f141b;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.history-item:hover {
  border-color: rgba(41, 211, 162, 0.45);
}

.active-history-item {
  border-color: rgba(41, 211, 162, 0.75);
  background: rgba(41, 211, 162, 0.1);
  box-shadow: inset 3px 0 0 rgba(41, 211, 162, 0.92);
}

.history-item span {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.history-detail {
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding: 18px;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.saved-result {
  color: #dce5ef;
  line-height: 1.65;
}

.saved-result h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.saved-markdown h2,
.saved-markdown h3 {
  letter-spacing: 0;
}

.saved-markdown h2 {
  margin-top: 22px;
}

.saved-markdown h3 {
  margin-top: 18px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}

.usage-page {
  display: grid;
  gap: 18px;
  padding-bottom: 42px;
}

.usage-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 20px;
  align-items: end;
}

.usage-summary h1 {
  max-width: 760px;
  margin: 10px 0 12px;
  font-size: clamp(2rem, 4vw, 4.1rem);
}

.usage-summary p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.7;
}

.usage-meter,
.plan-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 22, 29, 0.92);
  box-shadow: var(--shadow);
}

.usage-meter {
  display: grid;
  gap: 4px;
  padding: 18px;
}

.usage-meter span,
.usage-meter small,
.plan-card span,
.plan-card p {
  color: var(--muted);
}

.usage-meter strong {
  color: var(--accent);
  font-size: 3rem;
  line-height: 1;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.plan-card {
  display: flex;
  min-height: 228px;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding: 18px;
}

.plan-card.active-plan {
  border-color: rgba(41, 211, 162, 0.75);
  background: linear-gradient(180deg, rgba(41, 211, 162, 0.12), rgba(18, 22, 29, 0.92));
  box-shadow: inset 0 0 0 1px rgba(41, 211, 162, 0.25), var(--shadow);
}

.plan-card strong {
  font-size: 2.2rem;
}

.plan-card p {
  margin: 0;
}

.usage-table {
  padding: 12px;
}

.usage-row {
  display: grid;
  grid-template-columns: 1.35fr 0.7fr 0.75fr 0.75fr 0.65fr 0.75fr;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line-soft);
  color: #dce5ef;
  font-size: 0.9rem;
}

.usage-row span {
  min-width: 0;
}

.usage-head {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

@keyframes loading {
  0% {
    transform: translateX(-120%);
  }
  50% {
    transform: translateX(140%);
  }
  100% {
    transform: translateX(320%);
  }
}

@media (max-width: 900px) {
  .hero,
  .review-topbar {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 36px;
  }

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

  .site-header,
  .toolbar,
  .compact-toolbar,
  .compact-actions,
  .panel-head,
  .panel-actions,
  .actions {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    width: 100%;
  }

  .header-links,
  .header-account,
  .account-strip,
  .usage-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-grid,
  .usage-summary,
  .plans-grid {
    grid-template-columns: 1fr;
  }

  .history-list,
  .history-detail {
    max-height: none;
  }

  .usage-row {
    grid-template-columns: 1fr 1fr;
    padding: 8px 0;
  }

  .compact-drop {
    min-width: 100%;
    width: 100%;
  }

  .contract-input {
    min-height: 300px;
    max-height: none;
  }

  .pair-header,
  .review-pair {
    grid-template-columns: 1fr;
    column-gap: 0;
  }

  .pair-header span:first-child,
  .pair-source {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .paired-list {
    max-height: none;
  }

  .stream-overlay {
    position: relative;
    width: 100%;
    min-height: 0;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .connection-layer {
    display: none;
  }

}

/* Pagination Styles */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 20px;
  border-top: 1px solid var(--line-soft);
}

.pagination-btn {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--line-soft);
  border-color: var(--accent);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-info {
  color: var(--muted);
  font-size: 0.9rem;
}

/* History Loading More Styles */
.loading-more,
.no-more {
  padding: 16px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.loading-more {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
