/* ═══════════════════════════════════════════════════════════════
   cisot.dev — UI components. One style for each thing, used on every page.
   Values come from tokens.css only. Selectors ending in .is-hover / .is-active /
   .is-focus / .is-disabled render a state statically (for the styleguide).
   ═══════════════════════════════════════════════════════════════ */

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }
body {
  font-family: var(--font);
  font-size: var(--fs-14);
  line-height: var(--lh-14);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[hidden], .hidden { display: none !important; }
img, svg, canvas, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
p, li { color: inherit; }
::selection { background: rgba(240, 180, 58, 0.3); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: var(--r-full); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Type ── */
h1, h2, h3, h4 { font-weight: 600; color: var(--text); }
h1, .h1 { font-size: var(--fs-24); line-height: var(--lh-24); letter-spacing: -0.01em; }
h2, .h2 { font-size: var(--fs-20); line-height: var(--lh-20); letter-spacing: -0.01em; }
h3, .h3 { font-size: var(--fs-16); line-height: var(--lh-16); }
h4, .h4 { font-size: var(--fs-14); line-height: var(--lh-14); }
.display { font-size: var(--fs-32); line-height: var(--lh-32); font-weight: 600; letter-spacing: -0.02em; }
.display-lg { font-size: var(--fs-44); line-height: var(--lh-44); font-weight: 600; letter-spacing: -0.02em; }
.text-lg { font-size: var(--fs-16); line-height: var(--lh-16); }
.text-sm { font-size: var(--fs-13); line-height: var(--lh-13); }
.text-xs { font-size: var(--fs-12); line-height: var(--lh-12); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.medium { font-weight: 500; }
.mono { font-family: var(--mono); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
/* the one letter-spaced caps style: small section labels */
.section-label { font-size: var(--fs-12); line-height: var(--lh-12); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.link { color: var(--accent); }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-quiet { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.link-quiet:hover { color: var(--text); text-decoration-color: var(--text-3); }
code, .code { font-family: var(--mono); font-size: var(--fs-13); padding: 1px 5px; background: var(--bg-raised); border-radius: var(--r-xs); }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; font: 500 var(--fs-12) / 1 var(--mono); color: var(--text-2); background: var(--bg-raised); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--r-xs); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ── Layout ── */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.container-sm { max-width: 720px; }
.page { padding: var(--sp-8) 0 var(--sp-16); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-title { font-size: var(--fs-24); line-height: var(--lh-24); font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.page-desc { color: var(--text-2); margin-top: var(--sp-1); max-width: 64ch; }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; height: 24px; margin-bottom: var(--sp-3); color: var(--text-3); font-size: var(--fs-13); font-weight: 500; transition: color var(--dur) var(--ease); }
.back:hover { color: var(--text); }
.section { margin-top: var(--sp-10); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.row-nowrap { flex-wrap: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.divider { height: 1px; border: 0; background: var(--border); }
.spacer { flex: 1; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: rgba(10, 10, 12, 0.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.logo { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-14); font-weight: 500; color: var(--text); }
.logo-mark { width: 24px; height: 24px; flex: none; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.logo-mark svg { width: 14px; height: 14px; }
.header-nav { display: flex; align-items: center; gap: var(--sp-1); }
.header-nav a { display: inline-flex; align-items: center; height: 32px; padding: 0 10px; border-radius: var(--r-sm); color: var(--text-2); font-size: var(--fs-13); font-weight: 500; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.header-nav a:hover { background: var(--hover); color: var(--text); }
.header-nav a.on { color: var(--text); }
.avatar { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--bg-raised); border: 1px solid var(--border-strong); color: var(--text-2); display: grid; place-items: center; font-size: var(--fs-12); font-weight: 600; text-transform: uppercase; }
.avatar-lg { width: 36px; height: 36px; font-size: var(--fs-13); }
.user-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 4px; border-radius: var(--r-full); color: var(--text-2); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.user-btn .ic { color: var(--text-3); }
.user-btn:hover, .user-btn.is-hover, .user-btn[aria-expanded="true"] { background: var(--hover); color: var(--text); }

/* ── Menu (popover) ── */
.menu-host { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  min-width: 200px; padding: var(--sp-1);
  background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-md);
  animation: pop var(--dur) var(--ease);
}
.menu-left { right: auto; left: 0; }
.menu-static { position: static; display: inline-block; animation: none; }
.menu-head { padding: 6px 8px 8px; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-3); }
.menu-head b { display: block; color: var(--text); font-weight: 500; font-size: var(--fs-13); line-height: var(--lh-13); }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px; border-radius: var(--r-xs); color: var(--text); font-size: var(--fs-13); text-align: left; white-space: nowrap; transition: background var(--dur) var(--ease); }
.menu-item .ic { color: var(--text-3); }
.menu-item:hover, .menu-item.is-hover { background: var(--hover); }
.menu-item:focus-visible { outline: none; background: var(--hover); box-shadow: inset 0 0 0 1px var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ic { color: inherit; }
.menu-item .kbd, .menu-item .menu-end { margin-left: auto; }
.menu-sep { height: 1px; margin: 4px 0; background: var(--border); }

/* ── Buttons ── */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h-md); padding: 0 12px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: var(--fs-14); font-weight: 500; line-height: 1; white-space: nowrap;
  user-select: none; cursor: pointer; text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn .ic { width: 16px; height: 16px; }
.btn-sm { height: var(--h-sm); padding: 0 10px; gap: 6px; font-size: var(--fs-13); }
.btn-sm .ic { width: 14px; height: 14px; }
.btn-lg { height: var(--h-lg); padding: 0 16px; }
.btn-icon { width: var(--h-md); padding: 0; }
.btn-icon.btn-sm { width: var(--h-sm); }
.btn-icon.btn-lg { width: var(--h-lg); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover, .btn-primary.is-hover { background: var(--accent-hover); }
.btn-primary:active, .btn-primary.is-active { background: var(--accent-pressed); }
.btn-secondary { background: var(--bg-raised); border-color: var(--border); color: var(--text); }
.btn-secondary:hover, .btn-secondary.is-hover { border-color: var(--border-strong); background-image: linear-gradient(var(--hover), var(--hover)); }
.btn-secondary:active, .btn-secondary.is-active { background-image: linear-gradient(var(--pressed), var(--pressed)); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover, .btn-ghost.is-hover { background: var(--hover); color: var(--text); }
.btn-ghost:active, .btn-ghost.is-active { background: var(--pressed); color: var(--text); }
.btn-danger { background: var(--danger-tint); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover, .btn-danger.is-hover { background: rgba(248, 81, 73, 0.2); }
.btn-danger:active, .btn-danger.is-active { background: rgba(248, 81, 73, 0.26); }
.btn.is-focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn.is-disabled { opacity: 0.5; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: var(--text); animation: spin 0.7s linear infinite; }
.btn-primary.is-loading::after { border-color: rgba(26, 19, 5, 0.25); border-top-color: var(--accent-ink); }
.btn-danger.is-loading::after { border-color: rgba(248, 81, 73, 0.3); border-top-color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Icons ── */
.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 14px; height: 14px; }
.ic-lg { width: 20px; height: 20px; }
.ic-xl { width: 24px; height: 24px; }
.tile { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--bg-raised); border: 1px solid var(--border); color: var(--text-2); }
.tile .ic { width: 18px; height: 18px; }
.tile-lg { width: 44px; height: 44px; border-radius: var(--r-md); }
.tile-lg .ic { width: 22px; height: 22px; }
.tile-accent { background: var(--accent-tint); border-color: var(--accent-border); color: var(--accent); }

/* ── Fields ── */
.field {
  display: block; width: 100%; height: var(--h-md); padding: 0 10px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text); font-size: var(--fs-14); line-height: var(--lh-14); outline: none;
  appearance: none; -webkit-appearance: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field::placeholder { color: var(--text-3); }
.field:hover, .field.is-hover { border-color: var(--border-strong); }
.field:focus, .field.is-focus { border-color: var(--accent); box-shadow: var(--ring); }
.field[aria-invalid="true"], .field.is-invalid { border-color: var(--danger); }
.field[aria-invalid="true"]:focus, .field.is-invalid:focus, .field.is-invalid.is-focus { box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.3); }
.field:disabled, .field.is-disabled { opacity: 0.5; cursor: not-allowed; }
.field-sm { height: var(--h-sm); padding: 0 8px; font-size: var(--fs-13); }
.field-lg { height: var(--h-lg); padding: 0 12px; }
textarea.field { height: auto; min-height: 88px; padding: 8px 10px; resize: vertical; }
.select { padding-right: 32px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a93' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.select option { background: var(--bg-raised); color: var(--text); }
.field-wrap { position: relative; }
.field-wrap > .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.field-wrap > .field { padding-left: 34px; }
.field-wrap > .field-end { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.label { display: block; margin-bottom: 6px; font-size: var(--fs-13); line-height: var(--lh-13); font-weight: 500; color: var(--text-2); }
.label .text-3 { font-weight: 400; }
.hint { margin-top: 6px; font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-3); }
.hint.error { color: var(--danger); }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
/* checkbox + radio */
.check, .radio {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; flex: none; margin: 0; vertical-align: -3px;
  display: inline-grid; place-items: center;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-strong); border-radius: var(--r-xs);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.radio { border-radius: 50%; }
.check:hover, .radio:hover { border-color: var(--text-3); }
.check:checked, .radio:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: ''; width: 10px; height: 10px; background: var(--accent-ink); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; }
.radio:checked::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-ink); }
.check:disabled, .radio:disabled, .switch:disabled { opacity: 0.5; cursor: not-allowed; }
.choice { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-14); cursor: pointer; }
.choice-block { display: flex; align-items: flex-start; gap: 10px; }
.choice-block .check, .choice-block .radio, .choice-block .switch { margin-top: 2px; }
.choice-text { display: flex; flex-direction: column; }
.choice-text .hint { margin-top: 2px; }
/* switch */
.switch {
  appearance: none; -webkit-appearance: none;
  position: relative; width: 34px; height: 20px; flex: none; margin: 0; vertical-align: -5px;
  border-radius: var(--r-full); background: var(--bg-raised); border: 1px solid var(--border-strong); cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform var(--dur) var(--ease), background var(--dur) var(--ease); }
.switch:hover { border-color: var(--text-3); }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(14px); background: var(--accent-ink); }
/* range: --p = the filled share, kept in sync by UI.rangeFill */
.range { appearance: none; -webkit-appearance: none; width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer; --p: 50%; }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--accent) var(--p), var(--border-strong) var(--p)); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--text); border: 1px solid rgba(0, 0, 0, 0.35); box-shadow: var(--shadow-sm); }
.range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border-strong); }
.range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 1px solid rgba(0, 0, 0, 0.35); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }
.range:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Tags, badges, access, counts ── */
.tag, .badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: var(--r-full); background: var(--bg-raised); border: 1px solid var(--border);
  color: var(--text-2); font-size: var(--fs-12); line-height: 1; font-weight: 500; white-space: nowrap;
}
.tag .ic, .badge .ic { width: 12px; height: 12px; }
.badge-success { background: var(--success-tint); border-color: transparent; color: var(--success); }
.badge-warning { background: var(--warning-tint); border-color: transparent; color: var(--warning); }
.badge-danger { background: var(--danger-tint); border-color: transparent; color: var(--danger); }
.badge-info { background: var(--info-tint); border-color: transparent; color: var(--info); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.count { display: inline-flex; align-items: center; justify-content: center; height: 20px; min-width: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--bg-raised); border: 1px solid var(--border); color: var(--text-2); font: 500 var(--fs-12) / 1 var(--mono); font-variant-numeric: tabular-nums; }
.access { display: inline-flex; align-items: center; gap: 5px; color: var(--text-3); font-size: var(--fs-12); line-height: var(--lh-12); font-weight: 500; white-space: nowrap; }
.access .ic { width: 13px; height: 13px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-12); font-weight: 500; }
.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-tint); }

