*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0b; --surface: #0e0e10; --surface2: #141416; --card: #111113;
  --line: rgba(255,255,255,0.065); --line2: rgba(255,255,255,0.11);
  --text: #ededee; --soft: #8c8c96; --muted: #4a4a55;
  --ac: #6366f1; --pac-bg: rgba(99,102,241,0.12); --pac-bd: rgba(99,102,241,0.25);
  --r: 100px; --card-rad: 12px; --card-pad: 16px 18px; --card-shadow: none;
  --font: 'Geist', system-ui, sans-serif;
}

.hidden { display: none; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}

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

header.topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

header.topbar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

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

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--card-rad);
  padding: var(--card-pad);
  box-shadow: var(--card-shadow);
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, background .2s, transform .18s;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, var(--pac-bg) 0%, transparent 65%);
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}

.card:hover::before { opacity: 1; }

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
}

.card-header h3 {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.01em;
}

.slug {
  font-family: 'Geist Mono', monospace;
  color: var(--muted);
  font-size: 11px;
  position: relative;
}

.badge {
  display: inline-block;
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .02em;
  padding: 3px 8px;
  border-radius: 4px;
}

.badge.public {
  background: rgba(62,207,142,.1);
  color: #3ecf8e;
  border: 1px solid rgba(62,207,142,.18);
}

.badge.private {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--muted);
}

.status-dot.online {
  background: #3ecf8e;
  box-shadow: 0 0 0 3px rgba(62,207,142,.2);
}

.status-dot.offline {
  background: #f87171;
  box-shadow: 0 0 0 3px rgba(248,113,113,.18);
}

.ep-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
  margin: -4px;
  padding: 4px;
  border-radius: calc(var(--card-rad) * 0.6);
  transition: background .15s;
}

.ep-summary:hover {
  background: var(--surface2);
}

.ep-summary-text {
  flex: 1;
  min-width: 0;
}

.ep-name {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.01em;
}

.ep-note-preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chevron {
  color: var(--muted);
  font-size: 12px;
  transition: transform .2s;
  flex-shrink: 0;
}

.endpoint-card.expanded .chevron {
  transform: rotate(180deg);
}

.ep-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  position: relative;
}

textarea {
  background: var(--surface2);
  border: 1px solid var(--line2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
  width: 100%;
  resize: vertical;
}

.category-group {
  margin-bottom: 28px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.category-header h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--soft);
  text-transform: uppercase;
}

.example-tab {
  font-size: 11px;
  padding: 4px 10px;
}

.example-tab.active {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--ac);
}

.storage-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-top: 4px;
}

.storage-bar-fill {
  height: 100%;
  width: 0%;
  background: #3ecf8e;
  transition: width .3s ease, background .3s ease;
}

.storage-bar-fill.warn {
  background: #f0a85b;
}

.storage-bar-fill.danger {
  background: #f87171;
}

.range-btn.active {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--ac);
}

.history-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: calc(var(--card-rad) * 0.7);
  padding: 10px 14px;
  margin-bottom: 6px;
}

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.widget-tile {
  position: relative;
  cursor: pointer;
  background: color-mix(in srgb, var(--wc, var(--card)) 7%, var(--card));
  border: 1px solid color-mix(in srgb, var(--wc, var(--line)) 35%, var(--line));
  border-radius: var(--card-rad);
  padding: var(--card-pad);
  box-shadow: var(--card-shadow);
  transition: border-color .15s, background .15s, transform .1s;
}

.widget-tile:hover {
  border-color: color-mix(in srgb, var(--wc, var(--line2)) 55%, var(--line2));
}

.widget-tile:active {
  transform: scale(.99);
}

.widget-view {
  display: flex;
  align-items: center;
  gap: 14px;
}

.widget-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--wc, var(--ac)) 18%, transparent);
  color: var(--wc, var(--ac));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.widget-info {
  flex: 1;
  min-width: 0;
}

.widget-tile.dragging {
  opacity: .4;
}

.widget-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}

.widget-tile:hover .widget-actions,
.widget-divider:hover .widget-actions {
  opacity: 1;
}

.widget-drag {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  cursor: grab;
  color: var(--muted);
  font-size: 13px;
}

.widget-drag:active {
  cursor: grabbing;
}

