:root {
  --bg: #000000;
  --bg-alt: #040709;
  --panel: #040608;
  --panel-alt: #07090c;
  --panel-strong: #0b0e12;
  --line: rgba(80, 180, 200, 0.1);
  --line-strong: rgba(80, 180, 200, 0.22);
  --text: #d6eaf0;
  --muted: #527080;
  --soft: rgba(0, 180, 210, 0.04);
  --soft-2: rgba(0, 180, 210, 0.07);
  --good: #d6eaf0;
  --bad: #b8c8cc;
  --accent: #00bcd4;
  --accent-glow: rgba(0, 188, 212, 0.28);
  --amber: #e8a020;
  --amber-glow: rgba(232, 160, 32, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100vh;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
}

.app-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 80% at 50% 0%, rgba(0, 80, 120, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 15% 50%, rgba(0, 60, 100, 0.1) 0%, transparent 55%),
    radial-gradient(ellipse 50% 50% at 85% 70%, rgba(0, 40, 80, 0.08) 0%, transparent 55%);
}

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

label {
  display: grid;
  gap: 1px;
  background: var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

label > span {
  display: flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  background: #0b0b0b;
}

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

.auth-card {
  width: min(520px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  clip-path: polygon(14px 0%, 100% 0%, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0% 100%, 0% 14px);
}

.wallet-picker {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.confirm-card {
  width: min(380px, 100%);
  display: grid;
  gap: 1px;
  padding: 1px;
  background: rgba(0, 160, 190, 0.12);
  clip-path: polygon(10px 0%, 100% 0%, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0% 100%, 0% 10px);
}

.confirm-header,
#confirm-message,
.confirm-actions {
  background: #050505;
}

.confirm-header {
  padding: 10px 14px 8px;
}

.confirm-header h2 {
  font-size: 14px;
  margin-top: 2px;
}

#confirm-message {
  padding: 8px 14px 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}

.confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
}

.confirm-actions .button {
  width: 100%;
}

.wallet-picker-card {
  width: min(480px, 100%);
  display: grid;
  gap: 1px;
  padding: 1px;
  background: rgba(0, 160, 190, 0.12);
  clip-path: polygon(12px 0%, 100% 0%, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0% 100%, 0% 12px);
}

.wallet-picker-header {
  margin: 0;
  padding: 10px 14px 8px;
  background: var(--panel);
}

.wallet-picker-header h2 {
  font-size: 14px;
  margin-top: 2px;
}

.wallet-picker-card > .auth-copy {
  margin: 0;
  padding: 8px 14px;
  background: var(--panel);
  font-size: 12px;
}

.wallet-picker-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.wallet-picker-option {
  min-height: 54px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 1px;
  padding: 0;
  border: 0;
  background: var(--line);
  color: var(--text);
  text-align: left;
}

.wallet-picker-option {
  transition: box-shadow 180ms ease;
}

.wallet-picker-option:hover {
  background: var(--line-strong);
  box-shadow: inset 3px 0 0 var(--accent);
}

.wallet-picker-mark,
.wallet-picker-copy {
  display: flex;
  align-items: center;
  min-width: 0;
  background: var(--panel);
}

.wallet-picker-mark {
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.wallet-picker-copy {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 0 12px;
  gap: 2px;
}

.wallet-picker-copy strong {
  font-size: 12px;
  font-weight: 600;
}

.wallet-picker-copy span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

#wallet-picker-cancel {
  min-height: 34px;
  background: var(--panel);
}

.auth-brand,
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #000000;
  font-weight: 800;
  clip-path: polygon(8px 0%, 100% 0%, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0% 100%, 0% 8px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 10px;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

.auth-copy,
.empty-state,
.subtle {
  color: var(--muted);
  line-height: 1.45;
}

.stack {
  display: grid;
  gap: 1px;
}

.compact {
  gap: 1px;
}

.gap-sm {
  gap: 1px;
}

.dashboard {
  position: relative;
  z-index: 1;
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-wrap: wrap;
}

.topbar-session {
  display: grid;
  grid-template-columns: 88px minmax(180px, 1fr);
  gap: 1px;
  background: var(--line);
}

.topbar-label,
.topbar-session code {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  background: var(--panel-alt);
}

.topbar-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.admin-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid rgba(232, 160, 32, 0.35);
  background: rgba(232, 160, 32, 0.06);
  border-radius: 2px;
}

.admin-bar-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: nowrap;
}

.admin-impersonate-select {
  height: 26px;
  width: auto;
  max-width: 220px;
  font-size: 11px;
  padding: 0 6px;
  background: var(--panel-strong);
  border: 1px solid rgba(232, 160, 32, 0.3);
  color: var(--text);
  cursor: pointer;
}

.admin-impersonate-badge {
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color: var(--amber);
  background: rgba(232, 160, 32, 0.15);
  border: 1px solid rgba(232, 160, 32, 0.4);
  padding: 2px 6px;
  border-radius: 2px;
  white-space: nowrap;
  animation: admin-pulse 2s ease-in-out infinite;
}

@keyframes admin-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

.admin-wallet-picker {
  position: relative;
}

.admin-wallet-picker-btn {
  appearance: none;
  background: #090909;
  border: 1px solid rgba(80, 180, 200, 0.18);
  color: var(--text);
  font-size: 10px;
  height: 22px;
  padding: 0 8px;
  border-radius: 2px;
  cursor: pointer;
  min-width: 80px;
  text-align: left;
}
.admin-wallet-picker-btn:hover { border-color: rgba(80, 180, 200, 0.4); }

.admin-wallet-dropdown {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  z-index: 9999;
  background: var(--panel-strong);
  border: 1px solid var(--line-strong);
  min-width: 220px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  border-radius: 2px;
}

.admin-wallet-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(80, 180, 200, 0.06);
}
.admin-wallet-row:last-child { border-bottom: none; }
.admin-wallet-row.active { background: rgba(0, 188, 212, 0.07); }

