/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r2);
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  font-weight: 500;
  font-size: var(--fs-13);
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
}

.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-12);
}

.btn.md {
  height: 32px;
}

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn.primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

.btn.secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn.secondary:hover {
  border-color: var(--border-strong);
}

.btn.ghost {
  color: var(--text-2);
}

.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn.danger:hover {
  border-color: rgba(229, 99, 111, 0.4);
}

.btn.icon {
  width: 28px;
  height: 28px;
  padding: 0;
}

.btn.block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Badges and chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: var(--fs-12);
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.info {
  background: var(--info-soft);
  color: var(--info);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.plain::before {
  display: none;
}

.badge.xs {
  height: 18px;
  padding: 0 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-12);
  white-space: nowrap;
}

button.chip {
  cursor: pointer;
}

button.chip:hover {
  color: var(--text);
}

.chip b {
  color: var(--text);
  font-weight: 500;
}

.chip.low {
  background: var(--warn-soft);
  color: var(--warn);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.dot.lg {
  width: 12px;
  height: 12px;
}

.av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-12);
  font-weight: 600;
  flex: none;
  overflow: hidden;
  color: var(--text);
}

.av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sub {
  display: block;
  font-size: var(--fs-12);
  color: var(--text-3);
  margin-top: 2px;
}

/* Tabs and segmented control */
.tabs {
  display: flex;
  gap: var(--s5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s4);
}

.tabs a {
  padding: 10px 0;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a.on {
  color: var(--text);
  border-color: var(--accent);
}

.tabs a .n {
  font-size: var(--fs-12);
  color: var(--text-3);
  background: var(--surface-2);
  padding: 0 6px;
  border-radius: 999px;
}

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 2px;
}

.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 4px 10px;
  border-radius: var(--r1);
  color: var(--text-2);
  cursor: pointer;
  font-size: var(--fs-13);
}

.seg button.on {
  background: var(--surface-3);
  color: var(--text);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r3);
}

.card .hd {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s4) 0;
}

.card .hd h3 {
  font-size: var(--fs-14);
}

.card .bd,
.card.bd {
  padding: var(--s4);
}

.stat {
  padding: var(--s4);
}

.stat .l {
  font-size: var(--fs-12);
  color: var(--text-3);
}

.stat .v {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.stat .d {
  font-size: var(--fs-12);
  color: var(--text-2);
}

h2.sect {
  font-size: var(--fs-14);
  margin: var(--s6) 0 var(--s3);
}

/* Beginner hint card */
.hint {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--r3);
  background: var(--surface);
  margin-bottom: var(--s4);
}

.hint > .ico {
  color: var(--info);
  margin-top: 2px;
}

.hint p {
  color: var(--text-2);
  font-size: var(--fs-13);
}

.hint b {
  color: var(--text);
  font-weight: 600;
}

.hint .x {
  margin-left: auto;
}

/* Toolbar, inputs */
.tb {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s3);
  flex-wrap: wrap;
}

.tb .sp {
  flex: 1;
}

.input {
  height: 32px;
  border-radius: var(--r2);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 10px;
  min-width: 0;
}

.input:focus {
  border-color: var(--accent);
  outline: none;
}

.input::placeholder {
  color: var(--text-3);
}

textarea.input {
  height: auto;
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
}

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 14px, calc(100% - 9px) 14px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
  padding: 0 10px;
  color: var(--text-3);
  width: 240px;
}

.searchbox input {
  border: 0;
  background: none;
  outline: none;
  flex: 1;
  min-width: 0;
  color: var(--text);
}

.selbar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 6px 6px 6px 12px;
  border-radius: var(--r2);
  background: var(--accent-soft);
  border: 1px solid rgba(61, 186, 138, 0.3);
  font-size: var(--fs-13);
  margin-bottom: var(--s3);
}

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4);
}

.field label {
  display: block;
  font-size: var(--fs-12);
  color: var(--text-2);
  margin-bottom: 6px;
}

.field .input,
.field select {
  width: 100%;
}

.field .help {
  font-size: var(--fs-12);
  color: var(--text-3);
  margin-top: 4px;
}

.field .err {
  font-size: var(--fs-12);
  color: var(--danger);
  margin-top: 4px;
}

.chk {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-13);
  color: var(--text-2);
  cursor: pointer;
}

.chk input,
.cb {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

/* Switch: a real checkbox, styled. */
.sw {
  appearance: none;
  position: relative;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  flex: none;
  cursor: pointer;
}

.sw::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-3);
  transition: left 0.15s;
}

