/* Swivy base app styles */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: var(--fs-15);
  line-height: var(--lh-normal);
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* --- Shell --- */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.env-rail {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--env-current);
  z-index: 50;
  transition: background 240ms var(--ease-out);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-sunken);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px 17px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 18px;
}
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.02em;
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 48%, oklch(100% 0 0 / 0.12) 50%, transparent 52%);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.org-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color 120ms;
}
.org-switch:hover { border-color: var(--line-strong); }
.org-avatar {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-display);
}
.org-name { flex: 1; font-size: var(--fs-13); font-weight: 500; }
.org-sub { font-size: 11px; color: var(--ink-3); letter-spacing: 0.02em; }

.nav-section {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 10px 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--r-2);
  font-size: var(--fs-13);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.nav-item:hover { background: var(--panel); color: var(--ink); }
.nav-item.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}
.nav-item .nav-icon { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-item .nav-kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 2px;
}
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(from var(--accent) calc(l + 0.15) c h), var(--accent));
  display: grid; place-items: center;
  color: var(--accent-contrast);
  font-size: 11px;
  font-weight: 600;
}

/* --- Main --- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-13);
  color: var(--ink-3);
}
.crumbs b { color: var(--ink); font-weight: 500; }
.crumbs .sep { color: var(--ink-4); font-size: 11px; }

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border-radius: var(--r-full);
  background: color-mix(in oklch, var(--env-current) 10%, var(--bg));
  border: 1px solid color-mix(in oklch, var(--env-current) 35%, var(--line));
  font-size: 12px;
  font-weight: 500;
  color: color-mix(in oklch, var(--env-current) 80%, var(--ink));
  cursor: pointer;
  transition: background 120ms;
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}
.env-pill:hover { background: color-mix(in oklch, var(--env-current) 18%, var(--bg)); }
.env-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--env-current);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--env-current) 20%, var(--bg));
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  color: var(--ink-3);
  border-radius: var(--r-2);
  transition: background 120ms, color 120ms;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--ink); }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 30px;
  min-width: 240px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  color: var(--ink-4);
  font-size: var(--fs-13);
  cursor: pointer;
  transition: border-color 120ms;
}
.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--bg);
  color: var(--ink-3);
}

/* --- Content --- */
.content {
  padding: 32px 40px 120px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.page-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-32);
  letter-spacing: -0.028em;
  line-height: 1.1;
  margin: 0 0 6px;
}
.page-sub {
  font-size: var(--fs-14);
  color: var(--ink-3);
  line-height: 1.5;
  max-width: 64ch;
}
.page-actions { margin-left: auto; display: flex; gap: 8px; flex: none; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-2);
  font-size: var(--fs-13);
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms, transform 80ms;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}
.btn-primary:hover { background: oklch(from var(--ink) calc(l + 0.06) c h); }

.btn-secondary {
  background: var(--panel);
  border-color: var(--line-2);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--bg-sunken); border-color: var(--line-strong); }

.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--ink); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: oklch(from var(--danger) calc(l - 0.04) c h); }

.btn-danger-ghost { color: var(--danger); border-color: var(--line-2); background: var(--panel); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 40%, var(--line)); }

.btn-sm { height: 26px; padding: 0 9px; font-size: var(--fs-12); }
.btn-lg { height: 38px; padding: 0 16px; font-size: var(--fs-14); }

/* --- Cards --- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  overflow: hidden;
}
.card-hd {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-15);
  letter-spacing: -0.015em;
}
.card-sub { font-size: var(--fs-12); color: var(--ink-3); margin-top: 2px; }
.card-body { padding: 18px; }
.card-body.pad-lg { padding: 24px; }
.card-body.pad-0 { padding: 0; }

/* --- Tables --- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-12);
  letter-spacing: 0.01em;
  background: var(--bg-sunken);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: color-mix(in oklch, var(--bg-sunken) 50%, transparent); }

/* --- Status badges --- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 6px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  border: 1px solid transparent;
  font-family: var(--font-body);
}
.status .dot { width: 6px; height: 6px; border-radius: 50%; }

.status-active { background: var(--ok-soft); color: oklch(from var(--ok) calc(l - 0.12) c h); }
.status-active .dot { background: var(--ok); }
.status-pending { background: var(--warn-soft); color: oklch(from var(--warn) calc(l - 0.18) c h); }
.status-pending .dot { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
.status-revoked { background: var(--danger-soft); color: oklch(from var(--danger) calc(l - 0.1) c h); }
.status-revoked .dot { background: var(--danger); }
.status-verified { background: var(--ok-soft); color: oklch(from var(--ok) calc(l - 0.12) c h); }
.status-verified .dot { background: var(--ok); }
.status-failed { background: var(--danger-soft); color: oklch(from var(--danger) calc(l - 0.1) c h); }
.status-failed .dot { background: var(--danger); }
.status-action { background: var(--accent-soft); color: var(--accent-ink); }
.status-action .dot { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.status-neutral { background: var(--bg-sunken); color: var(--ink-2); border-color: var(--line); }
.status-neutral .dot { background: var(--ink-4); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Mono token (keys, addresses, ids) --- */
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: -0.01em;
}
.truncate-id {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 2px 7px;
  cursor: pointer;
}
.truncate-id:hover { background: var(--bg); border-color: var(--line-strong); }
.truncate-id .copy-icn { width: 11px; height: 11px; color: var(--ink-4); }