.admin-wallet-select-btn {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 10px;
  padding: 7px 8px;
  cursor: pointer;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-wallet-select-btn:hover { color: var(--accent); }

.admin-skim-label {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 8px 0 4px;
  font-size: 9px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.admin-skim-label:has(input:checked) { color: rgba(232, 160, 32, 0.9); }
.admin-skim-label input[type="checkbox"] { accent-color: rgba(232, 160, 32, 0.9); cursor: pointer; }

.admin-skim-pct-row {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.admin-skim-pct-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  width: 100%;
}
.admin-skim-pct-input {
  width: 48px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  color: var(--text);
  font-size: 10px;
  padding: 2px 4px;
  text-align: right;
  -moz-appearance: textfield;
}
.admin-skim-pct-input::-webkit-outer-spin-button,
.admin-skim-pct-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.admin-skim-pct-input:focus { outline: 1px solid rgba(80,180,200,0.5); border-color: rgba(80,180,200,0.5); }

.admin-edit-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0 2px;
  margin-left: 4px;
  cursor: pointer;
  color: rgba(232, 160, 32, 0.55);
  font-size: 10px;
  line-height: 1;
  vertical-align: middle;
  transition: color 0.15s;
}
.admin-edit-btn:hover {
  color: rgba(232, 160, 32, 1);
}

.epoch-th-del,
.epoch-td-del {
  width: 22px;
  padding: 2px 2px !important;
  text-align: center !important;
}

.epoch-del-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: rgba(224, 85, 85, 0.45);
  font-size: 12px;
  line-height: 1;
  transition: color 0.15s;
}
.epoch-del-btn:hover {
  color: rgba(224, 85, 85, 1);
}

.banner {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 12px 0 11px;
  border-bottom: 1px solid var(--line-strong);
  border-left: 3px solid rgba(0, 188, 212, 0.45);
  background: var(--panel-alt);
  font-size: 12px;
  transition: border-left-color 300ms ease;
}

.banner.error {
  border-left-color: rgba(200, 80, 80, 0.7);
}

.banner.success {
  border-left-color: rgba(80, 200, 120, 0.6);
}

.banner.success,
.banner.error,
.banner.info {
  color: var(--text);
}

.workspace {
  --left-col: 33vw;
  position: relative;
  display: grid;
  grid-template-columns: var(--left-col) minmax(420px, 1fr);
  gap: 1px;
  min-height: 0;
  background: var(--line-strong);
  overflow: hidden;
}

.dock-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  overflow: hidden;
  position: relative;
}

.dock-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  background: linear-gradient(180deg, rgba(0, 188, 212, 0.09) 0%, transparent 100%);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
}

.dock-panel:hover::before {
  animation: panel-header-flash 0.55s ease-out forwards;
}

@keyframes panel-header-flash {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}

.dock-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 6px 8px 6px 10px;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid rgba(0, 188, 212, 0.45);
  background: var(--panel-strong);
  position: relative;
}

.dock-titlebar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  right: 0;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(0, 188, 212, 0.5);
  border-bottom: 1px solid rgba(0, 188, 212, 0.5);
  pointer-events: none;
}

.dock-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  background: #06080a;
}

.workspace-column {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 1px;
  background: var(--line-strong);
  overflow: hidden;
}

.workspace-column-left {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000000;
  box-shadow: inset -1px 0 0 rgba(0, 160, 190, 0.18), inset 1px 0 0 rgba(0, 80, 120, 0.12);
}

.workspace-column-left .dock-panel {
  flex-shrink: 0;
  background: #000000;
}

.workspace-column-left .dock-body {
  flex: unset;
  min-height: unset;
  overflow: visible;
  opacity: 1;
}

.left-tab-bar {
  display: flex;
  flex-shrink: 0;
  background: var(--panel-strong);
  border-bottom: 1px solid var(--line-strong);
}

.left-tab {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 2px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s, background 0.15s;
}

.left-tab:last-child {
  border-right: none;
}

.left-tab:hover {
  color: var(--text);
  background: var(--soft);
}

.left-tab.active {
  color: var(--accent);
  background: var(--soft-2);
  border-bottom: 2px solid var(--accent);
}

.left-tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.left-tab-panel.active {
  display: flex;
}

.left-tab-panel.active .dock-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 188, 212, 0.2) transparent;
}

.workspace-column-center {
  --center-row-a: 394px;
  grid-template-rows: var(--center-row-a) minmax(160px, 1fr);
}

.center-bottom {
  position: relative;
  display: grid;
  grid-template-columns: var(--center-bottom-left, 380px) minmax(0, 1fr);
  gap: 1px;
  background: var(--line-strong);
  min-height: 0;
  overflow: hidden;
}

.center-bottom .workspace-splitter-v-center-bottom {
  left: var(--center-bottom-left, 380px);
  top: 0;
  bottom: 0;
}

#panel-chart,
#panel-detail,
#panel-position,
#panel-funding {
  min-width: 0;
  min-height: 0;
}

#panel-detail .dock-body,
#panel-position .dock-body,
#panel-funding .dock-body {
  min-width: 0;
}

#instance-settings-form {
  min-width: 0;
  width: 100%;
}

.settings-tab-bar {
  display: flex;
  gap: 1px;
  background: rgba(0, 160, 190, 0.1);
  border-bottom: 1px solid rgba(0, 160, 190, 0.18);
  flex-shrink: 0;
}

.settings-tab {
  flex: 1;
  height: 26px;
  padding: 0 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  border: 0;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}

.settings-tab:hover {
  color: var(--text);
  background: rgba(0, 188, 212, 0.06);
}

.settings-tab.active {
  color: var(--accent);
  background: rgba(0, 188, 212, 0.1);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.settings-sheet {
  display: grid;
  gap: 1px;
  padding: 0;
  background: rgba(0, 160, 190, 0.05);
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.12);
}

.settings-group[data-settings-tab] {
  display: none;
}

.settings-group[data-settings-tab].tab-active {
  display: grid;
  gap: 1px;
}

.settings-group {
  display: grid;
  gap: 1px;
  background: rgba(0, 160, 190, 0.04);
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.1);
}

.settings-group-head {
  min-height: 28px;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 1px;
  background: rgba(0, 160, 190, 0.08);
  border-left: 2px solid rgba(0, 188, 212, 0.3);
}

.settings-group-head > span,
.settings-group-head > strong {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 8px;
  background: #0b0b0b;
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.09);
}

.settings-group-head > span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.settings-group-head > strong {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
}

.settings-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: rgba(0, 160, 190, 0.04);
}

.settings-field {
  display: grid;
  grid-template-rows: 20px 34px;
  gap: 1px;
  background: rgba(0, 160, 190, 0.04);
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.09);
  transition: box-shadow 150ms ease;
}

.settings-field:focus-within {
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.45);
}

.settings-field:hover > span {
  color: var(--text);
  transition: color 150ms ease;
}

