:root {
  color-scheme: light;
  --page: #eef2f6;
  --page-2: #f7f9fc;
  --surface: #ffffff;
  --surface-soft: #f4f8fb;
  --ink: #17212b;
  --muted: #657381;
  --subtle: #8b98a5;
  --line: #dfe5ec;
  --line-strong: #cbd5df;
  --blue: #4f9bcf;
  --blue-dark: #1f6f9f;
  --blue-soft: #e8f4fb;
  --blue-line: #c9e3f2;
  --accent: #2d8f72;
  --danger: #be5146;
  --focus: #4f9bcf;
  --shadow-sm: 0 2px 10px rgba(22, 34, 46, 0.07);
  --shadow-md: 0 16px 38px rgba(22, 34, 46, 0.10);
  --shadow-lg: 0 28px 70px rgba(22, 34, 46, 0.13);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(247, 249, 252, 0.96) 0%, rgba(238, 242, 246, 1) 420px),
    var(--page);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  appearance: none;
}

textarea,
input,
select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0.76rem 0.86rem;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

select {
  cursor: pointer;
}

textarea {
  resize: vertical;
  font-family: "Cascadia Mono", "Consolas", monospace;
  line-height: 1.6;
}

textarea:hover,
input:hover,
select:hover {
  border-color: var(--line-strong);
}

textarea:disabled,
input:disabled,
select:disabled {
  background: #f2eee7;
  color: var(--subtle);
  cursor: not-allowed;
}

textarea:focus,
input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(105, 174, 218, 0.22);
  outline: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  background: rgba(247, 249, 252, 0.90);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(223, 229, 236, 0.84);
}

.brand,
.main-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  color: #25343d;
  font-weight: 850;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.main-nav a {
  border-radius: 7px;
  color: var(--muted);
  font-weight: 720;
  padding: 0.48rem 0.72rem;
}

.language-switcher {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.language-switcher select {
  width: auto;
  min-width: 7.4rem;
  min-height: 2.3rem;
  padding: 0.42rem 0.62rem;
}

.main-nav a[aria-current="page"],
.main-nav a:hover {
  background: var(--blue-soft);
  color: var(--blue-dark);
}

html[dir="rtl"] body {
  text-align: right;
}

html[dir="rtl"] .brand,
html[dir="rtl"] .main-nav,
html[dir="rtl"] .button,
html[dir="rtl"] .button-row,
html[dir="rtl"] .panel-head,
html[dir="rtl"] .stage-header,
html[dir="rtl"] .section-row,
html[dir="rtl"] .tool-nav-item,
html[dir="rtl"] .integration-slot,
html[dir="rtl"] .tool-card,
html[dir="rtl"] .command-meta,
html[dir="rtl"] .command-actions {
  direction: rtl;
}

html[dir="rtl"] textarea,
html[dir="rtl"] input,
html[dir="rtl"] select,
html[dir="rtl"] code,
html[dir="rtl"] .parse-output,
html[dir="rtl"] .command-hex,
html[dir="rtl"] .command-response {
  direction: ltr;
  text-align: left;
}

.home-hero,
.tool-hero,
.tool-list,
.tool-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.app-topbar {
  max-width: none;
  padding-inline: clamp(1rem, 2vw, 1.75rem);
}

.home-workbench {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 1rem;
  width: min(1480px, 100%);
  min-height: calc(100vh - 4.35rem);
  margin: 0 auto;
  padding: 1rem;
}

.tool-sidebar,
.tool-stage {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-md);
}

.tool-sidebar {
  display: grid;
  align-content: start;
  gap: 1rem;
  padding: 1rem;
}

.sidebar-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--page-2);
  padding: 1rem;
}

.sidebar-section:first-child {
  background:
    linear-gradient(135deg, rgba(31, 111, 159, 0.10), rgba(45, 143, 114, 0.08)),
    var(--surface);
}

.sidebar-section h1 {
  color: var(--ink);
  font-size: clamp(1.7rem, 3vw, 2.25rem);
  line-height: 1.08;
}

.sidebar-copy {
  color: var(--muted);
  line-height: 1.7;
  margin: 0.8rem 0 0;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  color: #425261;
  font-size: 0.9rem;
  font-weight: 820;
}

.section-row strong {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  height: 2rem;
  border-radius: 7px;
  background: var(--surface);
  color: var(--blue-dark);
  box-shadow: var(--shadow-sm);
}

.tool-nav-list {
  display: grid;
  gap: 0.65rem;
}

.tool-nav-item,
.integration-slot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.78rem;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0.85rem;
  text-align: left;
}