.widget-edit-btn,
.widget-remove {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  font-size: 11px;
}

.widget-edit {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.widget-edit input,
.widget-edit select {
  width: 100%;
}

.widget-label {
  font-size: 12px;
  color: var(--soft);
  letter-spacing: .02em;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.widget-value {
  font-size: 24px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
  font-family: 'Geist Mono', monospace;
}

.widget-unit {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.widget-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.icon-pick {
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 15px;
  border-radius: 8px;
}

.widget-divider {
  grid-column: 1 / -1;
  position: relative;
  padding: 6px 4px;
}

.widget-divider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.widget-divider-label {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  white-space: nowrap;
}

.widget-divider-row::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.widget-divider .widget-edit {
  background: var(--card);
  border: 1px solid var(--line2);
  border-radius: var(--card-rad);
  padding: 12px;
  margin-top: 8px;
}

.widget-graph-tile {
  grid-column: span 2;
}

.widget-graph-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.widget-icon-sm {
  font-size: 16px;
  flex-shrink: 0;
}

.widget-value-sm {
  margin-left: auto;
  font-family: 'Geist Mono', monospace;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.widget-sparkline {
  width: 100%;
  height: 50px;
  display: block;
  cursor: crosshair;
}

.widget-spark-wrap {
  position: relative;
}

.spark-tooltip {
  position: absolute;
  top: -6px;
  transform: translate(-50%, -100%);
  background: var(--surface2);
  border: 1px solid var(--line2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
  z-index: 2;
}

.spark-tooltip strong {
  color: var(--text);
  font-family: 'Geist Mono', monospace;
}

.spark-tooltip-time {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 1px;
}

.modal.more-info-card {
  max-width: 640px;
}

.more-info-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.more-info-title {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
}

.more-info-value {
  font-size: 32px;
  font-weight: 500;
  font-family: 'Geist Mono', monospace;
  color: var(--text);
  margin-bottom: 14px;
  text-align: left;
}

.more-info-graph-wrap {
  margin: 14px 0;
}

.more-info-graph {
  height: 160px;
}

.more-info-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  text-align: left;
}

.more-info-stats strong {
  color: var(--text);
  font-family: 'Geist Mono', monospace;
}

@media (max-width: 640px) {
  .widget-graph-tile {
    grid-column: 1 / -1;
  }
}

.public-board-header {
  justify-content: center;
}

.public-board-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}

.live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ac);
  box-shadow: 0 0 8px var(--ac);
  animation: livePulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.board-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.board-tab {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--soft);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
}

.board-tab:hover {
  color: var(--text);
  background: var(--surface2);
}

.board-tab.active {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--ac);
}

.board-tab-add {
  border-style: dashed;
}

pre.payload {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: calc(var(--card-rad) * 0.7);
  padding: 12px;
  overflow-x: auto;
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  margin: 12px 0;
  position: relative;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  align-items: center;
  position: relative;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--soft);
  border: 1px solid var(--line2);
  border-radius: var(--r);
  padding: 6px 14px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

button:hover, .btn:hover {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--line2);
}

button.danger {
  background: rgba(248,113,113,.08);
  border-color: rgba(248,113,113,.2);
  color: #f87171;
}

button.danger:hover {
  background: rgba(248,113,113,.16);
}

button.primary {
  background: var(--text);
  color: var(--bg);
  border: none;
  font-weight: 600;
}

button.primary:hover {
  opacity: .87;
}

input[type="text"] {
  background: var(--surface2);
  border: 1px solid var(--line2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
}

input[type="color"] {
  width: 32px;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--line2);
  border-radius: 6px;
  background: var(--surface2);
  cursor: pointer;
}

select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--font);
  font-size: 13px;
}

code.token {
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--soft);
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.embed-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  width: fit-content;
  min-width: 220px;
}

.embed-card.theme-light {
  background: #ffffff;
  color: #15171a;
  border-color: #e1e4e8;
}

.embed-card.theme-light pre.payload {
  background: #f5f6f8;
  border-color: #e1e4e8;
  color: #15171a;
}

/* live view */
.live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.kv-tree {
  font-family: 'Geist Mono', monospace;
  font-size: 13px;
  line-height: 1.7;
}