.settings-field > span {
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: #0d0d0d;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.08);
}

.settings-field > input,
.settings-field > select {
  background: #090909;
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.09);
}

.settings-field-wide {
  grid-column: span 2;
}

#settings-save-btn {
  width: auto;
  min-width: 72px;
  height: 28px;
  min-height: 28px;
  padding: 0 14px;
  font-size: 10px;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

#funding-form {
  display: grid;
  gap: 6px;
  padding: 6px;
  background: transparent;
}

.funding-group,
.funding-actions {
  display: grid;
  gap: 1px;
  background: transparent;
}

.funding-head {
  min-height: 20px;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 1px;
  background: rgba(0, 160, 190, 0.1);
}

.funding-head > span,
.funding-head > strong {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 8px;
  background: #050505;
}

.funding-head > span {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.funding-head > strong {
  justify-content: flex-end;
  font-size: 10px;
  font-weight: 600;
}

.asset-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(0, 160, 190, 0.1);
  margin-bottom: 1px;
}

.asset-btn {
  height: 32px;
  background: var(--panel);
  color: var(--muted);
  border: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.asset-btn::before {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -18%;
  width: 18%;
  background: rgba(0, 188, 212, 0.18);
  transform: skewX(-22deg) translateX(-280%);
  transition: transform 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: none;
  z-index: 0;
}

.asset-btn:hover {
  color: var(--text);
  background: rgba(0, 188, 212, 0.06);
}

.asset-btn:hover::before {
  transform: skewX(-22deg) translateX(760%);
}

.asset-btn.active {
  color: var(--accent);
  background: rgba(0, 188, 212, 0.1);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.perf-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  margin-bottom: 1px;
}

.perf-card-grid .metric-card {
  min-height: 48px;
}

.perf-card-grid .metric-card strong {
  font-size: 13px;
}

.perf-stats {
  display: grid;
  gap: 1px;
  background: rgba(0, 160, 190, 0.08);
  margin-bottom: 6px;
}

.perf-stats .kv {
  background: var(--panel);
}

.perf-chart-wrap {
  padding: 6px 6px 4px;
}

.perf-chart-label {
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  margin-bottom: 4px;
}

.perf-chart {
  display: block;
  width: 100%;
  height: 72px;
  overflow: visible;
}

.good { color: #4caf82; }
.bad  { color: #e05555; }

.epoch-section {
  padding: 0 6px 8px;
}

.epoch-section-label {
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  margin-bottom: 4px;
}

.epoch-table-wrap {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 188, 212, 0.15) transparent;
}

.epoch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: nowrap;
}

.epoch-table th {
  padding: 3px 6px;
  text-align: right;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 10px;
}

.epoch-table th:first-child {
  text-align: left;
}

.epoch-table td {
  padding: 3px 6px;
  text-align: right;
  color: var(--text);
  border-bottom: 1px solid rgba(80, 180, 200, 0.05);
}

.epoch-table td:first-child {
  text-align: left;
  color: var(--muted);
}

.epoch-table tbody tr:hover td {
  background: var(--soft);
}

.funding-toggle {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: 1px;
  background: rgba(0, 160, 190, 0.1);
}

.funding-toggle > span,
.funding-toggle > input,
.funding-ticks > span,
.funding-summary > span,
.funding-summary > strong,
.funding-summary > code {
  background: #050505;
}

.funding-toggle > span {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.funding-toggle > input,
#funding-percent-slider {
  width: 100%;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  height: 30px;
  padding: 0 10px;
  background: #050505;
}

.funding-ticks {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: rgba(0, 160, 190, 0.1);
}

.funding-ticks > span {
  min-height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.funding-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 1px;
  background: rgba(0, 160, 190, 0.1);
}

.funding-field {
  display: grid;
  grid-template-rows: 18px 30px;
  gap: 1px;
  background: rgba(0, 160, 190, 0.1);
}

.funding-field > span {
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: #050505;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.funding-field > input {
  background: #050505;
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.09);
}

.funding-summary {
  display: grid;
  gap: 1px;
  padding: 0;
  background: rgba(0, 160, 190, 0.1);
}

.funding-summary > span,
.funding-summary > strong,
.funding-summary > code {
  min-height: 16px;
  display: flex;
  align-items: center;
  padding: 0 8px;
}

.funding-summary > span {
  font-size: 10px;
  font-weight: 600;
}

.funding-summary > strong {
  font-size: 13px;
}

.funding-summary > code {
  color: var(--muted);
  font-size: 9px;
}

.funding-actions .button {
  width: 100%;
  min-height: 32px;
}

.funding-toggle > input::-webkit-slider-runnable-track,
#funding-percent-slider::-webkit-slider-runnable-track {
  height: 2px;
  background: rgba(0, 160, 190, 0.22);
}

.funding-toggle > input::-moz-range-track,
#funding-percent-slider::-moz-range-track {
  height: 2px;
  background: rgba(0, 160, 190, 0.22);
  border: 0;
}

.funding-toggle > input::-webkit-slider-thumb,
#funding-percent-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-radius: 999px;
  border: 1px solid rgba(0, 188, 212, 0.7);
  background: #000000;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.9) inset;
}

.funding-toggle > input::-moz-range-thumb,
#funding-percent-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 188, 212, 0.7);
  background: #000000;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.9) inset;
}

.workspace-splitter {
  position: absolute;
  z-index: 30;
  background: transparent;
  user-select: none;
  touch-action: none;
}

.workspace-splitter::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 160, 190, 0.18);
  transition: background 200ms ease;
}

.workspace-splitter:hover::before {
  background: rgba(0, 188, 212, 0.5);
}

.workspace-splitter-v {
  top: 0;
  bottom: 0;
  width: 8px;
  margin-left: -4px;
  cursor: col-resize;
}

.workspace-splitter-v::before {
  left: 3px;
  width: 1px;
}

.workspace-splitter-v-left {
  left: var(--left-col);
}


.workspace-splitter-h {
  left: 0;
  right: 0;
  height: 8px;
  margin-top: -4px;
  cursor: row-resize;
}

.workspace-splitter-h::before {
  top: 3px;
  height: 1px;
}

.workspace-column-left .workspace-splitter-h-left-a {
  top: var(--left-row-a);
}

.workspace-column-left .workspace-splitter-h-left-b {
  top: calc(var(--left-row-a) + var(--left-row-b));
}