/* ── Cards ── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-5); }
.card-sm { padding: var(--sp-4); }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-14); font-weight: 600; }
.card-title .ic { color: var(--text-3); }
.card-hover { cursor: pointer; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card-hover:hover, .card-hover.is-hover { background: var(--bg-raised); border-color: var(--border-strong); }
.card-arrow { margin-left: auto; color: var(--text-3); opacity: 0; transform: translateX(-4px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), color var(--dur) var(--ease); }
.card-hover:hover .card-arrow, .card-hover.is-hover .card-arrow { opacity: 1; transform: none; color: var(--text-2); }
.raised { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-md); }
/* the tool card: tile, title, a two-line description, access level, an arrow on hover */
.tool { display: flex; flex-direction: column; gap: var(--sp-3); height: 100%; }
.tool-top { display: flex; align-items: center; justify-content: space-between; }
.tool h3 { font-size: var(--fs-14); line-height: var(--lh-14); font-weight: 600; }
.tool p { color: var(--text-2); font-size: var(--fs-13); line-height: var(--lh-13); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tool-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: var(--sp-1); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-v { font-family: var(--mono); font-size: var(--fs-20); line-height: var(--lh-20); font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat-l { font-size: var(--fs-12); line-height: var(--lh-12); color: var(--text-3); }
.stat-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text-2); font-size: var(--fs-13); }
.stat-line .num { color: var(--text); font-weight: 500; }
.stat-line .dot { color: var(--text-3); }

