:root {
  color-scheme: dark;
  --bg: #080d16;
  --bg-soft: #0c1420;
  --surface: rgba(17, 26, 39, 0.52);
  --surface-raised: rgba(23, 34, 49, 0.94);
  --surface-hover: rgba(31, 46, 64, 0.94);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.3);
  --text: #f4f8fb;
  --muted: #9aaaba;
  --faint: #637486;
  --blue: #45b7f4;
  --blue-soft: rgba(69, 183, 244, 0.14);
  --mint: #68e1bc;
  --mint-soft: rgba(104, 225, 188, 0.14);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.12);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, #0a101a 0%, #080d16 100%);
}

.app-shell::before,
.app-shell::after {
  position: fixed;
  inset: -32vh -28vw;
  z-index: 0;
  pointer-events: none;
  content: "";
  mix-blend-mode: screen;
  opacity: 0.78;
  filter: blur(10px);
  transform-origin: 50% 50%;
  will-change: transform;
}

.app-shell::before {
  background:
    linear-gradient(118deg, transparent 8%, rgba(69, 183, 244, 0.28) 14%, transparent 23%),
    linear-gradient(143deg, transparent 23%, rgba(104, 225, 188, 0.25) 31%, transparent 41%),
    linear-gradient(69deg, transparent 45%, rgba(251, 113, 133, 0.24) 55%, transparent 66%),
    linear-gradient(102deg, transparent 65%, rgba(244, 197, 94, 0.18) 73%, transparent 83%);
  animation: ambientRibbonDrift 14s -5s ease-in-out infinite alternate;
}

.app-shell::after {
  background:
    linear-gradient(58deg, transparent 12%, rgba(104, 225, 188, 0.22) 21%, transparent 32%),
    linear-gradient(128deg, transparent 36%, rgba(69, 183, 244, 0.24) 45%, transparent 56%),
    linear-gradient(84deg, transparent 55%, rgba(251, 113, 133, 0.2) 64%, transparent 76%);
  animation: ambientRibbonDriftAlt 16s -9s ease-in-out infinite alternate;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(17, 26, 39, 0.52);
  backdrop-filter: blur(18px);
}

.app-header,
.workspace {
  position: relative;
  z-index: 1;
}

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

.brand-content {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-direction: row;
  gap: 13px;
}

.brand-mark {
  width: clamp(112px, 12vw, 154px);
  height: 48px;
  object-fit: contain;
}

.brand-meta {
  min-width: 0;
}

.brand-meta strong {
  display: block;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1rem;
  font-weight: 720;
  letter-spacing: 0.02em;
}

h2 {
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand p {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  width: min(1520px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.query-section {
  position: relative;
}

.query-form,
.settings-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.query-form {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px 11px 16px;
  border-color: rgba(69, 183, 244, 0.24);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(69, 183, 244, 0.04);
}

textarea {
  display: block;
  min-width: 0;
  width: 100%;
  min-height: 26px;
  max-height: 220px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.55;
}

textarea::placeholder {
  color: rgba(244, 248, 251, 0.58);
}

.query-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.run-state {
  color: #ffa313;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.agent-error .run-state {
  color: #ff6b6b;
  text-shadow: 0 0 14px rgba(236, 77, 77, 0.32);
}

.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: -6px;
  color: var(--blue);
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1;
}

.loading-dots[hidden] {
  display: none;
}

.loading-dots span {
  animation: loadingDotPulse 1.3s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 160ms;
}

.loading-dots span:nth-child(3) {
  animation-delay: 320ms;
}

.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 720;
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  border-color: transparent;
  background: linear-gradient(#101a28, #101a28) padding-box, linear-gradient(135deg, #68e1bc, #45b7f4) border-box;
  box-shadow: 0 8px 20px rgba(36, 117, 170, 0.2);
}

.button.primary:hover {
  box-shadow: 0 10px 24px rgba(69, 183, 244, 0.3), 0 0 0 3px rgba(69, 183, 244, 0.08);
}

.agent-error .button.primary {
  background: linear-gradient(#241317, #241317) padding-box, linear-gradient(135deg, #ff6b6b, #fb7185) border-box;
  box-shadow: 0 8px 22px rgba(236, 77, 77, 0.28), 0 0 0 3px rgba(236, 77, 77, 0.08);
}

.agent-error .button.primary:hover {
  box-shadow: 0 10px 26px rgba(236, 77, 77, 0.36), 0 0 0 3px rgba(236, 77, 77, 0.14);
}

.button.secondary {
  border-color: rgba(251, 113, 133, 0.38);
  background: var(--danger-soft);
  color: #fecdd3;
}

.button.secondary:hover {
  border-color: rgba(251, 113, 133, 0.7);
  background: rgba(251, 113, 133, 0.18);
}

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

.button[hidden] {
  display: none;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 26, 39, 0.76);
  color: var(--muted);
  font-size: 1.1rem;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.icon-button:hover {
  border-color: rgba(69, 183, 244, 0.55);
  background: var(--blue-soft);
  color: var(--blue);
  transform: translateY(-1px);
}

.icon-button.compact {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 1rem;
}

.settings-panel {
  margin-top: 10px;
  padding: 15px;
}

.settings-panel[hidden] {
  display: none;
}

.settings-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 18px 26px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 650;
}

.field strong {
  color: var(--mint);
}

.display-settings {
  gap: 6px;
}

.display-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
}

.display-check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--blue);
}