.workspace-column-left .workspace-splitter-h-left-c {
  top: calc(var(--left-row-a) + var(--left-row-b) + var(--left-row-c));
}

.workspace-column-center .workspace-splitter-h-center-a {
  top: var(--center-row-a);
}

.workspace-column-center .workspace-splitter-h-center-b {
  top: calc(var(--center-row-a) + var(--center-row-b));
}

.chart-full,
.hero-chart-frame {
  height: 100%;
  min-height: 100%;
}

.hero-chart-frame {
  border: 0;
  background: #000000;
  overflow: hidden;
}

.hero-chart-frame iframe {
  width: 100%;
  height: 100%;
  display: block;
}

.panel,
.subpanel {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.subpanel {
  margin-top: 1px;
}

.subpanel > h3,
.result-block,
.range-track,
.range-labels,
.range-fill,
.range-marker,
.kv > span,
.kv > code,
.kv > strong,
.wallet-row > span,
.wallet-row > strong {
  background: var(--panel-alt);
}

.panel.nested.subpanel > h3 {
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 0 8px 0 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(0, 188, 212, 0.55);
  border-left: 2px solid rgba(0, 188, 212, 0.25);
}

.panel-header,
.instance-top,
.action-row,
.wallet-row {
  display: grid;
  gap: 1px;
}

.action-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--line);
}

.action-row .button {
  width: 100%;
  min-height: 28px;
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 0 4px;
}

.grid-two,
.grid-three,
.metric-grid {
  display: grid;
  gap: 1px;
  background: var(--line);
}

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

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

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 1px;
}

.metric-grid-telemetry {
  margin-top: 0;
}

input,
select {
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border: 0;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  transition: background 150ms ease, box-shadow 150ms ease;
}

input:focus,
select:focus {
  outline: none;
  background: #0c1015;
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.5);
}

.button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  background: var(--panel-alt);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.03em;
  transition: background 150ms ease, box-shadow 150ms ease, color 120ms ease;
  transform: none;
  box-shadow: none;
  filter: none;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.button::before {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -18%;
  width: 18%;
  background: rgba(0, 188, 212, 0.18);
  transform: skewX(-22deg) translateX(-280%);
  transition: transform 550ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: none;
  z-index: 0;
}

.button-warn::before {
  background: rgba(232, 160, 32, 0.28);
}

.button-danger::before {
  background: rgba(200, 80, 80, 0.22);
}

.button-purple::before {
  background: rgba(160, 100, 240, 0.28);
}

.button-green::before {
  background: rgba(60, 200, 100, 0.28);
}

.button:hover::before,
.button:active::before {
  transform: skewX(-22deg) translateX(760%);
}

.button:disabled::before,
.button.is-busy::before {
  display: none;
}

.button:hover {
  background: #0d1215;
  transform: none;
  box-shadow: none;
  filter: none;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button.is-busy {
  background: #0d1215;
  animation: pulse-busy 1.6s ease-in-out infinite;
  pointer-events: none;
}

.button-primary {
  background: rgba(0, 188, 212, 0.08);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.45);
}

.button-primary:hover {
  background: rgba(0, 188, 212, 0.14);
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.72);
}

.button-secondary {
  background: var(--panel-alt);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.12);
}

.button-secondary:hover {
  background: #0d1215;
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.3);
}

.button-ghost {
  background: transparent;
  color: var(--muted);
}

.button-ghost:hover {
  background: rgba(0, 160, 190, 0.06);
  color: var(--text);
}

.button-danger {
  background: rgba(200, 50, 50, 0.07);
  color: #e05555;
  box-shadow: inset 0 0 0 1px rgba(200, 80, 80, 0.35);
}

.button-danger:hover {
  background: rgba(200, 50, 50, 0.14);
  color: #ff7070;
  box-shadow: inset 0 0 0 1px rgba(200, 80, 80, 0.6);
}

.button-danger:active {
  filter: brightness(0.9);
}

.metric-card-action {
  cursor: pointer;
}

.metric-card-action:hover {
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.5);
}

.metric-card-action:active {
  filter: brightness(0.92);
}

.metric-card-action.is-busy {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  animation: pulse-busy 1.6s ease-in-out infinite;
}

.button-warn {
  background: rgba(232, 160, 32, 0.07);
  color: var(--amber);
  box-shadow: inset 0 0 0 1px rgba(232, 160, 32, 0.35);
}

.button-warn:hover {
  background: rgba(232, 160, 32, 0.14);
  color: var(--amber);
  box-shadow: inset 0 0 0 1px rgba(232, 160, 32, 0.6);
}

.button-warn:active {
  filter: brightness(0.85);
}

.button-purple {
  background: rgba(139, 92, 246, 0.08);
  color: #b78bfa;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.4);
}

.button-purple:hover {
  background: rgba(139, 92, 246, 0.16);
  color: #c4a1ff;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.7);
}

.button-purple:active {
  filter: brightness(0.88);
}

.button-green {
  background: rgba(34, 197, 94, 0.08);
  color: #4ade80;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.4);
}

.button-green:hover {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.7);
}

.button-green:active {
  filter: brightness(0.88);
}

.action-row .button {
  background: #0b0b0b;
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.12);
}

.action-row .button.button-primary {
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.35);
}

.action-row .button.button-danger {
  color: #e05555;
  box-shadow: inset 0 0 0 1px rgba(200, 80, 80, 0.3);
}

.action-row .button.button-warn {
  color: var(--amber);
  box-shadow: inset 0 0 0 1px rgba(232, 160, 32, 0.3);
}

.action-row .button.button-purple {
  color: #b78bfa;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.35);
}

.action-row .button.button-green {
  color: #4ade80;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.35);
}

#restart-button:hover {
  box-shadow: inset 0 0 0 1px rgba(232, 160, 32, 0.55) !important;
}

#exit-button:hover {
  box-shadow: inset 0 0 0 1px rgba(200, 80, 80, 0.65) !important;
}

.action-row .button:hover {
  background: #0b0b0b;
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.45);
}

.action-row .button:active {
  background: #0b0b0b;
  filter: brightness(0.9);
  transform: translateY(1px);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid rgba(0, 188, 212, 0.3);
  background: var(--panel-alt);
  color: var(--text);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: border-color 200ms ease, color 200ms ease;
}

.pill.muted {
  color: var(--muted);
}