/* ── Tabs & segmented ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-2); font-size: var(--fs-14); font-weight: 500; white-space: nowrap; transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.tab:hover, .tab.is-hover { color: var(--text); }
.tab.on, .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-sm); }
.seg > button, .seg > a { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-xs); color: var(--text-2); font-size: var(--fs-13); font-weight: 500; white-space: nowrap; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.seg > :hover, .seg > .is-hover { color: var(--text); }
.seg > .on, .seg > .active, .seg > [aria-pressed="true"] { background: var(--pressed); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-sm > button, .seg-sm > a { height: 24px; padding: 0 8px; font-size: var(--fs-12); }
.seg-full { display: flex; }
.seg-full > * { flex: 1; }

/* ── Modal ── */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: var(--sp-4); overflow-y: auto;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade var(--dur-slow) var(--ease);
}
.modal {
  width: 100%; max-width: 440px; max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pop var(--dur-slow) var(--ease);
}
.modal-sm { max-width: 360px; }
.modal-wide { max-width: 640px; }
.modal-xl { max-width: 820px; }
.modal-static { animation: none; }
.modal-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); }
.modal-title { flex: 1; font-size: var(--fs-16); line-height: var(--lh-16); font-weight: 600; }
.modal-head .btn-icon { margin-right: -8px; }
.modal-body { padding: 0 var(--sp-5) var(--sp-5); color: var(--text-2); overflow-y: auto; }
.modal-body p + p { margin-top: var(--sp-3); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5) var(--sp-4); border-top: 1px solid var(--border); }
.modal-foot .start { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.985); } }

