/* ---------- 4. Primitives ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); font-size: var(--fs-sm); font-weight: 520; white-space: nowrap; box-shadow: var(--shadow-sm); color: var(--text); transition: background .12s, border-color .12s; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--hover); border-color: var(--line-hover); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn.lg { height: 42px; font-size: var(--fs-md); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-fg); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: none; border-color: transparent; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.danger { color: var(--err); }
.btn.primary.danger { background: var(--err); color: #fff; }
.btn.primary.danger:hover:not(:disabled) { background: var(--err); filter: brightness(1.08); }
.btn kbd { margin-left: 4px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--r-md); background: none; color: var(--text-dim); flex: none; }
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent-text); }
.icon-btn.sm { width: 26px; height: 26px; border-radius: var(--r-sm); }
.icon-btn.danger:hover:not(:disabled) { color: var(--err); background: color-mix(in srgb, var(--err-soft) 70%, transparent); }
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-md); flex: none; }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; border-radius: 6px; padding: 4px 11px; font-size: var(--fs-sm); color: var(--text-dim); }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.seg.sm button { padding: 1px 8px; font-size: 11.5px; }
.group-label { padding: 10px 10px 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-faint); letter-spacing: .02em; }
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--n7); }
.dot.running { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse 1.6s ease-in-out infinite; }
.dot.failed { background: var(--err); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px transparent; } }
.diffstat { display: inline-flex; gap: 6px; font: 500 12px var(--mono); flex: none; }
.diffstat b { font-weight: 500; }
.add { color: var(--ok); } .del { color: var(--err); }
.pill { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-dim); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.err { background: var(--err-soft); color: var(--err); }
.switch { position: relative; display: inline-block; width: 32px; height: 18px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--n7); transition: .15s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .15s var(--ease); box-shadow: var(--shadow-sm); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { translate: 14px 0; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; align-items: flex-start; }
.row.wrap > .field { flex: 1 1 180px; }
.row.end { justify-content: flex-end; }
.field { display: grid; gap: 5px; min-width: 0; }
.field-label { font-size: var(--fs-sm); font-weight: 550; }
.field > .seg { justify-self: start; }
.field-hint { font-size: 12.5px; color: var(--text-faint); }
.form-error { color: var(--err); font-size: var(--fs-sm); min-height: 1.2em; }
.form-error:empty { display: none; }
.form-card { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.form-card > strong { font-size: var(--fs-md); }
.form-card.reveal { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); }
.empty { display: grid; justify-items: center; gap: 6px; padding: 32px 16px; text-align: center; color: var(--text-dim); }
.empty strong { color: var(--text); font-weight: 600; }
.empty-body { font-size: var(--fs-sm); max-width: 340px; }
.empty-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-3); color: var(--text-dim); margin-bottom: 4px; }
.empty-icon .i { width: 20px; height: 20px; }
.pane-loading { display: flex; align-items: center; gap: 8px; color: var(--text-faint); font-size: var(--fs-sm); padding: 12px 2px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table-wrap th { text-align: left; font-weight: 600; color: var(--text-dim); background: var(--surface-2); }
.table-wrap th, .table-wrap td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-wrap tr:last-child td { border-bottom: 0; }

/* menus */
.menu { position: relative; flex: none; }
.menu-pop { position: fixed; z-index: 200; min-width: 220px; max-width: min(320px, calc(100vw - 16px)); display: grid; gap: 1px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: pop .14s var(--ease); }
.menu-item { display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; font-size: var(--fs-sm); }
.menu-item:hover { background: var(--hover); }
.menu-item .i { color: var(--text-dim); }
.menu-item.danger, .menu-item.danger .i { color: var(--err); }
.menu-label { padding: 6px 10px 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-faint); letter-spacing: .02em; }
.menu-item .i.invisible { visibility: hidden; }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }

/* toasts */
.toasts { position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top)); translate: -50% 0; z-index: 300; display: grid; gap: 8px; justify-items: center; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 14px; border-radius: var(--r-lg); background: var(--n12); color: var(--n1); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); pointer-events: auto; animation: pop .18s var(--ease); max-width: 100%; }
.toast > span:not(.i) { overflow-wrap: anywhere; }
.toast .i { color: var(--g11); }
.toast.err .i { color: var(--r9); }
.toast .icon-btn { color: inherit; opacity: .6; }
.toast .icon-btn:hover { background: color-mix(in srgb, var(--n1) 15%, transparent); color: inherit; opacity: 1; }

