:root {
  color-scheme: light;
  --page: #f7f6ef;
  --page-soft: #efeee6;
  --panel: #fcfbf7;
  --panel-raised: #fcfbf7;
  --panel-deep: #efeee6;
  --surface: #fcfbf7;
  --surface-alt: #efeee6;
  --line: #d8d9cf;
  --line-strong: #c2c8bd;
  --ink: #11271d;
  --text: #3f4a42;
  --muted: #788078;
  --accent: #0f503b;
  --accent-deep: #0a3d2d;
  --accent-soft: #dce8dd;
  --button-text: #fff;
  --blue: #0f503b;
  --cyan: #0f503b;
  --violet: #766d8d;
  --amber: #a46d40;
  --red: #9f4037;
  --green: #477c5d;
  --shadow: 0 14px 28px rgba(27, 45, 35, .10);
  --paper: var(--surface);
  --background: var(--page);
  --soft: var(--accent-soft);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111813;
  --page-soft: #1d2a21;
  --panel: #172019;
  --panel-raised: #1d2a21;
  --panel-deep: #111813;
  --surface: #172019;
  --surface-alt: #1d2a21;
  --line: #334337;
  --line-strong: #496050;
  --ink: #edf2e9;
  --text: #c7d0c5;
  --muted: #9eaa9e;
  --accent: #b9d7bf;
  --accent-deep: #d3e6d3;
  --accent-soft: #273d2d;
  --button-text: #122218;
  --blue: #b9d7bf;
  --cyan: #b9d7bf;
  --violet: #c8badd;
  --amber: #dfb279;
  --red: #efaca4;
  --green: #9bd4a9;
  --shadow: 0 14px 28px rgba(0, 0, 0, .25);
  --paper: var(--surface);
  --background: var(--page);
  --soft: var(--accent-soft);
}
body {
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 18%, rgba(171, 147, 107, .08), transparent 22rem),
    radial-gradient(circle at 84% 62%, rgba(71, 118, 91, .06), transparent 26rem),
    var(--page);
  font-size: 15px;
  line-height: 1.75;
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 14% 18%, rgba(101, 137, 105, .12), transparent 22rem),
    radial-gradient(circle at 84% 62%, rgba(57, 94, 70, .12), transparent 26rem),
    var(--page);
}
body::before {
  z-index: 30;
  opacity: .14;
  background-image: repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(71, 78, 64, .08) 32px);
  background-size: auto;
  mask-image: none;
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] body::before {
  opacity: .06;
  background-image: repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(177, 205, 179, .08) 32px);
  mix-blend-mode: screen;
}
::selection { color: var(--page); background: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.shell { width: min(1320px, calc(100% - 96px)); margin-inline: auto; }
.site-header { background: color-mix(in srgb, var(--page) 94%, transparent); border-bottom-color: var(--line); }
.header-inner { min-height: 72px; }
.brand { color: var(--ink); font-size: 20px; font-weight: 650; letter-spacing: -.045em; }
.brand:hover { color: var(--accent); }
.brand strong { color: var(--ink); font-weight: 650; }
.brand-mark {
  position: relative; display: block; width: 35px; height: 30px; flex: 0 0 35px;
  padding: 0; border: 0; border-radius: 0; background: transparent; transform: none;
}
.brand-mark::before, .brand-mark::after {
  position: absolute; inset: 5px 8px; border: 1.5px solid var(--accent); border-radius: 50%; content: "";
}
.brand-mark::after { inset: 9px 0; transform: rotate(-24deg); }
.brand-mark span { display: none; }
.brand-mark span:first-child {
  position: absolute; top: 2px; right: 6px; display: block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--accent);
}
.site-nav a:hover { color: var(--accent); }
.theme-toggle:hover { color: var(--ink); }