.titlebar-status-group {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.titlebar-status-group .pill {
  border-right: none;
  clip-path: none;
}

.detail-countdown {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid rgba(0, 188, 212, 0.3);
  border-left: 1px solid rgba(0, 188, 212, 0.15);
  background: var(--panel-alt);
  color: var(--accent);
  font-family: "Courier New", "Lucida Console", monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.detail-countdown.overdue {
  color: var(--amber);
  border-color: rgba(232, 160, 32, 0.35);
}

.instance-list,
#wallet-list {
  display: grid;
  gap: 1px;
  background: rgba(0, 160, 190, 0.08);
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.1);
}

.instance-card {
  width: 100%;
  padding: 0;
  border: 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: box-shadow 200ms ease;
}

.instance-card:not(.active):hover {
  box-shadow: inset 3px 0 0 rgba(0, 188, 212, 0.55);
}

.instance-card.active {
  outline: 1px solid rgba(0, 188, 212, 0.65);
  outline-offset: -1px;
  box-shadow: inset 0 0 18px rgba(0, 188, 212, 0.05);
  animation: active-border-pulse 3s ease-in-out infinite;
}

@keyframes active-border-pulse {
  0%, 100% { outline-color: rgba(0, 188, 212, 0.55); }
  50% { outline-color: rgba(0, 188, 212, 0.9); }
}

.instance-top {
  grid-template-columns: minmax(0, 1fr) auto;
}

.instance-top > * {
  min-height: 30px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--panel-strong);
}

.instance-name {
  font-weight: 600;
  font-size: 13px;
}

.instance-meta {
  display: grid;
  gap: 1px;
  background: var(--line);
  color: var(--muted);
}

.instance-meta > div {
  min-height: 28px;
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: var(--panel-alt);
  font-size: 11px;
}

.instance-meta > div > span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 9px;
}

.instance-meta > div > strong {
  justify-self: end;
  color: var(--text);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card {
  display: grid;
  grid-template-rows: 20px 1fr;
  min-height: 58px;
  background: linear-gradient(180deg, var(--panel-alt), #060a0c);
  clip-path: polygon(6px 0%, 100% 0%, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0% 100%, 0% 6px);
  transition: box-shadow 200ms ease;
}

.metric-card:not(.metric-card-action):hover {
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.2);
}

.metric-card:hover strong {
  color: #ffffff;
  transition: color 150ms ease;
}

.metric-card span {
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--line);
}

.metric-card strong {
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.metric-card-deployed {
  grid-template-rows: 20px auto 1fr auto;
  min-height: 72px;
}

.metric-deployed-assets {
  display: flex;
  align-items: center;
  padding: 2px 8px 0;
  font-size: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color: var(--accent);
  opacity: 0.8;
  white-space: nowrap;
}

.metric-deployed-pct {
  display: flex;
  align-items: center;
  padding: 0 8px 4px;
  font-size: 9px;
  letter-spacing: 0.06em;
}

.range-track {
  position: relative;
  height: 18px;
  overflow: hidden;
  background: #060a0c;
  box-shadow: inset 0 0 0 1px rgba(0, 188, 212, 0.22);
}

.range-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0;
  background: rgba(0, 188, 212, 0.2);
  transition: width 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.range-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 18px;
  background: var(--accent);
  transform: translateX(-50%);
  box-shadow: 0 0 6px var(--accent);
  transition: left 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.range-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
}

.range-labels span {
  min-height: 26px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: var(--panel-alt);
  font-size: 11px;
  white-space: nowrap;
}

#range-low {
  justify-content: flex-start;
  text-align: left;
}

#range-high {
  justify-content: flex-end;
  text-align: right;
}

.kv {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
}

.kv > span,
.kv > code,
.kv > strong {
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  min-width: 0;
}

.kv > span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 9px;
}

.wallet-row {
  grid-template-columns: 80px minmax(0, 1fr);
}

.wallet-row > span,
.wallet-row > strong {
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  min-width: 0;
}

.kv > code,
.kv > strong,
.wallet-row > strong,
.instance-meta > div > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle {
  align-content: stretch;
}

.toggle select {
  height: 34px;
  margin: 0;
  justify-self: stretch;
}

.spaced {
  grid-template-columns: 1fr;
}

.hidden {
  display: none !important;
}

.result-block {
  max-height: 320px;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 10px;
  color: #f5f5f5;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

code {
  font-size: 11px;
  color: #ffffff;
  word-break: break-all;
}

#wallet-form,
#instance-form {
  background: var(--line);
}

#wallet-form > *,
#instance-form > *,
#instance-settings-form > *,
#detail-view > * {
  margin: 0;
}

#instance-settings-form {
  background: transparent;
}

#detail-view {
  display: grid;
  gap: 1px;
  background: var(--line);
}

#detail-empty {
  padding: 12px;
  font-size: 12px;
}

#funding-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.45;
}

#wallet-list .instance-card,
#instance-list .instance-card,
#detail-view .subpanel,
#detail-view .metric-grid,
#detail-view .action-row,
#detail-view .grid-two {
  background: rgba(0, 160, 190, 0.06);
}

pre,
code,
.metric-card strong,
.pill,
.topbar-label,
.eyebrow {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (max-width: 1600px) {
  .workspace {
    grid-template-columns: var(--left-col) minmax(380px, 1fr);
  }
}

@media (min-width: 1900px) {
  .workspace {
    grid-template-columns: var(--left-col) minmax(860px, 1fr);
  }

  .workspace-column-left {
    --left-row-a: 78px;
    --left-row-b: 280px;
  }

  .workspace-column-center {
    --center-row-a: 460px;
    --center-row-b: 340px;
  }

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

@media (min-width: 2400px) {
  .workspace {
    grid-template-columns: var(--left-col) minmax(1100px, 1fr);
  }

  .workspace-column-left {
    --left-row-a: 82px;
    --left-row-b: 320px;
  }

  .workspace-column-center {
    --center-row-a: 540px;
    --center-row-b: 380px;
  }

  .dock-titlebar {
    min-height: 42px;
  }
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: var(--left-col) minmax(360px, 1fr);
  }
}

@media (max-width: 980px) {
  .workspace {
    position: static;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .workspace-column {
    grid-template-rows: auto !important;
  }

  .workspace-splitter {
    display: none;
  }

  .grid-three,
  .metric-grid,
  .grid-two,
  .action-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-meta {
    width: 100%;
  }

  .topbar-session {
    width: 100%;
    grid-template-columns: 88px minmax(0, 1fr);
  }
}

.dock-body::-webkit-scrollbar {
  width: 4px;
}

.dock-body::-webkit-scrollbar-track {
  background: transparent;
}

.dock-body::-webkit-scrollbar-thumb {
  background: rgba(0, 188, 212, 0.22);
  border-radius: 0;
}

.dock-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 188, 212, 0.45);
}

