:root {
  color-scheme: dark;
  --ink: #101416;
  --ink-2: #172025;
  --paper: #f6f1e7;
  --muted: #aeb8b5;
  --line: rgba(246, 241, 231, 0.14);
  --gold: #d5a85c;
  --gold-2: #f0d49a;
  --green: #5da17a;
  --red: #c96b5d;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(135deg, rgba(213, 168, 92, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(93, 161, 122, 0.08), transparent 42%),
    #101416;
}

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

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(16, 20, 22, 0.88);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.pane-header h2,
.detail h2,
.empty-detail h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.4rem, 2.2vw, 2.3rem);
  line-height: 1.08;
}

.title-with-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.title-with-logo img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex: 0 0 auto;
}

.app-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold-2);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.shell {
  width: min(1500px, calc(100% - 32px));
  margin: 24px auto 36px;
}

.search-panel,
.search-prompt,
.results-pane,
.detail-pane {
  border: 1px solid var(--line);
  background: rgba(23, 32, 37, 0.82);
  box-shadow: var(--shadow);
}

.search-panel {
  border-radius: 8px;
  padding: 18px;
}

.admin-panel {
  border: 1px solid rgba(213, 168, 92, 0.28);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  background: rgba(23, 32, 37, 0.92);
  box-shadow: var(--shadow);
}

.admin-header,
.admin-output-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.admin-header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.3vw, 2rem);
}

.admin-header p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  align-items: end;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.7fr) auto;
  gap: 12px;
  margin-top: 16px;
  align-items: end;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(720px, 100%);
}

.auth-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(22px, 4vw, 38px);
  background: rgba(23, 32, 37, 0.92);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1.08;
}

.auth-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.auth-card .login-panel {
  grid-template-columns: 1fr;
}

.auth-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.auth-links a {
  color: var(--gold-2);
  font-weight: 750;
}

.login-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.login-status {
  grid-column: 1 / -1;
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 0.88rem;
}

.admin-session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(93, 161, 122, 0.34);
  border-radius: 8px;
  background: rgba(93, 161, 122, 0.1);
  color: var(--paper);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.admin-payloads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.admin-payloads label,
.admin-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.admin-output {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(16, 20, 22, 0.78);
}

.admin-output-header {
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.admin-output pre {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--paper);
  font: 0.88rem/1.5 "Cascadia Mono", "Fira Code", Consolas, monospace;
}

.search-prompt {
  margin-top: 18px;
  min-height: 260px;
  border-radius: 8px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 34px 20px;
}

.search-prompt h2 {
  width: min(780px, 100%);
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.search-prompt p:last-child {
  width: min(620px, 100%);
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.search-main label,
.filters label,
.token-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(246, 241, 231, 0.16);
  border-radius: 6px;
  background: rgba(16, 20, 22, 0.82);
  color: var(--paper);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(213, 168, 92, 0.14);
}

textarea {
  resize: vertical;
  line-height: 1.45;
  font-family: "Cascadia Mono", "Fira Code", Consolas, monospace;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.38fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.results-pane,
.detail-pane {
  border-radius: 8px;
  min-height: calc(100vh - 245px);
}

.results-pane {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  overflow: hidden;
}

.pane-header,
.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.pane-header h2 {
  font-size: 1.05rem;
}

.status {
  min-height: 32px;
  padding: 10px 18px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.results-list {
  overflow: auto;
  padding: 10px;
}

.result-item {
  width: 100%;
  display: grid;
  gap: 9px;
  text-align: left;
  padding: 14px;
  margin: 0 0 10px;
  border: 1px solid rgba(246, 241, 231, 0.1);
  border-radius: 8px;
  background: rgba(16, 20, 22, 0.52);
  color: var(--paper);
}

.result-item:hover,
.result-item.active {
  border-color: rgba(213, 168, 92, 0.72);
  background: rgba(213, 168, 92, 0.08);
}

.result-title {
  font-weight: 800;
  line-height: 1.25;
}

.result-description,
.result-meta {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.result-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  border: 1px solid rgba(213, 168, 92, 0.28);
  color: var(--gold-2);
  border-radius: 999px;
  padding: 2px 8px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.detail-pane {
  overflow: hidden;
}

.empty-detail {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  padding: 36px;
  color: var(--muted);
}

.empty-detail h2 {
  max-width: 620px;
  color: var(--paper);
  font-size: clamp(1.4rem, 3vw, 2.7rem);
  line-height: 1.1;
}

.detail {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  height: 100%;
}

.hidden {
  display: none;
}

.detail-header {
  align-items: flex-start;
}

.detail h2 {
  font-size: clamp(1.25rem, 2.4vw, 2rem);
  line-height: 1.15;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button,
.primary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid rgba(246, 241, 231, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--paper);
  background: rgba(246, 241, 231, 0.06);
}

.icon-button svg,
.primary-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.primary-button {
  border-color: rgba(213, 168, 92, 0.62);
  background: var(--gold);
  color: #1d160d;
  font-weight: 850;
}

.ghost-button:hover,
.icon-button:hover {
  border-color: rgba(213, 168, 92, 0.54);
  color: var(--gold-2);
}

.compact {
  width: 42px;
  padding: 0;
}

.compact span {
  display: none;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.facts div {
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.facts div:last-child {
  border-right: 0;
}

dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 5px 0 0;
  font-weight: 750;
}

.summary {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.summary h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.summary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.document {
  overflow: auto;
  background: #f9f6ef;
  color: #192124;
}

.document pre {
  margin: 0;
  padding: clamp(18px, 3vw, 36px);
  white-space: pre-wrap;
  word-break: break-word;
  font: 1rem/1.65 Georgia, "Times New Roman", serif;
}

dialog {
  width: min(520px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--ink-2);
  color: var(--paper);
  box-shadow: var(--shadow);
}

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

.token-form {
  padding: 22px;
}

.token-form h2 {
  margin: 0 0 8px;
}

.token-form p {
  margin: 0 0 18px;
  color: var(--muted);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border-radius: 6px;
  color: #101416;
  background: var(--gold-2);
  font-weight: 750;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

.noscript-message {
  width: min(900px, calc(100% - 32px));
  margin: 16px auto;
  padding: 14px 16px;
  border: 1px solid rgba(213, 168, 92, 0.42);
  border-radius: 6px;
  background: rgba(213, 168, 92, 0.12);
  color: var(--gold-2);
  font-weight: 750;
}

@media (max-width: 980px) {
  .workspace,
  .filters,
  .login-panel,
  .admin-grid,
  .admin-payloads {
    grid-template-columns: 1fr;
  }

  .results-pane,
  .detail-pane {
    min-height: auto;
  }

  .results-list {
    max-height: 420px;
  }
}

@media (max-width: 640px) {
  .topbar,
  .search-row,
  .app-nav,
  .detail-header,
  .facts {
    display: grid;
    grid-template-columns: 1fr;
  }

  .facts div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .actions,
  .primary-button {
    width: 100%;
  }

  .icon-button {
    width: 100%;
  }
}