/* ── Table ── */
.table-wrap { overflow-x: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); line-height: var(--lh-13); }
.table th { padding: 10px 12px; text-align: left; font-size: var(--fs-12); font-weight: 500; color: var(--text-3); white-space: nowrap; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.015); }
.table td { padding: 10px 12px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td, .table tr.is-hover td { background: var(--hover); }
.table tr.on td { background: var(--accent-tint); }
.table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table th.num { font-family: var(--font); }
.table-compact th, .table-compact td { padding: 6px 12px; }
.pos { color: var(--success); }
.neg { color: var(--danger); }

/* ── Toast ── */
.toast {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 200;
  display: flex; align-items: center; gap: 10px;
  max-width: min(420px, calc(100vw - 32px)); padding: 10px 14px;
  background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-md);
  color: var(--text); font-size: var(--fs-13); line-height: var(--lh-13);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}
.toast.show { opacity: 1; transform: none; pointer-events: auto; }
.toast .ic { color: var(--success); }
.toast.err .ic { color: var(--danger); }
.toast.warn .ic { color: var(--warning); }
.toast.info .ic { color: var(--info); }
.toast-static { position: static; opacity: 1; transform: none; pointer-events: auto; }

/* ── Notice (inline callout) ── */
.notice { display: flex; gap: 10px; padding: 10px 12px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text-2); font-size: var(--fs-13); line-height: var(--lh-13); }
.notice .ic { margin-top: 2px; color: var(--text-3); }
.notice-success { background: var(--success-tint); border-color: rgba(63, 185, 80, 0.3); color: var(--text); }
.notice-success .ic { color: var(--success); }
.notice-warning { background: var(--warning-tint); border-color: rgba(240, 136, 62, 0.3); color: var(--text); }
.notice-warning .ic { color: var(--warning); }
.notice-danger { background: var(--danger-tint); border-color: var(--danger-border); color: var(--text); }
.notice-danger .ic { color: var(--danger); }
.notice-info { background: var(--info-tint); border-color: rgba(88, 166, 255, 0.3); color: var(--text); }
.notice-info .ic { color: var(--info); }