.sw:checked,
.sw.on {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.sw:checked::after,
.sw.on::after {
  left: 16px;
  background: var(--accent);
}

.sw:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.setrow {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border);
}

.setrow:last-child {
  border: 0;
}

.setrow .tx {
  flex: 1;
}

.setrow .tx div:first-child {
  font-weight: 500;
}

.setrow .tx div:last-child {
  font-size: var(--fs-12);
  color: var(--text-3);
}

/* Key-value lists */
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  font-size: var(--fs-13);
  margin: var(--s3) 0;
}

.kv dt,
.kv2 dt {
  color: var(--text-3);
}

.kv dd,
.kv2 dd {
  margin: 0;
}

.kv2 {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
  margin: 0;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-13);
}

.list li:last-child {
  border: 0;
}

/* Progress, warning line */
.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}

.warnline {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: var(--r2);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: var(--fs-13);
  margin-top: var(--s3);
}

.alert {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--r2);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-13);
}

.alert.warn {
  background: var(--warn-soft);
  border-color: rgba(217, 164, 65, 0.3);
  color: var(--warn);
}

.alert.bad {
  background: var(--danger-soft);
  border-color: rgba(229, 99, 111, 0.3);
  color: var(--danger);
}

.alert strong {
  color: inherit;
}

/* Topbar: wallet context, operator buttons, flyouts */
.ctx {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
}

.ctx:hover,
.ctx[aria-expanded="true"] {
  border-color: var(--border-strong);
}

.ctx b {
  font-weight: 500;
}

.ctx .dim {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-fly="wallet"] {
  min-width: 0;
  flex: 0 1 auto;
}

[data-fly="wallet"] > .ctx {
  max-width: 100%;
}

.ops {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.fly-wrap {
  position: relative;
}

.opbtn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--fs-13);
  color: var(--text-2);
  white-space: nowrap;
}

.opbtn:hover,
.opbtn[aria-expanded="true"] {
  border-color: var(--border-strong);
  color: var(--text);
}

.fly {
  position: absolute;
  top: 38px;
  right: 0;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r3);
  padding: var(--s4);
  z-index: 30;
  box-shadow: var(--shadow-pop);
}

.fly.left {
  left: 0;
  right: auto;
}

.fly h4 {
  margin: 0 0 2px;
  font-size: var(--fs-13);
}

.fly .row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--s3);
}

.fly .fnote {
  font-size: var(--fs-12);
  color: var(--text-3);
  margin-top: 8px;
}

.fly .stale {
  color: var(--warn);
}

/* Row menu "⋯" */
.menu {
  position: fixed;
  z-index: 60;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r2);
  padding: 4px;
  box-shadow: var(--shadow-pop);
}

.menu.static {
  position: static;
  display: inline-block;
}

.menu button,
.menu a {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  background: none;
  border-radius: var(--r1);
  cursor: pointer;
  color: var(--text);
  font-size: var(--fs-13);
  text-align: left;
}

.menu button:hover,
.menu a:hover {
  background: var(--surface-2);
}

.menu .d {
  color: var(--danger);
}

.menu hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

/* Native dialog */
dialog.dlg {
  border: 1px solid var(--border-strong);
  border-radius: var(--r3);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: 520px;
  max-width: 92vw;
}

dialog.dlg::backdrop {
  background: var(--backdrop);
}

dialog.dlg .dh {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
}

dialog.dlg .dh h3 {
  font-size: 15px;
  flex: 1;
}

dialog.dlg .db {
  padding: var(--s5);
}

dialog.dlg .df {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--border);
}

/* Toast */
.toast-host {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r2);
  padding: 10px 14px;
  font-size: var(--fs-13);
  display: flex;
  gap: 8px;
  align-items: center;
  box-shadow: var(--shadow-pop);
}

.toast .ico {
  color: var(--accent);
}

.toast.bad .ico {
  color: var(--danger);
}

/* Tooltip on [data-tip] */
[data-tip] {
  position: relative;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r1);
  padding: 4px 8px;
  font-size: var(--fs-12);
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  z-index: 80;
}

/* Empty state, skeleton */
.empty {
  padding: var(--s8) var(--s6);
  text-align: center;
  color: var(--text-2);
}

.empty h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 15px;
}

.empty .row {
  display: flex;
  justify-content: center;
  gap: var(--s2);
  margin-top: var(--s4);
}

.skel {
  display: block;
  height: 12px;
  border-radius: var(--r1);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
}

@keyframes skel {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skel {
    animation: none;
  }
}

.kbd {
  font-family: var(--mono);
  font-size: var(--fs-12);
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
}