.text-accent {
  color: var(--accent);
}

@keyframes pulse-busy {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.result-block::-webkit-scrollbar {
  width: 4px;
}

.result-block::-webkit-scrollbar-track {
  background: transparent;
}

.result-block::-webkit-scrollbar-thumb {
  background: rgba(0, 188, 212, 0.22);
}

.result-block::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 188, 212, 0.45);
}

/* ─── Entrance animations ─── */

.dashboard:not(.hidden) {
  animation: dashboard-enter 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes dashboard-enter {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-card {
  animation: card-enter 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.confirm-modal:not(.hidden) {
  animation: overlay-enter 0.2s ease-out both;
}

@keyframes overlay-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.wallet-picker:not(.hidden) {
  animation: overlay-enter 0.2s ease-out both;
}

/* ─── Background world scan line ─── */

.app-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.app-bg::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -3px;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, rgba(0, 188, 212, 0.06) 40%, rgba(0, 188, 212, 0.12) 50%, rgba(0, 188, 212, 0.06) 60%, transparent 100%);
  animation: world-scan 10s linear infinite;
  pointer-events: none;
}

@keyframes world-scan {
  0%   { top: -3px; }
  100% { top: 100%; }
}

/* ─── Banner flash on update ─── */

@keyframes banner-enter {
  0%   { opacity: 0.4; transform: translateX(-6px); }
  100% { opacity: 1;   transform: translateX(0); }
}

.banner-flash {
  animation: banner-enter 0.22s ease-out both;
}

/* ─── Value flash on telemetry update ─── */

@keyframes value-flash {
  0%   { color: var(--accent); }
  100% { color: var(--text); }
}

.value-flash {
  animation: value-flash 0.6s ease-out both;
}

/* ─── Metric card action shimmer on hover ─── */

.metric-card-action {
  position: relative;
  overflow: hidden;
}

.metric-card-action::before {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -50%;
  width: 50%;
  background: rgba(0, 188, 212, 0.07);
  transform: skewX(-18deg) translateX(-200%);
  transition: transform 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  pointer-events: none;
}

.metric-card-action:hover::before {
  transform: skewX(-18deg) translateX(500%);
}

/* ─── Portfolio bar ─── */

.portfolio-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1px;
  padding: 0;
  border-bottom: 1px solid var(--line-strong);
  background: var(--line-strong);
  font-size: 11px;
  flex-shrink: 0;
}

.portfolio-stats {
  display: flex;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.portfolio-stat {
  display: grid;
  grid-template-rows: 14px 22px;
  padding: 0;
  background: var(--panel);
  min-width: 80px;
  flex: 1;
}

.portfolio-stat > span {
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background: #0b0b0b;
}

.portfolio-stat > strong {
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-alt);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.portfolio-right {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  background: var(--panel);
}

.portfolio-countdown {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: nowrap;
  background: var(--panel);
}

.portfolio-notify-btn {
  min-height: 36px;
  width: 36px;
  padding: 0;
  font-size: 14px;
  text-align: center;
}

/* ─── Copy-to-clipboard feedback ─── */

code {
  cursor: pointer;
  transition: color 120ms ease;
}

code.just-copied {
  color: var(--accent) !important;
}

.clickable-address {
  cursor: pointer;
}

.clickable-address:hover {
  color: var(--accent);
}

/* ─── Out-of-range range bar ─── */

.range-track.out-of-range {
  box-shadow: inset 0 0 0 1px rgba(200, 80, 80, 0.5), 0 0 8px rgba(200, 80, 80, 0.15);
}

.range-track.out-of-range .range-fill {
  background: rgba(200, 80, 80, 0.2);
}

.range-track.out-of-range .range-marker {
  background: #e05555;
  box-shadow: 0 0 6px #e05555;
}

/* ─── Instance cards with stats ─── */

.instance-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
}

.instance-stat {
  display: grid;
  grid-template-rows: 16px 22px;
  background: var(--panel-alt);
}

