:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #eef2f6;
  --ink: #111827;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #d9e0e8;
  --line-strong: #c5ced8;
  --brand: #0f766e;
  --brand-2: #2563eb;
  --brand-soft: #d9f4ef;
  --amber: #b7791f;
  --danger: #c2410c;
  --danger-soft: #fff1e8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 28rem),
    radial-gradient(circle at 88% 8%, rgba(37, 99, 235, 0.09), transparent 22rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--brand-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand), #0d9488);
  border: 1px solid transparent;
  border-radius: 7px;
  box-shadow: var(--shadow-sm);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.button:hover {
  filter: brightness(0.96);
  text-decoration: none;
}

button:focus-visible,
.button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #fed7aa;
}

.mini {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.disabled {
  cursor: default;
  opacity: 0.45;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 34px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(18px);
}

.wordmark,
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.wordmark::before,
.brand-mark::before {
  width: 30px;
  height: 30px;
  content: "";
  background:
    linear-gradient(90deg, var(--brand), var(--brand)) 5px 6px / 18px 4px no-repeat,
    linear-gradient(90deg, var(--brand-2), var(--brand-2)) 5px 13px / 12px 4px no-repeat,
    linear-gradient(90deg, var(--amber), var(--amber)) 5px 20px / 20px 4px no-repeat,
    var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow-sm);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar nav a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--ink-soft);
  border-radius: 7px;
  font-weight: 650;
  white-space: nowrap;
}

.topbar nav a:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.topbar nav a.active {
  color: #0f3f3a;
  background: var(--brand-soft);
  box-shadow: inset 0 -2px 0 var(--brand);
}

.link-button {
  justify-content: center;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.nav-menu-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.nav-menu-panel form {
  margin-left: auto;
}

.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow-sm);
  font-weight: 750;
  cursor: pointer;
}

body.authenticated .app-shell {
  width: min(1240px, calc(100vw - 56px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

body.public .app-shell {
  width: 100%;
  margin: 0;
  padding: 0;
}

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

.login-panel {
  display: grid;
  width: min(460px, 100%);
  gap: 18px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.06;
  font-weight: 850;
}

h2 {
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 800;
}

p {
  margin: 6px 0 0;
  max-width: 720px;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin-bottom: 22px;
}

.toolbar h1 {
  margin-bottom: 2px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric,
.list-card,
.form-panel,
.result-card,
.secret-box,
.empty,
table,
.document-text,
.result {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric {
  position: relative;
  min-height: 108px;
  overflow: hidden;
  padding: 16px;
}

.metric::after {
  position: absolute;
  inset: auto 14px 14px auto;
  width: 38px;
  height: 5px;
  content: "";
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px;
  opacity: 0.8;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 18px;
  color: var(--ink);
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 850;
  line-height: 1;
}

.two-column,
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.45fr);
  gap: 18px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

tr:hover td {
  background: #fbfdff;
}

tr:last-child td {
  border-bottom: 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font: inherit;
  font-weight: 500;
  text-transform: none;
}

select {
  min-height: 42px;
}

select[multiple] {
  min-height: 140px;
}

textarea,
pre {
  white-space: pre-wrap;
}

.form-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.form-panel.compact {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  margin-bottom: 24px;
}

.wide {
  grid-column: 1 / -1;
}

.form-section {
  margin: 4px 0 -4px;
  padding-top: 10px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.inline-search {
  display: grid;
  grid-template-columns: minmax(240px, 340px) auto;
  gap: 8px;
}

.subtle-count {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.document-text,
.result {
  overflow: auto;
  padding: 16px;
  color: var(--ink-soft);
  background: #0f172a;
  border-color: #1e293b;
  color: #dbeafe;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

dl {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0 0 24px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.chunk-item,
.list-card,
.result-card,
.empty,
.secret-box {
  padding: 14px;
}

.chunk-item {
  display: flex;
  justify-content: space-between;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}

.chunk-item:last-child {
  border-bottom: 0;
}

.list-card {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.list-card span,
.result-card span,
.chunk-item span {
  color: var(--muted);
  font-size: 13px;
}

.results {
  margin-top: 24px;
}

.result-card {
  margin-bottom: 12px;
}

.result-card p {
  max-width: none;
  color: var(--ink-soft);
}

.status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  color: #0f513f;
  background: var(--brand-soft);
  border: 1px solid #b8e4dc;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.status.bad {
  color: #7c2d12;
  background: var(--danger-soft);
  border-color: #fed7aa;
}

.status.useful {
  color: #0f513f;
  background: var(--brand-soft);
}

.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.feedback-panel {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.section-stack {
  margin-top: 24px;
}

.playground-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.playground-main,
.playground-side {
  min-width: 0;
}

.playground-side {
  position: sticky;
  top: 34px;
}

.provider-form {
  grid-template-columns: 1fr;
  margin-bottom: 14px;
}

code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.principles {
  margin: 0;
  padding: 14px 14px 14px 32px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.principles li + li {
  margin-top: 8px;
}

.secret-box {
  margin-bottom: 18px;
  border-color: #f3c37a;
  background: #fffaf0;
}

.secret-box pre {
  margin-bottom: 0;
  color: #7c2d12;
  background: #fff7ed;
  border-color: #fed7aa;
}

@media (max-width: 980px) {
  body.authenticated .app-shell {
    width: min(100%, 1240px);
    padding: 24px 16px 48px;
  }

  .toolbar,
  .two-column,
  .detail-grid,
  .playground-grid,
  .form-panel,
  .form-panel.compact,
  .feedback-panel {
    grid-template-columns: 1fr;
  }

  .button-row {
    justify-content: flex-start;
  }

  .playground-side {
    position: static;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  table {
    display: block;
    overflow-x: auto;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: sticky;
    padding: 12px 14px;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .nav-menu-panel {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 14px;
    width: min(280px, calc(100vw - 28px));
    gap: 8px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
  }

  .nav-toggle:checked ~ .nav-menu-panel {
    display: grid;
  }

  .nav-menu-panel nav {
    display: grid;
    gap: 4px;
  }

  .nav-menu-panel form {
    margin-left: 0;
  }

  .nav-menu-panel .link-button {
    width: 100%;
    justify-content: flex-start;
  }

  .link-button {
    min-height: 34px;
    padding: 6px 8px;
  }
}

@media (max-width: 560px) {
  .inline-search {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }

  .nav-menu-panel nav a {
    min-height: 34px;
    padding: 7px 9px;
  }
}