/* --- Form --- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.field-label .req { color: var(--danger); }
.field-hint { font-size: var(--fs-12); color: var(--ink-3); line-height: 1.45; }
.field-error { font-size: var(--fs-12); color: var(--danger); display: flex; align-items: center; gap: 5px; }

.input, .select, .textarea {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  padding: 8px 11px;
  font-size: var(--fs-13);
  color: var(--ink);
  transition: border-color 120ms, box-shadow 120ms;
  width: 100%;
}
.input:hover, .select:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { font-family: var(--font-mono); font-size: var(--fs-12); resize: vertical; min-height: 80px; }

/* Segmented */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  gap: 2px;
}
.segmented button {
  padding: 4px 11px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-3);
  border-radius: 4px;
  transition: background 120ms, color 120ms;
}
.segmented button:hover { color: var(--ink); }
.segmented button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Checkbox / toggle */
.toggle {
  width: 30px; height: 18px;
  border-radius: 999px;
  background: var(--line-2);
  position: relative;
  cursor: pointer;
  transition: background 160ms;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: transform 160ms var(--ease-out);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(12px); }

/* --- Layouts --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }

/* --- Code block --- */
.code {
  background: var(--bg-code);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
}
.code-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 14px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
  height: 34px;
}
.code-tab {
  padding: 0 10px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11.5px;
  margin-bottom: -1px;
}
.code-tab.on { color: var(--ink); border-bottom-color: var(--accent); background: var(--bg-code); }
.code-lang {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.code-body {
  padding: 14px 16px;
  color: var(--ink);
  overflow: auto;
  max-height: 420px;
}
.code-body .ln { color: var(--ink-4); user-select: none; margin-right: 14px; display: inline-block; width: 1.6em; text-align: right; }
.tok-k { color: oklch(45% 0.15 300); font-weight: 500; }
.tok-s { color: oklch(44% 0.13 145); }
.tok-n { color: oklch(48% 0.14 35); }
.tok-c { color: var(--ink-4); font-style: italic; }
.tok-f { color: oklch(40% 0.14 255); }
.tok-p { color: var(--ink-2); }

[data-theme="dark-ink"] .tok-k { color: oklch(75% 0.16 300); }
[data-theme="dark-ink"] .tok-s { color: oklch(75% 0.14 145); }
[data-theme="dark-ink"] .tok-n { color: oklch(78% 0.14 35); }
[data-theme="dark-ink"] .tok-f { color: oklch(72% 0.14 255); }
[data-theme="dark-ink"] .tok-p { color: var(--ink-2); }

/* --- Chain badge --- */
.chain {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 4px;
  border-radius: var(--r-full);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.chain-glyph {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

/* --- Modal --- */
.scrim {
  position: fixed; inset: 0;
  background: color-mix(in oklch, var(--ink) 30%, transparent);
  backdrop-filter: blur(3px);
  z-index: 90;
  animation: fadein 160ms var(--ease-out);
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup {
  from { opacity: 0; transform: translate(-50%, -44%) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.modal {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-5);
  box-shadow: var(--shadow-modal);
  z-index: 100;
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideup 220ms var(--ease-out);
}
.modal-hd {
  padding: 20px 24px 12px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.modal-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-3);
  display: grid; place-items: center;
  flex: none;
}
.modal-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.02em;
  margin: 2px 0 4px;
}
.modal-desc { font-size: var(--fs-13); color: var(--ink-3); line-height: 1.5; }
.modal-body { padding: 4px 24px 16px; flex: 1; overflow: auto; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg-sunken);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-foot .spacer { flex: 1; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(620px, 96vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: drawerIn 280ms var(--ease-out);
}

/* --- Util --- */
.hr { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink-2);
}
.muted { color: var(--ink-3); }
.dim { color: var(--ink-4); }

/* --- Tweaks panel --- */
.tweaks-panel {
  position: fixed;
  bottom: 20px; right: 20px;
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.tweaks-hd {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}
.tweaks-body {
  max-height: 64vh;
  overflow: auto;
  padding: 10px 14px 14px;
}
.tweak-row {
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.tweak-row:last-child { border-bottom: 0; }
.tweak-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.tweak-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tweak-chip {
  font-size: 11.5px;
  padding: 4px 8px;
  border-radius: var(--r-2);
  background: var(--bg-sunken);
  color: var(--ink-2);
  border: 1px solid transparent;
  cursor: pointer;
}
.tweak-chip:hover { background: var(--bg); border-color: var(--line-2); }
.tweak-chip.on { background: var(--ink); color: var(--bg); }

/* --- Empty state --- */
.empty {
  padding: 48px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.015em;
}
.empty-desc { font-size: var(--fs-13); color: var(--ink-3); max-width: 44ch; line-height: 1.55; }
.empty-illus {
  width: 220px; height: 120px;
  position: relative;
}