.instance-stat > span {
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.instance-stat > strong {
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.instance-range-warning {
  grid-column: span 2;
  min-height: 22px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: rgba(200, 80, 80, 0.08);
  color: #e05555;
  font-size: 9px;
  letter-spacing: 0.06em;
  border-top: 1px solid rgba(200, 80, 80, 0.2);
}

/* ─── Activity log ─── */

.log-list {
  display: grid;
  gap: 1px;
  background: rgba(0, 160, 190, 0.06);
}

.log-entry {
  display: grid;
  gap: 1px;
  background: var(--line);
  padding: 0;
}

.log-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 26px;
  padding: 4px 8px;
  background: var(--panel-strong);
}

.log-time {
  color: var(--muted);
  font-size: 9px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: nowrap;
}

.log-event {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.log-trigger, .log-regime {
  font-size: 8px;
  padding: 1px 5px;
  background: rgba(0, 160, 190, 0.1);
  color: var(--muted);
  border: 1px solid rgba(0, 160, 190, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.log-detail {
  padding: 4px 8px 6px;
  background: var(--panel-alt);
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
  word-break: break-word;
}

.log-entry-error .log-event {
  color: #e05555;
}

.log-entry-error .log-detail {
  color: #e05555;
}

.log-entry-ok .log-event {
  color: var(--text);
}

/* ─── Account panel ─── */

#withdraw-form {
  padding: 6px;
  background: rgba(0, 160, 190, 0.04);
}

#withdraw-form .button {
  min-height: 32px;
  width: 100%;
  margin-top: 1px;
}

.balance-history-wrap {
  margin-top: 1px;
}

/* ─── Mobile nav (hidden on desktop) ─── */

.mobile-nav {
  display: none;
}

/* ─── Mobile layout ─── */

@media (max-width: 768px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .dashboard {
    height: 100dvh;
    height: 100vh;
    grid-template-rows: auto auto auto 1fr auto;
    overflow: hidden;
  }

  /* Portfolio bar: compact 1-row strip */
  .portfolio-bar {
    padding: 0 8px;
    min-height: 28px;
    gap: 0;
  }

  .portfolio-stats {
    flex-wrap: nowrap;
    gap: 0;
    flex: 1;
    min-width: 0;
  }

  .portfolio-stat {
    min-width: 0;
    flex: 1;
    padding: 3px 4px;
    gap: 1px;
    border-right: 1px solid var(--line);
  }

  .portfolio-stat:last-child {
    border-right: none;
  }

  .portfolio-stat > span {
    font-size: 7px;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .portfolio-stat > strong {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .portfolio-right {
    display: none;
  }

  /* Show mobile nav */
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--line-strong);
    border-top: 1px solid var(--line-strong);
    flex-shrink: 0;
  }

  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    padding: 4px 2px;
    background: var(--panel);
    color: var(--muted);
    border: 0;
    font-size: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    cursor: pointer;
    transition: color 150ms ease, background 150ms ease, box-shadow 150ms ease;
  }

  .mobile-nav-btn.active {
    color: var(--accent);
    background: rgba(0, 188, 212, 0.08);
    box-shadow: inset 0 2px 0 var(--accent);
  }

  .mobile-nav-icon {
    font-size: 16px;
    line-height: 1;
    font-family: "Segoe UI", Arial, sans-serif;
  }

  /* Workspace: single scrollable column */
  .workspace {
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    gap: 1px !important;
    background: var(--line-strong) !important;
  }

  /* Flatten columns and center-bottom into flow */
  .workspace-column,
  .center-bottom {
    display: contents !important;
  }

  /* On mobile show position/action panel above settings panel */
  #panel-position { order: -1; }
  #panel-detail   { order: 0; }

  /* On mobile panels must not shrink — workspace scrolls instead */
  .dock-panel {
    flex-shrink: 0;
    overflow: visible;
  }

  /* On mobile panels have no fixed height — dock-body must grow with content */
  .dock-body {
    flex: unset !important;
    min-height: unset !important;
    overflow-y: visible !important;
    height: auto !important;
  }

  /* Panel header: slimmer on mobile */
  .dock-titlebar {
    min-height: 36px;
    padding: 0 8px;
  }

  .dock-titlebar h2 {
    font-size: 11px;
  }

  .dock-titlebar .eyebrow {
    font-size: 7px;
  }

  /* Hide splitters */
  .workspace-splitter {
    display: none !important;
  }

  /* Panel tab visibility: hide all grouped panels by default */
  [data-mobile-group] {
    display: none !important;
  }

  body[data-mobile-tab="instances"] [data-mobile-group="instances"] {
    display: flex !important;
  }

  body[data-mobile-tab="position"] [data-mobile-group="position"] {
    display: flex !important;
  }

  body[data-mobile-tab="stats"] [data-mobile-group="stats"] {
    display: flex !important;
  }

  body[data-mobile-tab="tools"] [data-mobile-group="tools"] {
    display: flex !important;
  }

  /* Override left-column accordion: always expand on mobile */
  .workspace-column-left .dock-body {
    max-height: unset !important;
    opacity: 1 !important;
    transition: none !important;
  }

  .workspace-column-left .dock-titlebar h2::after {
    content: none !important;
  }

  /* Instance card: compact layout */
  .instance-top > * {
    min-height: 26px;
  }

  .instance-name {
    font-size: 12px;
  }

  .instance-meta > div {
    min-height: 24px;
    grid-template-columns: 72px minmax(0, 1fr);
    font-size: 10px;
    padding: 0 6px;
    gap: 4px;
  }

  .instance-meta > div > span {
    font-size: 8px;
  }

  .instance-stat {
    grid-template-rows: 14px 20px;
  }

  .instance-stat > span {
    font-size: 7px;
    padding: 0 6px;
  }

  .instance-stat > strong {
    font-size: 11px;
    padding: 0 6px;
  }

  /* Chart height */
  #panel-chart .dock-body,
  .hero-chart-frame,
  .chart-full {
    height: 240px !important;
    min-height: 240px !important;
  }

  /* Settings: single-column fields */
  .settings-group-grid {
    grid-template-columns: 1fr !important;
  }

  .settings-field-wide {
    grid-column: span 1 !important;
  }

  /* Grid layouts: 2 columns on mobile */
  .grid-two {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .spaced {
    grid-template-columns: 1fr !important;
  }

  /* Metric grid: 2 cols */
  .metric-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Action row: 2 cols */
  .action-row {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Left-tab nav is replaced by the bottom mobile-nav on mobile */
  .left-tab-bar { display: none !important; }

  /* Admin bar dropdown is clipped by topbar overflow — hide on mobile */
  #admin-bar { display: none !important; }

  /* Topbar: single compact row */
  .topbar {
    flex-wrap: nowrap;
    gap: 4px;
    padding: 0 8px;
    min-height: 36px;
    height: 36px;
    overflow: hidden;
  }

  .topbar-brand {
    flex-shrink: 0;
  }

  /* Hide brand text (eyebrow + h1), keep mark */
  .topbar-brand > div {
    display: none;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
    font-size: 13px;
  }

  .topbar-meta {
    flex: 1;
    min-width: 0;
    gap: 4px;
    flex-wrap: nowrap;
    overflow: hidden;
  }

  .topbar-session {
    flex: 1;
    min-width: 0;
    grid-template-columns: 56px minmax(0, 1fr);
    font-size: 9px;
  }

  .topbar-session code {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 9px;
  }

  .topbar-meta .button {
    font-size: 9px;
    padding: 0 6px;
    min-height: 26px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Banner compact */
  #action-banner {
    min-height: 22px;
    font-size: 10px;
    padding: 2px 8px;
    line-height: 1.3;
  }
}

/* ─── Instance card wrap + delete button ─── */
.instance-card-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px;
  background: var(--line);
}

.instance-delete-btn {
  min-width: 28px;
  max-width: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--muted);
  background: var(--panel-strong);
  border: 0;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 150ms, color 150ms;
}
.instance-card-wrap:hover .instance-delete-btn { opacity: 1; }
.instance-delete-btn:hover { color: #e05555; }

/* ─── Status pills ─── */
.pill-running {
  background: rgba(74, 222, 128, 0.14);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.35);
  animation: pill-running-pulse 1.5s ease-in-out infinite;
}
@keyframes pill-running-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.pill-error {
  background: rgba(224, 85, 85, 0.14);
  color: #e05555;
  border: 1px solid rgba(224, 85, 85, 0.35);
  cursor: help;
}

/* ─── Instance nav in position panel header ─── */
.titlebar-instance-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.titlebar-instance-nav > div {
  min-width: 0;
}
.titlebar-instance-nav h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-icon {
  min-width: 26px;
  max-width: 26px;
  width: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* ─── Instance Manager panel ─── */
.im-dock-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.im-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
}

.im-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  background: var(--panel-strong);
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  transition: background 120ms;
}
.im-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.im-item-stats {
  display: flex;
  gap: 10px;
  font-size: 10px;
  color: var(--muted);
}
.im-item-stats strong { color: var(--text); font-weight: 600; }
.im-range-warn { color: #e8a020; font-size: 9px; }
.im-item:hover { background: rgba(255,255,255,0.03); }
.im-item.active {
  background: rgba(0, 188, 212, 0.07);
  outline: 1px solid rgba(0, 188, 212, 0.4);
  outline-offset: -1px;
}
.im-item-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.im-item-wallet {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.im-pill { font-size: 9px; padding: 1px 5px; }
.im-error-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(224, 85, 85, 0.2);
  color: #e05555;
  font-size: 9px;
  font-weight: 700;
  cursor: help;
}

.im-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.im-controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.im-controls-head > strong {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.im-head-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.im-head-actions .button {
  padding: 0 8px;
  font-size: 10px;
  min-height: 26px;
}
.im-danger-btn { color: #e05555 !important; }
.im-danger-btn:hover { background: rgba(224, 85, 85, 0.08) !important; }
.im-assign-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}
.im-assign-row select {
  font-size: 11px;
  min-height: 28px;
  padding: 0 6px;
}
.im-assign-row .button {
  font-size: 10px;
  padding: 0 8px;
  min-height: 28px;
  white-space: nowrap;
}
.im-fund-btn {
  font-size: 10px;
  min-height: 26px;
  color: var(--muted);
  padding: 0 8px;
  text-align: left;
}
.im-fund-btn:hover { color: var(--text); }

.im-create {
  border-top: 1px solid var(--line);
}
.im-create-summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 10px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  user-select: none;
  transition: color 120ms;
}
.im-create-summary::-webkit-details-marker { display: none; }
.im-create-summary:hover { color: var(--text); }
.im-create[open] .im-create-summary { color: var(--text); }
.im-create-body {
  padding: 8px 10px 10px;
}

/* Instance Manager panel needs no special override — sidebar is always-open now */

/* Sidebar scrollbar webkit */
.left-tab-panel.active .dock-body::-webkit-scrollbar { width: 4px; }
.left-tab-panel.active .dock-body::-webkit-scrollbar-track { background: transparent; }
.left-tab-panel.active .dock-body::-webkit-scrollbar-thumb {
  background: rgba(0, 188, 212, 0.18);
  border-radius: 2px;
}
.left-tab-panel.active .dock-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 188, 212, 0.35);
}

