:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #14213d;
  --muted: #667085;
  --border: #d8e0ea;
  --primary: #0e7c66;
  --primary-2: #0b5f4f;
  --accent: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 16px 50px rgba(20, 33, 61, .12);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg: #071318;
  --surface: #0f2027;
  --surface-2: #132b33;
  --text: #edf7f5;
  --muted: #9fb3bd;
  --border: #25434b;
  --primary: #34d399;
  --primary-2: #10b981;
  --accent: #fbbf24;
  --danger: #fb7185;
  --shadow: 0 20px 60px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(14,124,102,.16), transparent 28rem),
    linear-gradient(180deg, var(--bg), var(--surface-2));
  min-height: 100vh;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px 14px calc(92px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 4px 18px;
}
.topbar h1 { font-size: clamp(1.45rem, 6vw, 2.4rem); line-height: 1.05; margin: 0; letter-spacing: -.04em; }
.eyebrow { color: var(--primary); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; margin: 0 0 6px; }
.icon-btn, .ghost-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.06);
}
.ghost-btn { min-height: 38px; font-weight: 750; color: var(--primary); }

.view { display: none; animation: fade .18s ease-out; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.summary-card {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.summary-card strong { display: block; font-size: 1.55rem; line-height: 1; }
.summary-card span { color: var(--muted); font-size: .84rem; }

.sticky-tools {
  position: sticky;
  top: 0;
  z-index: 4;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  padding: 10px 0;
  margin: 0 -2px 10px;
}
.search-box {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
}
.search-box span { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; margin-bottom: 4px; }
.search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  width: 100%;
  font-size: 1rem;
}
.filter-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 8px; }
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 8px;
  min-height: 42px;
}
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin: 18px 0 10px;
}
.results-header h2 { margin: 0; font-size: 1.15rem; }
.results-header p { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }

.endpoint-list { display: grid; gap: 10px; }
.endpoint-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 8px 25px rgba(0,0,0,.07);
  transition: transform .16s, border-color .16s;
}
.endpoint-card:hover { transform: translateY(-1px); border-color: var(--primary); }
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.api-title { margin: 5px 0 8px; font-size: 1.02rem; line-height: 1.2; }
.endpoint-path {
  display: block;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: .78rem;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px;
  margin: 8px 0;
}
.use-case { color: var(--text); font-size: .9rem; line-height: 1.45; margin: 10px 0 12px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 5px 8px; font-size: .72rem; font-weight: 850; border: 1px solid var(--border); background: var(--surface-2); }
.method { color: #fff; border: none; }
.method.GET { background: #2563eb; }
.method.POST { background: #059669; }
.method.PUT, .method.PATCH { background: #d97706; }
.method.DELETE { background: #dc2626; }
.risk-low { color: #047857; }
.risk-medium { color: #b45309; }
.risk-high { color: #dc2626; }
.card-actions { display:flex; gap:8px; margin-top: 12px; }
.primary-btn, .copy-btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 800;
}
.primary-btn { background: var(--primary); color: white; flex: 1; }
.copy-btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.endpoint-dialog {
  width: min(920px, calc(100vw - 18px));
  max-height: min(88vh, 900px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 24px;
  box-shadow: 0 28px 90px rgba(0,0,0,.35);
  padding: 0;
}
.endpoint-dialog::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(4px); }
.dialog-header { position: sticky; top:0; background: var(--surface); border-bottom:1px solid var(--border); padding: 16px; display:flex; align-items:flex-start; justify-content:space-between; gap:12px; z-index:1; }
.dialog-header h2 { margin:0; font-size: 1.25rem; }
.dialog-body { padding: 16px; overflow: auto; }
.detail-grid { display: grid; gap: 12px; }
.detail-box { border:1px solid var(--border); border-radius:16px; padding:12px; background: var(--surface-2); }
.detail-box h3 { margin:0 0 8px; font-size: .95rem; }
.param-table { width:100%; border-collapse: collapse; font-size: .82rem; }
.param-table th, .param-table td { text-align:left; border-bottom: 1px solid var(--border); padding: 8px 4px; vertical-align: top; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #071318; color:#d1fae5; padding:12px; border-radius:14px; max-height: 280px; overflow:auto; font-size:.78rem; }
.code-block { display:grid; gap:8px; margin:12px 0; }
.code-block code { display:block; padding:10px; border-radius:12px; background: var(--surface-2); overflow-wrap:anywhere; }
.guide-card, .map-card { background: var(--surface); border:1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.guide-card h2, .map-card h2 { margin: 0 0 10px; }

.lead { font-size: 1rem; line-height: 1.55; color: var(--text); margin: 0; }
.muted-text { color: var(--muted); line-height: 1.5; }
.hero-doc { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 16%, var(--surface)), var(--surface)); }
.flow-list { display: grid; gap: 10px; margin-top: 12px; }
.flow-list div { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.flow-list strong { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; background: var(--primary); color: #fff; }
.doc-table-wrap { overflow-x: auto; }
.guide-card code { overflow-wrap: anywhere; }
.steps { padding-left: 20px; line-height: 1.55; }
.danger-soft { border-color: color-mix(in srgb, var(--danger), var(--border) 55%); }
.mapping-list { display:grid; gap: 12px; }
.map-card .endpoint-path { margin: 4px 0; }

.bottom-tabs {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + var(--safe-bottom));
  width: min(680px, calc(100vw - 18px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px;
  backdrop-filter: blur(16px);
  z-index: 8;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 18px;
  padding: 8px 4px;
  display: grid;
  gap: 2px;
  justify-items: center;
}
.tab.active { background: var(--primary); color: #fff; }
.tab span { font-size: 1.1rem; }
.tab strong { font-size: .75rem; }
.toast { position: fixed; left:50%; transform: translateX(-50%) translateY(18px); bottom: calc(88px + var(--safe-bottom)); background:#111827; color:white; border-radius:999px; padding:10px 14px; opacity:0; pointer-events:none; transition:.18s; z-index: 20; }
.toast.show { opacity:1; transform: translateX(-50%) translateY(0); }
.empty { text-align:center; color: var(--muted); padding: 40px 12px; }

@media (min-width: 760px) {
  .app-shell { padding-left: 24px; padding-right: 24px; }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .endpoint-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-box.full { grid-column: 1 / -1; }
}