.kv-tree ul {
  list-style: none;
  margin: 4px 0 4px 16px;
  padding: 0;
  border-left: 1px solid var(--line);
  padding-left: 12px;
}

.kv-tree .kv-key { color: var(--muted); margin-right: 6px; }
.kv-tree .kv-string { color: #3ecf8e; }
.kv-tree .kv-number { color: var(--ac); }
.kv-tree .kv-bool { color: #f0a85b; }
.kv-tree .kv-null { color: var(--muted); }

/* theme drawer */
.theme-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: transparent;
  pointer-events: none;
  transition: background .25s;
}

.theme-overlay.open {
  background: rgba(0,0,0,.65);
  pointer-events: auto;
  backdrop-filter: blur(3px);
}

.theme-drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(360px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line2);
  transform: translateX(100%);
  z-index: 201;
  transition: transform .3s cubic-bezier(.22,1,.36,1);
  overflow-y: auto;
}

.theme-overlay.open .theme-drawer { transform: none; }

.td-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
}

.td-title { font-size: 13px; font-weight: 500; }

.ico-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
}

.ico-btn:hover { color: var(--text); background: var(--surface2); }

.td-body { padding: 16px 20px; }

.theme-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--soft);
}

.td-section-title {
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.td-section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.preset-swatch {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 10px 8px;
  border-radius: 8px;
  border: 1px solid var(--line2);
  background: var(--sw-bg, var(--surface2));
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}

.preset-swatch::before {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sw-ac, var(--ac));
}

.preset-swatch:hover {
  border-color: var(--sw-ac, var(--ac));
  transform: translateY(-1px);
}

/* confirm modal */
.mbg {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,.75);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.mbg.open { display: flex; }

.modal {
  background: var(--surface2);
  border: 1px solid var(--line2);
  border-radius: 14px;
  padding: 24px 26px;
  max-width: 300px;
  width: 100%;
  text-align: center;
}

.modal h3 { font-size: 15px; font-weight: 500; letter-spacing: -.02em; margin-bottom: 8px; }
.modal p { font-size: 13px; color: var(--soft); line-height: 1.6; margin-bottom: 20px; }

.m-row { display: flex; gap: 8px; justify-content: center; }

.m-btn {
  padding: 8px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--soft);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.m-btn:hover { color: var(--text); background: var(--surface2); }
.m-btn.danger { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.2); color: #f87171; }
.m-btn.danger:hover { background: rgba(248,113,113,.18); }

/* toast */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--line2);
  color: var(--text);
  padding: .7rem 1.1rem;
  border-radius: 9px;
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0,0,0,.45);
  animation: toastIn .2s ease both;
  max-width: 300px;
  pointer-events: auto;
}

.toast--success { border-color: rgba(62,207,142,.35); }
.toast--error { border-color: rgba(248,113,113,.35); }
.toast--hide { opacity: 0; transform: translateX(20px); transition: all .25s; }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.site-footer {
  text-align: center;
  padding: 24px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  margin-top: 24px;
}

/* ── mobile ── */
@media (max-width: 640px) {
  header.topbar {
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }

  header.topbar nav {
    flex-wrap: wrap;
    gap: 6px;
  }

  main {
    padding: 16px 14px 60px;
  }

  .card {
    padding: 14px;
  }

  .row {
    gap: 6px;
  }

  .row button, .row .btn, .row form button {
    flex: 1 1 auto;
    justify-content: center;
    padding: 9px 12px;
    font-size: 13px;
  }

  .row input[type="text"], .row select {
    flex: 1 1 100%;
    width: 100%;
  }

  .ep-summary {
    gap: 8px;
  }

  .ep-name {
    font-size: 13px;
  }

  .ep-note-preview {
    font-size: 11px;
  }

  .theme-drawer {
    width: 100vw;
  }

  .category-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  pre.payload {
    font-size: 11px;
    padding: 10px;
  }

  .kv-tree {
    font-size: 12px;
    word-break: break-word;
  }

  .kv-tree ul {
    margin-left: 8px;
    padding-left: 8px;
  }

  .modal {
    max-width: 90vw;
  }

  #toast-container {
    left: 1.25rem;
    right: 1.25rem;
    bottom: 1rem;
  }

  .toast {
    max-width: none;
  }

  .site-footer {
    padding: 16px;
  }
}
