/* Serial Port Monitor — styles matching gfelectronic.com theme.
   Self-contained: includes the site's design tokens + minimal page chrome so
   the page works standalone; safe to load alongside the main styles.css. */

:root {
  --bg: #0c0f12;
  --bg-elevated: #141a21;
  --surface: #1c242e;
  --border: #2a3544;
  --text: #eef2f6;
  --text-muted: #9aa8b8;
  --accent: #d4a012;
  --accent-dim: #a67c0a;
  --accent-glow: rgba(212, 160, 18, 0.35);
  --steel: #6b7c8f;
  --success: #2d8a54;
  --danger: #c0392b;
  --font-sans: "Source Sans 3", system-ui, sans-serif;
  --font-display: "Oswald", var(--font-sans);
  --font-mono: ui-monospace, Consolas, "Cascadia Mono", Menlo, monospace;
  --space: clamp(1rem, 3vw, 2rem);
  --radius: 10px;
  --max: 1180px;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- page chrome ---------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(12, 15, 18, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.85rem var(--space);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.1rem, 4vw, 1.35rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}

.brand:hover {
  text-decoration: none;
}

.brand span,
.brand .brand-text span {
  color: var(--accent);
}

.brand .gf-logo-mark {
  height: 2.65rem;
  width: auto;
  display: block;
  flex-shrink: 0;
  border-radius: 6px;
  background: #0a0a0a;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 0 3px rgba(0, 51, 141, 0.35),
    0 6px 18px rgba(0, 0, 0, 0.45);
  object-fit: contain;
}

.brand .brand-text {
  display: inline-block;
  line-height: 1.15;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(12, 15, 18, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid #00338d;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
  align-items: center;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--space);
}

.tool-hero {
  padding: calc(var(--space) * 1.5) 0 var(--space);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

.tool-hero-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tool-hero-brand img {
  height: 1.5rem;
  width: auto;
  border-radius: 4px;
  background: #0a0a0a;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.tool-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.tool-hero h1 span {
  color: var(--accent);
}

.tool-hero p {
  color: var(--text-muted);
  max-width: 62ch;
  margin: 0;
}

.banner {
  margin: var(--space) 0 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  background: rgba(212, 160, 18, 0.08);
  font-size: 0.95rem;
}

/* ---------- tool layout ---------- */

.tool-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space);
  margin: var(--space) 0;
  align-items: start;
}

@media (max-width: 860px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.field label {
  font-size: 0.92rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.field select,
.field input[type="number"] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.92rem;
  width: 9.5rem;
  max-width: 55%;
}

.field select:focus-visible,
.field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: var(--steel);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #141002;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}

.btn-danger {
  border-color: var(--danger);
  color: #ff8a7a;
}

.btn-block {
  width: 100%;
  margin-top: 0.35rem;
}

.btn-with-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
}

.btn-with-logo .btn-gf-logo {
  height: 1.35rem;
  width: auto;
  border-radius: 3px;
  background: #0a0a0a;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

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

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--steel);
  flex: none;
}

.status-connected {
  background: var(--success);
  box-shadow: 0 0 8px rgba(45, 138, 84, 0.8);
}

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

.status-scanning,
.status-demo {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ---------- terminal ---------- */

.terminal-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.term-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.7rem;
  font-size: 0.9rem;
}

.term-toolbar .seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.term-toolbar .seg label {
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  color: var(--text-muted);
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.term-toolbar .seg label:last-child {
  border-right: 0;
}

.term-toolbar .seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.term-toolbar .seg input:checked + span {
  color: var(--accent);
  font-weight: 700;
}

.term-toolbar .check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  cursor: pointer;
}

.term-toolbar .spacer {
  flex: 1;
}

.term-toolbar .btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.88rem;
}

.terminal {
  background: #07090b;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.45;
  padding: 0.75rem;
  height: 380px;
  overflow-y: auto;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.term-line {
  min-height: 1.28em;
}

.term-rx {
  color: #b8e0a8;
}

.term-tx {
  color: var(--accent);
}

.term-info {
  color: var(--steel);
  font-style: italic;
}

.term-meta {
  color: var(--steel);
}

.term-ctrl {
  color: #7aa0c4;
  opacity: 0.8;
  font-size: 0.82em;
}

.term-hexrow {
  white-space: pre;
}

.term-hexascii {
  color: var(--text-muted);
}

/* ---------- send row ---------- */

.send-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}

.send-row input[type="text"] {
  flex: 1;
  min-width: 180px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.92rem;
}

.send-row select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
}

.send-row .check {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- scale mode ---------- */

.scale-toggle-row {
  margin-top: var(--space);
}

.scale-panel {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space);
  align-items: center;
}

@media (max-width: 700px) {
  .scale-panel {
    grid-template-columns: 1fr;
  }
}

.scale-display {
  text-align: center;
  padding: 1rem;
  background: #07090b;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.scale-value {
  font-family: var(--font-mono);
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  font-weight: 700;
  color: #b8e0a8;
  line-height: 1.1;
}

.scale-unit {
  font-size: 1.4rem;
  color: var(--text-muted);
  margin-left: 0.4rem;
}

.scale-hold {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0.15rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.scale-hold.is-stable {
  background: rgba(45, 138, 84, 0.18);
  color: #5fd18d;
  border: 1px solid var(--success);
}

.scale-hold.is-motion {
  background: rgba(212, 160, 18, 0.12);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}

.scale-raw {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--steel);
  min-height: 1.3em;
}

.scale-controls .field {
  margin-bottom: 0.6rem;
}

.scale-factor-hint {
  margin: 0.2rem 0 0.7rem;
  font-size: 0.85rem;
  color: var(--steel);
}

.scale-factor-hint.is-ok {
  color: #5fd18d;
}

.scale-controls .btn-block {
  margin-bottom: 0.6rem;
}

.scale-controls .btn {
  margin-right: 0.4rem;
  margin-bottom: 0.4rem;
}

/* ---------- content / guide ---------- */

.content-section {
  margin: calc(var(--space) * 2) 0;
  max-width: 75ch;
}

.content-section h2 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 1.35rem;
  margin: 0 0 0.6rem;
}

.content-section h3 {
  font-size: 1.05rem;
  margin: 1.2rem 0 0.4rem;
}

.content-section p,
.content-section li {
  color: var(--text-muted);
}

.content-section strong {
  color: var(--text);
}

.cta-box {
  margin: calc(var(--space) * 1.5) 0;
  padding: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
}

.cta-box h2 {
  font-family: var(--font-display);
  text-transform: uppercase;
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
}

.cta-box p {
  margin: 0 0 0.8rem;
  color: var(--text-muted);
}

.site-footer {
  border-top: 2px solid #00338d;
  margin-top: calc(var(--space) * 2);
  padding: var(--space) 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  justify-content: space-between;
}
