/* ---------- buttons ---------- */
.btn {
  --bh: 40px;
  position: relative; overflow: hidden; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--bh); padding: 0 16px; border-radius: var(--r);
  font: 500 14px/1 var(--f-sans); letter-spacing: -.005em; white-space: nowrap;
  border: 1px solid transparent; color: var(--text);
  transition: background var(--d-2) var(--ease), border-color var(--d-2) var(--ease), color var(--d-2) var(--ease), transform var(--d-1) var(--ease), box-shadow var(--d-2) var(--ease);
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn .i { width: 16px; height: 16px; }
.btn.sm { --bh: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn.lg { --bh: 48px; padding: 0 22px; font-size: 15px; }
.btn.full { width: 100%; }
.btn.icon { width: var(--bh); padding: 0; }

/* primary: marble slab */
.btn.primary { background: var(--text); color: #0a0a0e; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18), 0 1px 0 rgba(255, 255, 255, .06); }
.btn.primary:hover:not(:disabled) { background: #fff; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18), 0 0 0 4px rgba(243, 242, 238, .08), 0 8px 26px -10px rgba(123, 149, 255, .55); }
/* secondary: outline on ink */
.btn.ghost { background: var(--ink-2); border-color: var(--line-2); box-shadow: var(--chisel); }
.btn.ghost:hover:not(:disabled) { background: var(--ink-3); border-color: var(--line-3); }
.btn.quiet { color: var(--text-2); }
.btn.quiet:hover:not(:disabled) { color: var(--text); background: var(--ink-3); }
.btn.blue { background: var(--blue-2); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn.blue:hover:not(:disabled) { background: #6582ff; }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: rgba(255, 125, 125, .28); }
.btn.danger:hover:not(:disabled) { background: rgba(255, 125, 125, .16); }
.btn.busy { color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--text-3) var(--text-3) var(--text-3) transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after { border-color: #555 #555 #555 transparent; }

/* ripple: the signature press feedback, a ring spreading from where you touched */
.rpl { position: absolute; z-index: -1; border-radius: 50%; pointer-events: none; transform: translate(-50%, -50%) scale(0); border: 1px solid currentColor; opacity: .5; animation: rpl .7s var(--ease-out) forwards; }
.btn.primary .rpl { color: var(--blue-2); }
@keyframes rpl { to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

.link { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-3); text-underline-offset: 3px; transition: text-decoration-color var(--d-2); }
.link:hover { text-decoration-color: var(--blue); }
.arrow-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 500; }
.arrow-link .i { transition: transform var(--d-2) var(--ease); }
.arrow-link:hover .i { transform: translateX(3px); }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field .hint { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.field .err { font-size: 12.5px; color: var(--bad); min-height: 0; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 13px;
  background: var(--ink-1); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r);
  font-size: 14.5px; transition: border-color var(--d-2), box-shadow var(--d-2), background var(--d-2);
}
.textarea { height: auto; min-height: 96px; padding: 11px 13px; line-height: 1.5; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-soft); outline: none; background: var(--ink-0); }
.input[aria-invalid="true"] { border-color: rgba(255, 125, 125, .55); box-shadow: 0 0 0 3px var(--bad-soft); }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6d7b' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.select option { background: var(--ink-2); }
.input.sm, .select.sm { height: 34px; font-size: 13.5px; border-radius: var(--r-sm); }

/* repent.bio/ prefix input */
.affix { display: flex; align-items: center; width: 100%; height: 42px; background: var(--ink-1); border: 1px solid var(--line-2); border-radius: var(--r); transition: border-color var(--d-2), box-shadow var(--d-2); overflow: hidden; }
.affix:focus-within { border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-soft); }
.affix > span { padding-left: 13px; font: 500 13.5px var(--f-mono); color: var(--text-3); white-space: nowrap; user-select: none; }
.affix > input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; padding: 0 13px 0 1px; font: 500 14px var(--f-mono); color: var(--text); }
.affix > input:focus { outline: none; }
.affix > .btn { margin: 4px; height: 32px; }
.affix > .affix-r { padding: 0 12px; display: flex; color: var(--text-3); }
.pw-toggle { color: var(--text-3); display: grid; place-items: center; width: 40px; height: 100%; }
.pw-toggle:hover { color: var(--text); }

.avail { font: 500 12.5px var(--f-mono); display: flex; align-items: center; gap: 6px; min-height: 18px; color: var(--text-3); }
.avail.ok { color: var(--ok); }
.avail.bad { color: var(--bad); }
.avail::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.avail:empty::before { display: none; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 36px; height: 21px; flex: none; border-radius: 11px; background: var(--ink-4); border: 1px solid var(--line-3); transition: background var(--d-2), border-color var(--d-2); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--text-2); transition: transform var(--d-2) var(--ease-out), background var(--d-2); }
.switch input:checked + .track { background: var(--blue-2); border-color: var(--blue-2); }
.switch input:checked + .track::after { transform: translateX(15px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .4; }
.switch .sw-t { display: flex; flex-direction: column; gap: 2px; }
.switch .sw-t small { color: var(--text-3); font-size: 12.5px; }
.row-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.row-switch:first-child { border-top: 0; }

/* segmented choice */
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--ink-1); border: 1px solid var(--line-2); border-radius: var(--r); }
.seg label { flex: 1 1 auto; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 7px; font-size: 13px; color: var(--text-2); white-space: nowrap; transition: background var(--d-2), color var(--d-2); }
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--ink-4); color: var(--text); box-shadow: var(--chisel), 0 0 0 1px var(--line-3); }
.seg input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }

/* option tiles (layouts, fonts, effects) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: var(--r); background: var(--ink-1); border: 1px solid var(--line-2); text-align: left; transition: border-color var(--d-2), background var(--d-2); }
.tile:hover { border-color: var(--line-3); background: var(--ink-2); }
.tile[aria-pressed="true"], .tile[aria-checked="true"] { border-color: var(--blue-line); background: var(--blue-soft); box-shadow: 0 0 0 1px var(--blue-line) inset; }
.tile b { font-size: 13px; font-weight: 500; }
.tile small { font-size: 11.5px; color: var(--text-3); line-height: 1.35; }
.tile .tile-vis { height: 64px; border-radius: 7px; background: var(--ink-0); border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; }

/* range */
.range { display: flex; align-items: center; gap: 12px; }
.range output { min-width: 44px; text-align: right; font: 500 12.5px var(--f-mono); color: var(--text-2); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--blue-2) var(--p, 50%), var(--ink-4) var(--p, 50%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--ink-4); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--blue-2); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--text); border: 0; box-shadow: 0 0 0 4px rgba(85, 118, 255, .25), 0 2px 6px rgba(0, 0, 0, .6); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 0; box-shadow: 0 0 0 4px rgba(85, 118, 255, .25); }

/* color */
.color { display: inline-flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px 0 5px; border-radius: var(--r); background: var(--ink-1); border: 1px solid var(--line-2); font: 500 12.5px var(--f-mono); color: var(--text-2); cursor: pointer; }
.color input[type="color"] { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px; background: none; cursor: pointer; }
.color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(255, 255, 255, .14); border-radius: 7px; }
.color input[type="color"]::-moz-color-swatch { border: 1px solid rgba(255, 255, 255, .14); border-radius: 7px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(255, 255, 255, .12); transition: transform var(--d-1); }
.swatches button:hover { transform: scale(1.08); }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink-0), 0 0 0 4px var(--blue); }

/* ---------- surfaces ---------- */
.panel { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s5); box-shadow: var(--chisel); }
.panel + .panel { margin-top: var(--s3); }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--s4); }
.panel-h h2, .panel-h h3 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.panel-h p { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.panel.flush { padding: 0; overflow: hidden; }
.well { background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); }
.divider { height: 1px; background: var(--line); margin: var(--s5) 0; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack.sm { gap: var(--s2); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* chips + badges */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-xs); background: var(--ink-3); border: 1px solid var(--line-2); font: 500 11px/1 var(--f-mono); letter-spacing: .02em; color: var(--text-2); white-space: nowrap; }
.chip.blue { background: var(--blue-soft); border-color: var(--blue-line); color: #c4d0ff; }
.chip.ok { background: rgba(94, 224, 160, .08); border-color: rgba(94, 224, 160, .3); color: var(--ok); }
.chip.warn { background: rgba(245, 197, 107, .08); border-color: rgba(245, 197, 107, .3); color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: rgba(255, 125, 125, .3); color: var(--bad); }
.chip .i { width: 12px; height: 12px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(94, 224, 160, .6); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line-3); border-bottom-width: 2px; font: 500 11px var(--f-mono); color: var(--text-2); }

/* tabs: an underline that slides, not a pill */
.tabs { position: relative; display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role="tab"] { position: relative; height: 40px; padding: 0 12px; font-size: 13.5px; font-weight: 500; color: var(--text-3); white-space: nowrap; display: flex; align-items: center; gap: 7px; transition: color var(--d-2); }
.tabs [role="tab"]:hover { color: var(--text-2); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); }
.tabs [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); }
.tabs [role="tab"] .i { width: 15px; height: 15px; }

