:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #5b6472;
  --border: #d8dce2;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --error: #b91c1c;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1d2026;
    --text: #e7e9ec;
    --muted: #9aa3af;
    --border: #2c313a;
    --accent: #3b82f6;
    --accent-text: #0b1220;
    --ok: #4ade80;
    --warn: #fbbf24;
    --error: #f87171;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2.5rem 1rem;
}

main {
  width: 100%;
  max-width: 30rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.25rem;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  text-decoration: none;
  color: var(--text);
}

.brand-header .brand-mark {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.brand-header .brand-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

/* Compact icon-only "back to homepage" link, used on the utility pages
   (home/client/settings) instead of the full brand-header wordmark. Fixed
   in the corner so it stays out of the content flow and reads as a
   persistent nav affordance rather than part of the page content. */
.home-icon-link {
  position: fixed;
  top: 1.1rem;
  left: 1.1rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: filter 0.15s ease, transform 0.05s ease;
}

.home-icon-link:hover {
  filter: brightness(1.08);
}

.home-icon-link:active {
  transform: translateY(1px);
}

.home-icon-link svg {
  width: 1.2rem;
  height: 1.2rem;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  font-size: 1.1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  letter-spacing: 0.05em;
}

input[type="file"] {
  width: 100%;
  color: var(--text);
}

button {
  font-size: 1rem;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover:not(:disabled) {
  filter: none;
  border-color: var(--accent);
}

.field {
  margin-bottom: 1rem;
}

.row {
  display: flex;
  gap: 0.75rem;
}

.code-display {
  font-family: var(--mono);
  font-size: 2.25rem;
  letter-spacing: 0.15em;
  text-align: center;
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
  margin: 0.5rem 0 1rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.status .dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--muted);
  flex-shrink: 0;
}

.status.ok .dot {
  background: var(--ok);
}

.status.warn .dot {
  background: var(--warn);
}

.status.error .dot {
  background: var(--error);
}

.status.error {
  color: var(--error);
}

.log {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 10rem;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

progress {
  width: 100%;
  height: 0.6rem;
  accent-color: var(--accent);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin: 0 0 1rem;
  padding: 0.75rem;
}

legend {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 0.4rem;
}

.hidden {
  display: none !important;
}

.button-link {
  display: inline-block;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--accent-text);
  text-align: center;
  transition: filter 0.15s ease, transform 0.05s ease;
}

.button-link:hover {
  filter: brightness(1.08);
}

.button-link:active {
  transform: translateY(1px);
}

.button-link.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.button-link.secondary:hover {
  filter: none;
  border-color: var(--accent);
}

.help-text {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}

.row-between {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

/* Rotary "knob" control (settings.html's location-sensitivity field) --
   a real pot-style knob you drag/twist rather than a straight slider.
   Sweeps 270 degrees (-135deg..135deg, bottom 90 degrees dead) like a
   physical knob; see settings.js for the drag/keyboard/wheel logic. */
.knob-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin: 0.5rem 0 0.35rem;
}

.knob {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, var(--panel), var(--bg));
  border: 1px solid var(--border);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.15),
    0 1px 2px rgba(0, 0, 0, 0.08);
  position: relative;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  outline-offset: 3px;
}

.knob:active {
  cursor: grabbing;
}

.knob:focus-visible {
  outline: 2px solid var(--accent);
}

.knob-pointer {
  position: absolute;
  top: 8%;
  left: 50%;
  width: 0.2rem;
  height: 42%;
  margin-left: -0.1rem;
  background: var(--accent);
  border-radius: 999px;
  transform-origin: 50% 100%;
}

.knob-readout {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.knob-readout #sensitivity-value {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
}

/* Blocking-but-dismissible overlay dialog, used for anything a user is
   likely to click past if it's just inline text (e.g. the legacy-device
   first-time-setup prompt on /client/). */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.75rem;
  max-width: 26rem;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.modal-panel h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.modal-panel p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 1rem;
}

.modal-panel .button-link {
  display: block;
  text-align: center;
  margin-bottom: 0.75rem;
}

.modal-panel button.secondary {
  width: 100%;
}