.tool-hero {
  display: block; min-height: 0; padding: 52px 0 35px; border-bottom: 1px solid var(--line);
}
.eyebrow, .panel-kicker {
  color: var(--muted); font: 10px/1.5 var(--mono); letter-spacing: .13em;
}
.eyebrow { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.eyebrow span {
  width: 30px; height: 1px; flex: 0 0 30px; border-radius: 0; background: var(--accent); box-shadow: none;
}
h1, h2, h3 { color: var(--ink); font-weight: 600; }
h1 { max-width: 780px; font-size: clamp(36px, 4.1vw, 54px); line-height: 1.2; letter-spacing: -.055em; }
h1 em { color: var(--accent); font-style: normal; }
.panel-kicker { margin-bottom: 7px; font-size: 10px; letter-spacing: .1em; }

.workspace { grid-template-columns: minmax(270px, 320px) minmax(0, 1fr); gap: 22px; padding-top: 28px; }
.sidebar { gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); box-shadow: var(--shadow); }
.connection-panel, .device-panel, .guide-panel { padding: 22px; }
.panel-heading { gap: 15px; margin-bottom: 21px; }
.compact-heading { margin-bottom: 16px; }
.panel-heading h2 { color: var(--ink); font-size: 19px; letter-spacing: -.025em; }
.panel-icon { width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 2px; color: var(--accent); background: var(--surface-alt); }
.field { gap: 7px; margin-bottom: 16px; }
.field-label { color: var(--text); font-size: 12px; }
.field-label b, .field-label i { color: var(--accent); font: 10px/1.2 var(--mono); font-style: normal; font-weight: 500; }
.field-label i { color: var(--muted); }
input, textarea, select {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 3px;
  color: var(--ink); background: var(--page); outline: none;
  transition: border-color .18s, box-shadow .18s, background-color .18s;
}
input { min-height: 40px; padding: 8px 11px; font: 12px/1.4 var(--mono); }
textarea { min-height: 112px; padding: 13px; font: 13px/1.8 var(--mono); }
select { min-height: 40px; padding: 8px 10px; font: 12px/1.4 var(--mono); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent); background: var(--surface);
}
.field-hint { color: var(--muted); font-size: 11px; }
.field-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
.number-field input { width: 73px; min-height: 35px; padding-block: 6px; text-align: center; }
.number-field span { color: var(--muted); }
.connection-actions { gap: 9px; margin-top: 19px; }
.button {
  min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 2px;
  font-size: 13px; font-weight: 600;
  transition: transform .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { color: var(--button-text); background: var(--accent); box-shadow: none; }
.button-primary:hover:not(:disabled) { background: var(--accent-deep); }
.button-secondary { border-color: var(--line); color: var(--ink); background: transparent; }
.button-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-soft); }
.button-spinner { border-color: color-mix(in srgb, var(--button-text) 35%, transparent); border-top-color: var(--button-text); }
.connection-status { min-height: 24px; margin-top: 13px; color: var(--muted); }
.status-dot { box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 10%, transparent); }
.connection-status[data-state="connected"] { color: var(--green); }
.connection-status[data-state="connected"] .status-dot { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 12%, transparent), 0 0 12px color-mix(in srgb, var(--green) 30%, transparent); }
.connection-status[data-state="pending"] { color: var(--amber); }
.connection-status[data-state="pending"] .status-dot { background: var(--amber); box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 12%, transparent); }
.connection-status[data-state="error"] { color: var(--red); }
.connection-status[data-state="error"] .status-dot { background: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 12%, transparent); }
.inline-note { border-color: var(--line); border-radius: 2px; color: var(--muted); background: var(--surface-alt); }
.note-mark { border-color: var(--line-strong); color: var(--accent); }
.connection-pill, .live-indicator { border-color: var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-alt); }
.connection-pill[data-state="connected"], .live-indicator[data-state="connected"] { border-color: color-mix(in srgb, var(--green) 35%, var(--line)); color: var(--green); }
.device-details div { border-top-color: var(--line); }
.device-details dt { color: var(--muted); }
.device-details dd { color: var(--text); }
.quick-steps li > span { border-color: var(--line); border-radius: 2px; color: var(--accent); background: var(--accent-soft); }
.quick-steps p { color: var(--text); font-size: 12px; }