/* tooltips: [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% + 8px); transform: translateX(-50%);
  padding: 6px 9px; border-radius: 7px; background: #f3f2ee; color: #0a0a0e; font: 500 12px/1.3 var(--f-sans); letter-spacing: 0;
  white-space: nowrap; pointer-events: none; z-index: var(--z-menu); box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  animation: tipIn var(--d-2) var(--ease-out);
}
@keyframes tipIn { from { opacity: 0; transform: translate(-50%, 3px); } }

/* ---------- overlays ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(420px, calc(100vw - 32px)); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 11px 14px; border-radius: var(--r); background: var(--ink-3); border: 1px solid var(--line-3); box-shadow: var(--sh-2); font-size: 13.5px; animation: toastIn var(--d-3) var(--ease-out); }
.toast .tear { flex: none; }
.toast.bad .tear { background: var(--bad); box-shadow: 0 0 10px rgba(255, 125, 125, .5); }
.toast.ok .tear { background: var(--ok); box-shadow: 0 0 10px rgba(94, 224, 160, .5); }
.toast.out { animation: toastOut var(--d-2) var(--ease-in) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

.overlay { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: 16px; background: rgba(3, 3, 6, .74); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn var(--d-2) var(--ease); overflow-y: auto; }
.modal { position: relative; width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--ink-2); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--sh-3); padding: var(--s6); animation: modalIn var(--d-3) var(--ease-out); }
.modal.wide { width: min(760px, 100%); }
.modal h2 { font-size: 18px; letter-spacing: -.02em; }
.modal .modal-sub { color: var(--text-2); font-size: 14px; margin-top: 6px; }
.modal .modal-x { position: absolute; top: 14px; right: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: var(--s6); }
@media (max-width: 520px) { .modal-actions { flex-direction: column-reverse; } .modal-actions .btn { width: 100%; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.menu { position: absolute; z-index: var(--z-menu); min-width: 200px; padding: 5px; background: var(--ink-3); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: var(--sh-3); animation: menuIn var(--d-2) var(--ease-out); }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border-radius: 8px; font-size: 13.5px; color: var(--text-2); text-align: left; }
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible { background: var(--ink-4); color: var(--text); outline: none; }
.menu .sep { height: 1px; background: var(--line-2); margin: 5px 4px; }
.menu .danger { color: var(--bad); }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- loading + empty ---------- */
.skel { position: relative; overflow: hidden; background: var(--ink-3); border-radius: var(--r-sm); }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .04), transparent); animation: shimmer 1.6s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* the tear loader: a drop falls, lands, and leaves a ring */
.loader { position: relative; width: 28px; height: 36px; display: inline-block; }
.loader::before { content: ""; position: absolute; left: 50%; top: 0; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 0 50% 50% 50%; transform: rotate(45deg); background: var(--tear); animation: tearFall 1.3s var(--ease-in) infinite; }
.loader::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 28px; height: 8px; margin-left: -14px; border-radius: 50%; border: 1px solid var(--blue); opacity: 0; animation: tearRing 1.3s var(--ease-out) infinite; }
@keyframes tearFall { 0% { transform: translateY(0) rotate(45deg); opacity: 0; } 15% { opacity: 1; } 62% { transform: translateY(22px) rotate(45deg); opacity: 1; } 66%, 100% { transform: translateY(22px) rotate(45deg); opacity: 0; } }
@keyframes tearRing { 0%, 60% { transform: scale(.2); opacity: 0; } 66% { opacity: .9; } 100% { transform: scale(1.2); opacity: 0; } }
.boot { min-height: 70vh; display: grid; place-items: center; gap: 12px; color: var(--text-3); font-size: 13px; }
.boot > div { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: var(--s10) var(--s6); color: var(--text-2); }
.empty .empty-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--ink-3); border: 1px solid var(--line-2); color: var(--text-2); margin-bottom: 4px; }
.empty h3 { font-size: 15px; color: var(--text); }
.empty p { font-size: 13.5px; max-width: 40ch; }

/* list rows */
.rows { display: flex; flex-direction: column; }
.rowi { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.rowi:first-child { border-top: 0; }
.rowi .rowi-ic { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--ink-3); border: 1px solid var(--line-2); color: var(--text-2); overflow: hidden; }
.rowi .rowi-ic img { width: 100%; height: 100%; object-fit: cover; }
.rowi .rowi-m { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rowi .rowi-m b { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowi .rowi-m small { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* bars (analytics breakdowns) */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; position: relative; padding: 7px 10px; border-radius: 7px; font-size: 13px; isolation: isolate; }
.bar::before { content: ""; position: absolute; inset: 0; width: var(--w); border-radius: 7px; background: var(--blue-soft); z-index: -1; }
.bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar b { font: 500 12px var(--f-mono); color: var(--text-2); }