.tool-nav-item {
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.tool-nav-item:hover {
  border-color: var(--blue-line);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.tool-nav-item.active {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: inset 3px 0 0 var(--blue-dark), var(--shadow-sm);
}

.tool-nav-item svg,
.integration-slot svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--blue-dark);
}

.tool-nav-item > i,
.integration-slot > i,
.tool-nav-item > svg,
.integration-slot > svg {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 7px;
  background: var(--surface-soft);
}

.tool-nav-item span,
.integration-slot span {
  min-width: 0;
}

.tool-nav-item strong,
.integration-slot strong {
  display: block;
  color: #24323f;
  font-size: 0.95rem;
}

.tool-nav-item small,
.integration-slot small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
  margin-top: 0.2rem;
}

.muted-section {
  background: var(--surface);
}

.integration-slot {
  color: var(--muted);
  border-style: dashed;
  background: #fbfcfe;
}

.tool-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 5.4rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.stage-header h2 {
  font-size: clamp(1.18rem, 2vw, 1.55rem);
}

.stage-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.tool-frame-shell {
  min-height: 0;
  background: #f5f8fb;
}

.tool-frame-shell iframe {
  display: block;
  width: 100%;
  height: calc(100vh - 10.75rem);
  min-height: 720px;
  border: 0;
  background: var(--page);
}

.embedded-tool {
  background: var(--page);
}

.embedded-tool .topbar,
.embedded-tool .site-footer {
  display: none;
}

.embedded-tool .language-switcher {
  display: none;
}

.embedded-tool .tool-shell {
  max-width: none;
  padding: 1rem;
}

.embedded-tool .tool-title {
  display: none;
}

.tool-title {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  margin-bottom: 1rem;
  padding: 1.55rem 1.65rem;
}

.tool-title h1 {
  font-size: clamp(1.45rem, 3vw, 2.15rem);
}

.home-hero,
.tool-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(340px, 0.84fr);
  gap: 1.1rem;
  align-items: stretch;
}

.home-copy,
.tool-hero > div {
  position: relative;
  min-height: 380px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: clamp(2.25rem, 5vw, 4.4rem);
}

.home-copy::after,
.tool-hero > div::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 42%;
  height: 42%;
  border-top: 1px solid var(--blue-line);
  border-left: 1px solid var(--blue-line);
  background:
    linear-gradient(90deg, rgba(105, 174, 218, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(105, 174, 218, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
  pointer-events: none;
}

.compat-panel,
.status-board,
.panel,
.tool-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.eyebrow {
  margin: 0 0 0.72rem;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0;
  color: var(--blue-dark);
  font-size: clamp(2.35rem, 5.5vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  color: #2c495a;
  font-size: 1.34rem;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 0.36rem;
  color: #2c495a;
  font-size: 1.05rem;
}

.home-copy p:not(.eyebrow),
.tool-hero p:not(.eyebrow) {
  position: relative;
  z-index: 1;
  max-width: 760px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.78;
}

.compat-panel p,
.tool-card p,
.hint {
  color: var(--muted);
  line-height: 1.72;
}

.hero-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.button,
.icon-button,
.tab {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 2.65rem;
  padding: 0.66rem 0.95rem;
  cursor: pointer;
  font-weight: 760;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease, color 140ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.button.primary {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  color: #fff;
  box-shadow: 0 8px 18px rgba(47, 125, 169, 0.22);
}

.button:hover,
.icon-button:hover,
.tab:hover {
  transform: translateY(-1px);
  border-color: var(--blue);
  box-shadow: var(--shadow-sm);
}

.button.primary:hover {
  background: #276e98;
  border-color: #276e98;
}

.button svg,
.icon-button svg {
  width: 1.05rem;
  height: 1.05rem;
}

.status-board,
.compat-panel {
  padding: 1rem;
}

.compat-panel {
  display: grid;
  align-content: start;
  gap: 0.9rem;
}

.compat-panel strong {
  display: block;
  color: #2c495a;
  font-size: 1.08rem;
}

.compat-panel p {
  margin: 0;
}

.status-board {
  display: grid;
  gap: 0.82rem;
}

.status-board div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--page-2);
  padding: 1rem;
}

.status-board span,
.tool-icon {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 7px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-weight: 850;
}

.status-board strong {
  display: block;
  margin-top: 0.75rem;
  color: #2c495a;
}

.status-board p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.68;
}

.tool-list {
  padding-top: 0;
}

.section-head {
  margin-bottom: 1rem;
}

.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.15rem;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.tool-card + .tool-card {
  margin-top: 0.8rem;
}

.tool-card:hover {
  border-color: var(--blue-line);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-shell {
  padding-top: 1rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(350px, 0.9fr);
  gap: 1rem;
}

.serial-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
  grid-template-areas:
    "connection connection"
    "send receive"
    "commands commands";
  gap: 1rem;
}

.code-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr);
  grid-template-areas:
    "generator preview"
    "decoder decoder";
  gap: 1rem;
}