.console-panel { padding: 22px 22px 17px; }
.console-actions { gap: 5px; }
.text-button { padding: 5px 7px; border: 0; border-radius: 2px; color: var(--muted); background: transparent; font-size: 11px; }
.text-button:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
.live-indicator { color: var(--muted); }
.live-indicator[data-state="connected"] .status-dot { background: var(--green); box-shadow: 0 0 8px color-mix(in srgb, var(--green) 35%, transparent); }
.log-toolbar { margin-top: 17px; padding-bottom: 11px; border-bottom-color: var(--line); }
.toolbar-label { color: var(--muted); }
.segmented-control, .mode-tabs { padding: 3px; border: 1px solid var(--line); border-radius: 2px; background: var(--surface-alt); }
.segmented-control button, .mode-tab { border-radius: 2px; color: var(--muted); background: transparent; }
.segmented-control button[aria-pressed="true"], .mode-tab.active { color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.log-panel { min-height: 360px; max-height: 510px; padding: 10px 2px 7px 0; scrollbar-color: var(--line-strong) transparent; }
.log-empty { color: var(--muted); }
.empty-symbol { color: var(--accent); }
.log-empty strong { color: var(--ink); }
.log-empty p { color: var(--muted); }
.log-entry { border-bottom-color: var(--line); }
.log-entry:hover { background: var(--surface-alt); }
.log-direction { border-radius: 2px; }
.log-direction.rx { color: var(--green); background: color-mix(in srgb, var(--accent-soft) 80%, transparent); }
.log-direction.tx { color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 54%, transparent); }
.log-time, .log-value-label, .byte-count, .console-footnote { color: var(--muted); }
.log-value code { color: var(--text); }
.log-value.ascii code { color: var(--green); }
.send-divider { color: var(--muted); }
.send-divider span { background: var(--line); }
.send-heading span { color: var(--muted); }
.send-form textarea { background: var(--page); }
.protocol-note { margin: 19px 0 42px; padding: 16px 19px; border: 1px solid var(--line); border-radius: 4px; background: var(--accent-soft); }
.protocol-icon { border-color: var(--line-strong); border-radius: 2px; color: var(--accent); }
.protocol-note strong { color: var(--ink); }
.protocol-note p { color: var(--text); }
.protocol-workspace { border-color: var(--line); border-radius: 4px; background: var(--surface-alt); }
.protocol-editor select, .protocol-field input, .serial-send-options select { border-color: var(--line); border-radius: 3px; color: var(--ink); background: var(--page); }
.protocol-result, .protocol-results { border-color: var(--line); }
.protocol-result p, .protocol-status, .protocol-hint { color: var(--muted); }
.protocol-table th, .protocol-table td { border-bottom-color: var(--line); }
.protocol-note a { color: var(--accent); }
.tool-footer { border-top-color: var(--line); background: var(--page); }
.footer-inner { padding: 22px 0 calc(22px + env(safe-area-inset-bottom)); color: var(--muted); }

@media (max-width: 960px) {
  .shell { width: min(100% - 64px, 1200px); }
  .workspace { grid-template-columns: 285px minmax(0, 1fr); gap: 16px; }
}
@media (max-width: 800px) {
  .shell { width: min(100% - 40px, 680px); }
  .tool-hero { padding: 44px 0 32px; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .connection-panel { grid-row: span 2; }
  .guide-panel { grid-column: 2; }
}
@media (max-width: 760px) {
  .sidebar { grid-template-columns: 1fr; }
  .connection-panel { grid-row: auto; }
  .guide-panel { grid-column: auto; }
  .console-panel { padding: 18px 16px 16px; }
  .connection-panel, .device-panel, .guide-panel { padding: 18px; }
  .log-toolbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .log-panel { min-height: 315px; max-height: 470px; }
  .log-empty { min-height: 275px; }
  .send-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .send-footer { align-items: flex-start; flex-direction: column; }
  .send-actions { width: 100%; }
  .send-actions .button { flex: 1; }
  .protocol-note { margin-bottom: 32px; padding: 14px; }
  .footer-inner { flex-direction: column; gap: 6px; }
}
@media (max-width: 520px) {
  .shell { width: min(100% - 28px, 480px); }
  .tool-hero { padding: 34px 0 28px; }
  h1 { font-size: clamp(32px, 10vw, 44px); }
  .brand { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