.logout-field {
  gap: 7px;
  margin-left: auto;
}

.logout-button {
  min-height: 36px;
}

select {
  min-height: 36px;
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: #0a111b;
  color: var(--text);
}

select:focus {
  border-color: rgba(69, 183, 244, 0.76);
  box-shadow: 0 0 0 3px rgba(69, 183, 244, 0.1);
}

input[type="range"] {
  width: 210px;
  accent-color: var(--mint);
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  margin: -12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.77rem;
  user-select: none;
  transition: transform 180ms ease;
  will-change: transform;
}

.check-field input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.main-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
}

.panel {
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 360ms ease, transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.panel[hidden] {
  display: none;
}

.panel.panel-revealing {
  opacity: 0;
  transform: translateY(14px);
}

.panel-header {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--line);
  background: #191818;
}

.panel-header h2 {
  color: var(--mint);
}

.panel-header span {
  color: var(--muted);
  font-size: 0.74rem;
}

.analysis-step-origin {
  position: relative;
  padding: 9px 1px 0;
}

.analysis-step-origin::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 14px;
  height: 10px;
  border-left: 1px solid var(--line-strong);
}

.analysis-step-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px 4px 9px;
  border: 1px solid rgba(90, 225, 184, 0.24);
  border-radius: 999px;
  background: rgba(90, 225, 184, 0.07);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 720;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: border-color 260ms ease, background 260ms ease, box-shadow 260ms ease, transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.analysis-step-counter strong {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  background: rgba(90, 225, 184, 0.16);
  color: var(--mint);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.analysis-step-error-icon {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  background: rgba(236, 77, 77, 0.18);
  color: #ff6b6b;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
}

.analysis-step-error-icon[hidden] {
  display: none;
}

.analysis-step-activity {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(90, 225, 184, 0.22);
  border-top-color: var(--mint);
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(90, 225, 184, 0.2);
  animation: analysisStepSpin 820ms linear infinite;
}

.analysis-step-activity[hidden] {
  display: none;
}

.analysis-step-counter.connection-lost {
  border-color: rgba(236, 77, 77, 0.72);
  background: rgba(236, 77, 77, 0.12);
  color: #ff9a9a;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 0 0 18px rgba(236, 77, 77, 0.16);
}

.analysis-step-counter.connection-lost strong {
  display: none;
}

.analysis-step-counter.updating {
  border-color: rgba(90, 225, 184, 0.66);
  background: rgba(90, 225, 184, 0.14);
  box-shadow: 0 0 18px rgba(90, 225, 184, 0.18);
  animation: counterLift 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.analysis-step-counter.updating strong {
  animation: counterNumber 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.answer-body {
  padding: 20px;
  overflow-wrap: anywhere;
  color: #191818;
  background-color: #e6e8da;
  font-size: 0.92rem;
  line-height: 1.72;
}

.answer-body.empty {
  color: var(--muted);
}

.answer-body h1,
.answer-body h2,
.answer-body h3 {
  margin: 1.1em 0 0.5em;
  color: #ac5600;
  font-size: 1rem;
  font-weight: 740;
  letter-spacing: 0;
  text-transform: none;
}

.answer-body p {
  margin: 0.65em 0;
}

.answer-body ul,
.answer-body ol {
  margin: 0.7em 0;
  padding-left: 1.4em;
}

.answer-body a {
  color: var(--blue);
}

.answer-body code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ff9910a1;
}

.answer-body pre {
  overflow-x: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #08101a;
}

.insights-panel {
  position: sticky;
  top: 90px;
  display: flex;
  height: 30vh;
  max-height: 30vh;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
  transition: height 520ms cubic-bezier(0.22, 1, 0.36, 1), max-height 520ms cubic-bezier(0.22, 1, 0.36, 1), opacity 360ms ease, transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.insights-panel[hidden] {
  display: none;
}

.insights-panel.revealing {
  opacity: 0;
  transform: translateY(-12px);
}

.insights-panel.collapsed {
  height: 46px;
  max-height: 46px;
}

.insights-list {
  flex: 1;
  align-content: start;
  margin: 0;
  padding: 10px 14px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
  list-style: none;
  opacity: 1;
  transition: opacity 260ms ease;
}

.insights-panel.collapsed .insights-list,
.insights-panel.collapsed .empty-state {
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.insights-panel .empty-state {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 260ms ease;
}

.insight {
  position: relative;
  padding: 8px 0 8px 20px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  line-height: 1.42;
  opacity: 1;
  outline: none;
  transform: translateY(0);
  transition: opacity 520ms ease, transform 520ms cubic-bezier(0.22, 1, 0.36, 1), margin-left 360ms ease, border-color 240ms ease;
}

.insight.entering {
  opacity: 0;
  transform: translateY(-14px);
}

.insight:hover strong,
.insight:focus-visible strong {
  color: var(--blue);
}

.insight:focus-visible {
  border-radius: 0 6px 6px 0;
  background: var(--blue-soft);
}

.insight::before {
  content: "";
  position: absolute;
  top: 12px;
  left: -5px;
  width: 9px;
  height: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg-soft);
  transition: all 280ms ease;
}

.insight.active::before {
  border-color: var(--blue);
  background: var(--bg-soft);
  animation: insightPulse 1.4s ease-in-out infinite;
}

.insight.completed::before {
  content: "\2713";
  display: grid;
  top: 10px;
  left: -7px;
  width: 13px;
  height: 13px;
  place-items: center;
  border-color: var(--mint);
  background: var(--mint);
  color: #06231b;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

.insight.error {
  border-left-color: rgba(251, 113, 133, 0.5);
  color: #ffb4bf;
}

.insight.error::before {
  content: "!";
  display: grid;
  top: 9px;
  left: -8px;
  width: 15px;
  height: 15px;
  place-items: center;
  border-color: var(--danger);
  background: rgba(251, 113, 133, 0.18);
  color: #ff8fa1;
  font-size: 10px;
  font-weight: 900;
}

.insight.error strong {
  color: #ff8fa1;
}

.insight strong {
  display: block;
  color: #e5e7d9;
  font-size: 0.71rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 180ms ease;
}

.insight strong::after {
  content: " +";
  color: var(--faint);
  font-weight: 500;
}

.insight.expanded strong::after {
  content: " \2212";
}

.insight-detail {
  display: grid;
  max-height: 0;
  gap: 5px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: max-height 360ms ease, opacity 240ms ease, transform 360ms ease, margin-top 360ms ease;
}

.insight.expanded .insight-detail {
  max-height: 500px;
  margin-top: 6px;
  opacity: 1;
  transform: translateY(0);
}

.insight-detail span {
  display: block;
}

.insight.subagent-branch {
  margin-left: 14px;
  border-left-color: rgba(69, 183, 244, 0.8);
}

.insight.subagent-branch::after {
  content: "";
  position: absolute;
  top: 16px;
  left: -15px;
  width: 14px;
  border-top: 1px solid rgba(69, 183, 244, 0.8);
}

.empty-state {
  padding: 16px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.evidence-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
}

.evidence-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(8, 15, 24, 0.74);
}

.evidence-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 34, 49, 0.78);
}

.evidence-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-page {
  flex: 0 0 auto;
  color: var(--mint);
  font-size: 0.72rem;
  font-weight: 700;
}

.highlight-label {
  padding: 11px 13px 7px;
  color: var(--mint);
  font-size: 0.69rem;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.preview-wrap {
  position: relative;
  margin: 0 12px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.highlight-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.highlight-box {
  position: absolute;
  border: 1px solid rgba(104, 225, 188, 0.9);
  border-radius: 2px;
  background: rgba(104, 225, 188, 0.25);
  box-shadow: 0 0 0 1px rgba(104, 225, 188, 0.08);
}

.evidence-detail {
  padding: 0 13px 12px;
  color: #cedbe4;
  font-size: 0.79rem;
  line-height: 1.55;
}

.evidence-detail strong {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.document-preview-wrap {
  padding: 11px 12px 12px;
  border-top: 1px solid var(--line);
}

.document-preview {
  display: block;
  width: 100%;
  height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.evidence-actions {
  display: flex;
  justify-content: flex-end;
  padding: 10px 13px;
  border-top: 1px solid var(--line);
  background: rgba(23, 34, 49, 0.52);
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 0.77rem;
  font-weight: 720;
}

.link-button:hover {
  color: var(--mint);
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  padding: 22px;
  background: rgba(3, 7, 13, 0.84);
  backdrop-filter: blur(8px);
}

.modal[hidden] {
  display: none;
}

.modal-dialog {
  display: flex;
  width: min(1280px, 100%);
  height: 100%;
  margin: auto;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-raised);
}

.modal-header strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal iframe {
  width: 100%;
  flex: 1;
  border: 0;
  background: #fff;
}

.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;
}

@keyframes loadingDotPulse {

  0%,
  70%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }

  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes insightPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(69, 183, 244, 0.2);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(69, 183, 244, 0);
  }
}

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

@keyframes ambientRibbonDrift {
  from {
    transform: rotate(-13deg) scale(1.05) translate3d(-9vw, -5vh, 0);
  }

  to {
    transform: rotate(15deg) scale(1.18) translate3d(8vw, 6vh, 0);
  }
}

@keyframes ambientRibbonDriftAlt {
  from {
    transform: rotate(18deg) scale(1.08) translate3d(8vw, 5vh, 0);
  }

  to {
    transform: rotate(-17deg) scale(1.2) translate3d(-9vw, -6vh, 0);
  }
}

@keyframes counterLift {
  0% {
    transform: translateY(0);
  }

  42% {
    transform: translateY(-3px);
  }

  100% {
    transform: translateY(0);
  }
}

@keyframes counterNumber {
  0% {
    opacity: 0.35;
    transform: scale(0.72);
  }

  55% {
    opacity: 1;
    transform: scale(1.18);
  }

  100% {
    transform: scale(1);
  }
}

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

  .insights-panel {
    position: static;
    grid-row: 1;
    min-height: 190px;
  }
}