/* Deploy % slider in settings fields */
.settings-field > .deploy-pct-slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 34px;
  padding: 0 8px;
  background: #090909;
  box-shadow: inset 0 0 0 1px rgba(80, 180, 200, 0.09);
  cursor: pointer;
}
.deploy-pct-slider::-webkit-slider-runnable-track {
  height: 3px;
  background: rgba(0, 188, 212, 0.18);
  border-radius: 2px;
}
.deploy-pct-slider::-moz-range-track {
  height: 3px;
  background: rgba(0, 188, 212, 0.18);
  border-radius: 2px;
}
.deploy-pct-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
.deploy-pct-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
/* slider in new-instance form (no settings-field wrapper) */
label > .deploy-pct-slider {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 28px;
  padding: 0 2px;
  background: transparent;
  cursor: pointer;
}

/* ── Detail panel top-level tabs (Config / Messages) ─────────────── */
.detail-tab-bar {
  display: flex;
  gap: 1px;
  background: rgba(0, 160, 190, 0.1);
  border-bottom: 1px solid rgba(0, 160, 190, 0.18);
  flex-shrink: 0;
}

.detail-tab {
  flex: 1;
  height: 30px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  border: 0;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.detail-tab:hover {
  color: var(--text);
  background: rgba(0, 188, 212, 0.06);
}

.detail-tab.active {
  color: var(--accent);
  background: rgba(0, 188, 212, 0.1);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.detail-tab-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.detail-tab-content.hidden {
  display: none;
}

/* ── Unread badge ─────────────────────────────────────────────────── */
.msg-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #000;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

.msg-badge.hidden { display: none; }

/* ── Messages: username setup ─────────────────────────────────────── */
.msg-setup {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.msg-setup.hidden { display: none; }

.msg-username-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 240px;
}

.msg-setup-label {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.msg-name-input {
  background: var(--panel-alt);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  transition: border-color 150ms;
}

.msg-name-input:focus {
  border-color: var(--accent);
}

/* ── Messages: chat UI ────────────────────────────────────────────── */
.msg-ui {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.msg-ui.hidden { display: none; }

.msg-user-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.msg-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 120ms;
  gap: 8px;
}

.msg-user-row:hover {
  background: var(--soft-2);
}

.msg-user-name {
  font-size: 13px;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-user-key {
  font-size: 9px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
}

.msg-user-unread {
  flex-shrink: 0;
}

.msg-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.msg-thread.hidden { display: none; }

.msg-thread-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

.msg-thread-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
}

.msg-bubble {
  max-width: 85%;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.msg-bubble.mine {
  align-self: flex-end;
  background: rgba(0, 188, 212, 0.18);
  border-bottom-right-radius: 3px;
  color: var(--text);
}

.msg-bubble.theirs {
  align-self: flex-start;
  background: var(--panel-strong);
  border-bottom-left-radius: 3px;
  color: var(--text);
}

.msg-bubble-time {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
}

.msg-receipt {
  font-size: 9px;
  letter-spacing: -1px;
  color: var(--muted);
}

.msg-bubble.mine .msg-bubble-time { justify-content: flex-end; }

.msg-receipt.read { color: var(--accent); }

.msg-send-form {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.msg-send-form input {
  flex: 1;
  background: var(--panel-alt);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 6px 9px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  transition: border-color 150ms;
}

.msg-send-form input:focus {
  border-color: var(--accent);
}

.msg-send-form .button {
  padding: 0 10px;
  font-size: 13px;
}

.msg-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px 4px;
  flex-shrink: 0;
}

.msg-typing-indicator.hidden { display: none; }

.msg-typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-dot 1.2s ease-in-out infinite;
}

.msg-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.msg-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-5px); opacity: 1; }
}
