:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-2: #f4f7fb;
  --page-grad-1: rgba(255, 90, 60, 0.08);
  --page-grad-2: rgba(255, 184, 102, 0.08);
  --page-base: #ffffff;
  --page-base-2: #f7f9fc;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-border: rgba(17, 24, 39, 0.08);
  --text: #0f172a;
  --muted: #556174;
  --accent: #ff5a3c;
  --accent-2: #ffb866;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, var(--page-grad-1), transparent 34%),
    radial-gradient(circle at right 18%, var(--page-grad-2), transparent 28%),
    linear-gradient(180deg, var(--page-base) 0%, var(--page-base-2) 100%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  padding: 24px;
}

code {
  font-family: "Cascadia Mono", Consolas, monospace;
  color: #a63d22;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-2: #111827;
  --page-grad-1: rgba(255, 90, 60, 0.16);
  --page-grad-2: rgba(255, 184, 102, 0.12);
  --page-base: #0b1220;
  --page-base-2: #111827;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #edf3fb;
  --muted: #a9b7ca;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
}

body[data-theme="dark"] code {
  color: #ffb6a4;
}

.app-shell {
  max-width: 1680px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 24px;
}

.intro-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  color: #111827;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  width: fit-content;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 16px;
  background: #ffffff;
  color: #111827;
  border: 1px solid rgba(17, 24, 39, 0.08);
}

.theme-toggle {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #0f172a;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.theme-toggle-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.theme-toggle-icon svg {
  width: 100%;
  height: 100%;
}

.brand-logo {
  display: block;
  width: auto;
  height: 42px;
  flex: 0 0 auto;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.9rem, 3.6vw, 3rem);
  line-height: 1.05;
}

.lede {
  margin: 10px 0 0;
  max-width: 58rem;
  color: var(--muted);
  line-height: 1.6;
}

.search {
  padding: 18px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.search-row input {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #ffffff;
  color: var(--text);
  border-radius: 16px;
  padding: 16px 18px;
  font: inherit;
  font-size: 1rem;
  outline: none;
}

.search-row input:focus {
  border-color: rgba(255, 90, 60, 0.6);
  box-shadow: 0 0 0 4px rgba(255, 90, 60, 0.12);
}

.search-row button {
  border: 0;
  border-radius: 16px;
  padding: 0 22px;
  background: linear-gradient(135deg, var(--accent), #ff7a59);
  color: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.search-row button:hover {
  filter: brightness(1.05);
}

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

.results-panel,
.viewer-panel {
  padding: 18px;
}

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

.panel-header h2 {
  font-size: 1.2rem;
}

.result-summary,
.active-info {
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mobile-results-toggle {
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  padding: 8px 12px;
  cursor: pointer;
}

.results {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding-right: 4px;
}

.results-section {
  display: grid;
  gap: 10px;
}

.section-title {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-2);
}

.section-note {
  color: var(--muted);
  font-size: 0.88rem;
}

.section-results {
  display: grid;
  gap: 12px;
}

.result-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background: #ffffff;
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.result-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 90, 60, 0.45);
}

.result-card.active {
  border-color: rgba(255, 90, 60, 0.9);
  background: rgba(255, 90, 60, 0.06);
}

.code-line {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 1rem;
  color: #8f2f1c;
}

.doc-line {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.badge-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  color: #334155;
  background: #f8fafc;
}

.viewer {
  min-height: min(78vh, 980px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.image-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-stage img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(74vh, 900px);
  height: auto;
  object-fit: contain;
}

.viewer-empty {
  color: var(--muted);
  text-align: center;
  font-size: 1rem;
  padding: 40px 24px;
}

.marker {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(255, 90, 60, 0.6);
  transform: translate(-50%, -50%);
  animation: pulse 1.6s infinite;
  pointer-events: none;
}

.marker-label {
  position: absolute;
  transform: translate(14px, -10px);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: #0f172a;
  white-space: nowrap;
  pointer-events: none;
}

.hidden {
  display: none;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 90, 60, 0.55);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(255, 90, 60, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 90, 60, 0);
  }
}

@media (max-width: 1080px) {
  .intro,
  .results-layout {
    grid-template-columns: 1fr;
  }

  .results {
    max-height: none;
  }

  .viewer {
    min-height: 52vh;
  }
}

@media (max-width: 720px) {
  body {
    padding: 14px;
  }

  .theme-toggle {
    width: 42px;
    height: 42px;
  }

  .intro,
  .search,
  .results-panel,
  .viewer-panel {
    padding: 16px;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .result-summary,
  .active-info {
    text-align: left;
  }

  .viewer {
    min-height: calc(100vh - 240px);
  }

  .image-stage img {
    max-height: calc(100vh - 280px);
  }

  .brand-row {
    gap: 10px;
    padding: 8px 12px;
  }

  .intro-header {
    align-items: center;
  }

  .brand-logo {
    height: 34px;
  }

  .eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
  }

  h1 {
    font-size: clamp(1.7rem, 8vw, 2.35rem);
  }

  .mobile-results-toggle {
    display: inline-flex;
  }

  body:not(.has-search) .results-panel {
    display: none;
  }

  body.drawer-closed .results-panel {
    display: none;
  }

  body.drawer-open .results-panel {
    display: block;
  }

  .results-layout {
    gap: 12px;
  }

  .viewer-panel {
    order: 1;
  }

  .results-panel {
    order: 2;
  }

  .viewer-actions {
    flex-direction: column;
    align-items: flex-end;
  }

  .active-info {
    text-align: right;
    max-width: 100%;
  }
}

body[data-theme="dark"] .brand-row {
  background: rgba(15, 23, 42, 0.92);
  color: #edf3fb;
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .eyebrow {
  color: #edf3fb;
}

body[data-theme="dark"] .search-row input {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(255, 255, 255, 0.14);
  color: #edf3fb;
}

body[data-theme="dark"] .mobile-results-toggle {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(255, 255, 255, 0.12);
  color: #edf3fb;
}

body[data-theme="dark"] .result-card {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .result-card.active {
  background: rgba(255, 90, 60, 0.18);
}

body[data-theme="dark"] .code-line {
  color: #ffd0c4;
}

body[data-theme="dark"] .badge {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: #d8e4f2;
}

body[data-theme="dark"] .viewer {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(17, 24, 39, 0.9));
  border-color: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .marker-label {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(255, 255, 255, 0.12);
  color: #edf3fb;
}

body[data-theme="dark"] .theme-toggle {
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(255, 255, 255, 0.1);
  color: #f8fbff;
}

body[data-theme="dark"] .theme-toggle:hover {
  background: rgba(30, 41, 59, 0.94);
}

body[data-theme="dark"] .theme-toggle-sun {
  display: none;
}

body[data-theme="dark"] .theme-toggle-moon {
  display: inline;
}