/* ── Empty state ── */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-10) var(--sp-4); text-align: center; color: var(--text-3); }
.empty .tile { margin-bottom: var(--sp-1); }
.empty-title { font-size: var(--fs-14); line-height: var(--lh-14); font-weight: 500; color: var(--text); }
.empty-desc { font-size: var(--fs-13); line-height: var(--lh-13); max-width: 36ch; }
.empty .btn { margin-top: var(--sp-2); }
.empty-sm { padding: var(--sp-6) var(--sp-4); }

/* ── Loading: skeletons + spinner ── */
.skel { position: relative; overflow: hidden; background: rgba(255, 255, 255, 0.06); border-radius: var(--r-xs); }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent); animation: shimmer 1.6s var(--ease) infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }
.skel-text { height: 12px; width: 100%; }
.skel-title { height: 16px; width: 40%; }
.skel-tile { width: 36px; height: 36px; border-radius: var(--r-sm); }
.skel-card { height: 120px; border-radius: var(--r-md); }
.skel-stack { display: flex; flex-direction: column; gap: 10px; }
.skel-row { display: flex; align-items: center; gap: var(--sp-3); }
.w-80 { width: 80%; } .w-60 { width: 60%; } .w-40 { width: 40%; } .w-25 { width: 25%; }
.spinner { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--text-2); animation: spin 0.7s linear infinite; }
.loading { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: var(--fs-13); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .page { padding-top: var(--sp-6); }
  .page-title { font-size: var(--fs-20); line-height: var(--lh-20); }
  .display { font-size: var(--fs-24); line-height: var(--lh-24); }
  .display-lg { font-size: var(--fs-32); line-height: var(--lh-32); }
  .modal-back { padding: var(--sp-3); align-items: end; }
  .modal { max-height: calc(100vh - 24px); }
  .modal-head, .modal-foot { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .modal-body { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .toast { right: var(--sp-4); left: var(--sp-4); bottom: var(--sp-4); max-width: none; }
  .hide-mobile { display: none !important; }
}