.code-generator-panel {
  grid-area: generator;
}

.code-preview-panel {
  grid-area: preview;
}

.code-decode-panel {
  grid-area: decoder;
}

.code-preview-box,
.decode-preview {
  display: grid;
  place-items: center;
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #f2f5f8 25%, transparent 25%),
    linear-gradient(-45deg, #f2f5f8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f2f5f8 75%),
    linear-gradient(-45deg, transparent 75%, #f2f5f8 75%),
    #fff;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  overflow: auto;
  padding: 1rem;
}

.code-preview-box canvas {
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.code-output {
  min-height: 6.5rem;
}

.decode-preview {
  min-height: 260px;
  margin-top: 1rem;
  color: var(--subtle);
}

.decode-preview svg {
  width: 3rem;
  height: 3rem;
}

.decode-preview img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 1.1rem;
}

.command-panel {
  grid-row: span 2;
}

.connection-panel {
  grid-column: 1 / -1;
}

.serial-send-panel,
.serial-receive-panel {
  min-width: 0;
}

.serial-connection-panel {
  grid-area: connection;
}

.serial-send-panel {
  grid-area: send;
}

.serial-receive-panel {
  grid-area: receive;
}

.serial-command-panel {
  grid-area: commands;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.65rem;
  padding: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.field-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.serial-composer-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.serial-composer-grid label,
.serial-composer-grid input,
.serial-composer-grid select {
  min-width: 0;
}

.serial-composer-grid.receive-options {
  grid-template-columns: 1fr 1fr auto auto;
  align-items: end;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 740;
}

label span {
  color: #5d707b;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

label.wide {
  grid-column: 1 / -1;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
}

.inline-check input {
  width: 1rem;
  min-height: auto;
}

.form-section,
.protocol-box,
.command-queue {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--page-2);
  padding: 1rem;
}

.form-section + .protocol-columns {
  margin-top: 1rem;
}

.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.section-label span {
  color: #2c495a;
  font-size: 0.98rem;
  font-weight: 850;
}

.section-label small {
  color: var(--subtle);
  font-size: 0.82rem;
}

.protocol-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.protocol-box {
  display: grid;
  align-content: start;
  gap: 0.85rem;
  background: #fff;
}

.result-stack {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.form-actions,
.serial-actions {
  margin-top: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--page-2);
  padding: 0.8rem;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 720;
}

.stats-grid strong {
  display: block;
  color: var(--blue-dark);
  font-size: 1.35rem;
  margin-top: 0.25rem;
}

.send-preview {
  display: grid;
  gap: 0.45rem;
  border: 1px solid var(--blue-line);
  border-radius: 8px;
  background: var(--surface-soft);
  margin: 0.9rem 0;
  padding: 0.78rem 0.9rem;
}

.send-preview span {
  color: #5d707b;
  font-size: 0.86rem;
  font-weight: 780;
}

.send-preview code {
  color: #2d3d47;
  font-family: "Cascadia Mono", "Consolas", monospace;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.timer-options {
  max-width: 260px;
  margin-bottom: 1rem;
}

.parse-output {
  display: block;
  min-height: 9rem;
  margin-top: 1rem;
  border: 1px solid #203947;
  border-radius: 8px;
  background: #172832;
  color: #e6f7ff;
  padding: 1rem;
  font-family: "Cascadia Mono", "Consolas", monospace;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.format-table-panel {
  margin-top: 1rem;
}

.format-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  padding: 0.9rem 1rem;
}

.format-table-head h3 {
  margin: 0;
  font-size: 1rem;
}

.format-table-head span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 780;
  white-space: nowrap;
}

.format-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: #fff;
}

.format-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.format-table th,
.format-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.62rem 0.72rem;
  text-align: left;
  vertical-align: middle;
}

.format-table th {
  background: var(--page-2);
  color: #415260;
  font-size: 0.78rem;
  font-weight: 850;
}

.format-table tr:last-child td {
  border-bottom: 0;
}

.format-table tr.consumed-row td {
  background: #fbfcfe;
  color: var(--subtle);
}

.format-table code {
  color: #2d3d47;
  font-family: "Cascadia Mono", "Consolas", monospace;
  white-space: nowrap;
}

.format-table strong {
  color: var(--blue-dark);
  font-weight: 850;
}

.table-select {
  min-height: 2.25rem;
  min-width: 8.6rem;
  padding: 0.45rem 0.62rem;
}

.table-state {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 820;
  white-space: nowrap;
}

.table-state.ok {
  background: #e8f8ec;
  color: #38754a;
}

.table-state.warn {
  background: #fff2d7;
  color: #8a642d;
}

.table-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0.9rem 1rem;
  line-height: 1.6;
}

