*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

h1, h2, h3, p { margin: 0; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button { cursor: pointer; }

::selection { background: var(--accent-soft); color: var(--fg-strong); }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.grow { flex: 1 1 auto; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: var(--r-sm);
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  font-size: 12.5px;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.btn:hover { background: var(--bg-3); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

.btn.primary:hover { filter: brightness(1.08); }

.btn.icon { width: 28px; padding: 0; font-size: 14px; color: var(--muted); }
.btn.icon:hover { color: var(--fg-strong); }
.btn.sm { height: 24px; padding: 0 9px; font-size: 12px; }
.btn.icon.sm { width: 24px; }
.btn.tiny { height: 22px; padding: 0 8px; font-size: 11.5px; }
.btn.lg { height: 34px; padding: 0 18px; font-size: 13.5px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--fg-strong); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn.select {
  padding-right: 6px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

select.btn option { background: var(--bg-1); color: var(--fg); }

.input {
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--fg-strong);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}

.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { height: 24px; width: 190px; font-size: 12px; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-2);
}

.seg-btn {
  height: 26px;
  padding: 0 9px;
  font-size: 11.5px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  transition: background var(--t-fast), color var(--t-fast);
}

.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--bg-3); color: var(--fg); }
.seg-btn.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.tabs { display: inline-flex; gap: 2px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; }

.tab {
  height: 24px;
  padding: 0 12px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast);
}

.tab:hover { color: var(--fg); }
.tab.on { background: var(--bg-1); color: var(--fg-strong); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.18); }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 12.5px; }
.check.inline { height: 24px; }
.check input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.field.inline { justify-content: flex-start; }
.field.block { display: block; }
.field.block span { display: block; margin-bottom: 6px; color: var(--muted); }
.field > span { color: var(--muted); }

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-strong);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
}

kbd:empty { visibility: hidden; }
