:root {
  --bg: #f2efe8;
  --panel: rgba(255, 251, 243, 0.88);
  --panel-strong: #fffdf8;
  --line: rgba(50, 36, 20, 0.12);
  --text: #20170f;
  --muted: #685646;
  --accent: #d2542f;
  --accent-strong: #8c2d17;
  --shadow: 0 24px 80px rgba(79, 46, 22, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(210, 84, 47, 0.22), transparent 32%),
    radial-gradient(circle at right center, rgba(230, 171, 81, 0.2), transparent 30%),
    linear-gradient(160deg, #f4efe7 0%, #ece5d8 48%, #efe7db 100%);
}

.page-shell {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.hero {
  padding: 18px 4px 24px;
}

.eyebrow {
  margin: 0 0 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.76rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.3rem, 7vw, 4.8rem);
  line-height: 0.92;
  font-family: Georgia, "Times New Roman", serif;
}

.hero-copy {
  width: min(650px, 100%);
  margin: 18px 0 0;
  font-size: 1.03rem;
  line-height: 1.7;
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 20px;
  overflow: visible;
}

.search-form {
  display: grid;
  gap: 16px;
}

.control-block {
  display: grid;
  gap: 8px;
  position: relative;
}

.control-block label {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
}

.source-switch {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

.source-pill {
  border: 1px solid rgba(140, 45, 23, 0.16);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.source-pill:hover,
.source-pill:focus-visible {
  transform: translateY(-1px);
}

.source-pill.active {
  background: var(--accent);
  color: #fff9f2;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.search-row > * {
  min-width: 0;
}

.search-row input,
.control-block select,
.search-row button,
.action-button,
.link-button {
  min-height: 48px;
  border-radius: 14px;
  font: inherit;
}

.search-row input {
  width: 100%;
  border: 1px solid rgba(50, 36, 20, 0.1);
  background: var(--panel-strong);
  padding: 0 16px;
  color: var(--text);
}

.control-block select {
  width: 100%;
  border: 1px solid rgba(50, 36, 20, 0.1);
  background: var(--panel-strong);
  padding: 0 44px 0 16px;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.control-block::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 19px;
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(140, 45, 23, 0.7);
  border-bottom: 2px solid rgba(140, 45, 23, 0.7);
  transform: rotate(45deg);
  pointer-events: none;
}

.control-block.is-active select {
  border-color: rgba(210, 84, 47, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 245, 235, 0.96), rgba(255, 250, 244, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 0 0 3px rgba(210, 84, 47, 0.08);
}

.search-row input:focus-visible {
  outline: 2px solid rgba(210, 84, 47, 0.25);
  outline-offset: 1px;
}

.control-block select:focus-visible {
  outline: 2px solid rgba(210, 84, 47, 0.25);
  outline-offset: 1px;
}

.search-row button,
.action-button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.search-row button,
.action-button.primary {
  background: var(--accent);
  color: #fff8f0;
}

.action-button.secondary,
.link-button {
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  border: 1px solid rgba(50, 36, 20, 0.08);
}

.source-note,
.helper-banner,
.status {
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 0.95rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-note {
  background: rgba(210, 84, 47, 0.08);
  color: var(--accent-strong);
}

.helper-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  border: 1px solid rgba(50, 36, 20, 0.08);
}

.helper-banner.is-ready {
  background: rgba(58, 146, 88, 0.08);
  color: #255337;
  border-color: rgba(58, 146, 88, 0.18);
}

.helper-banner.is-warning {
  background: rgba(210, 84, 47, 0.08);
  color: var(--accent-strong);
  border-color: rgba(210, 84, 47, 0.14);
}

.helper-banner a {
  color: inherit;
  font-weight: 700;
}

.status {
  min-height: 52px;
  display: flex;
  align-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.48);
}

.status.error {
  color: #a22222;
  background: rgba(183, 41, 41, 0.08);
}

.results {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
  min-width: 0;
}

.workspace.is-source-sukebei {
  grid-template-columns: minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 16px;
  border: 1px solid rgba(50, 36, 20, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62);
  padding: 16px;
  display: grid;
  gap: 14px;
  min-width: 0;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 1rem;
}

.results-panel {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.results-panel > * {
  min-width: 0;
}

.hidden {
  display: none !important;
}

.query-plan-panel {
  border: 1px solid rgba(50, 36, 20, 0.08);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(247, 235, 224, 0.88)),
    radial-gradient(circle at top right, rgba(210, 84, 47, 0.14), transparent 34%);
  padding: 16px;
  overflow: hidden;
}

.query-plan-panel.is-complete {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(233, 245, 233, 0.92)),
    radial-gradient(circle at top right, rgba(58, 146, 88, 0.12), transparent 34%);
}

.query-plan-panel.is-fading {
  animation: panelFadeOut 900ms ease forwards;
}

.query-plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.query-plan-eyebrow {
  margin: 0 0 6px;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-strong);
  font-weight: 700;
}

.query-plan-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

.query-plan-pulse {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(210, 84, 47, 0.44);
  animation: pulse 1.8s infinite;
}

.query-plan-panel.is-complete .query-plan-pulse {
  background: #3a9258;
  animation: settlePulse 520ms ease forwards;
}

.query-plan-stage {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.query-plan-stage-label {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
}

.query-plan-current {
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 16px;
  background: rgba(32, 23, 15, 0.05);
  font-size: 1rem;
  font-weight: 700;
  transform-origin: left center;
  min-width: 0;
  overflow-wrap: anywhere;
}

.query-plan-current.is-animating {
  animation: swapWord 480ms ease;
}

.query-plan-panel.is-complete .query-plan-current {
  background: rgba(58, 146, 88, 0.08);
}

.query-plan-caption {
  margin: 10px 0 0;
  min-height: 20px;
  color: var(--muted);
  font-size: 0.88rem;
}

.query-plan-caption.is-done {
  color: #255337;
  font-weight: 700;
}

.query-plan-track {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.query-plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(50, 36, 20, 0.08);
  color: var(--muted);
  font-size: 0.88rem;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.query-plan-chip.active {
  background: var(--accent);
  color: #fff8f0;
  transform: translateY(-1px);
}

.query-plan-chip.done {
  background: rgba(58, 146, 88, 0.12);
  color: #255337;
  border-color: rgba(58, 146, 88, 0.14);
}

.query-plan-chip .reason {
  font-size: 0.76rem;
  opacity: 0.72;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.result-card {
  opacity: 0;
  transform: translateY(10px);
  animation: reveal 240ms ease forwards;
  border-radius: var(--radius);
  border: 1px solid rgba(50, 36, 20, 0.08);
  padding: 18px;
  background: rgba(255, 255, 255, 0.7);
  min-width: 0;
}

.result-title {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.5;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  min-width: 0;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(32, 23, 15, 0.06);
  color: var(--muted);
  font-size: 0.86rem;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  min-width: 0;
}

.action-row > * {
  min-width: 0;
  max-width: 100%;
}

.action-button.is-copied {
  background: #3a9258;
  color: #fffaf4;
  animation: copiedPop 640ms ease;
}

.action-button.helper-115-button {
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.action-button.helper-115-button.is-success {
  background: rgba(58, 146, 88, 0.14);
  color: #255337;
  border: 1px solid rgba(58, 146, 88, 0.2);
}

.action-button.helper-115-button.is-working {
  background: rgba(210, 84, 47, 0.12);
  color: var(--accent-strong);
  border: 1px solid rgba(210, 84, 47, 0.18);
}

.pagination {
  display: flex;
  justify-content: center;
  margin-top: 24px;
  min-height: 52px;
}

.pagination-note {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(50, 36, 20, 0.08);
  color: rgba(50, 36, 20, 0.82);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.pagination.is-loading .pagination-note {
  background: rgba(210, 84, 47, 0.12);
  color: var(--accent-strong);
}

.pagination.is-complete .pagination-note {
  background: rgba(58, 146, 88, 0.12);
  color: #255337;
}

.group-tree {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.group-node {
  border: 1px solid rgba(50, 36, 20, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.54);
  padding: 10px 12px 14px;
}

.group-node summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.group-node summary::-webkit-details-marker {
  display: none;
}

.group-meta {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.group-children {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(210, 84, 47, 0.44);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(210, 84, 47, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(210, 84, 47, 0);
  }
}

@keyframes swapWord {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes settlePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(58, 146, 88, 0.34);
  }
  70% {
    transform: scale(1.18);
    box-shadow: 0 0 0 12px rgba(58, 146, 88, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(58, 146, 88, 0);
  }
}

@keyframes copiedPop {
  0% {
    transform: scale(0.96);
    filter: brightness(0.98);
  }
  40% {
    transform: scale(1.06);
    filter: brightness(1.04);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes panelFadeOut {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 1080px);
    padding-top: 20px;
  }

  .panel {
    padding: 16px;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .action-row > * {
    flex: 1 1 calc(50% - 10px);
  }
}