@media (max-width: 640px) {
  .app-header {
    min-height: 60px;
    padding: 8px 12px;
  }

  .brand {
    gap: 8px;
  }

  .brand-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .brand-mark {
    width: 94px;
    height: 40px;
  }

  h1 {
    font-size: 0.88rem;
  }

  .brand p {
    max-width: 180px;
    font-size: 0.66rem;
  }

  .workspace {
    width: min(100% - 20px, 1520px);
    padding: 12px 0 24px;
  }

  .query-form,
  .settings-panel {
    padding: 12px;
  }

  .query-form {
    flex-wrap: wrap;
    gap: 8px;
  }

  textarea {
    flex-basis: 100%;
    max-height: 180px;
    font-size: 0.88rem;
  }

  .query-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
  }

  .run-state {
    margin-right: auto;
  }

  .settings-grid {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .settings-grid .field,
  .settings-grid select,
  .settings-grid input[type="range"] {
    width: 100%;
  }

  .check-field {
    width: 100%;
    margin: -10px;
    padding: 10px;
    white-space: normal;
  }

  .logout-field {
    margin-left: 0;
  }

  .result-grid,
  .main-column {
    gap: 12px;
  }

  .result-grid {
    margin-top: 12px;
  }

  .panel-header {
    min-height: 42px;
    padding: 9px 12px;
  }

  .answer-body {
    padding: 14px;
    font-size: 0.86rem;
  }

  .insights-panel {
    min-height: 180px;
  }

  .analysis-step-origin {
    padding: 8px 11px 0;
  }

  .analysis-step-origin::after {
    left: 11px;
  }

  .insights-list {
    padding: 8px 11px 11px;
  }

  .insight {
    padding: 7px 0 7px 18px;
    font-size: 0.72rem;
  }

  .insight.subagent-branch {
    margin-left: 9px;
  }

  .insight.subagent-branch::after {
    left: -10px;
    width: 9px;
  }

  .evidence-list {
    gap: 11px;
    padding: 9px;
  }

  .evidence-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
    padding: 9px 11px;
  }

  .highlight-label {
    padding: 9px 11px 6px;
  }

  .preview-wrap {
    margin: 0 9px 9px;
  }

  .evidence-detail {
    padding: 0 11px 11px;
  }

  .document-preview-wrap {
    padding: 9px;
  }

  .document-preview {
    height: 58vh;
    min-height: 320px;
    max-height: 520px;
  }

  .evidence-actions {
    padding: 9px 11px;
  }

  .modal {
    padding: 5px;
  }

  .modal-dialog {
    border-radius: 6px;
  }

  .modal-header {
    padding: 8px 9px;
  }

  .modal-header strong {
    font-size: 0.74rem;
  }
}