.table-empty.error {
  border-color: #efc1bb;
  background: #fff7f6;
  color: var(--danger);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.tab.active {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 0.9rem;
}

.status-pill {
  border: 1px solid var(--blue-line);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  padding: 0.36rem 0.76rem;
  font-size: 0.82rem;
  font-weight: 850;
}

.hint {
  border: 1px solid var(--blue-line);
  border-radius: 8px;
  background: var(--surface-soft);
  margin: 1rem 0;
  padding: 0.82rem 0.9rem;
}

.command-queue {
  margin: 1rem 0;
  background: #fff;
}

.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.quick-builder {
  display: grid;
  grid-template-columns: 0.8fr 0.7fr 1.35fr 0.8fr 0.75fr 1.15fr 0.8fr auto;
  gap: 0.75rem;
  align-items: end;
  border: 1px solid var(--blue-line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 0.9rem;
}

.quick-add {
  min-width: 5.2rem;
}

.command-list {
  display: grid;
  gap: 0.72rem;
  margin-top: 1rem;
}

.empty-commands {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 1rem;
  text-align: center;
}

.command-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--page-2);
  padding: 0.9rem;
}

.command-main {
  min-width: 0;
}

.command-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.command-badge {
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 820;
  padding: 0.25rem 0.55rem;
}

.command-badge.waiting {
  background: #fff2d7;
  color: #8a642d;
}

.command-badge.done {
  background: #e8f8ec;
  color: #38754a;
}

.command-badge.error {
  background: #fdeceb;
  color: var(--danger);
}

.command-hex,
.command-response {
  color: #2d3d47;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.command-response {
  border-top: 1px solid var(--line);
  margin-top: 0.55rem;
  padding-top: 0.55rem;
}

.command-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.command-actions .icon-button {
  width: 2.45rem;
  min-height: 2.45rem;
}

.local-note {
  border: 1px solid var(--blue-line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-top: 1rem;
  padding: 1rem 1.15rem;
}

.local-note strong {
  color: #2c495a;
}

.local-note p {
  color: var(--muted);
  line-height: 1.72;
  margin: 0.5rem 0 0;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1240px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  color: var(--muted);
}

.tips-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.tips-message {
  border: 1px solid var(--blue-line);
  border-left: 4px solid var(--blue-dark);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-md);
  color: var(--ink);
  padding: 0.82rem 0.95rem;
  font-size: 0.92rem;
  font-weight: 720;
  line-height: 1.5;
  opacity: 0;
  transform: translateX(24px);
  animation: tip-in 180ms ease forwards;
}

.tips-message.success {
  border-left-color: #438d58;
}

.tips-message.error {
  border-left-color: var(--danger);
}

.tips-message.leaving {
  animation: tip-out 240ms ease forwards;
}

@keyframes tip-in {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes tip-out {
  to {
    opacity: 0;
    transform: translateX(120%);
  }
}

@media (max-width: 920px) {
  .home-workbench {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .tool-sidebar {
    position: static;
  }

  .tool-nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-frame-shell iframe {
    height: 78vh;
    min-height: 680px;
  }

  .home-hero,
  .tool-hero,
  .workspace-grid,
  .serial-layout,
  .code-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "connection"
      "send"
      "receive"
      "commands";
  }

  .code-layout {
    grid-template-areas:
      "generator"
      "preview"
      "decoder";
  }

  .home-copy,
  .tool-hero > div {
    min-height: auto;
  }

  .field-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .protocol-columns,
  .quick-builder,
  .serial-composer-grid,
  .serial-composer-grid.receive-options {
    grid-template-columns: 1fr 1fr;
  }

  .serial-receive-panel,
  .serial-command-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .quick-add {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .home-workbench {
    padding: 0.75rem;
  }

  .tool-nav-list {
    grid-template-columns: 1fr;
  }

  .stage-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .format-table-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stage-actions {
    width: 100%;
    justify-content: stretch;
  }

  .stage-actions .button,
  .stage-actions .status-pill {
    flex: 1 1 auto;
  }

  .tool-frame-shell iframe {
    height: 82vh;
    min-height: 620px;
  }

  .topbar,
  .site-footer,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid,
  .field-grid.compact {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
  }

  h1 {
    font-size: 2.16rem;
  }

  .tool-title h1 {
    font-size: 1.45rem;
  }

  .protocol-columns,
  .quick-builder,
  .serial-composer-grid,
  .serial-composer-grid.receive-options,
  .stats-grid,
  .command-item {
    grid-template-columns: 1fr;
  }

  .section-label,
  .queue-head,
  .command-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
