:root {
  --bg: #edf3f5;
  --surface: rgba(255, 255, 255, 0.62);
  --panel: rgba(255, 255, 255, 0.54);
  --panel-strong: rgba(248, 251, 253, 0.48);
  --ink: #1f2630;
  --muted: #667386;
  --line: #dfe5ec;
  --line-strong: #bac6d4;
  --outline: #d7e0e8;
  --outline-strong: #aebdcb;
  --separator: #e2e8ee;
  --surface-raised: rgba(255, 255, 255, 0.56);
  --accent: #2f9b82;
  --accent-strong: #247f6a;
  --accent-soft: #e7f5f1;
  --accent-soft-strong: #d4eee7;
  --warn: #d58a00;
  --warn-soft: #fff2d7;
  --danger: #dd354b;
  --danger-soft: #ffe8ec;
  --button-secondary-bg: rgba(247, 250, 252, 0.56);
  --button-secondary-ink: var(--ink);
  --button-secondary-border: var(--line);
  --remove-hover-bg: color-mix(in srgb, var(--danger) 12%, var(--button-secondary-bg) 88%);
  --remove-hover-border: color-mix(in srgb, var(--danger) 54%, var(--button-secondary-border) 46%);
  --status-ok-ink: #15705f;
  --status-warn-ink: #9a6100;
  --status-error-ink: #bd2639;
  --output-bg: rgba(247, 250, 252, 0.52);
  --output-border: var(--line);
  --output-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --output-row: #e3e9f0;
  --log-bg: rgba(249, 252, 253, 0.66);
  --log-ink: #3e4856;
  --log-placeholder: #8a96a6;
  --log-match: #3e4856;
  --log-fresh-bg: rgba(78, 92, 109, 0.08);
  --log-fresh-ink: #1f2630;
  --log-warn: #9a6100;
  --log-warn-fresh: #7e5000;
  --log-warn-bg: rgba(213, 138, 0, 0.12);
  --log-error: #bd2639;
  --log-error-fresh: #9f1f31;
  --log-error-bg: rgba(221, 53, 75, 0.12);
  --pill-bg: rgba(235, 243, 246, 0.62);
  --pill-ink: #4e5c6d;
  --control-shadow: inset 0 1px 2px rgba(31, 41, 55, 0.03);
  --glass-bg: rgba(255, 255, 255, 0.5);
  --glass-line: rgba(255, 255, 255, 0.68);
  --shadow: 0 14px 38px rgba(47, 65, 78, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --shadow-soft: 0 6px 20px rgba(47, 65, 78, 0.07);
  --header-bg: rgba(248, 253, 253, 0.48);
  --header-line: rgba(255, 255, 255, 0.62);
  --nav-glass-bg: color-mix(in srgb, var(--header-bg) 86%, transparent 14%);
  --nav-glass-line: color-mix(in srgb, #fff 64%, rgba(173, 194, 205, 0.54));
  --nav-glass-shadow: 0 12px 38px rgba(47, 65, 78, 0.11), inset 0 -1px 0 rgba(255, 255, 255, 0.46);
  --nav-glass-bottom-shadow: 0 -12px 38px rgba(47, 65, 78, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.46);
  --nav-glass-filter: blur(28px) saturate(185%);
  --nav-menu-gap: 6px;
  --nav-menu-gutter: 8px;
  --account-menu-separator: rgba(120, 141, 158, 0.5);
  --radius-xl: 16px;
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --content-width: 1560px;
  --sidebar-width: 340px;
  --space-1: 8px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 14px;
  --space-5: 18px;
  --space-6: 22px;
  --page-gutter: clamp(10px, 1.6vw, 18px);
  --app-header-height: 56px;
  --header-safe-top: calc(var(--app-header-height) + var(--space-3));
  --sidebar-padding: 12px;
  --sidebar-gap: 8px;
  --sidebar-row-height: 40px;
  --sidebar-row-padding: 6px 8px;
  --sidebar-font-size: 0.9rem;
  --sidebar-heading-gap: 14px;
  --sidebar-heading-rule-gap: 8px;
  --sidebar-icon-size: 24px;
  --plc-icon-button-size: 34px;
  --plc-row-icon-button-size: 38px;
  --field-label-gap: 4px;
  --control-font-size: 0.9rem;
}

:root[data-theme="dark"] {
  --bg: #090d12;
  --surface: #151b23;
  --panel: #10161e;
  --panel-strong: #18202a;
  --ink: #eef3f8;
  --muted: #a1adba;
  --line: #26313e;
  --line-strong: #3d4b5c;
  --outline: #293544;
  --outline-strong: #405064;
  --separator: #2b3745;
  --surface-raised: rgba(16, 22, 30, 0.82);
  --accent: #4fd0a4;
  --accent-strong: #66dfb4;
  --accent-soft: rgba(79, 208, 164, 0.14);
  --accent-soft-strong: rgba(79, 208, 164, 0.22);
  --warn: #ffb020;
  --warn-soft: rgba(255, 176, 32, 0.15);
  --danger: #ef5365;
  --danger-soft: rgba(239, 83, 101, 0.15);
  --button-secondary-bg: #161b22;
  --button-secondary-ink: var(--ink);
  --button-secondary-border: var(--line);
  --remove-hover-bg: color-mix(in srgb, var(--danger) 12%, var(--button-secondary-bg) 88%);
  --remove-hover-border: color-mix(in srgb, var(--danger) 54%, var(--button-secondary-border) 46%);
  --status-ok-ink: #82edaa;
  --status-warn-ink: #ffc95c;
  --status-error-ink: #ff9ba7;
  --output-bg: #111821;
  --output-border: var(--line);
  --output-row: #27313d;
  --log-bg: #070b10;
  --log-ink: #d6dee8;
  --log-placeholder: rgba(198, 208, 220, 0.72);
  --log-match: #d6dee8;
  --log-fresh-bg: rgba(214, 222, 232, 0.08);
  --log-fresh-ink: #f0f4f8;
  --log-warn: #ffc95c;
  --log-warn-fresh: #ffdb91;
  --log-warn-bg: rgba(255, 176, 32, 0.08);
  --log-error: #ff9ba7;
  --log-error-fresh: #ffc2ca;
  --log-error-bg: rgba(239, 83, 101, 0.08);
  --pill-bg: #1d2530;
  --pill-ink: #c1c9d4;
  --control-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
  --glass-bg: rgba(16, 22, 30, 0.76);
  --glass-line: rgba(61, 75, 92, 0.74);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.14);
  --header-bg: rgba(13, 19, 27, 0.76);
  --header-line: rgba(61, 75, 92, 0.78);
  --nav-glass-line: color-mix(in srgb, #fff 14%, var(--header-line));
  --nav-glass-shadow: 0 10px 36px rgba(0, 0, 0, 0.18);
  --nav-glass-bottom-shadow: 0 -10px 36px rgba(0, 0, 0, 0.18);
  --account-menu-separator: rgba(100, 116, 139, 0.52);
}

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

html {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  padding: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 4%, rgba(79, 208, 164, 0.14), transparent 34rem),
    radial-gradient(circle at 92% 22%, rgba(111, 164, 202, 0.14), transparent 38rem),
    linear-gradient(180deg, rgba(252, 255, 255, 0.74) 0, var(--bg) 360px),
    var(--bg);
  background-attachment: fixed;
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(180deg, #111821 0, var(--bg) 260px),
    var(--bg);
}

a {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

.site-shell {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  padding: 0 var(--page-gutter);
}

body.log-viewer-page {
  min-height: 100dvh;
}

body.plc-builder-page {
  min-height: 100dvh;
}

html.log-window-fullscreen,
body.log-window-fullscreen {
  overflow: hidden;
  margin: 0;
  padding: 0;
}

body.log-window-fullscreen .site-header {
  display: none;
}

body.log-window-fullscreen .log-control-panel {
  display: none;
}

body.log-window-fullscreen .site-shell-log-viewer {
  position: static;
  width: 100vw;
  max-width: none;
  min-height: 100dvh;
  height: 100dvh;
  margin: 0;
  padding: 0;
  border-radius: 0;
}

body.log-window-fullscreen .log-viewer-layout {
  display: block;
  height: 100dvh;
  margin: 0;
  padding: 0;
  border-radius: 0;
}

.site-shell-log-viewer {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.site-shell-log-viewer > .log-viewer-layout {
  flex: 0 0 auto;
}

@media (min-width: 901px) {
  body.modbus-page {
    min-height: 100dvh;
    overflow-y: auto;
  }

  .modbus-page .site-shell {
    min-height: 100dvh;
  }

  .modbus-page .site-header {
    flex: 0 0 auto;
  }

  .modbus-layout {
    position: sticky;
    top: 0;
    height: 100dvh;
    align-items: stretch;
  }

  .modbus-page .modbus-scroll-panel {
    min-height: 0;
    overflow: visible;
  }
}

.log-viewer-results {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.log-viewer-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: var(--space-3);
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  padding-top: var(--header-safe-top);
  padding-bottom: var(--space-3);
}

.log-control-panel {
  align-self: start;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
}

.log-control-fields {
  display: grid;
  gap: var(--sidebar-gap);
}

.log-control-actions {
  display: grid;
  gap: var(--sidebar-gap);
  margin-top: var(--space-3);
}

.log-control-actions button {
  width: 100%;
  min-height: var(--sidebar-row-height);
  padding: var(--sidebar-row-padding);
  font-size: var(--sidebar-font-size);
}

.log-control-actions .status {
  margin-top: var(--space-3);
}

@media (min-width: 901px) {
  .site-shell-log-viewer {
    height: 100dvh;
  }

  .log-viewer-layout {
    height: 100dvh;
    align-items: stretch;
  }
}

.log-viewer-results.is-fullscreen {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  z-index: 50;
  width: 100vw;
  height: 100dvh;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0;
  background: var(--log-bg);
  border: 0;
  box-shadow: none;
  transform: none;
}

.log-viewer-results.is-fullscreen .toolbar {
  display: none;
}

.log-frame {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 260px;
  position: relative;
}

.log-fullscreen-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-width: 48px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
  color: #f7f7f5;
  background: rgba(0, 0, 0, 0.72);
  border: 0;
  opacity: 0.92;
}

.log-fullscreen-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.log-fullscreen-button .fullscreen-close-icon {
  display: none;
}

.log-fullscreen-button:hover,
.log-fullscreen-button:focus-visible {
  background: rgba(0, 0, 0, 0.84);
  opacity: 1;
}

.log-viewer-results.is-fullscreen .log-fullscreen-button {
  display: inline-flex;
  right: 16px;
  bottom: 24px;
  z-index: 52;
}

.log-viewer-results.is-fullscreen .log-frame {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: var(--log-bg);
}

.log-viewer-results.is-fullscreen .fullscreen-open-icon {
  display: none;
}

.log-viewer-results.is-fullscreen .fullscreen-close-icon {
  display: block;
}

.log-viewer-page .toolbar {
  gap: var(--space-2);
}

.log-viewer-page .toolbar-block {
  flex: 1 1 180px;
}

.log-viewer-results .toolbar {
  align-items: center;
  flex-wrap: nowrap;
}

.log-viewer-results .toolbar-block {
  flex: 1 1 auto;
  min-width: 0;
}

.log-viewer-results .toolbar-actions {
  flex: 0 0 auto;
  align-items: center;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.log-viewer-results .toolbar-actions button {
  width: auto;
  white-space: nowrap;
}

.site-header,
.hero,
.profile-tabs-panel,
.panel,
.tool-card {
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow);
}

.hero {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(140%);
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--app-header-height);
  padding-block: 7px;
  padding-inline: max(var(--page-gutter), calc((100vw - var(--content-width)) / 2 + var(--page-gutter)));
  border: 0;
  border-bottom: 1px solid var(--header-line);
  border-radius: 0;
  background: var(--header-bg);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 10px;
  min-width: 0;
  min-height: 40px;
  padding: 4px 10px 4px 6px;
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.brand:hover {
  background: color-mix(in srgb, var(--panel-strong) 46%, transparent 54%);
}

.brand-icon {
  width: 32px;
  height: 32px;
  display: block;
  flex: 0 0 auto;
  border-radius: 10px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.16));
}

.brand-mark {
  overflow: hidden;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow,
.section-kicker,
.meta-copy {
  color: var(--muted);
}

.section-kicker,
.eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 36px;
  padding: 0;
  border-radius: 0;
  border: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  background: transparent;
  box-shadow: none;
  transition: color 0.18s ease, opacity 0.18s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
  background: transparent;
  box-shadow: none;
}

.hero {
  margin-top: var(--header-safe-top);
  padding: 14px;
  border-radius: var(--radius-lg);
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-2);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.76rem, 3.4vw, 2.95rem);
  line-height: 0.98;
}

h2 {
  font-size: clamp(0.98rem, 1.2vw, 1.12rem);
}

h3 {
  font-size: 0.98rem;
}

.lead,
.hero-copy,
.body-copy {
  line-height: 1.62;
  color: var(--muted);
}

.hero-copy {
  max-width: 760px;
  font-size: 0.94rem;
}

.home-hub {
  display: grid;
  width: min(100%, 1040px);
  gap: var(--space-5);
  margin: 0 auto;
  padding-top: var(--header-safe-top);
}

.home-intro {
  display: flex;
  flex-direction: column;
  padding: var(--space-2) 0 var(--space-3);
}

.home-intro h1 {
  max-width: 780px;
  margin-bottom: var(--space-1);
}

.home-copy {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.62;
}

.home-tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.home-tool-grid .tool-card {
  min-height: 158px;
  color: inherit;
  text-decoration: none;
}

.home-tool-grid .tool-card:hover {
  box-shadow: none;
}

.hero-actions,
.button-row,
.toolbar-actions,
.inline-toggle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.button-row {
  align-items: center;
}

.controls-row {
  justify-content: space-between;
}

.controls-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-left: auto;
}

.button,
button {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--accent) 44%, var(--line));
  border-radius: 9px;
  cursor: pointer;
  min-height: 38px;
  padding: 7px 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.button:hover,
button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft-strong);
  transform: none;
}

.button-primary,
button,
button.primary {
  color: var(--accent-strong);
  background: var(--accent-soft);
  box-shadow: none;
}

.button-secondary,
button.secondary {
  color: var(--button-secondary-ink);
  background: var(--button-secondary-bg);
  border: 1px solid var(--button-secondary-border);
  box-shadow: none;
}

.button-secondary:hover,
button.secondary:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: none;
}

.button-danger,
button.danger {
  border-color: color-mix(in srgb, var(--danger) 48%, var(--line));
  color: var(--danger);
  background: var(--danger-soft);
  box-shadow: none;
}

button.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 22%, var(--panel-strong));
}

.button:focus-visible,
button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.section-grid,
.tool-grid,
.form-grid,
.stats-grid {
  display: grid;
  gap: var(--space-3);
}

.section-grid,
.tool-grid {
  margin-top: 0;
}

[data-app-shell] + .section-grid,
[data-app-shell] + .tool-grid {
  padding-top: var(--header-safe-top);
}

.profile-tabs-panel {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: 7px;
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(140%);
}

.modbus-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: var(--space-3);
  margin-top: 0;
  min-height: 0;
}

.modbus-profile-sidebar {
  align-self: start;
  display: grid;
  gap: var(--sidebar-gap);
  min-width: 0;
  max-height: 100%;
  overflow: auto;
}

.modbus-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.modbus-profile-header h2 {
  margin-bottom: 0;
}

.profile-add-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 1.08rem;
  line-height: 1;
}

.profile-tabs {
  display: flex;
  flex: 1 1 auto;
  gap: var(--sidebar-gap);
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.modbus-profile-sidebar .profile-tabs {
  flex: 0 1 auto;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 0;
}

.profile-tab {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
  min-width: 150px;
  max-width: 240px;
  padding: var(--sidebar-row-padding);
  border: 1px solid color-mix(in srgb, var(--line) 56%, transparent 44%);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  cursor: grab;
  position: relative;
  user-select: none;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.modbus-profile-sidebar .profile-tab {
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: var(--sidebar-row-height);
}

.modbus-profile-sidebar .profile-tab.drop-before::before,
.modbus-profile-sidebar .profile-tab.drop-after::after {
  right: 10px;
  left: 10px;
  width: auto;
  height: 2px;
  top: auto;
  bottom: auto;
}

.modbus-profile-sidebar .profile-tab.drop-before::before {
  top: -7px;
}

.modbus-profile-sidebar .profile-tab.drop-after::after {
  bottom: -7px;
}

.profile-tab:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.profile-tab:active {
  cursor: grabbing;
}

.profile-tab[aria-selected="true"] {
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line) 46%);
  background: var(--surface);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 10%, transparent 90%);
}

.profile-tab.is-dragging {
  opacity: 0.55;
}

.profile-tab.drop-before::before,
.profile-tab.drop-after::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 999px;
  background: var(--accent);
}

.profile-tab.drop-before::before {
  left: -5px;
}

.profile-tab.drop-after::after {
  right: -5px;
}

.profile-tab-name {
  width: auto;
  min-width: 0;
  height: 24px;
  min-height: 24px;
  flex: 1 1 auto;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 2px 4px;
  font-size: var(--sidebar-font-size);
  font-weight: 700;
}

.profile-tab-name:focus {
  outline: 0;
}

.profile-tab-name:not([readonly]):focus {
  background: var(--panel-strong);
}

.profile-tab-name[readonly] {
  cursor: pointer;
  color: var(--muted);
  pointer-events: none;
}

.profile-tab[aria-selected="true"] .profile-tab-name[readonly] {
  color: var(--ink);
}

.profile-tab-close {
  display: inline-grid;
  place-items: center;
  position: relative;
  aspect-ratio: 1;
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0;
  line-height: 1;
  box-shadow: none;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.profile-tab-close::before,
.profile-tab-close::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.profile-tab-close::before {
  transform: rotate(45deg);
}

.profile-tab-close::after {
  transform: rotate(-45deg);
}

.profile-tab-close:hover {
  transform: none;
  background: color-mix(in srgb, var(--ink) 10%, transparent 90%);
  color: var(--ink);
}

.profile-tab-close:disabled {
  visibility: hidden;
}

.section-grid + .panel,
.section-grid + .tool-card,
.section-grid + .section-grid {
  margin-top: var(--space-3);
}

.section-grid {
  align-items: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-grid > .panel {
  align-self: start;
}

@media (min-width: 901px) {
  .modbus-workspace {
    height: 100%;
    min-height: 0;
    margin-top: 0;
    overflow: visible;
  }

  .modbus-page .modbus-pane-scroll {
    height: 100%;
    min-height: 0;
    padding-top: var(--header-safe-top);
    padding-bottom: var(--space-3);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
  }

  .modbus-page .modbus-profile-sidebar {
    margin-top: var(--header-safe-top);
    margin-bottom: var(--space-3);
    max-height: calc(100% - var(--header-safe-top) - var(--space-3));
  }

  .modbus-page .modbus-scroll-area {
    min-height: 0;
    overflow: visible;
  }
}

.tool-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.site-shell > .section-grid:first-of-type .tool-card {
  min-height: 0;
}

.panel,
.tool-card {
  background: color-mix(in srgb, var(--glass-bg) 88%, transparent 12%);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.panel,
.tool-card {
  border-color: color-mix(in srgb, var(--glass-line) 78%, transparent 22%);
}

.panel {
  padding: var(--space-5);
}

.log-control-panel,
.modbus-profile-sidebar,
.plc-palette-panel {
  padding: var(--sidebar-padding);
}

.tool-card {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.tool-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: none;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.tool-card-main {
  display: block;
}

.tool-card-main h2 {
  margin-bottom: var(--space-1);
}

.tool-card-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

.tool-card-open {
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--pill-bg);
  color: var(--pill-ink);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent 30%);
}

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

.form-grid.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid + .button-row,
.form-grid + .compact-stack,
.form-grid + .output {
  margin-top: var(--space-4);
}

.section-grid > .full-span {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin-bottom: var(--field-label-gap);
  font-size: 0.78rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--ink) 86%, var(--muted) 14%);
}

.modbus-profile-sidebar .profile-tab,
.modbus-profile-sidebar .profile-tab-name,
.plc-palette-block {
  font-size: var(--sidebar-font-size);
}

.log-control-actions button {
  font-size: var(--sidebar-font-size);
}

.log-control-fields > div,
.form-grid > div:not(.full),
.plc-block-form > div,
.plc-event-action-row > div,
.plc-condition-action-row > div,
.plc-time-control {
  display: grid;
  gap: var(--field-label-gap);
  min-width: 0;
}

.log-control-fields > div > label,
.form-grid > div:not(.full) > label,
.plc-block-form > div > label,
.plc-event-action-row > div > label,
.plc-condition-action-row > div > label,
.plc-time-control > label {
  margin-bottom: 0;
}

.field-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.81rem;
  line-height: 1.4;
}

.field-note[hidden] {
  display: none;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent 18%);
  background: var(--panel-strong);
  color: var(--ink);
  min-height: 38px;
  padding: 7px 9px;
  font-size: var(--control-font-size);
  line-height: 1.35;
  box-shadow: none;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  -webkit-text-size-adjust: 100%;
}

.log-control-panel input,
.log-control-panel select {
  min-height: var(--sidebar-row-height);
  padding: var(--sidebar-row-padding);
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--panel-strong);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23a1adba' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 9px center;
  background-repeat: no-repeat;
  background-size: 16px 16px;
  height: 38px;
  padding-right: 32px;
  text-overflow: ellipsis;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  border-radius: var(--radius-sm) !important;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent 86%);
}

select:focus {
  background-color: var(--surface);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

button:disabled:hover {
  transform: none;
  box-shadow: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
}

.toolbar-block {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
}

.status {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: var(--radius-md);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.2;
  width: fit-content;
  max-width: 100%;
  border: 1px solid transparent;
}

.status.ok {
  background: var(--accent-soft);
  color: var(--status-ok-ink);
  border-color: color-mix(in srgb, var(--accent) 24%, transparent 76%);
}

.status.warn {
  background: var(--warn-soft);
  color: var(--status-warn-ink);
  border-color: color-mix(in srgb, var(--warn) 24%, transparent 76%);
}

.status.error {
  background: var(--danger-soft);
  color: var(--status-error-ink);
  border-color: color-mix(in srgb, var(--danger) 24%, transparent 76%);
}

.output {
  margin-top: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--output-bg) 82%, transparent 18%);
  border: 1px solid color-mix(in srgb, var(--output-border) 84%, transparent 16%);
  box-shadow: none;
}

.mono,
.hex-box,
.log-surface,
code,
pre {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
}

pre {
  margin: 0;
}

.hex-box {
  margin: var(--space-2) 0 0;
  font-size: 0.9rem;
  line-height: 1.65;
  word-break: break-word;
}

.meta-table,
.value-table {
  width: 100%;
  margin-top: var(--space-2);
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.meta-table + .status {
  margin-top: var(--space-3);
}

.meta-table td,
.value-table th,
.value-table td {
  padding: 8px;
  border-bottom: 1px solid var(--output-row);
  text-align: left;
  vertical-align: top;
}

.value-table thead th {
  background: color-mix(in srgb, var(--panel-strong) 82%, var(--surface) 18%);
}

.value-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--panel-strong) 52%, transparent 48%);
}

.meta-table td:first-child {
  width: 120px;
  color: var(--muted);
  font-weight: 700;
}

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

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

.value-table th {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.value-table th:nth-child(1),
.value-table td:nth-child(1) {
  width: 68px;
}

.value-table th:nth-child(2),
.value-table td:nth-child(2) {
  width: 78px;
}

.value-table th:nth-child(3),
.value-table td:nth-child(3) {
  width: 128px;
}

.value-table td:last-child {
  width: auto;
  min-width: 0;
}

.value-table[data-show-bits="false"] th:nth-child(4),
.value-table[data-show-bits="false"] td:nth-child(4) {
  display: none;
}

.hex-box {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--line) 74%, transparent 26%);
  box-shadow: none;
}

:root[data-theme="dark"] .hex-box {
  background: var(--panel);
}

.log-surface {
  min-height: 260px;
  height: clamp(260px, 38vh, 460px);
  max-height: 38vh;
  overflow: auto;
  margin-top: var(--space-3);
  padding: var(--space-4);
  font-size: 0.9rem;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent 18%);
  background: var(--log-bg);
  color: var(--log-ink);
  line-height: 1.55;
  box-shadow: none;
}

.log-frame .log-surface {
  margin-top: var(--space-3);
  width: 100%;
}

.log-viewer-results .log-surface {
  flex: 1 1 0;
  height: 0;
  max-height: none;
  min-height: 0;
  min-width: 0;
  overflow: auto;
}

.log-viewer-page .log-surface {
  margin-top: var(--space-2);
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.log-viewer-results.is-fullscreen .log-surface {
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  border-radius: 0 !important;
  border: 0 !important;
  outline: 0;
  margin-top: 0;
  box-shadow: none;
  padding: 8px 8px 25px;
  line-height: 1.2;
}

.log-viewer-results.is-fullscreen .stats-grid {
  display: none;
}

.log-surface .placeholder {
  color: var(--log-placeholder);
}

.log-surface .error-line {
  color: var(--log-error);
  background: var(--log-error-bg);
  font-weight: 700;
}

.log-surface .warning-line {
  color: var(--log-warn);
  background: var(--log-warn-bg);
  font-weight: 700;
}

.log-surface .match-line {
  color: var(--log-match);
}

.log-surface .fresh-line {
  background: var(--log-fresh-bg);
  color: var(--log-fresh-ink);
  animation: fresh-log-line-fade 2.4s ease-out forwards;
}

.log-surface .error-line.fresh-line {
  color: var(--log-error-fresh);
  background: var(--log-error-bg);
}

.log-surface .warning-line.fresh-line {
  color: var(--log-warn-fresh);
  background: var(--log-warn-bg);
}

@keyframes fresh-log-line-fade {
  0% {
    filter: saturate(1.05) brightness(1.04);
  }

  100% {
    filter: none;
  }
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-top: var(--space-2);
}

.log-viewer-page .stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  padding: 8px 9px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.stat-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-value {
  display: block;
  margin-top: 4px;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: 0.84rem;
}

.stat-delta {
  margin-left: 5px;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.9;
}

@media (min-width: 901px) and (max-width: 1350px) {
  .log-viewer-page .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.helper-list {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.helper-item {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel);
}

.helper-item p,
.helper-item h3 {
  margin: 0;
}

.helper-item p + p,
.helper-item h3 + p {
  margin-top: 6px;
}

.site-footer {
  margin-top: var(--space-5);
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  gap: 18px;
  min-width: 0;
}

.nav-toggle {
  display: none;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  line-height: 0;
  background: color-mix(in srgb, var(--surface) 18%, transparent 82%);
  border-color: transparent;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 13%, transparent 87%),
    0 10px 30px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: color-mix(in srgb, currentColor 84%, var(--muted) 16%);
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.theme-toggle .icon-sun {
  opacity: 0;
  transform: translateY(8px) scale(0.7);
}

.theme-toggle .icon-moon {
  opacity: 1;
  transform: translateY(0) scale(1);
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  opacity: 1;
  transform: translateY(0) scale(1);
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  opacity: 0;
  transform: translateY(-8px) scale(0.7);
}

.compact-stack {
  display: grid;
  gap: var(--space-3);
}

.section-heading {
  display: grid;
  gap: 4px;
  margin-bottom: var(--sidebar-gap);
}

.section-heading h2,
.toolbar-block h2 {
  margin-bottom: 0;
}

.log-control-panel .section-heading,
.modbus-profile-header,
.plc-palette-panel .section-heading {
  margin-bottom: var(--sidebar-heading-gap);
  padding-bottom: var(--sidebar-heading-rule-gap);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 62%, transparent 38%);
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.request-copy-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.request-copy-actions .inline-checkbox {
  min-height: 36px;
  padding: 0 2px;
  color: var(--muted);
  white-space: nowrap;
}

.request-copy-actions button {
  padding-inline: 14px;
  white-space: nowrap;
}

.modbus-page .output:has(.request-copy-actions) .output-header {
  flex-wrap: nowrap;
  gap: var(--space-2);
}

.modbus-page .output:has(.request-copy-actions) .pill-row {
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.modbus-page .request-copy-actions {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}

.modbus-page .request-copy-actions .inline-checkbox {
  flex: 0 1 auto;
  min-width: 28px;
  overflow: hidden;
}

.modbus-page .request-copy-actions .inline-checkbox input,
.modbus-page .request-copy-actions button {
  flex: 0 0 auto;
}

.modbus-page .request-copy-actions .inline-checkbox span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.inline-checkbox input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.write-composer {
  display: grid;
  container-type: inline-size;
  gap: 0;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent 18%);
  border-radius: var(--radius-md);
  background: transparent;
  overflow: hidden;
}

.write-composer[hidden] {
  display: none;
}

.write-composer.full {
  grid-column: 1 / -1;
}

.write-composer-summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 42px;
  padding: 8px 14px;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
  list-style: none;
}

.write-composer-summary::-webkit-details-marker {
  display: none;
}

.write-composer-summary::after {
  content: none;
}

.write-composer-chevron {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  margin-left: var(--space-2);
  width: 22px;
  height: 22px;
  color: var(--muted);
  line-height: 1;
  transform: rotate(0);
  transform-origin: center;
  transition: transform 160ms ease;
}

.write-composer-chevron svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.write-composer[open] .write-composer-summary {
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent 28%);
}

.write-composer[open] .write-composer-chevron {
  transform: rotate(180deg);
}

.write-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
}

.write-composer-summary > span:first-child {
  min-width: 0;
}

.write-signed-toggle {
  min-height: 34px;
  padding: 0 2px;
  color: var(--muted);
}

.write-composer-actions button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.86rem;
  white-space: nowrap;
}

.write-composer:not([open]) .write-composer-actions button {
  display: none;
}

.write-composer-column-head {
  display: grid;
  grid-template-columns: 24px minmax(62px, 0.64fr) minmax(84px, 0.76fr) minmax(132px, 1.45fr) 46px 34px;
  gap: 6px;
  padding: 6px 10px 5px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel-strong) 44%, transparent 56%);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent 28%);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.write-composer.single-write .write-composer-column-head,
.write-composer.single-write .write-composer-row {
  grid-template-columns: 24px minmax(62px, 0.64fr) minmax(84px, 0.76fr) minmax(132px, 1.45fr) 46px;
}

.write-composer-rows {
  display: grid;
  gap: 0;
}

.write-composer-row {
  display: grid;
  grid-template-columns: 24px minmax(62px, 0.64fr) minmax(84px, 0.76fr) minmax(132px, 1.45fr) 46px 34px;
  gap: 6px;
  align-items: start;
  padding: 7px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent 28%);
  background: color-mix(in srgb, var(--panel-strong) 52%, transparent 48%);
}

.write-composer-row:last-child {
  border-bottom: 0;
}

.write-composer-index {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 0;
  color: color-mix(in srgb, var(--muted) 82%, transparent 18%);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  user-select: none;
}

button.write-composer-index {
  cursor: grab;
  transition:
    color 160ms ease,
    background 160ms ease;
}

button.write-composer-index:hover,
button.write-composer-index:focus-visible {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent 90%);
  outline: none;
}

button.write-composer-index:active {
  cursor: grabbing;
}

.write-composer-rows.is-dragging .write-composer-row {
  transition: transform 120ms ease, opacity 120ms ease;
}

.write-composer-row.dragging {
  opacity: 0.48;
  background: color-mix(in srgb, var(--accent) 10%, var(--panel-strong) 90%);
}

.write-composer-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.write-composer-row label span {
  display: none;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.write-composer-row input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 6px 7px;
  font-size: 0.78rem;
}

.write-composer-row input.mono {
  font-size: 0.76rem;
}

.write-composer-remove {
  position: relative;
  display: inline-grid;
  grid-column: 6;
  grid-row: 1;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  align-self: start;
  color: var(--danger);
  background: var(--button-secondary-bg);
  border: 1px solid var(--button-secondary-border);
  border-radius: var(--radius-sm);
  font-size: 0;
}

.write-composer-remove::before,
.write-composer-remove::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.write-composer-remove::before {
  transform: rotate(45deg);
}

.write-composer-remove::after {
  transform: rotate(-45deg);
}

.write-composer-remove:hover,
.write-composer-remove:focus-visible {
  color: var(--danger);
  background: var(--remove-hover-bg);
  border-color: var(--remove-hover-border);
}

.write-composer-remove:disabled {
  color: var(--muted);
  opacity: 0.45;
}

.write-composer-remove:disabled:hover {
  color: var(--muted);
  background: var(--button-secondary-bg);
  border-color: var(--button-secondary-border);
}

.write-byte-settings {
  grid-column: 5;
  grid-row: 1;
  align-self: start;
  justify-self: stretch;
  min-width: 0;
  margin-top: 0;
}

.write-byte-settings summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 34px;
  padding: 5px 5px;
  border: 1px solid var(--button-secondary-border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--button-secondary-bg);
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1;
  list-style: none;
}

.write-byte-settings summary::marker {
  content: "";
}

.write-byte-settings summary::-webkit-details-marker {
  display: none;
}

.write-byte-settings summary::after {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-1px) rotate(45deg);
  transition: transform 160ms ease;
}

.write-byte-settings[open] summary {
  width: 100%;
  min-width: 0;
  margin-bottom: 0;
  border-color: color-mix(in srgb, var(--accent) 64%, var(--line) 36%);
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent-soft) 76%, transparent 24%);
}

.write-byte-settings[open] {
  grid-column: 5;
  grid-row: 1;
  margin-top: 0;
}

.write-byte-settings[open] summary::after {
  transform: translateY(2px) rotate(225deg);
}

.write-byte-panel {
  display: none;
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  margin-top: 0;
}

.write-byte-settings[open] + .write-byte-panel {
  display: block;
}

.write-byte-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 10px;
}

.write-operation-group {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent 22%);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--panel-strong) 42%, transparent 58%);
}

.write-byte-actions button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.78rem;
}

.write-operation-symbols button {
  min-width: 38px;
  font-size: 1rem;
}

.write-bit-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(34px, 1fr));
  width: min(100%, 920px);
  margin-inline: auto;
  gap: 7px;
}

.write-bit-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 4px;
  color: var(--text);
  background: var(--button-secondary-bg);
  border: 1px solid var(--button-secondary-border);
  border-radius: 999px;
  line-height: 1;
}

.write-bit-button span {
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 800;
}

.write-bit-button strong {
  font-size: 1.05rem;
  line-height: 1;
}

.write-bit-button.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 84%, transparent 16%);
}

.modbus-page #writeValues {
  min-height: 64px;
}

.modbus-page #writeValueSingle {
  height: 38px;
  min-height: 38px;
}

.modbus-page #writeValuesField {
  display: contents;
}

.modbus-page #writeValuesField[hidden] {
  display: none;
}

.write-raw-value-field {
  display: grid;
  gap: 0;
}

.write-raw-value-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: 4px;
  min-height: 17px;
}

.write-raw-value-header label {
  margin: 0;
}

.write-raw-value-header > label:first-child {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.2;
}

.write-raw-value-header .write-signed-toggle {
  flex: 0 0 auto;
  min-height: 0;
  padding: 0;
  font-size: 0.78rem;
  line-height: 1.2;
}

.write-raw-value-header .write-signed-toggle input {
  width: 16px;
  height: 16px;
}

.write-raw-value-field.full {
  grid-column: 1 / -1;
}

.write-raw-value-field .field-note {
  margin-top: 6px;
}

.bit-array {
  display: grid;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.bit-array-empty {
  color: var(--muted);
}

.bit-array-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(22px, 1fr));
  gap: 4px;
  min-width: min(100%, 208px);
}

.bit-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 3px 4px;
  width: 100%;
  min-width: 0;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  line-height: 1;
}

.bit-chip.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 88%, transparent 12%);
  box-shadow: none;
}

.bit-chip-index {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.bit-chip-value {
  min-width: 1ch;
  font-weight: 700;
  white-space: nowrap;
}

.plc-builder-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: var(--space-3);
  margin-top: 0;
  align-items: start;
}

.plc-builder-workspace {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
}

.plc-palette-panel,
.plc-workspace-panel,
.plc-code-panel {
  min-width: 0;
}

.plc-pane-scroll {
  min-width: 0;
}

.plc-block-palette {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sidebar-gap);
}

.cnc-device-panel {
  display: grid;
  gap: var(--sidebar-gap);
  min-height: 0;
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}

.cnc-server-field {
  display: grid;
  gap: var(--field-label-gap);
  min-width: 0;
}

.cnc-device-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.cnc-device-heading h3 {
  margin: 0;
  font-size: 0.95rem;
}

.cnc-server-field > label,
.cnc-device-browser > label {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.cnc-device-panel select,
.cnc-device-panel input,
.cnc-device-panel button {
  width: 100%;
  min-height: var(--sidebar-row-height);
}

.cnc-device-panel #deviceServer,
.cnc-device-panel #deviceServer:focus {
  color: var(--ink);
  background-color: var(--panel-strong);
}

.cnc-server-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sidebar-gap);
}

.cnc-server-row #refreshDevicesBtn {
  display: inline-grid;
  place-items: center;
  width: var(--sidebar-row-height);
  min-width: var(--sidebar-row-height);
  padding: 0;
}

.cnc-server-row #refreshDevicesBtn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cnc-device-browser {
  display: grid;
  gap: var(--field-label-gap);
  min-height: 0;
}

.cnc-device-list {
  max-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
}

.cnc-device-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  box-sizing: border-box;
  min-height: 52px;
  margin: 0;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}

.cnc-device-identity {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  gap: 2px;
}

.cnc-device-name {
  overflow: hidden;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cnc-device-identity small {
  color: var(--muted);
  font-size: .68rem;
  line-height: 1.2;
}

.cnc-device-row:last-child {
  border-bottom-color: transparent;
}

.cnc-device-row:hover {
  background: var(--accent-soft);
}

.cnc-device-row input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.cnc-device-empty {
  padding: var(--space-3);
  color: var(--muted);
  font-size: 0.8rem;
}

.cnc-device-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sidebar-gap);
}

.cnc-device-actions .cnc-history-button { grid-column: 1 / -1; }

.cnc-history-dialog {
  width: min(1120px, calc(100% - 32px));
  height: min(760px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}
.cnc-history-dialog:focus { outline: none; }
.cnc-history-dialog::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); }
.cnc-history-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.cnc-history-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 48px 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}
.cnc-history-header h2 { margin: 2px 0; font-size: 1.25rem; }
.cnc-history-header p { margin: 0; color: var(--muted); font-size: .82rem; }
.cnc-history-eyebrow { color: var(--accent); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.cnc-history-close {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1;
}
.cnc-history-close:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent 93%); }
.cnc-history-close:focus { outline: none; box-shadow: none; }
.cnc-history-close:focus-visible { background: color-mix(in srgb, var(--ink) 7%, transparent 93%); }
.cnc-history-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 0; }
.cnc-history-timeline { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; border-right: 1px solid var(--line); }
.cnc-history-timeline-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.cnc-history-timeline-heading button { min-height: 34px; padding: 5px 10px; }
.cnc-history-timeline-toggle { display: flex; align-items: center; gap: 7px; padding-left: 0 !important; border: 0; color: var(--ink); background: transparent; box-shadow: none; cursor: default; pointer-events: none; }
.cnc-history-timeline-toggle > span { display: none; }
.cnc-history-list { min-height: 0; overflow-y: auto; }
.cnc-history-entry {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 78px;
  padding: 12px 12px 12px 52px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  text-align: left;
  background: transparent;
}
.cnc-history-entry:hover { border-color: transparent; }
.cnc-history-entry:hover, .cnc-history-entry.active { color: var(--ink); background: var(--accent-soft); }
.cnc-history-entry strong { font-size: .82rem; }
.cnc-history-entry > span:last-child { color: var(--muted); font-size: .72rem; }
.cnc-history-version { position: absolute; top: 14px; left: 12px; color: var(--accent); font-family: "IBM Plex Mono", monospace; font-size: .75rem; font-weight: 700; }
.cnc-history-empty { padding: 20px 14px; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.cnc-history-inspector { display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.cnc-history-compare-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: end; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.cnc-history-compare-controls label { display: grid; gap: 4px; margin: 0; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.cnc-history-compare-controls select { width: 100%; min-width: 0; }
.cnc-history-compare-controls > span { display: grid; place-items: center; align-self: end; height: 38px; line-height: 1; }
.cnc-history-compare-actions { display: grid; align-items: center; }
.cnc-history-compare-actions button { min-height: 38px; padding-inline: 12px; white-space: nowrap; }
.cnc-history-summary { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.cnc-diff-add-count { color: #16794b; font-weight: 700; }
.cnc-diff-remove-count { color: #b42318; font-weight: 700; }
.cnc-history-diff { min-width: 0; min-height: 0; padding: 8px 0 16px; overflow: auto; color: var(--log-ink); background: var(--log-bg); }
.cnc-diff-content { display: grid; width: max-content; min-width: 100%; }
.cnc-diff-line { display: grid; grid-template-columns: 44px 24px minmax(max-content, 1fr); min-height: 21px; font-family: "IBM Plex Mono", monospace; font-size: .76rem; line-height: 1.4; }
.cnc-diff-line > span { padding: 1px 6px; color: var(--muted); text-align: right; user-select: none; }
.cnc-diff-line .cnc-diff-line-number { border-right: 1px solid color-mix(in srgb, var(--line) 70%, transparent 30%); }
.cnc-diff-line .cnc-diff-marker { padding-inline: 5px; text-align: center; }
.cnc-diff-line code { padding: 1px 10px; color: inherit; white-space: pre; }
.cnc-diff-line.same { color: var(--log-ink); background: transparent; }
.cnc-diff-line.add { color: var(--log-ink); background: color-mix(in srgb, #22c55e 18%, var(--log-bg)); }
.cnc-diff-line.remove { color: var(--log-ink); background: color-mix(in srgb, #ef4444 18%, var(--log-bg)); }
.cnc-diff-line.add .cnc-diff-marker { color: #22c55e; }
.cnc-diff-line.remove .cnc-diff-marker { color: #ef4444; }
.cnc-history-diff .plc-token-number { color: #2563eb; }
:root[data-theme="dark"] .cnc-history-diff .plc-token-number { color: #93c5fd; }

/* Keep the light history viewer quiet and content-first. Dark mode retains
   its existing layered surfaces for contrast. */
:root:not([data-theme="dark"]) .cnc-history-dialog {
  background: rgba(250, 253, 254, .97);
  box-shadow: 0 24px 70px rgba(43, 61, 73, .18);
}
:root:not([data-theme="dark"]) .cnc-history-header,
:root:not([data-theme="dark"]) .cnc-history-timeline-heading,
:root:not([data-theme="dark"]) .cnc-history-compare-controls,
:root:not([data-theme="dark"]) .cnc-history-summary {
  background: transparent;
}
:root:not([data-theme="dark"]) .cnc-history-timeline {
  background: rgba(248, 252, 253, .58);
}
:root:not([data-theme="dark"]) .cnc-history-inspector,
:root:not([data-theme="dark"]) .cnc-history-diff {
  background: rgba(255, 255, 255, .72);
}
:root:not([data-theme="dark"]) .cnc-history-entry:hover {
  background: rgba(234, 247, 244, .62);
}
:root:not([data-theme="dark"]) .cnc-history-entry.active {
  background: var(--accent-soft);
}
:root:not([data-theme="dark"]) .cnc-history-dialog select,
:root:not([data-theme="dark"]) .cnc-history-dialog button:not(.cnc-history-entry):not(.cnc-history-timeline-toggle):not(.cnc-history-close) {
  background: rgba(255, 255, 255, .78);
  box-shadow: none;
}

@media (max-width: 1100px) {
  .cnc-history-compare-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .cnc-history-compare-controls > span { display: none; }
  .cnc-history-compare-actions { grid-column: 1 / -1; }
  .cnc-history-compare-actions button { width: 100%; }
}

@media (max-width: 900px) {
  .cnc-history-dialog {
    width: calc(100% - 12px);
    height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
    max-width: calc(100% - 12px);
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
    margin: calc(env(safe-area-inset-top) + 8px) auto calc(env(safe-area-inset-bottom) + 8px);
    border-radius: 14px;
  }
  .cnc-history-header { padding: 10px 42px 10px 12px; }
  .cnc-history-header h2 { margin-top: 0; font-size: 1.08rem; }
  .cnc-history-eyebrow { display: none; }
  .cnc-history-header p { max-width: calc(100vw - 80px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cnc-history-close { top: 7px; right: 7px; }
  .cnc-history-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .cnc-history-timeline { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .cnc-history-timeline-heading { position: relative; min-height: 52px; padding: 0; }
  .cnc-history-timeline-toggle,
  .cnc-history-timeline-toggle:hover,
  .cnc-history-timeline-toggle:active,
  .cnc-history-timeline-toggle:focus {
    width: 100%;
    height: 52px;
    min-height: 52px;
    box-sizing: border-box;
    padding: 8px 12px !important;
    border: 0;
    color: var(--ink);
    background: transparent;
    box-shadow: none;
    transform: none;
    transition: color .16s ease, background-color .16s ease;
    cursor: pointer;
    pointer-events: auto;
  }
  .cnc-history-timeline-toggle > strong { font-size: .94rem; line-height: 1.2; white-space: nowrap; }
  .cnc-history-timeline-toggle > span { display: inline-grid; place-items: center; flex: 0 0 22px; width: 22px; height: 22px; margin-left: auto; color: var(--muted); font-size: 1rem; line-height: 1; transform: rotate(180deg); transform-origin: center; transition: transform .16s ease; }
  .cnc-history-timeline-toggle svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .cnc-history-dialog.timeline-collapsed .cnc-history-timeline-toggle > span { transform: rotate(0); }
  .cnc-history-timeline-heading #refreshHistoryBtn { position: absolute; z-index: 1; top: 9px; right: 46px; min-height: 34px; padding: 6px 10px; font-size: .86rem; }
  .cnc-history-dialog.timeline-collapsed #refreshHistoryBtn { display: none; }
  .cnc-history-list { display: block; min-height: 0; padding: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
  .cnc-history-entry { width: 100%; min-height: 66px; padding: 9px 10px 9px 44px; border-right: 0; border-bottom: 1px solid var(--line); }
  .cnc-history-entry strong { overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
  .cnc-history-entry > span:last-child { font-size: .68rem; }
  .cnc-history-version { top: 11px; left: 10px; }
  .cnc-history-dialog.timeline-collapsed .cnc-history-list { display: none; }
  .cnc-history-dialog:not(.timeline-collapsed) .cnc-history-body { grid-template-rows: minmax(0, 1fr); }
  .cnc-history-dialog:not(.timeline-collapsed) .cnc-history-inspector { display: none; }
  .cnc-history-inspector { min-height: 0; }
  .cnc-history-compare-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .cnc-history-compare-controls > span { display: none; }
  .cnc-history-compare-controls { gap: 8px; padding: 9px 10px; }
  .cnc-history-compare-controls label { font-size: .64rem; }
  .cnc-history-compare-controls select { height: 40px; min-height: 40px; padding-block: 5px; font-size: .76rem; }
  .cnc-history-compare-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr; }
  .cnc-history-compare-actions button { width: 100%; min-width: 0; min-height: 42px; padding-inline: 6px; font-size: .74rem; white-space: normal; }
  .cnc-history-summary { min-height: 38px; padding: 6px 10px; overflow-x: auto; white-space: nowrap; }
  .cnc-history-diff { padding-top: 5px; }
  .cnc-diff-line { grid-template-columns: 34px 18px minmax(max-content, 1fr); min-height: 20px; font-size: .68rem; }
  .cnc-diff-line > span { padding-inline: 4px; }
  .cnc-diff-line code { padding-inline: 8px; }
}

.cnc-device-panel > .status {
  display: block;
  width: 100%;
  white-space: normal;
  line-height: 1.4;
}

/* G10 Modbus Tool */
.g10-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: var(--space-2); padding-top: var(--header-safe-top); padding-bottom: var(--space-3); }
.g10-sidebar { position: sticky; top: var(--header-safe-top); align-self: start; display: grid; gap: var(--sidebar-gap); max-height: calc(100dvh - var(--header-safe-top) - var(--space-3)); padding: 12px; overflow: auto; }
.g10-sidebar .section-heading { margin-bottom: 0; }
.g10-sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.g10-inline { display: grid; grid-template-columns: minmax(0, 1fr) 42px; gap: var(--sidebar-gap); }
.g10-refresh-button { display: inline-grid; place-items: center; width: 42px; min-width: 42px; padding: 0; }
.g10-refresh-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.g10-device-list { max-height: 300px; }
.g10-workspace { display: grid; align-content: start; grid-auto-rows: max-content; min-width: 0; gap: var(--space-2); }
.g10-workspace > .panel { align-self: start; width: 100%; min-width: 0; height: fit-content; padding: 12px; }
.g10-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); margin-bottom: 10px; }
.g10-heading-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-2); }
.g10-heading-actions select { width: auto; min-width: 84px; }
.g10-collapsible-panel > summary { display: flex; align-items: center; width: 100%; min-height: 54px; padding: 8px 2px; gap: var(--space-2); list-style: none; cursor: pointer; }
.g10-collapsible-panel > summary { -webkit-user-select: none; user-select: none; }
.g10-collapsible-panel > summary::-webkit-details-marker { display: none; }
.g10-collapsible-panel > summary::before { order: 2; flex: 0 0 12px; width: 12px; height: 12px; margin: 0 6px 0 auto; content: ""; background: var(--muted); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 8 6 4 10 8' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; transform: rotate(180deg); transition: transform 160ms ease; }
.g10-collapsible-panel[open] > summary::before { transform: rotate(0deg); }
.g10-collapsible-panel > summary strong { margin: 0; color: var(--ink); font-family: "IBM Plex Sans", "Segoe UI", sans-serif; font-size: clamp(0.98rem, 1.2vw, 1.12rem); font-weight: 700; line-height: 1.25; }
.g10-collapsible-panel:not([open]) { display: flex; align-items: center; min-height: 52px; }
.g10-collapsible-panel:not([open]) > summary { width: 100%; }
.g10-collapsible-content { height: fit-content; margin-top: 10px; }
.g10-registers-heading { position: relative; display: flex; align-items: center; min-height: 54px; gap: var(--space-2); }
.g10-panel-header-actions .inline-checkbox { margin: 0; align-items: center; }
.g10-panel-header-actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; pointer-events: auto; }
.g10-collapsible-panel:not([open]) .g10-panel-header-actions { display: none; }
.g10-register-summary-actions { cursor: default; }
.g10-register-summary-actions .inline-checkbox { gap: 7px; color: var(--ink); font-family: "IBM Plex Sans", "Segoe UI", sans-serif; font-size: .82rem; font-weight: 700; line-height: 1; }
.g10-register-summary-actions #pollInterval, .g10-register-summary-actions #addRegister { height: 38px; min-height: 38px; }
.g10-delete-preset { color: var(--danger); }
.g10-delete-preset:hover:not(:disabled) { border-color: color-mix(in srgb, var(--danger) 42%, var(--line)); color: var(--danger); background: var(--danger-soft); }
.g10-toolbar { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.g10-toolbar-button { display: inline-grid; grid-auto-flow: column; grid-template-columns: 18px max-content; align-items: center; justify-content: center; width: auto; min-width: 0; min-height: 38px; padding: 7px 14px; column-gap: 8px; border: 1px solid transparent; border-radius: 9px; box-shadow: none; font-family: "IBM Plex Sans", "Segoe UI", sans-serif; font-size: .78rem; font-weight: 700; line-height: 1; }
.g10-toolbar-button svg { display: block; width: 18px; height: 18px; margin: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.g10-toolbar-button span { display: block; margin: 0; }
.g10-toolbar-button:hover:not(:disabled) { transform: none; box-shadow: none; }
.g10-toolbar-button.is-new, .g10-toolbar-button.is-duplicate, .g10-toolbar-button.is-bulk { border-color: var(--line); color: var(--muted); background: var(--panel-strong); }
.g10-toolbar-button.is-new:hover:not(:disabled), .g10-toolbar-button.is-duplicate:hover:not(:disabled), .g10-toolbar-button.is-bulk:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }
.g10-toolbar-button.is-delete { border-color: color-mix(in srgb, var(--danger) 44%, var(--line)); color: #ff9d9d; background: color-mix(in srgb, var(--danger) 14%, var(--panel-strong)); }
.g10-toolbar-button.is-delete:hover:not(:disabled) { border-color: var(--danger); color: #ffd6d6; background: color-mix(in srgb, var(--danger) 25%, var(--panel-strong)); }
.g10-toolbar-button.is-save, .g10-toolbar-button.is-send { border-color: color-mix(in srgb, #4fd1a5 48%, var(--line)); color: #7ee7c4; background: color-mix(in srgb, #31b88c 16%, var(--panel-strong)); }
.g10-toolbar-button.is-save:hover:not(:disabled), .g10-toolbar-button.is-send:hover:not(:disabled) { border-color: #4fd1a5; color: #c9f8e8; background: color-mix(in srgb, #31b88c 28%, var(--panel-strong)); }
.g10-raw-command .g10-toolbar-button.is-send { height: 38px; min-height: 38px; }
.g10-config-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g10-config-grid > .form-field:first-child { grid-column: span 2; }
.g10-preset-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.g10-timeout-field { width: 100%; max-width: none; }
.g10-timeout-field .input-with-unit { display: block; }
.g10-config-grid :is(input, select, .input-with-unit),
.g10-config-grid .input-with-unit > input { width: 100%; min-width: 0; height: 38px; min-height: 38px; }
.g10-raw-command { display: grid; grid-template-columns: 170px 230px minmax(0, 1fr) auto; align-items: end; gap: var(--space-2); }
.g10-raw-command button { min-width: 76px; }
.g10-raw-command #rawUartSettings { height: 38px; min-height: 38px !important; padding: 4px 9px; }
.g10-raw-command #rawUartSettings strong { font-size: .78rem; }
.g10-raw-command #rawUartSettings small { font-size: .54rem; }
.g10-page .form-field > label { min-height: 0; }
.g10-page input[type="checkbox"], .g10-page input[type="radio"] { accent-color: var(--accent); }
.plc-builder-page input[type="checkbox"], .plc-builder-page input[type="radio"] { accent-color: var(--accent); }
.hint { position: relative; display: inline-grid; place-items: center; width: 16px; min-width: 16px; height: 16px; min-height: 16px; margin: 0; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--muted); background: transparent; box-shadow: none; font-size: .66rem; line-height: 1; cursor: help; vertical-align: 1px; }
.hint:hover, .hint:focus-visible { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); outline: none; }
.hint::after { position: absolute; left: 50%; top: calc(100% + 8px); z-index: 30; width: max-content; max-width: 260px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: var(--panel-strong); box-shadow: var(--shadow); content: attr(data-hint); font-size: .72rem; font-weight: 500; line-height: 1.35; text-align: left; white-space: normal; opacity: 0; visibility: hidden; pointer-events: none; transform: translate(-50%, -4px); transition: opacity .14s ease, transform .14s ease, visibility .14s ease; }
.hint:hover::after, .hint:focus::after, .hint:focus-visible::after { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.input-with-unit { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); }
.input-with-unit span { color: var(--muted); font-size: .8rem; }
.g10-table-wrap { max-width: 100%; height: fit-content; overflow-x: auto; overscroll-behavior-inline: contain; border: 0; border-radius: 0; scrollbar-gutter: stable; -webkit-overflow-scrolling: touch; }
.g10-table-wrap + .status { margin-top: var(--space-2); }
#modbusStatus { border-radius: 999px; }
#modbusStatus:not(.ok):not(.warn):not(.error) {
  border-color: var(--line);
  color: var(--muted);
  background: var(--panel-strong);
}
#rawStatus:empty { display: none; }
.g10-register-table { width: 100%; min-width: 1040px; height: auto; table-layout: fixed; border: 0; border-radius: 0; background: transparent; }
.g10-register-table th:nth-child(1), .g10-register-table td:nth-child(1) { width: 3.5%; padding-left: 2px; padding-right: 2px; text-align: center; }
.g10-register-table th:nth-child(2), .g10-register-table td:nth-child(2) { width: 15%; }
.g10-register-table th:nth-child(3), .g10-register-table td:nth-child(3) { width: 11%; }
.g10-register-table th:nth-child(4), .g10-register-table td:nth-child(4) { width: 8.25%; }
.g10-register-table th:nth-child(5), .g10-register-table td:nth-child(5) { width: 8.25%; }
.g10-register-table th:nth-child(6), .g10-register-table td:nth-child(6) { width: 12%; }
.g10-register-table th:nth-child(7), .g10-register-table td:nth-child(7),
.g10-register-table th:nth-child(8), .g10-register-table td:nth-child(8) { width: 14%; }
.g10-register-table th:nth-child(9), .g10-register-table td:nth-child(9) { width: 14%; padding-left: 4px; padding-right: 4px; text-align: left; }
.g10-register-table th { height: 38px; padding: 5px 7px; border: 0; border-bottom: 1px solid var(--line); background: transparent; font-size: .68rem; vertical-align: middle; }
.g10-register-table td { padding: 6px; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 52%, transparent); vertical-align: top; }
.g10-register-table td:first-child { padding-top: 6px; vertical-align: top; }
.g10-poll-cell { display: flex; align-items: center; justify-content: center; width: 100%; height: 32px; margin: 0; }
.g10-poll-all-label { display: inline-flex; align-items: center; justify-content: center; gap: 5px; max-width: 100%; height: 24px; min-height: 24px; margin: 0; color: inherit; font-size: inherit; line-height: 1; vertical-align: middle; white-space: nowrap; cursor: pointer; }
.g10-poll-all-label input { display: block; flex: 0 0 18px; width: 18px !important; min-width: 18px; height: 18px !important; min-height: 18px !important; margin: 0; padding: 0; }
.g10-register-table .g10-poll { display: block; flex: 0 0 18px; width: 18px !important; min-width: 18px; height: 18px; min-height: 0 !important; margin: 0; padding: 0; transform: none; }
.g10-register-table tbody tr:last-child td { border-bottom: 0; }
.g10-register-table input, .g10-register-table select, .g10-register-table button { height: 32px; min-height: 32px; font-size: .78rem; }
.g10-register-table input[type="checkbox"] { width: auto; }
.g10-register-table input, .g10-register-table select { width: 100%; min-width: 0; }
.g10-register-table input:not([type="checkbox"]), .g10-register-table textarea.g10-name, .g10-register-table .g10-config-trigger, .g10-register-table .g10-action-button { border-color: transparent; background: transparent; box-shadow: none; }
.g10-register-table input:not([type="checkbox"]):hover, .g10-register-table textarea.g10-name:hover, .g10-register-table .g10-config-trigger:hover, .g10-register-table .g10-action-button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--line) 70%, transparent); background: color-mix(in srgb, var(--surface) 72%, transparent); }
.g10-register-table input:not([type="checkbox"]):focus, .g10-register-table textarea.g10-name:focus, .g10-register-table .g10-config-trigger:focus-visible, .g10-register-table .g10-action-button:focus-visible { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent); }
.g10-register-table textarea.g10-name { display: block; width: 100%; min-width: 0; min-height: 32px; padding: 5px 7px; overflow: hidden; resize: none; font-size: .78rem; line-height: 1.3; overflow-wrap: anywhere; }
.g10-flags-menu { margin-top: 4px; color: var(--muted); font-size: .7rem; }
.g10-flags-menu summary { width: max-content; cursor: pointer; font-weight: 600; }
.g10-flags-menu > div { display: grid; grid-template-columns: max-content; gap: 0; width: max-content; margin-top: 3px; padding: 0; border: 0; background: transparent; }
.g10-flags-menu label { display: flex; align-items: center; gap: 5px; min-height: 20px; margin: 0; padding: 1px; border-radius: 4px; color: var(--muted); font-size: .61rem; line-height: 1; white-space: nowrap; }
.g10-flags-menu input[type="checkbox"] { width: 14px !important; min-width: 14px; height: 14px; min-height: 0 !important; margin: 0; }
.g10-flags-menu label:hover { background: var(--surface); }
.g10-config-trigger { display: grid; align-content: center; justify-items: start; width: 100%; min-width: 0; height: 32px; min-height: 32px !important; padding: 3px 6px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); background: var(--panel-strong); box-shadow: none; font-size: .62rem; text-align: left; white-space: nowrap; }
.g10-config-trigger strong, .g10-config-trigger small { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g10-config-trigger strong { font-weight: 500; }
.g10-config-trigger small { color: var(--muted); font-size: .54rem; }
.g10-config-trigger:hover { transform: none; border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--surface); }
.g10-settings-dialog { width: min(580px, calc(100% - 32px)); }
.g10-dialog-grid { grid-template-columns: 1fr; }
.g10-format-options { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.g10-format-options legend { padding: 0 5px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.g10-format-options > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.g10-bulk-dialog { width: min(680px, calc(100% - 32px)); }
.g10-bulk-dialog:focus { outline: none; }
.g10-bulk-dialog > .confirmation-form {
  max-height: calc(100dvh - 32px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
.g10-bulk-registers { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.g10-bulk-registers legend { padding: 0 5px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.g10-bulk-select-all { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.g10-bulk-registers > div { display: grid; grid-template-columns: minmax(0, 1fr); max-height: 240px; margin-top: 8px; gap: 5px; overflow-y: auto; }
.g10-bulk-registers > div .inline-checkbox { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; min-width: 0; padding: 6px; border-radius: 6px; }
.g10-bulk-registers > div .inline-checkbox:hover { background: var(--surface); }
.g10-bulk-registers > div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g10-bulk-registers > div small { color: var(--muted); font-size: .65rem; white-space: nowrap; }
.g10-bulk-register-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; min-width: 0; gap: 8px; }
.g10-bulk-reorder { display: inline-flex; gap: 4px; }
.g10-bulk-reorder button { display: grid; place-items: center; width: 30px; min-width: 30px; height: 30px; min-height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: var(--panel-strong); box-shadow: none; font-size: .9rem; }
.g10-bulk-reorder button:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); background: var(--surface); transform: none; }
.g10-bulk-reorder button:disabled { opacity: .3; cursor: not-allowed; }
.g10-bulk-settings { display: grid; grid-template-columns: max-content max-content; align-items: center; justify-content: start; gap: 10px 14px; }
.g10-bulk-settings > .inline-checkbox > span { color: color-mix(in srgb, var(--ink) 86%, var(--muted) 14%); font-family: "IBM Plex Sans", "Segoe UI", sans-serif; font-size: .78rem; font-weight: 600; line-height: normal; }
.g10-bulk-settings .g10-config-trigger, .g10-bulk-settings > input { width: 140px; height: 42px; min-height: 42px !important; }
.g10-bulk-settings .g10-config-trigger strong { font-size: .7rem; }
.g10-bulk-settings .g10-config-trigger small { font-size: .62rem; }
.g10-bulk-settings .g10-config-trigger:disabled, .g10-bulk-settings > input:disabled { opacity: .5; cursor: not-allowed; }
.g10-value { display: grid; align-content: center; min-width: 0; min-height: 32px; gap: 1px; }
.g10-value strong { font-family: "IBM Plex Mono", monospace; font-size: .9rem; }
.g10-value small { color: var(--muted); font-size: .68rem; line-height: 1.35; overflow-wrap: anywhere; }
.g10-value small:empty { display: none; }
.g10-read-value [data-raw] { display: block; max-width: 100%; font-size: .6rem; letter-spacing: -.015em; white-space: nowrap; }
.g10-read-value, .g10-write-field { height: 38px; min-height: 38px; margin: -3px; padding: 3px; border-radius: 6px; transition: background-color .2s ease, box-shadow .2s ease; }
.g10-read-value strong { transition: color .2s ease; }
.g10-read-value.is-transaction-pending, .g10-write-field.is-transaction-pending { background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 38%, transparent); }
.g10-read-value.is-transaction-pending strong, .g10-write-field.is-transaction-pending .g10-write-value { color: var(--warn); }
.g10-read-value.is-updated, .g10-write-field.is-updated { background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent); }
.g10-read-value.is-updated strong, .g10-write-field.is-updated .g10-write-value { color: var(--accent); }
.g10-read-value.has-transaction-error, .g10-write-field.has-transaction-error { background: var(--danger-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 42%, transparent); cursor: help; }
.g10-read-value.has-transaction-error strong { color: var(--danger); }
.g10-register-table input.g10-write-value { font-family: "IBM Plex Mono", monospace; font-size: .9rem; font-weight: 700; }
.g10-write-field { min-width: 0; }
.g10-write-field .g10-write-value { transition: color .2s ease; }
.g10-write-field.has-transaction-error .g10-write-value { color: var(--danger); cursor: help; }
.g10-write { display: grid; grid-template-columns: minmax(58px, 1fr) auto; gap: 5px; }
.g10-register-actions { display: inline-flex; height: 32px; gap: 3px; }
.g10-action-button.icon-action { display: inline-grid; place-items: center; width: 32px; min-width: 32px; height: 32px; min-height: 32px !important; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--muted); background: var(--panel-strong); box-shadow: none; }
.g10-action-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.g10-action-button > span { font-family: "IBM Plex Mono", monospace; font-size: .82rem; font-weight: 700; line-height: 1; }
.g10-action-button.icon-action:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }
.g10-action-button.is-write { color: var(--accent); }
.g10-action-button.is-write:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--accent-strong); background: var(--accent-soft); }
.g10-action-button.icon-action:disabled { border-color: var(--line); color: color-mix(in srgb, var(--muted) 52%, transparent); background: var(--panel-strong); cursor: not-allowed; }
.g10-remove-register { margin: 0; }
.g10-row-tools { display: flex; width: 100%; gap: 3px; white-space: nowrap; }
.g10-row-tools .g10-action-button { flex: 1 1 0; width: auto; min-width: 30px; }
.g10-register-table input:not([type="checkbox"]), .g10-register-table .g10-config-trigger { border-color: var(--line); background: var(--panel-strong); box-shadow: none; }
.g10-register-table textarea.g10-name, .g10-register-table input.g10-write-value { border-color: transparent; background: transparent; box-shadow: none; }
.g10-register-table .g10-action-button.icon-action { border-color: var(--line); background: var(--panel-strong); box-shadow: none; }
.g10-remove-register.icon-danger:hover:not(:disabled) { border-color: color-mix(in srgb, var(--danger) 42%, var(--line)); color: var(--danger); background: var(--danger-soft); }
.g10-raw-response { display: grid; gap: 6px; margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--line); }
.g10-raw-response .hex-box { min-height: 0; padding: 10px 12px; }
.g10-page textarea { min-height: 72px; }
@media (max-width: 1100px) {
  .g10-config-grid, .g10-preset-picker { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .g10-layout { grid-template-columns: minmax(0, 1fr); }
  .g10-sidebar { position: static; max-height: none; }
  .g10-device-list { max-height: 220px; }
  .g10-raw-command { grid-template-columns: minmax(0, 1fr); }
  .g10-section-heading { align-items: stretch; flex-direction: column; }
  .g10-heading-actions { justify-content: flex-start; }
  .g10-registers-heading { align-items: stretch; flex-direction: column; }
  .g10-register-summary-actions { width: 100%; margin-left: 0; }
  .g10-register-table { display: block; min-width: 1090px; table-layout: auto; }
  .g10-register-table thead, .g10-register-table tbody { display: block; }
  .g10-register-table tr { display: grid; grid-template-columns: 210px 140px 44px 120px 140px 110px 93px 93px 140px; }
  .g10-register-table th, .g10-register-table td { width: auto !important; min-width: 0; }
  .g10-register-table td[colspan] { grid-column: 1 / -1; }
  .g10-register-table th:nth-child(2), .g10-register-table td:nth-child(2) { order: 1; }
  .g10-register-table th:nth-child(7), .g10-register-table td:nth-child(7) { order: 2; }
  .g10-register-table th:nth-child(1), .g10-register-table td:nth-child(1) { order: 3; }
  .g10-register-table th:nth-child(8), .g10-register-table td:nth-child(8) { order: 4; }
  .g10-register-table th:nth-child(9), .g10-register-table td:nth-child(9) { order: 5; }
  .g10-register-table th:nth-child(3), .g10-register-table td:nth-child(3) { order: 6; }
  .g10-register-table th:nth-child(4), .g10-register-table td:nth-child(4) { order: 7; }
  .g10-register-table th:nth-child(5), .g10-register-table td:nth-child(5) { order: 8; }
  .g10-register-table th:nth-child(6), .g10-register-table td:nth-child(6) { order: 9; }
}

@media (max-width: 900px) {
  .g10-layout { gap: var(--space-2); padding-bottom: var(--space-3); }
  .g10-workspace { gap: var(--space-2); }
  .g10-workspace > .panel, .g10-sidebar { padding: 12px; }
  .g10-heading-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .g10-heading-actions > button { width: 100%; min-width: 0; }
  .g10-heading-actions > button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .g10-register-summary-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g10-register-summary-actions > .g10-toolbar { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g10-register-summary-actions > .g10-toolbar .g10-toolbar-button { width: 100%; }
  .g10-register-summary-actions .inline-checkbox { justify-content: flex-start; min-height: 38px; }
  .g10-register-summary-actions #pollInterval, .g10-register-summary-actions #addRegister { width: 100%; min-width: 0; }
  .g10-table-wrap { margin-inline: -12px; padding-inline: 12px; }
  .g10-register-table { min-width: 1090px; }
  .g10-raw-command button, .g10-raw-command #rawUartSettings { width: 100%; }
  .g10-format-options > div { grid-template-columns: minmax(0, 1fr); }
  .g10-bulk-registers > div, .g10-bulk-settings { grid-template-columns: minmax(0, 1fr); }
  .g10-bulk-settings .g10-config-trigger, .g10-bulk-settings > input { width: 100%; }
  .g10-settings-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); margin: auto; }
  .g10-bulk-dialog > .confirmation-form {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (max-width: 900px) {
  .g10-heading-actions, .g10-register-summary-actions { grid-template-columns: minmax(0, 1fr); }
  .g10-heading-actions > button:last-child:nth-child(odd) { grid-column: auto; }
}

.plc-palette-block {
  display: grid;
  grid-template-columns: var(--sidebar-icon-size) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--sidebar-row-height);
  padding: var(--sidebar-row-padding);
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent 24%);
  background: var(--panel-strong);
  color: var(--ink);
  text-align: left;
  box-shadow: none;
}

.plc-palette-block:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: none;
}

.log-control-panel input:hover,
.log-control-panel select:hover,
.log-control-actions button.secondary:hover,
.profile-add-btn:hover,
.profile-tab:hover,
.plc-palette-block:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.profile-tab[aria-selected="true"],
.plc-palette-block:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line) 46%);
}

.plc-block-icon {
  display: inline-grid;
  place-items: center;
  width: var(--sidebar-icon-size);
  height: var(--sidebar-icon-size);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent-soft) 72%, transparent 28%);
  color: var(--accent-strong);
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-weight: 700;
  font-size: 0.78rem;
}

.plc-program-settings {
  align-items: end;
  margin-top: var(--space-3);
}

.plc-settings-field {
  display: grid;
  gap: var(--field-label-gap);
  min-height: 0;
}

.plc-settings-field > label,
.plc-import-field > label {
  margin-bottom: 0;
}

.plc-workspace-panel > .toolbar {
  align-items: center;
  flex-wrap: nowrap;
}

.plc-workspace-panel > .toolbar .toolbar-block {
  flex: 1 1 auto;
  min-width: 0;
}

.plc-workspace-panel > .toolbar .toolbar-block h2 {
  white-space: nowrap;
}

.plc-workspace-panel > .toolbar .toolbar-actions {
  flex: 0 0 auto;
  gap: 6px;
  justify-content: flex-end;
}

.plc-workspace-panel > .toolbar .toolbar-actions button {
  min-height: 35px;
  padding-inline: 9px;
  white-space: nowrap;
}

.plc-import-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: var(--page-gutter);
  background: color-mix(in srgb, var(--page-bg) 68%, transparent 32%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.plc-import-overlay[hidden] {
  display: none;
}

.plc-import-dialog {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: var(--space-2);
  width: min(560px, calc(100vw - var(--page-gutter) * 2));
  height: fit-content;
  min-height: 0;
  max-height: min(560px, calc(100dvh - var(--page-gutter) * 2));
  margin: auto;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.plc-confirm-dialog {
  width: min(420px, calc(100vw - var(--page-gutter) * 2));
}

.cnc-editor-dialog {
  width: min(560px, calc(100% - 32px));
  max-height: min(560px, calc(100dvh - 32px));
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.cnc-editor-dialog .plc-import-dialog {
  width: 100%;
  max-height: inherit;
  padding: var(--space-3);
  border: 0;
  border-radius: inherit;
  box-shadow: none;
}

.plc-write-warnings {
  display: grid;
  min-height: 0;
  gap: 8px;
  margin-top: var(--space-1);
  overflow: auto;
}

.plc-write-warnings[hidden] {
  display: none;
}

.plc-write-warnings > strong {
  color: var(--status-warn-ink);
  font-size: 0.82rem;
}

.plc-import-dialog h3 {
  margin: 0;
  font-size: 1.08rem;
}

.plc-import-header {
  display: grid;
  gap: 6px;
}

.plc-import-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.plc-import-field {
  display: grid;
  gap: var(--field-label-gap);
  min-height: 0;
}

.plc-import-dialog textarea {
  width: 100%;
  min-height: 140px;
  height: 180px;
  max-height: min(240px, 38dvh);
  overflow: auto;
  padding: 8px 9px;
  resize: vertical;
}

.plc-import-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.plc-import-footer .status {
  min-width: 0;
}

.plc-import-footer .controls-row-actions {
  flex: 0 0 auto;
}

@media (max-width: 900px) {
  .plc-import-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .plc-import-footer .controls-row-actions {
    justify-content: flex-end;
  }
}

.plc-workspace {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.plc-empty-workspace {
  margin-top: var(--space-3);
  min-height: 170px;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
  background: color-mix(in srgb, var(--panel-strong) 48%, transparent 52%);
  text-align: center;
}

.plc-workspace-block {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent 12%);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.plc-workspace-block:focus-within {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line) 38%);
}

.plc-workspace-block.has-schedule-error,
.plc-workspace-block.has-schedule-error:focus-within {
  border-color: color-mix(in srgb, var(--danger) 78%, var(--line) 22%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent 86%);
}

.plc-block-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: flex-start;
  margin-bottom: var(--space-3);
}

.plc-block-header h3 {
  margin-bottom: 0;
}

.plc-block-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.plc-icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--plc-icon-button-size);
  min-width: var(--plc-icon-button-size);
  height: var(--plc-icon-button-size);
  min-height: var(--plc-icon-button-size);
  padding: 0;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.plc-icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.plc-icon-btn[data-action^="remove"] {
  color: var(--danger);
}

.plc-icon-btn[data-action^="remove"]:hover,
.plc-icon-btn[data-action^="remove"]:focus-visible {
  color: var(--danger);
  background: var(--remove-hover-bg);
  border-color: var(--remove-hover-border);
}

.plc-block-form {
  margin-top: 0;
}

.plc-event-list {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.plc-weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.plc-weekday-option {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 38px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  cursor: pointer;
}

.plc-weekday-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.plc-weekday-option span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.plc-weekday-option:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line) 40%);
  background: var(--accent-soft);
}

.plc-weekday-option:has(input:checked) span {
  color: var(--accent-strong);
}

.plc-event-row {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent 28%);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--panel-strong) 58%, transparent 42%);
  min-width: 0;
}

.plc-event-time-grid,
.plc-event-action-row,
.plc-condition-action-row {
  display: grid;
  align-items: end;
  gap: var(--space-2);
  min-width: 0;
}

.plc-event-time-grid {
  grid-template-columns: minmax(130px, 1fr) var(--plc-row-icon-button-size);
}

.plc-time-control {
  min-width: 0;
}

.plc-time-input-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--plc-row-icon-button-size);
  gap: var(--space-2);
  align-items: center;
}

.plc-time-picker-toggle {
  width: var(--plc-row-icon-button-size);
  height: var(--plc-row-icon-button-size);
}

.plc-time-control.is-picker-open input,
.plc-time-control.is-picker-open .plc-time-picker-toggle {
  border-color: color-mix(in srgb, var(--accent) 68%, var(--line) 32%);
  background: color-mix(in srgb, var(--accent-soft) 44%, var(--panel-strong) 56%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent 86%);
}

.plc-time-control.is-picker-open .plc-time-picker-toggle {
  color: var(--accent-strong);
}

.plc-event-time-grid > .plc-icon-btn,
.plc-event-action-row > .plc-icon-btn,
.plc-condition-action-row > .plc-icon-btn {
  width: var(--plc-row-icon-button-size);
  min-width: var(--plc-row-icon-button-size);
  height: var(--plc-row-icon-button-size);
  min-height: var(--plc-row-icon-button-size);
}

.plc-time-picker {
  position: fixed;
  left: 0;
  top: calc(100% + 4px);
  z-index: 70;
  display: grid;
  gap: var(--space-2);
  width: min(244px, calc(100vw - 48px));
  padding: var(--space-2);
  border: 1px solid color-mix(in srgb, var(--nav-glass-line) 62%, transparent);
  border-radius: var(--radius-md);
  background: var(--nav-glass-bg);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .28), var(--nav-glass-shadow), inset 0 1px 0 color-mix(in srgb, #fff 12%, transparent);
  backdrop-filter: var(--nav-glass-filter);
  -webkit-backdrop-filter: var(--nav-glass-filter);
}

.plc-time-picker.is-above {
  top: auto;
  bottom: calc(100% + 4px);
}

.plc-time-picker-header {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.plc-time-picker-tabs {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.plc-time-picker-header button {
  min-height: 30px;
  padding: 4px 9px;
}

.plc-time-picker-header .plc-time-picker-close {
  grid-column: 3;
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
}

.plc-time-picker-header .plc-time-picker-close svg {
  width: 15px;
  height: 15px;
}

.plc-time-picker-header button.active {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--line) 28%);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.plc-time-picker-face {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  touch-action: none;
  background:
    radial-gradient(circle at center, color-mix(in srgb, var(--accent-soft) 34%, transparent 66%) 0 20%, transparent 20.5%),
    radial-gradient(circle at center, transparent 0 31%, color-mix(in srgb, var(--line) 42%, transparent 58%) 31.4% 31.9%, transparent 32.3%),
    color-mix(in srgb, var(--panel-strong) 76%, transparent 24%);
}

.plc-time-picker-face::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  z-index: 3;
}

.plc-time-picker-hand {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: var(--hand-length);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 76%, var(--ink) 24%);
  transform: translate(-50%, -100%) rotate(var(--hand-angle));
  transform-origin: 50% 100%;
  z-index: 1;
  pointer-events: none;
}

.plc-time-picker-option {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  transform: translate(-50%, -50%);
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  z-index: 2;
}

.plc-time-picker-option.inner {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  font-size: 0.7rem;
}

.plc-time-picker-option:hover,
.plc-time-picker-option.active {
  border-color: color-mix(in srgb, var(--accent) 64%, var(--line) 36%);
  background: var(--accent-soft);
  box-shadow: none;
  color: var(--accent-strong);
  transform: translate(-50%, -50%);
}

.plc-event-actions {
  display: grid;
  gap: var(--space-2);
}

.plc-event-action-row,
.plc-condition-action-row {
  grid-template-columns: minmax(82px, 0.8fr) minmax(96px, 1fr) var(--plc-row-icon-button-size);
}

.plc-condition-action-section {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-2);
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent 28%);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--panel-strong) 58%, transparent 42%);
}

.plc-condition-action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.plc-condition-action-header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.plc-condition-actions {
  display: grid;
  gap: var(--space-2);
}

.plc-elif-list {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.plc-condition-branch {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-2);
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent 28%);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--panel-strong) 42%, transparent 58%);
}

.plc-elif-list .plc-condition-branch {
  margin-top: 0;
}

.plc-condition-branch .plc-condition-action-section {
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.plc-add-elif {
  margin-top: var(--space-3);
}

.plc-event-action-row input.has-warning,
.plc-event-action-row select.has-warning {
  border-color: color-mix(in srgb, var(--warn) 72%, var(--line) 28%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 13%, transparent 87%);
}

input.has-error,
.plc-event-row.has-warning input.has-error,
.plc-event-row.has-warning select.has-error {
  border-color: color-mix(in srgb, var(--danger) 78%, var(--line) 22%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent 86%);
}

.plc-input-error {
  grid-column: 1 / -1;
  margin-top: var(--space-1);
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--danger) 34%, transparent 66%);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--status-error-ink);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
}

.plc-row-warnings {
  grid-column: 1 / -1;
  display: grid;
  gap: var(--space-1);
}

.plc-row-warning {
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--warn) 34%, transparent 66%);
  background: var(--warn-soft);
  color: var(--status-warn-ink);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.plc-add-event {
  margin-top: var(--space-2);
}

.plc-add-event-action {
  justify-self: start;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.86rem;
}

.plc-code-panel .status {
  margin-top: var(--space-3);
}

.plc-compiler-card {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-4);
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent 18%);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--panel-strong) 66%, transparent 34%);
}

.plc-compiler-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: flex-start;
}

.plc-compiler-header h3 {
  margin: 0;
}

.plc-compiler-header .status {
  margin-top: 0;
}

.plc-compiler-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  align-items: start;
  gap: 6px;
}

.plc-compiler-metric {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent 24%);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.plc-compiler-metric.error {
  border-color: color-mix(in srgb, var(--danger) 58%, var(--line) 42%);
  background: var(--danger-soft);
}

.plc-compiler-metric span,
.plc-compiler-metric strong {
  display: block;
}

.plc-compiler-metric span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.plc-compiler-metric strong {
  margin-top: 2px;
  color: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.92rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.plc-compiler-metric.error span,
.plc-compiler-metric.error strong {
  color: var(--status-error-ink);
}

.plc-compiler-issues {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plc-compiler-issues li {
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.plc-compiler-issues li.ok {
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent 76%);
  background: var(--accent-soft);
  color: var(--status-ok-ink);
}

.plc-compiler-issues li.warn {
  border: 1px solid color-mix(in srgb, var(--warn) 24%, transparent 76%);
  background: var(--warn-soft);
  color: var(--status-warn-ink);
}

.plc-compiler-issues li.error {
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent 76%);
  background: var(--danger-soft);
  color: var(--status-error-ink);
}

.plc-code-viewer {
  min-height: 0;
  max-height: calc(100dvh - 260px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  overflow: auto;
  margin-top: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent 18%);
  background: var(--log-bg);
  color: var(--log-ink);
}

.plc-builder-page .plc-code-viewer {
  margin-bottom: 0;
}

.plc-code-lines,
.plc-code-surface {
  min-height: 0;
  padding: var(--space-4) 0;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre;
  tab-size: 4;
}

.plc-code-lines {
  min-width: 44px;
  padding-right: 10px;
  padding-left: 10px;
  border-right: 1px solid color-mix(in srgb, var(--line) 70%, transparent 30%);
  color: var(--muted);
  text-align: right;
  user-select: none;
}

.plc-code-surface {
  min-width: max-content;
  padding-right: var(--space-4);
  padding-left: var(--space-4);
}

@media (min-width: 901px) {
  html:has(body.plc-builder-page) {
    height: 100%;
    overflow: visible;
    overscroll-behavior: none;
  }

  body.plc-builder-page {
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .site-shell-plc-builder {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .plc-builder-page .plc-builder-layout {
    position: static;
    height: 100dvh;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
  }

  .plc-builder-page .plc-builder-workspace {
    height: 100%;
    min-height: 0;
    margin-top: 0;
    overflow: hidden;
  }

  .plc-builder-page .plc-palette-panel {
    display: flex;
    flex-direction: column;
    align-self: start;
    margin-top: var(--header-safe-top);
    margin-bottom: var(--space-3);
    max-height: calc(100% - var(--header-safe-top) - var(--space-3));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
  }

  .plc-builder-page .cnc-device-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .plc-builder-page .cnc-device-browser {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .plc-builder-page .cnc-device-list {
    flex: 0 1 auto;
    min-height: 0;
  }

  .plc-builder-page .plc-pane-scroll {
    height: 100%;
    min-height: 0;
    padding-top: var(--header-safe-top);
    padding-bottom: var(--space-3);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
  }

  .plc-builder-page .plc-workspace-panel,
  .plc-builder-page .plc-code-panel {
    min-height: 0;
    overflow: visible;
  }

  .plc-builder-page .plc-code-viewer {
    max-height: calc(100dvh - 260px);
  }
}

.plc-token-keyword {
  color: #8b5cf6;
  font-weight: 700;
}

.plc-token-label {
  color: var(--ink);
  font-weight: 700;
}

.plc-token-helper {
  color: #0f8b8d;
  font-weight: 700;
}

.plc-token-variable {
  color: #1d74d8;
}

.plc-token-port {
  color: #c05621;
  font-weight: 700;
}

.plc-token-constant {
  color: #b7791f;
  font-weight: 700;
}

.plc-token-number {
  color: #22863a;
}

.plc-token-operator {
  color: var(--muted);
}

.plc-token-comment {
  color: color-mix(in srgb, var(--muted) 72%, transparent 28%);
  font-style: italic;
}

:root[data-theme="dark"] .plc-token-keyword {
  color: #c4a7ff;
}

:root[data-theme="dark"] .plc-token-label {
  color: #eef3f8;
}

:root[data-theme="dark"] .plc-token-helper {
  color: #57d8d4;
}

:root[data-theme="dark"] .plc-token-variable {
  color: #8ecbff;
}

:root[data-theme="dark"] .plc-token-port {
  color: #ffb36b;
}

:root[data-theme="dark"] .plc-token-constant {
  color: #ffd166;
}

:root[data-theme="dark"] .plc-token-number {
  color: #9be28f;
}

@media (max-width: 900px) {
  .modbus-layout {
    grid-template-columns: 1fr;
    padding-top: var(--header-safe-top);
    padding-bottom: var(--space-3);
  }

  .modbus-profile-sidebar {
    overflow: visible;
  }

  .site-shell-log-viewer {
    min-height: 100dvh;
  }

  .log-viewer-layout {
    grid-template-columns: 1fr;
  }

  .log-control-panel {
    overflow: visible;
  }

  .log-viewer-results {
    min-height: 560px;
  }

  .log-viewer-page .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .log-viewer-results .toolbar-actions {
    flex-wrap: wrap;
  }

  .home-hub {
    padding-top: var(--header-safe-top);
  }

  .home-intro {
    padding: var(--space-2) 0 var(--space-3);
  }

  .home-intro h1 {
    max-width: 720px;
  }

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

  .section-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid.three-up {
    grid-template-columns: 1fr;
  }

  .site-header {
    align-items: center;
    flex-direction: row;
    gap: 8px;
  }

  .brand {
    max-width: 172px;
    padding-right: 8px;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .brand-mark {
    font-size: 0.94rem;
  }

  .header-actions {
    flex: 0 0 auto;
    min-width: 0;
  }

  .site-nav {
    gap: 14px;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
  }

  .site-nav a {
    flex: 0 0 auto;
    text-align: center;
    white-space: nowrap;
  }

  .plc-builder-layout {
    grid-template-columns: 1fr;
    padding-top: var(--header-safe-top);
    padding-bottom: var(--space-3);
  }

  .plc-builder-workspace {
    grid-template-columns: 1fr;
  }

  .plc-event-action-row,
  .plc-condition-action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) var(--plc-row-icon-button-size);
  }

  .plc-weekday-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .plc-compiler-header {
    grid-template-columns: 1fr;
  }

  .plc-compiler-header {
    display: grid;
  }

  .plc-compiler-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plc-code-viewer {
    min-height: 0;
    max-height: 70dvh;
  }

  .modbus-page .value-table[data-show-bits="true"],
  .modbus-page .value-table[data-show-bits="true"] thead,
  .modbus-page .value-table[data-show-bits="true"] tbody,
  .modbus-page .value-table[data-show-bits="true"] tr,
  .modbus-page .value-table[data-show-bits="true"] th,
  .modbus-page .value-table[data-show-bits="true"] td {
    display: block;
  }

  .modbus-page .value-table[data-show-bits="true"] thead {
    display: none;
  }

  .modbus-page .value-table[data-show-bits="true"] tbody tr {
    display: grid;
    grid-template-columns: 54px minmax(68px, 0.7fr) minmax(68px, 1fr);
    border-bottom: 1px solid var(--output-row);
  }

  .modbus-page .value-table[data-show-bits="true"] tbody tr:last-child {
    border-bottom: 0;
  }

  .modbus-page .value-table[data-show-bits="true"] td {
    width: auto !important;
    border-bottom: 0;
  }

  .modbus-page .value-table[data-show-bits="true"] td:nth-child(4) {
    grid-column: 1 / -1;
    padding-top: 0;
  }

  .modbus-page .bit-array-row {
    grid-template-columns: repeat(8, minmax(20px, 1fr));
    gap: 4px;
  }

  .modbus-page .bit-chip {
    gap: 3px;
    min-height: 24px;
    padding: 3px 4px;
  }

  .modbus-page .bit-chip-index {
    font-size: 0.62rem;
  }

  .modbus-page .bit-chip-value {
    font-size: 0.78rem;
  }

  .write-composer-column-head,
  .write-composer-row {
    grid-template-columns: 36px repeat(2, minmax(0, 1fr)) var(--plc-row-icon-button-size);
  }

  .write-composer-row label:nth-of-type(3) {
    grid-column: 2 / -1;
  }

  .write-byte-settings,
  .write-byte-settings[open] {
    grid-column: 2 / -1;
    grid-row: auto;
    justify-self: start;
    min-width: 84px;
  }

  .write-byte-panel {
    grid-column: 1 / -1;
  }

  .write-bit-grid {
    gap: 6px;
  }

  .write-bit-button {
    width: 100%;
    height: 40px;
    min-height: 40px;
  }

  .write-composer-remove {
    grid-column: 4;
    grid-row: 1;
  }
}

/* The composer can sit in a narrow desktop column as well as a small viewport.
   Respond to the component width so every control remains reachable. */
@container (max-width: 680px) {
  .write-composer-column-head {
    display: none;
  }

  .write-composer-row,
  .write-composer.single-write .write-composer-row {
    grid-template-columns: 28px minmax(70px, 0.72fr) minmax(104px, 1fr) 68px 34px;
    gap: 6px;
    padding: 8px;
  }

  .write-composer-index {
    grid-column: 1;
    grid-row: 1;
  }

  .write-composer-row label {
    grid-row: 1;
  }

  .write-composer-row label:nth-of-type(1) {
    grid-column: 2;
  }

  .write-composer-row label:nth-of-type(2) {
    grid-column: 3;
  }

  .write-composer-row label:nth-of-type(3) {
    grid-column: 2 / -1;
    grid-row: 2;
  }

  .write-composer-row label span {
    display: block;
  }

  .write-byte-settings,
  .write-byte-settings[open] {
    grid-column: 4;
    grid-row: 1;
    min-width: 0;
  }

  .write-composer-remove {
    grid-column: 5;
    grid-row: 1;
  }

  .write-byte-panel {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .write-byte-actions {
    gap: 6px;
  }

  .write-operation-group {
    gap: 3px;
    padding: 3px;
  }

  .write-byte-actions button {
    min-height: 30px;
    padding: 5px 7px;
    font-size: 0.7rem;
  }

  .write-operation-symbols button {
    min-width: 32px;
    font-size: 0.9rem;
  }

  .write-bit-grid {
    grid-template-columns: repeat(8, minmax(28px, 1fr));
    gap: 5px;
  }
}

/* USB Serial Console ----------------------------------------------------- */
.usb-serial-page .site-shell {
  min-height: 100dvh;
}

.usb-serial-layout {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--page-gutter);
  padding-top: var(--space-3);
}

.usb-serial-sidebar,
.usb-serial-workspace,
.usb-terminal-panel,
.usb-send-panel {
  min-width: 0;
}

.usb-serial-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-self: start;
}

.usb-serial-sidebar .section-heading,
.usb-send-panel .section-heading {
  margin-bottom: 0;
}

.usb-support-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
}

.usb-support-card strong {
  font-size: .84rem;
}

.usb-support-card span {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.45;
}

.usb-support-card.is-supported {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--outline));
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--panel-strong));
}

.usb-support-card.is-unsupported {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--outline));
  background: color-mix(in srgb, var(--danger-soft) 55%, var(--panel-strong));
}

.usb-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.usb-settings-grid .full {
  grid-column: 1 / -1;
}

.usb-signal-settings {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 14px;
  min-width: 0;
  margin: 0;
  padding: 9px 10px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
}

.usb-signal-settings legend {
  padding-inline: 4px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}

.usb-signal-settings .field-note {
  margin: 0;
  text-align: right;
}

.usb-port-actions,
.usb-connect-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 0;
}

.usb-connect-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.usb-serial-workspace {
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto;
  gap: var(--space-3);
}

.usb-terminal-panel {
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.usb-terminal-heading {
  align-items: flex-start;
  gap: var(--space-3);
}

.usb-terminal-heading > div:first-child {
  display: grid;
  gap: 4px;
}

.usb-terminal-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.usb-terminal-controls > label:not(.inline-checkbox) {
  margin: 0;
}

.usb-terminal-controls select {
  width: auto;
  min-width: 125px;
}

.usb-terminal {
  flex: 1 1 auto;
  min-height: 360px;
  max-height: calc(100dvh - 390px);
  margin-top: var(--space-3);
  padding: var(--space-3);
  overflow: auto;
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--output-bg);
  color: var(--ink);
  font-size: .82rem;
  line-height: 1.55;
}

.usb-terminal-placeholder {
  color: var(--muted);
}

.usb-terminal-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.usb-terminal-meta {
  color: var(--muted);
  font-weight: 700;
}

.usb-terminal-row.is-rx .usb-terminal-meta {
  color: var(--accent-strong);
}

.usb-terminal-row.is-tx .usb-terminal-meta {
  color: var(--status-warn-ink);
}

.usb-send-grid {
  display: grid;
  grid-template-columns: 150px 150px minmax(240px, 1fr) auto;
  align-items: end;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.usb-payload-field textarea {
  min-height: 76px;
}

.usb-send-button {
  min-width: 96px;
  margin-bottom: 28px;
}

@media (max-width: 1100px) {
  .usb-serial-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

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

  .usb-payload-field {
    grid-column: 1 / -1;
  }

  .usb-send-button {
    grid-column: 1 / -1;
    margin: 0;
  }
}

@media (max-width: 900px) {
  .usb-serial-layout {
    display: block;
    padding: var(--page-gutter);
  }

  .usb-serial-sidebar,
  .usb-serial-workspace {
    margin-bottom: var(--space-3);
  }

  .usb-terminal-panel {
    min-height: 430px;
  }

  .usb-terminal {
    min-height: 280px;
    max-height: 55dvh;
  }
}

@media (max-width: 560px) {
  .usb-signal-settings {
    grid-template-columns: auto auto;
  }

  .usb-signal-settings .field-note {
    grid-column: 1 / -1;
    text-align: left;
  }

  .usb-terminal-heading,
  .usb-terminal-controls {
    align-items: stretch;
  }

  .usb-terminal-heading {
    display: grid;
  }

  .usb-terminal-controls {
    justify-content: stretch;
  }

  .usb-terminal-controls select,
  .usb-terminal-controls button {
    width: 100%;
  }

  .usb-send-grid {
    grid-template-columns: 1fr;
  }

  .usb-payload-field,
  .usb-send-button {
    grid-column: auto;
  }
}

/* Keep non-field controls on the same baseline as the DEC/HEX/BIN inputs. */
.modbus-page .write-composer-index,
.modbus-page .write-composer-remove,
.modbus-page .write-byte-settings,
.modbus-page .write-byte-settings[open] {
  align-self: end;
}

/* On touch layouts, visually separate the stable value toolbar from the
   controls revealed below it. */
@media (max-width: 900px) {
  .modbus-page .write-byte-settings[open] + .write-byte-panel {
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid color-mix(in srgb, var(--line) 78%, transparent 22%);
  }
}

@container (max-width: 430px) {
  .write-composer-summary {
    gap: 6px;
    padding-inline: 10px;
  }

  .write-composer-summary > span:first-child {
    font-size: 0.88rem;
  }

  .write-composer-actions {
    gap: 5px;
  }

  .write-composer-actions button {
    width: 34px;
    min-width: 34px;
    padding-inline: 0;
    overflow: hidden;
    font-size: 0;
  }

  .write-composer-actions button::before {
    content: "+";
    font-size: 1rem;
  }

  .write-composer-row,
  .write-composer.single-write .write-composer-row {
    grid-template-columns: 28px repeat(2, minmax(0, 1fr)) 34px;
  }

  .write-composer-row label:nth-of-type(1) {
    grid-column: 2;
  }

  .write-composer-row label:nth-of-type(2) {
    grid-column: 3;
  }

  .write-composer-row label:nth-of-type(3) {
    grid-column: 2 / -1;
    grid-row: 2;
  }

  .write-byte-settings,
  .write-byte-settings[open] {
    grid-column: 2 / 4;
    grid-row: 3;
  }

  .write-composer-remove {
    grid-column: 4;
  }

  .write-byte-panel {
    grid-row: 4;
  }

  .write-byte-actions {
    justify-content: stretch;
  }

  .write-operation-group {
    display: grid;
    flex: 1 1 calc(50% - 3px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .write-operation-group:first-child {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex-basis: 100%;
  }

  .write-operation-symbols {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    flex-basis: 100%;
  }

  .write-operation-symbols button {
    min-width: 0;
  }

  .write-bit-grid {
    grid-template-columns: repeat(4, minmax(40px, 1fr));
  }
}

/* Keep mobile user actions beside the identity; permissions remain a full-row
   summary below. Destructive actions retain their distinct danger treatment. */
.icon-action.icon-danger:not(:disabled) {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--outline));
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, var(--button-secondary-bg));
}

.icon-action.icon-danger:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--danger) 68%, var(--outline));
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 15%, var(--button-secondary-bg));
}

#userDialog:focus,
#userDialog:focus-visible {
  outline: none;
}

@media (max-width: 900px) {
  #userDialog .dialog-close {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
  }
  #userDialog .dialog-close:focus {
    outline: none;
    box-shadow: none;
  }

  .admin-page .user-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .admin-page .user-identity {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .admin-page .user-identity > span:last-child { min-width: 0; }
  .admin-page .user-identity strong { overflow-wrap: anywhere; }
  .admin-page .user-actions {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .admin-page .permission-tags {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* Canonical tablet range: mobile ends at 900px and desktop starts at 1351px. */
@media (min-width: 901px) and (max-width: 1350px) {
  .modbus-page .modbus-layout {
    position: static;
    height: auto;
    align-items: start;
    padding-top: var(--header-safe-top);
    padding-bottom: var(--space-3);
  }

  .modbus-workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  .modbus-page .modbus-pane-scroll {
    height: auto;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: visible;
  }

  .modbus-page .modbus-profile-sidebar {
    margin-top: 0;
    margin-bottom: 0;
    max-height: none;
  }

  .modbus-page .modbus-scroll-panel,
  .modbus-page .modbus-profile-sidebar {
    padding: var(--space-4);
  }

  .modbus-page .section-heading {
    margin-bottom: var(--space-3);
  }

  .modbus-page .form-grid {
    gap: var(--space-2);
  }

  .modbus-page .output {
    margin-top: var(--space-3);
    padding: var(--space-3);
  }

  .modbus-page .meta-table td:first-child {
    width: 112px;
  }

  .modbus-page .value-table th,
  .modbus-page .value-table td {
    padding: 7px;
  }

  .modbus-page .value-table th:nth-child(1),
  .modbus-page .value-table td:nth-child(1) {
    width: 60px;
  }

  .modbus-page .value-table th:nth-child(2),
  .modbus-page .value-table td:nth-child(2) {
    width: 58px;
  }

  .modbus-page .value-table th:nth-child(3),
  .modbus-page .value-table td:nth-child(3) {
    width: 84px;
  }

  .modbus-page .value-table[data-show-bits="true"],
  .modbus-page .value-table[data-show-bits="true"] thead,
  .modbus-page .value-table[data-show-bits="true"] tbody,
  .modbus-page .value-table[data-show-bits="true"] tr,
  .modbus-page .value-table[data-show-bits="true"] th,
  .modbus-page .value-table[data-show-bits="true"] td {
    display: block;
  }

  .modbus-page .value-table[data-show-bits="true"] {
    border-spacing: 0;
  }

  .modbus-page .value-table[data-show-bits="true"] thead {
    display: none;
  }

  .modbus-page .value-table[data-show-bits="true"] tbody tr {
    display: grid;
    grid-template-columns: 60px minmax(74px, 0.7fr) minmax(74px, 1fr);
    gap: 0;
    border-bottom: 1px solid var(--output-row);
  }

  .modbus-page .value-table[data-show-bits="true"] tbody tr:last-child {
    border-bottom: 0;
  }

  .modbus-page .value-table[data-show-bits="true"] td {
    width: auto !important;
    border-bottom: 0;
  }

  .modbus-page .value-table[data-show-bits="true"] td:nth-child(4) {
    grid-column: 1 / -1;
    padding-top: 0;
  }

  .modbus-page .bit-array-row {
    grid-template-columns: repeat(8, minmax(22px, 1fr));
    gap: 4px;
  }

  .modbus-page .bit-chip {
    gap: 3px;
    min-height: 24px;
    padding: 3px 4px;
  }

  .modbus-page .bit-chip-index {
    font-size: 0.62rem;
  }

  .modbus-page .bit-chip-value {
    font-size: 0.78rem;
  }

  .write-composer-column-head,
  .write-composer-row {
    grid-template-columns: 22px minmax(56px, 0.62fr) minmax(76px, 0.72fr) minmax(116px, 1.5fr) 42px 32px;
    gap: 5px;
  }

  .write-composer.single-write .write-composer-column-head,
  .write-composer.single-write .write-composer-row {
    grid-template-columns: 22px minmax(56px, 0.62fr) minmax(76px, 0.72fr) minmax(116px, 1.5fr) 42px;
  }

  .write-composer-summary {
    min-height: 40px;
    padding: 7px 12px;
    font-size: 0.94rem;
  }

  .write-composer-column-head {
    padding-inline: 9px;
  }

  .write-composer-row {
    padding: 6px 9px;
  }

  .write-composer-index {
    font-size: 0.64rem;
  }

  .write-composer-row input {
    min-height: 32px;
    padding: 5px 6px;
    font-size: 0.72rem;
  }

  .write-composer-row input.mono {
    font-size: 0.7rem;
  }

  .write-byte-settings summary {
    min-height: 32px;
    padding-inline: 4px;
    font-size: 0.62rem;
  }

  .write-composer-remove {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .plc-builder-page .plc-builder-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: max-content;
    gap: var(--space-3);
    height: 100%;
    min-height: 0;
    padding-top: var(--header-safe-top);
    padding-bottom: var(--space-3);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
  }

  .plc-builder-page .plc-pane-scroll {
    height: auto;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: visible;
  }

}

@media (max-width: 900px) {
  .home-copy {
    font-size: 0.94rem;
  }

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

  .write-composer-column-head {
    display: none;
  }

  .write-composer-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .write-composer-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: space-between;
  }

  .write-composer-row {
    grid-template-columns: 1fr var(--plc-row-icon-button-size);
  }

  .write-composer.single-write .write-composer-row {
    grid-template-columns: 1fr;
  }

  .write-composer-index {
    grid-column: 1 / -1;
    min-height: 0;
    margin-top: 0;
    place-items: start;
  }

  .write-composer-row label,
  .write-composer-row label:nth-of-type(3),
  .write-byte-settings,
  .write-byte-settings[open],
  .write-byte-panel {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .write-composer-row label span {
    display: block;
  }

  .write-composer-remove {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    margin-top: 0;
  }
}

.modbus-page .value-table[data-show-bits="true"] {
  display: block;
  overflow: visible;
  border-radius: 0;
  table-layout: auto;
}

.modbus-page .value-table[data-show-bits="true"] thead {
  display: none;
}

.modbus-page .value-table[data-show-bits="true"] tbody {
  display: grid;
  gap: 8px;
}

.modbus-page .value-table[data-show-bits="true"] .bit-result-row,
.modbus-page .value-table[data-show-bits="true"] .bit-result-cell {
  display: block;
  width: auto !important;
  padding: 0;
  border-bottom: 0;
}

.modbus-page .value-table[data-show-bits="true"] .bit-result-row:nth-child(even) .bit-result-cell {
  background: transparent;
}

.bit-result-card {
  display: grid;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent 18%);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--panel) 76%, transparent 24%);
}

.bit-result-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}

.bit-result-field {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--panel-strong) 72%, transparent 28%);
}

.bit-result-label {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bit-result-value {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 750;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bit-result-bits {
  display: flex;
  justify-content: flex-start;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.modbus-page .bit-result-bits .bit-array {
  width: 100%;
  overflow-x: visible;
  padding-bottom: 0;
}

.modbus-page .bit-result-bits .bit-array-row {
  grid-template-columns: repeat(8, minmax(24px, 1fr));
  gap: 5px;
  min-width: 0;
}

.modbus-page .bit-result-bits .bit-chip {
  flex-direction: column;
  gap: 2px;
  min-height: 32px;
  padding: 4px 3px;
}

.modbus-page .bit-result-bits .bit-chip-index {
  font-size: 0.6rem;
  line-height: 1;
}

.modbus-page .bit-result-bits .bit-chip-value {
  font-size: 0.98rem;
  line-height: 1;
}

@media (max-width: 900px) {
  .bit-result-meta {
    gap: 8px;
  }

  .bit-result-field {
    padding: 6px 7px;
  }

  .bit-result-bits {
    justify-content: flex-start;
  }

  .modbus-page .bit-result-bits .bit-array-row { gap: 4px; }
}

.account-actions { display: flex; align-items: center; gap: 10px; }
.account-actions a { color: var(--text); font-weight: 700; text-decoration: none; }
.account-name, .muted { color: var(--muted); }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); display: grid; gap: var(--space-3); padding: 28px; }
.auth-card label,
.user-form > label,
.user-form .form-grid > label {
  display: grid;
  gap: var(--field-label-gap);
  margin-bottom: 0;
}
.auth-card h1, .user-form h2 { margin: 0; }
.admin-panel { padding: 24px; }
.user-list { display: grid; gap: 10px; margin-top: 20px; }
.user-row { display: grid; grid-template-columns: minmax(160px, .7fr) 2fr auto; align-items: center; gap: 18px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; }
.user-row > div:first-child { display: grid; gap: 3px; }
.user-row > div:first-child span { color: var(--muted); font-size: .86rem; }
.permission-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { padding: 3px 7px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: .75rem; }
.tag.danger { color: #b42318; background: #fee4e2; }
.danger-button { background: #b42318; border-color: #b42318; }
dialog { width: min(640px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); }
dialog::backdrop { background: color-mix(in srgb, var(--bg) 62%, transparent 38%); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.confirmation-dialog { width: min(440px, calc(100% - 32px)); }
.confirmation-dialog:focus { outline: none; }
.confirmation-form { display: grid; gap: 24px; padding: 24px; }
.confirmation-form h2 { margin: 0 0 8px; font-size: 1.3rem; }
.confirmation-form p { margin: 0; color: var(--muted); line-height: 1.5; }
.user-form { display: grid; gap: 16px; padding: 24px; }
.user-form fieldset { display: grid; gap: 9px; border: 1px solid var(--border); border-radius: 9px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 900px) { .user-row { grid-template-columns: 1fr; } .account-name { display: none; } }

/* Authenticated navigation and account menu */
.header-actions { gap: 12px; }
.site-nav { align-items: center; gap: 6px; padding: 4px; border: 1px solid var(--glass-line); border-radius: 12px; background: color-mix(in srgb, var(--panel-strong) 42%, transparent); }
.site-nav a { min-height: 32px; padding: 0 10px; border-radius: 8px; font-size: .86rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: var(--panel-strong); }
.nav-group-label { padding: 0 5px 0 7px; color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.account-actions { position: relative; display: flex; align-items: center; gap: 8px; }
.admin-nav-link { display: inline-flex; align-items: center; min-height: 36px; padding: 0 10px; border-radius: 9px; color: var(--muted); font-size: .86rem; font-weight: 700; text-decoration: none; }
.admin-nav-link:hover, .admin-nav-link.current { color: var(--ink); background: var(--panel-strong); }
.account-menu { position: relative; }
.account-trigger { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 4px 9px 4px 5px; border: 1px solid var(--glass-line); border-radius: 12px; color: var(--ink); background: color-mix(in srgb, var(--panel-strong) 48%, transparent); box-shadow: none; }
.account-trigger:hover { transform: none; background: var(--panel-strong); }
.account-trigger svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.account-avatar, .user-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 32px; height: 32px; border-radius: 9px; color: #fff; background: var(--accent); font-weight: 800; }
.account-avatar { border-radius: 50%; }
.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff !important;
}
.account-trigger-copy { display: grid; min-width: 0; text-align: left; line-height: 1.1; }
.account-trigger-copy strong { max-width: 120px; overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.account-trigger-copy small { color: var(--muted); font-size: .68rem; }
.account-popover { position: absolute; top: calc(100% + 8px); right: 0; z-index: 50; display: grid; width: 190px; padding: 6px; border: 1px solid var(--glass-line); border-radius: 12px; background: var(--panel-strong); box-shadow: var(--shadow); }
.account-popover[hidden] { display: none; }
.account-popover button, .account-popover a { display: flex; align-items: center; justify-content: flex-start; min-height: 38px; padding: 0 10px; border: 0; border-radius: 8px; color: var(--ink); background: transparent; box-shadow: none; font-size: .82rem; font-weight: 700; text-align: left; text-decoration: none; }
.account-popover button:hover, .account-popover a:hover { transform: none; background: var(--panel); }
.menu-separator { height: 1px; margin: 4px; background: var(--line); }
.account-dialog { width: min(620px, calc(100% - 28px)); }
.password-section { display: grid; gap: 12px; padding-top: 4px; }
.password-section h3, .password-section p { margin: 0; }

/* User management */
.admin-page .site-shell { padding-top: var(--header-safe-top); }
.admin-panel { width: min(100%, 1040px); margin: 0 auto; overflow: visible; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.admin-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 8px 0 20px; border: 0; }
.admin-heading h1 { margin: 0; }
.admin-heading p { margin: 8px 0 0; }
.admin-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 0 14px; border-bottom: 1px solid var(--line); color: var(--muted); background: transparent; font-size: .78rem; }
.admin-summary button { flex: 0 0 auto; }
.user-list { gap: 0; margin: 0; }
.user-row { grid-template-columns: minmax(230px, .85fr) minmax(280px, 1.6fr) auto; min-height: 84px; padding: 16px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.user-row:last-child { border-bottom: 0; }
.user-row.is-disabled { opacity: .68; }
.user-identity { display: flex !important; align-items: center; gap: 12px !important; }
.user-identity > span:last-child { display: grid; gap: 3px; }
.user-identity small { color: var(--muted); }
.user-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.icon-action { display: grid; place-items: center; width: 42px; min-width: 42px; height: 42px; min-height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--panel-strong); box-shadow: none; }
.icon-action svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-action:hover:not(:disabled) { transform: none; border-color: color-mix(in srgb, var(--accent) 38%, var(--line)); background: color-mix(in srgb, var(--accent) 8%, var(--panel-strong)); }
.icon-action:disabled,
.icon-action:disabled:hover { transform: none; border-color: var(--line); color: var(--muted); background: var(--panel-strong); box-shadow: none; cursor: not-allowed; }
.icon-danger { color: var(--danger); }
.icon-danger:hover:not(:disabled) { border-color: color-mix(in srgb, var(--danger) 48%, var(--line)); background: color-mix(in srgb, var(--danger) 10%, var(--panel-strong)); }
.permission-tags .tag { color: var(--ink); background: var(--panel-strong); }
:root:not([data-theme="dark"]) .permission-tags .tag {
  border: 1px solid rgba(117, 140, 155, .34);
  color: #263744;
  background: rgba(222, 233, 238, .88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .68);
}
:root:not([data-theme="dark"]) .permission-tags .tag.danger {
  border-color: rgba(180, 35, 24, .28);
  color: #9f241a;
  background: rgba(254, 226, 226, .86);
}
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 4px 0 0; font-size: 1.35rem; }
.dialog-close {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
}
.user-form { max-height: min(820px, calc(100vh - 40px)); overflow-y: auto; gap: var(--space-3); padding: 26px; }
.user-form label > small { color: var(--muted); font-size: .72rem; font-weight: 600; }
.user-form fieldset { padding: 0; }
.user-form legend { padding: 0; color: var(--muted); font-size: .78rem; font-weight: 800; letter-spacing: 0; text-transform: none; }
.form-field { display: grid; gap: var(--field-label-gap); min-width: 0; }
.form-field > label { margin: 0; }
.form-field > label,
.g10-response-label > label,
.log-control-fields > div > label,
.form-grid > div:not(.full) > label,
.auth-card label,
.user-form > label,
.user-form .form-grid > label,
.plc-block-form > div > label,
.plc-event-action-row > div > label,
.plc-condition-action-row > div > label,
.plc-time-control > label,
.plc-settings-field > label,
.plc-import-field > label,
label:has(> input:not([type="checkbox"]):not([type="radio"])),
label:has(> select),
label:has(> textarea),
label:has(+ input:not([type="checkbox"]):not([type="radio"])),
label:has(+ select),
label:has(+ textarea) {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.2;
}
.form-field,
.log-control-fields > div,
.form-grid > div,
.plc-block-form > div,
.plc-event-action-row > div,
.plc-condition-action-row > div,
.plc-time-control,
.plc-settings-field,
.plc-import-field {
  row-gap: var(--field-label-gap);
}
.form-grid > .full:has(> label + input),
.form-grid > .full:has(> label + select),
.form-grid > .full:has(> label + textarea) {
  display: grid;
}
label:has(> input:not([type="checkbox"]):not([type="radio"])),
label:has(> select),
label:has(> textarea) {
  display: grid;
  gap: var(--field-label-gap);
}
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-label-row label { margin: 0; color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1.2; }
.field-label-row small { color: var(--muted); font-size: .72rem; font-weight: 600; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.choice-card { display: flex !important; align-items: center; gap: 11px !important; min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--panel-strong) 45%, transparent); cursor: pointer; }
.choice-card:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.choice-card input, .listener-grid input, .project-summary-main input { flex: 0 0 auto; width: 18px !important; height: 18px !important; min-height: 0 !important; margin: 0; padding: 0; }
.user-form input[type="checkbox"] { accent-color: var(--accent); }
.user-form .danger-choice input[type="checkbox"] { accent-color: #d92d20; }
.choice-card span { display: grid; gap: 2px; min-width: 0; }
.choice-card small { color: var(--muted); font-size: .72rem; line-height: 1.25; }
.listener-grid { display: grid; grid-template-columns: 1fr; gap: 4px; max-height: 240px; overflow-y: auto; padding: 2px; }
.listener-grid label { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 4px; font-size: .82rem; cursor: pointer; }
.access-help { margin: -4px 0 12px; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.access-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.access-section-heading .access-help { margin: 0; }
.compact-actions { display: flex; gap: 6px; }
.compact-actions button { width: auto; min-height: 30px; padding: 0 9px; font-size: .72rem; }
.listener-grid { gap: 7px; }
.listener-grid .listener-choice { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: color-mix(in srgb, var(--panel-strong) 38%, transparent); }
.listener-grid .listener-choice:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 48%, var(--line)); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.listener-choice span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sensitive-choice { max-width: none; }

/* Minimal hierarchical permission editor */
.tools-access-section { padding: 0 !important; border: 0 !important; border-radius: 0 !important; }
.permission-stack { display: grid; gap: 8px; }
.permission-group { display: grid; gap: 0; }
.tool-choice { width: 100%; min-height: 56px; padding: 11px 12px; background: transparent; }
.tool-choice:has(input:checked) { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.permission-group:not(.permission-details) > .tool-choice,
.permission-group:not(.permission-details) > .tool-choice:has(input:checked) { border-color: var(--line); }
.permission-details { border: 1px solid var(--line); border-radius: 11px; overflow: clip; }
.permission-details[open] { border-color: var(--line); }
.permission-details > summary { list-style: none; border: 0; border-radius: 10px; }
.permission-details > summary::-webkit-details-marker { display: none; }
.permission-details[open] > summary { border-radius: 10px 10px 0 0; }
.permission-details > summary > span:nth-child(2) { flex: 1 1 auto; }
.permission-details > summary small > span { display: inline; }
.permission-chevron { position: relative; display: inline-flex !important; flex: 0 0 18px !important; width: 18px; height: 18px; }
.permission-chevron::before { content: ""; position: absolute; top: 4px; left: 5px; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s ease; }
.permission-details[open] .permission-chevron::before { transform: translateY(3px) rotate(225deg); }
.nested-access { position: relative; display: grid; gap: 8px; margin: 0 8px 6px 24px; padding: 10px 0 8px 16px; border-left: 1px solid color-mix(in srgb, var(--accent) 44%, var(--line)); }
.nested-access[hidden] { display: none; }
.nested-access-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nested-access-heading > div:first-child { display: grid; gap: 2px; }
.nested-access-heading strong { font-size: .8rem; }
.nested-access-heading small { color: var(--muted); font-size: .72rem; }
.nested-access .listener-grid { grid-template-columns: 1fr; max-height: 240px; gap: 3px; padding-right: 4px; }
.nested-access .listener-choice { min-height: 36px; padding: 7px 9px; border: 0; border-radius: 7px; background: transparent; }
.nested-access .listener-choice:hover { background: color-mix(in srgb, var(--panel-strong) 70%, transparent); }
.nested-access .listener-choice:has(input:checked) { border: 0; background: color-mix(in srgb, var(--accent) 9%, transparent); }
.nested-access .sensitive-choice { min-height: 52px; padding: 10px 12px; border-style: dashed; background: transparent; }
.tools-access-section > .access-help { margin: 6px 0 12px; }
.listener-projects { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; padding-right: 4px; }
.listener-project { border: 1px solid var(--line); border-radius: 9px; overflow: clip; }
.listener-project summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; background: color-mix(in srgb, var(--panel-strong) 48%, transparent); cursor: pointer; list-style: none; }
.listener-project summary::-webkit-details-marker { display: none; }
.project-summary-main { display: flex; align-items: center; gap: 9px; min-width: 0; }
.project-summary-main > span { display: flex; align-items: baseline; gap: 7px; }
.project-summary-main strong { font-size: .82rem; }
.project-summary-main small { color: var(--muted); font-size: .7rem; }
.project-chevron { display: inline-flex; align-items: center; justify-content: center; align-self: center; width: 18px; height: 18px; color: var(--muted); font-size: 0; line-height: 1; transition: transform .15s ease; }
.project-chevron::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.listener-project[open] .project-chevron { transform: rotate(180deg); }
.listener-project .listener-grid { max-height: none; padding: 5px 8px 7px 28px; }

@media (max-width: 900px) {
  .nested-access { margin-left: 15px; padding-left: 12px; }
  .nested-access .listener-grid { grid-template-columns: 1fr; }
  .nested-access-heading { align-items: flex-start; flex-direction: column; }
}
.danger-choice { border-color: var(--line); }
.danger-choice:has(input:checked) { border-color: color-mix(in srgb, #d92d20 68%, var(--line)); background: color-mix(in srgb, #d92d20 11%, var(--panel)); }
.login-theme-toggle { position: fixed; top: 20px; right: 20px; z-index: 2; }

@media (max-width: 980px) {
  .site-header { padding-inline: 12px; }
  .nav-group-label, .account-trigger-copy { display: none; }
  .site-nav { max-width: min(52vw, 500px); overflow-x: auto; }
  .admin-nav-link { padding-inline: 8px; }
  .user-row { grid-template-columns: minmax(200px, 1fr) 1.4fr auto; padding-inline: 0; }
}

@media (max-width: 900px) {
  .brand-mark { display: block; font-size: .94rem; letter-spacing: .04em; }
  .brand { padding-right: 2px; }
  .header-actions { gap: 6px; }
  .site-nav { max-width: calc(100vw - 154px); gap: 2px; }
  .site-nav a { padding-inline: 8px; font-size: .78rem; }
  .admin-nav-link { display: none; }
  .theme-toggle { width: 34px; min-width: 34px; height: 34px; }
  .admin-heading { align-items: stretch; flex-direction: column; padding: 8px 0 20px; }
  .admin-summary { padding-inline: 0; }
  .user-row { grid-template-columns: 1fr; gap: 12px; padding: 16px 0; }
  .user-actions { justify-content: flex-start; }
  .choice-grid, .listener-grid, .form-grid.two-up { grid-template-columns: 1fr; }
  .listener-grid { max-height: 190px; }
}

/* Classic liquid-glass header */
.g10-raw-panel > summary > span { display: inline-grid; gap: 3px; }


.site-header {
  border-bottom: 1px solid color-mix(in srgb, var(--nav-glass-line) 62%, transparent);
  background: var(--nav-glass-bg);
  box-shadow: var(--nav-glass-shadow);
  backdrop-filter: var(--nav-glass-filter);
  -webkit-backdrop-filter: var(--nav-glass-filter);
}
.header-actions { gap: 16px; }
.site-nav { gap: 24px; max-width: none; overflow: visible; padding: 0; border: 0; border-radius: 0; background: transparent; }
.site-nav a { min-height: 40px; padding: 0; border-radius: 0; color: var(--muted); font-size: .92rem; background: transparent; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); background: transparent; }
.account-actions { flex: 0 0 auto; }
.account-trigger { display: grid; place-items: center; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; border: 1px solid var(--glass-line); border-radius: 999px; background: color-mix(in srgb, var(--surface) 22%, transparent 78%); box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 16%, transparent), 0 8px 26px rgba(0, 0, 0, .1); backdrop-filter: blur(22px) saturate(170%); -webkit-backdrop-filter: blur(22px) saturate(170%); }
.account-trigger:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--glass-line)); background: color-mix(in srgb, var(--surface) 40%, transparent 60%); }
.account-trigger .account-avatar { width: 32px; height: 32px; border-radius: 999px; }
.nav-toggle,
.account-trigger {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.nav-toggle:hover,
.account-trigger:hover,
.nav-toggle:active,
.account-trigger:active {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.account-popover { top: calc(100% + var(--nav-menu-gap)); width: min(300px, calc(100vw - 16px)); padding: 8px; border-color: color-mix(in srgb, var(--nav-glass-line) 62%, transparent); border-radius: 16px; background: var(--nav-glass-bg); box-shadow: 0 22px 60px rgba(0, 0, 0, .28), var(--nav-glass-shadow), inset 0 1px 0 color-mix(in srgb, #fff 12%, transparent); backdrop-filter: var(--nav-glass-filter); -webkit-backdrop-filter: var(--nav-glass-filter); }
.account-popover.account-popover-portal { position: fixed; right: auto; }
.account-popover button, .account-popover a { min-height: 48px; font-size: .9rem; }
.account-popover button:hover, .account-popover a:hover { background: color-mix(in srgb, var(--surface) 24%, transparent); }
.account-popover .menu-separator { background: var(--account-menu-separator); }
.account-menu-identity { display: flex; align-items: center; gap: 10px; padding: 8px; }
.account-menu-identity > span:last-child { display: grid; min-width: 0; }
.account-menu-identity strong { overflow: hidden; color: var(--ink); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-identity small { color: var(--muted); font-size: .72rem; }
.menu-icon { display: inline-grid; place-items: center; width: 22px; color: var(--muted); font-size: 1rem; }
.tool-menu { display: none; }

@media (max-width: 1350px) {
  .site-header { padding-inline: 12px; }
  .brand-mark { display: block; }
  .brand { padding-right: 6px; }
  .header-actions { gap: 9px; }
  /* One Switch Tool component for tablet and mobile. The mobile
     presentation is the source of truth throughout this range. */
  .nav-toggle { display: inline-grid; place-items: center; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; }
  .nav-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .site-nav { display: none; }
  .tool-menu { position: fixed; inset: calc(var(--app-header-height) + env(safe-area-inset-top) + var(--nav-menu-gap)) var(--nav-menu-gutter) auto auto; z-index: 70; display: grid; width: min(300px, calc(100vw - 2 * var(--nav-menu-gutter))); max-height: calc(100dvh - var(--app-header-height) - env(safe-area-inset-top) - 16px); padding: 8px; overflow: auto; border: 1px solid color-mix(in srgb, var(--nav-glass-line) 62%, transparent); border-radius: 16px; background: color-mix(in srgb, var(--header-bg) 78%, transparent 22%); box-shadow: 0 22px 60px rgba(0, 0, 0, .28), var(--nav-glass-shadow), inset 0 1px 0 color-mix(in srgb, #fff 12%, transparent); opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-8px) scale(.985); transform-origin: top right; transition: opacity .16s ease, transform .16s ease, visibility .16s ease; backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%); }
  .tool-menu.is-open { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }
  .tool-menu::before { content: "Switch tool"; display: flex; align-items: center; min-height: 48px; padding: 0 10px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
  .tool-menu a { display: flex; align-items: center; justify-content: flex-start; min-height: 48px; padding: 0 10px; border: 0; border-radius: 8px; color: var(--ink); background: transparent; box-shadow: none; font-size: .9rem; font-weight: 700; text-align: left; text-decoration: none; white-space: nowrap; }
  .tool-menu a:hover { color: var(--ink); background: color-mix(in srgb, var(--surface) 24%, transparent); }
  .tool-menu a[aria-current="page"] { color: var(--accent-strong); background: var(--accent-soft); }
  .tool-menu a[aria-current="page"]::after { content: "Current"; margin-left: auto; color: var(--muted); font-size: .68rem; font-weight: 700; }
  .account-trigger { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .account-trigger .account-avatar { width: 32px; height: 32px; }
}

@media (max-width: 900px) {
  .brand { gap: 7px; padding-left: 2px; }
  .brand-icon { width: 32px; height: 32px; }
  .brand-mark { font-size: .94rem; }
}

.mobile-module-nav { display: none; }

/* One canonical mobile experience. Tablet and desktop stay unchanged. */
@media (max-width: 900px) {
  :root {
    --app-header-height: 58px;
    --header-safe-top: calc(var(--app-header-height) + env(safe-area-inset-top) + 12px);
    --page-gutter: 12px;
    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 12px;
    --plc-icon-button-size: 44px;
    --plc-row-icon-button-size: 44px;
    --mobile-module-tab-height: 50px;
    --mobile-module-nav-padding: 4px;
    --mobile-module-content-gap: 8px;
    --mobile-module-nav-height: calc(var(--mobile-module-tab-height) + var(--mobile-module-nav-padding) + var(--mobile-module-nav-padding) + env(safe-area-inset-bottom) + 1px);
    --nav-glass-bg: color-mix(in srgb, var(--header-bg) 78%, transparent 22%);
    --nav-glass-filter: blur(24px) saturate(180%);
    --app-mobile-height: 100dvh;
  }

  :root.pwa-ios-standalone { --app-mobile-height: 100lvh; }

  html {
    -webkit-text-size-adjust: 100%;
  }
  html:has(body.modbus-page),
  html:has(body.log-viewer-page),
  html:has(body.plc-builder-page),
  html:has(body.g10-page) {
    /* Color any OS-owned edge below the layout like the bottom glass bar. */
    background: color-mix(in srgb, var(--panel-strong) 90%, transparent 10%);
  }
  body { padding-bottom: env(safe-area-inset-bottom); }
  body.modbus-page, body.log-viewer-page, body.plc-builder-page, body.g10-page {
    /* Do not reserve the fixed bar on body itself. iOS standalone mode uses
       body padding when resolving bottom: 0 before its first viewport reflow,
       which lifts the bar by exactly one navbar height. */
    padding-bottom: 0;
    scrollbar-width: none;
  }
  body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page)::-webkit-scrollbar { display: none; }
  body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    z-index: 19;
    height: calc(var(--app-header-height) + env(safe-area-inset-top));
    border-bottom: 1px solid color-mix(in srgb, var(--nav-glass-line) 62%, transparent);
    background: var(--nav-glass-bg);
    box-shadow: var(--nav-glass-shadow);
    pointer-events: none;
    backdrop-filter: var(--nav-glass-filter);
    -webkit-backdrop-filter: var(--nav-glass-filter);
  }
  body:has(.auth-page)::before { content: none; }
  h1 { font-size: clamp(1.7rem, 8vw, 2.15rem); line-height: 1.08; }
  h2 { font-size: 1.08rem; }

  .site-shell { width: 100%; padding-inline: var(--page-gutter); }
  .site-header {
    min-height: calc(var(--app-header-height) + env(safe-area-inset-top));
    padding: calc(7px + env(safe-area-inset-top)) 12px 7px;
    border-bottom: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .brand { min-height: 44px; padding: 4px; }
  .brand-icon { width: 32px; height: 32px; border-radius: 10px; }
  .brand-mark { display: block; font-size: .94rem; letter-spacing: .04em; }
  .header-actions { gap: 8px; }
  .nav-toggle, .account-trigger {
    width: 44px; min-width: 44px; height: 44px; min-height: 44px;
    border: 0; border-radius: 0; background: transparent; box-shadow: none;
  }
  .nav-toggle:hover, .account-trigger:hover,
  .nav-toggle:active, .account-trigger:active {
    border-color: transparent; background: transparent; box-shadow: none;
  }
  .account-trigger .account-avatar { width: 32px; height: 32px; }

  button, .button, input, select { min-height: 44px; }
  input, select, textarea { max-width: 100%; font-size: 16px; border-radius: 11px; }
  button, .button { padding: 9px 14px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; }
  .inline-checkbox { min-height: 44px; }
  .section-heading, .toolbar { gap: 10px; }
  .panel { border-radius: var(--radius-lg); box-shadow: none; }

  .mobile-module-nav {
    position: absolute;
    inset: auto 0 0;
    z-index: 18;
    display: grid; grid-template-columns: repeat(var(--mobile-module-count), minmax(0, 1fr)); gap: 2px;
    width: 100%; max-width: 100vw; margin: 0;
    padding: var(--mobile-module-nav-padding) max(6px, env(safe-area-inset-right)) calc(var(--mobile-module-nav-padding) + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    overflow: hidden;
    border: 0; border-top: 1px solid color-mix(in srgb, var(--nav-glass-line) 62%, transparent);
    border-radius: 0; background: var(--nav-glass-bg);
    box-shadow: var(--nav-glass-bottom-shadow);
    isolation: isolate;
    transition: opacity 80ms ease-out;
    backdrop-filter: var(--nav-glass-filter); -webkit-backdrop-filter: var(--nav-glass-filter);
  }
  @media (display-mode: standalone) {
    :root:not(.pwa-ios-standalone) .mobile-module-nav {
      position: static;
    }
  }
  .mobile-module-nav.is-pwa-settling {
    opacity: 0;
    pointer-events: none;
    transition: none;
  }
  html.mobile-keyboard-open .mobile-module-nav {
    opacity: 0;
    pointer-events: none;
  }
  .mobile-module-tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    width: 100%; min-width: 0; min-height: var(--mobile-module-tab-height); padding: 4px 3px;
    border-color: transparent; border-radius: 0; color: var(--muted); background: transparent;
    font-size: .76rem; font-weight: 700; line-height: 1; box-shadow: none;
  }
  .mobile-module-tab-icon { display: grid; place-items: center; width: 22px; height: 22px; }
  .mobile-module-tab-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-module-tab-label { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-module-tab::before { content: none; }
  .mobile-module-tab:hover { border-color: transparent; color: var(--ink); background: transparent; }
  .mobile-module-tab.is-active { border-color: transparent; color: var(--accent-strong); background: transparent; font-weight: 800; }
  [data-mobile-module-hidden] { display: none !important; }
  .mobile-module:not(.mobile-module-active) { display: none !important; }
  .mobile-module-active { animation: mobile-module-enter .18s ease both; }
  @keyframes mobile-module-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

  /* The selected module is the phone page; an additional outer card only costs space. */
  body .mobile-module-active.panel,
  body .mobile-module-active > .panel {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  dialog,
  .account-dialog,
  .confirmation-dialog,
  .g10-settings-dialog,
  .cnc-editor-dialog {
    width: calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-width: none;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: auto;
    overflow: hidden;
    border-radius: 20px;
  }
  html:has(dialog[open]), body:has(dialog[open]) {
    overflow: hidden;
    overscroll-behavior: none;
  }
  .user-form {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 20px 16px;
  }
  .confirmation-form { max-height: none; padding: 20px 16px; }
  .dialog-close { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .dialog-actions {
    position: sticky;
    bottom: -20px;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 0 -16px -20px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--line);
    background: var(--panel);
  }
  .dialog-actions button { width: 100%; min-width: 0; }

  /* Home: list-like destinations are faster to scan than nested cards. */
  .home-hub { gap: 16px; padding-top: var(--header-safe-top); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .home-intro { padding: 4px 4px 8px; }
  .home-intro h1 { margin: 0 0 8px; }
  .home-copy { font-size: .94rem; line-height: 1.5; }
  .home-tool-grid { grid-template-columns: 1fr; gap: 8px; }
  .home-tool-grid .tool-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    height: 88px;
    min-height: 88px;
    padding: 12px 14px;
    gap: 12px;
    border-color: var(--line);
    border-radius: 14px;
    background: var(--surface);
  }
  .tool-card-main { display: grid; min-width: 0; gap: 3px; }
  .tool-card-main h2 { margin: 0; font-size: 1rem; }
  .tool-card-main p {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-size: .82rem;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .tool-card-footer { align-self: stretch; margin-top: 0; padding-top: 0; }
  .tool-card-open { font-size: .82rem; }

  /* Shared tool layout: one clear vertical task flow with flatter sections. */
  .modbus-layout, .log-viewer-layout, .plc-builder-layout, .g10-layout {
    gap: 10px; padding-top: var(--header-safe-top); padding-bottom: 12px;
  }
  .modbus-workspace, .plc-builder-workspace, .g10-workspace { gap: 10px; }
  .modbus-profile-sidebar, .log-control-panel, .plc-palette-panel, .g10-sidebar,
  .modbus-scroll-panel, .log-viewer-results, .plc-workspace-panel, .plc-code-panel,
  .g10-workspace > .panel { padding: 14px; }
  .section-heading { margin-bottom: 12px; }
  .form-grid, .form-grid.three-up, .form-grid.two-up { grid-template-columns: 1fr; gap: 10px; }
  .output { padding: 12px; border-radius: 12px; }
  .hex-box { padding: 12px; overflow-wrap: anywhere; }
  .meta-table { font-size: .78rem; }
  .meta-table td { padding: 8px 6px; }

  /* Modbus profiles use a simple full-width list on phones. */
  .modbus-profile-sidebar { display: block; }
  .modbus-page .site-shell {
    height: calc(100dvh - var(--mobile-module-nav-height));
    min-height: 0;
    overflow: hidden;
  }
  .modbus-page .modbus-layout {
    grid-template-rows: minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    padding-top: calc(var(--app-header-height) + env(safe-area-inset-top));
    padding-bottom: 0;
    align-items: stretch;
    overflow: hidden;
  }
  .modbus-page .modbus-workspace {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .modbus-page .modbus-pane-scroll.mobile-module-active,
  .modbus-page .modbus-profile-sidebar.mobile-module-active {
    height: 100%;
    min-height: 0;
    padding-top: 12px;
    padding-bottom: 8px;
    overflow-x: clip;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }
  .modbus-page .modbus-profile-sidebar.mobile-module-active {
    height: auto;
    align-self: stretch;
  }
  .modbus-profile-header { margin-bottom: 8px; }
  .profile-add-btn { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .modbus-profile-sidebar .profile-tabs {
    flex-direction: column;
    gap: 6px;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 0;
    scroll-snap-type: none;
  }
  .modbus-profile-sidebar .profile-tab {
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 48px;
    scroll-snap-align: none;
  }
  .profile-tab-close { width: 32px; min-width: 32px; height: 32px; min-height: 32px; }
  .write-composer-summary {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
  }
  .write-composer-actions {
    grid-column: auto;
    grid-row: auto;
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
  }
  .modbus-page .value-table:not([data-show-bits="true"]) {
    display: table;
    width: 100%;
    table-layout: fixed;
    white-space: normal;
  }
  .modbus-page .value-table:not([data-show-bits="true"]) th:nth-child(1),
  .modbus-page .value-table:not([data-show-bits="true"]) td:nth-child(1) { width: 15%; }
  .modbus-page .value-table:not([data-show-bits="true"]) th:nth-child(2),
  .modbus-page .value-table:not([data-show-bits="true"]) td:nth-child(2) { width: 35%; white-space: nowrap; }
  .modbus-page .value-table:not([data-show-bits="true"]) th:nth-child(3),
  .modbus-page .value-table:not([data-show-bits="true"]) td:nth-child(3) { width: 50%; overflow-wrap: anywhere; }
  /* Log viewer prioritizes the log surface and keeps secondary stats compact. */
  .log-viewer-page { overflow-x: clip; }
  .log-viewer-page .site-shell-log-viewer,
  .log-viewer-page .log-viewer-layout,
  .log-viewer-page .log-control-panel,
  .log-viewer-page .log-control-fields,
  .log-viewer-page .log-control-fields > div,
  .log-viewer-page .log-control-actions {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .log-viewer-page .log-control-panel { overflow-x: clip; }
  .log-viewer-page .log-control-panel input,
  .log-viewer-page .log-control-panel select { width: 100%; max-width: 100%; min-width: 0; }
  .log-control-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .log-control-actions button { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  .log-control-actions .status { grid-column: 1 / -1; margin-top: 2px; }
  .log-viewer-page .log-viewer-layout {
    height: calc(var(--app-mobile-height, 100dvh) - var(--mobile-module-nav-height));
    min-height: 0;
    padding-bottom: 8px;
  }
  .log-viewer-page .site-shell-log-viewer {
    height: calc(var(--app-mobile-height, 100dvh) - var(--mobile-module-nav-height));
    min-height: 0;
  }
  .log-viewer-results.mobile-module-active {
    width: 100vw;
    height: 100%;
    min-height: 0;
    margin-left: calc(-1 * var(--page-gutter));
    overflow: hidden;
  }
  .log-viewer-results .toolbar {
    flex: 0 0 auto;
    align-items: center;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    padding-left: var(--page-gutter);
    padding-right: 6px;
  }
  .log-viewer-results .toolbar h2 { font-size: .9rem; white-space: nowrap; }
  .log-viewer-results .toolbar-actions { width: auto; margin-left: auto; justify-content: flex-end; gap: 6px; }
  .log-viewer-results .toolbar-actions button { min-width: 70px; min-height: 40px; padding-inline: 10px; }
  .log-viewer-results .toolbar-actions .inline-checkbox { min-height: 40px; gap: 5px; font-size: .72rem; white-space: nowrap; }
  .log-viewer-results .log-frame { flex: 1 1 0; min-height: 0; }
  .log-viewer-page .log-surface {
    min-height: 0;
    margin-top: 6px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    font-size: .72rem;
  }
  .log-viewer-page .stats-grid {
    flex: 0 0 auto;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    margin-top: 0;
    border-top: 0;
  }
  .log-viewer-page .stat-card {
    min-width: 0;
    min-height: 48px;
    padding: 7px 6px;
    overflow: hidden;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .log-viewer-page .stat-card:last-child { border-right: 0; }
  .log-viewer-page .stat-label { overflow: hidden; font-size: .48rem; text-overflow: ellipsis; white-space: nowrap; }
  .log-viewer-page .stat-value { overflow: hidden; margin-top: 3px; font-size: .72rem; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
  .log-viewer-page .stat-delta { margin-left: 2px; font-size: .58rem; }

  /* CNC builder: tappable palette, stacked editing, actions that do not squeeze. */
  html:has(body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page)) {
    background: var(--bg);
  }
  html:root body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) {
    background: var(--bg);
  }
  body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) .site-shell,
  body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) :is(.modbus-layout, .log-viewer-layout, .plc-builder-layout, .g10-layout),
  body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) :is(.modbus-workspace, .plc-builder-workspace, .g10-workspace) {
    background: transparent;
  }
  html:has(body.plc-builder-page),
  html:root body.plc-builder-page {
    overflow-x: clip;
  }
  html:root body.plc-builder-page {
    overscroll-behavior-x: none;
  }
  .plc-builder-page .site-shell-plc-builder,
  .plc-builder-page .plc-builder-layout,
  .plc-builder-page .plc-builder-workspace,
  .plc-builder-page #workspaceScrollArea,
  .plc-builder-page .plc-workspace-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: transparent;
  }
  .plc-builder-page .plc-builder-layout {
    height: calc(100dvh - var(--mobile-module-nav-height));
    min-height: 0;
    padding-top: calc(var(--app-header-height) + env(safe-area-inset-top));
    padding-bottom: 0;
    align-items: stretch;
    overflow: hidden;
  }
  .plc-builder-page #workspaceScrollArea.mobile-module-active {
    overflow-x: clip;
    overscroll-behavior-x: none;
    touch-action: pan-y;
  }
  .plc-builder-page .plc-builder-workspace {
    height: 100%;
    min-height: 0;
  }
  .plc-builder-page .plc-builder-layout > .mobile-module-active,
  .plc-builder-page .plc-builder-workspace > .mobile-module-active {
    padding-top: 12px;
  }
  .plc-builder-page .plc-pane-scroll.mobile-module-active {
    height: 100%;
    min-height: 0;
    padding-bottom: 0;
    overflow-x: clip;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }
  .plc-builder-page #workspaceScrollArea.mobile-module-active .plc-workspace-panel {
    margin-bottom: 8px;
  }
  .plc-builder-page #workspaceScrollArea.mobile-module-active *,
  .plc-builder-page .plc-mobile-program-palette {
    max-width: 100%;
  }
  .plc-builder-page .plc-palette-panel.mobile-module-active {
    display: flex;
    align-self: stretch;
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }
  .plc-builder-page .plc-palette-panel.mobile-module-active .cnc-device-panel {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
  .plc-builder-page .plc-palette-panel.mobile-module-active .cnc-device-browser {
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    min-height: 0;
  }
  .plc-builder-page .plc-palette-panel.mobile-module-active .cnc-device-list {
    flex: 0 1 auto;
    min-height: 0;
    max-height: none;
  }
  .plc-builder-page .plc-palette-panel.mobile-module-active .cnc-device-panel > .status {
    margin-bottom: 8px;
  }
  .plc-builder-page .plc-builder-workspace:not(:has(> .mobile-module-active)) { display: none; }
  .plc-mobile-program-palette {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
  }
  .plc-mobile-program-palette .section-heading { margin-bottom: 10px; }
  .plc-block-palette { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .plc-palette-block { min-height: 48px; }
  .cnc-device-actions { grid-template-columns: 1fr 1fr; }
  .cnc-device-actions button { width: 100%; }
  .plc-workspace-panel > .toolbar { align-items: stretch; flex-direction: column; }
  .plc-workspace-panel > .toolbar .toolbar-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .plc-workspace-panel > .toolbar .toolbar-actions button { width: 100%; min-width: 0; min-height: 44px; padding-inline: 8px; }
  .plc-program-settings,
  .plc-block-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plc-program-settings input,
  .plc-block-form input { width: 100%; min-width: 0; }
  .plc-workspace-block { padding: 12px; box-shadow: none; }
  .plc-block-header { align-items: flex-start; }
  .plc-block-header > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
  }
  .plc-block-header h3 { overflow-wrap: anywhere; }
  .plc-block-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
  }
  .plc-event-action-row,
  .plc-condition-action-row {
    grid-template-columns: minmax(0, .85fr) minmax(0, 1fr) var(--plc-row-icon-button-size);
    gap: 6px;
  }
  .plc-event-action-row > div,
  .plc-condition-action-row > div { min-width: 0; }
  .plc-event-action-row input,
  .plc-condition-action-row input { width: 100%; min-width: 0; padding-inline: 8px; }
  .plc-event-action-row label,
  .plc-condition-action-row label { font-size: .72rem; }
  .plc-weekday-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .plc-weekday-option { min-height: 38px; }
  .plc-weekday-option span { font-size: .7rem; }
  .plc-compiler-metrics { grid-template-columns: 1fr 1fr; }
  .plc-import-dialog { width: calc(100vw - 16px); padding: 16px; border-radius: 18px; }

  /* G10: controls stay readable; register table remains a deliberate swipe surface. */
  .g10-page .g10-layout {
    height: calc(100dvh - var(--mobile-module-nav-height));
    min-height: 0;
    padding-top: calc(var(--app-header-height) + env(safe-area-inset-top));
    padding-bottom: 0;
    align-items: stretch;
    overflow: hidden;
  }
  .g10-page .site-shell {
    height: calc(100dvh - var(--mobile-module-nav-height));
    min-height: 0;
    padding-inline: 0;
    overflow: hidden;
  }
  .g10-page .g10-workspace {
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  .g10-page :is(.g10-sidebar, .g10-workspace > .panel, .g10-workspace > details).mobile-module-active {
    height: 100%;
    min-height: 0;
    padding-top: 12px;
    padding-bottom: 8px;
    overflow-x: clip;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }
  .g10-sidebar.mobile-module-active {
    position: static;
    display: grid;
    grid-template-rows: repeat(5, auto);
    align-content: start;
    align-self: start;
    height: 100%;
    min-height: 0;
    max-height: none;
  }
  .g10-sidebar.mobile-module-active,
  .g10-workspace > :is(article.panel, details).mobile-module-active {
    width: calc(100% - var(--page-gutter) * 2);
    margin-inline: var(--page-gutter);
  }
  .g10-workspace:not(:has(> .mobile-module-active)) { display: none; }
  .g10-registers-panel.mobile-module-active {
    width: 100%;
    max-width: none;
    margin: 0;
  }
  .g10-registers-panel.mobile-module-active > .g10-registers-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 10px;
    padding-inline: var(--page-gutter);
  }
  .g10-registers-panel.mobile-module-active #toggleRegisters {
    position: static;
    min-height: 32px;
    padding: 0 var(--page-gutter);
  }
  .g10-registers-panel.mobile-module-active #modbusStatus {
    margin-inline: var(--page-gutter);
  }
  .g10-device-list {
    min-height: 0;
    max-height: max(220px, calc(100dvh - 420px - env(safe-area-inset-bottom)));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .g10-heading-actions, .g10-register-summary-actions { gap: 8px; }
  .g10-register-summary-actions {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    width: 100%;
    margin: 0;
    padding-right: 0;
    justify-content: stretch;
  }
  .g10-register-summary-actions > .g10-toolbar {
    display: contents;
  }
  .g10-register-summary-actions #pollInterval { grid-column: 1 / 3; grid-row: 1; }
  .g10-register-summary-actions #bulkEditRegisters { grid-column: 3 / 5; grid-row: 1; }
  .g10-register-summary-actions #addRegister { grid-column: 5 / 7; grid-row: 1; }
  .g10-register-summary-actions .g10-poll-all-label { grid-column: 1 / 4; grid-row: 2; }
  .g10-register-summary-actions .inline-checkbox:not(.g10-poll-all-label) { grid-column: 4 / 7; grid-row: 2; }
  .g10-register-summary-actions > .g10-toolbar .g10-toolbar-button,
  .g10-register-summary-actions #pollInterval { width: 100%; min-width: 0; padding-inline: 8px; }
  .g10-toolbar-button { min-height: 44px; }
  .g10-register-summary-actions .inline-checkbox { justify-content: center; min-height: 40px; padding-inline: 0; }
  .g10-register-summary-actions #pollInterval,
  .g10-register-summary-actions #addRegister,
  .g10-register-summary-actions .g10-toolbar-button {
    height: 44px;
    min-height: 44px;
  }
  .g10-table-wrap {
    position: static;
    width: 100%;
    max-width: none;
    margin-inline: 0;
    padding: 0 0 8px;
    scroll-snap-type: x proximity;
    background: none;
    transform: none;
  }
  .g10-register-table { min-width: 1090px; }
  .g10-register-table tr { grid-template-columns: 52px 175px 120px 120px 165px 130px 92px 96px minmax(140px, 1fr); }
  .g10-register-table thead tr { min-height: 38px; align-items: stretch; }
  .g10-register-table thead th { display: flex; align-items: center; height: 38px; }
  .g10-register-table thead th:first-child { justify-content: center; }
  .g10-register-table th:nth-child(1), .g10-register-table td:nth-child(1) { order: 1; }
  .g10-register-table th:nth-child(2), .g10-register-table td:nth-child(2) { order: 2; }
  .g10-register-table th:nth-child(7), .g10-register-table td:nth-child(7) { order: 3; }
  .g10-register-table th:nth-child(8), .g10-register-table td:nth-child(8) { order: 4; }
  .g10-register-table th:nth-child(9), .g10-register-table td:nth-child(9) { order: 5; }
  .g10-register-table input,
  .g10-register-table select,
  .g10-register-table button,
  .g10-register-table textarea.g10-name,
  .g10-register-table .g10-config-trigger {
    height: 38px;
    min-height: 38px !important;
  }
  .g10-poll-cell,
  .g10-register-actions,
  .g10-row-tools,
  .g10-value,
  .g10-read-value,
  .g10-write-field { height: 38px; min-height: 38px; margin-block: 0; }
  .g10-row-tools .g10-action-button {
    flex: 0 0 38px;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px !important;
    padding: 0;
  }
  .g10-page #toggleRegisters,
  .g10-page #rawPanel > summary {
    pointer-events: none;
    cursor: default;
  }
  .g10-page #toggleRegisters::before,
  .g10-page #rawPanel > summary::before { display: none; }
  .g10-raw-command { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g10-raw-command #rawUartSettings,
  .g10-raw-command #rawFormat { height: 44px; min-height: 44px !important; }
  .g10-raw-command > :nth-child(3),
  .g10-raw-command > .g10-toolbar-button { grid-column: 1 / -1; }
  .g10-raw-command .g10-toolbar-button { width: 100%; }
  .g10-raw-panel.mobile-module-active {
    display: block;
    align-content: initial;
  }
  .g10-raw-panel.mobile-module-active > summary {
    min-height: 32px;
    padding: 0;
  }

  /* Admin/auth: reduce nesting and keep primary actions reachable. */
  .auth-page {
    min-height: 100dvh;
    place-items: center;
    padding: calc(24px + env(safe-area-inset-top)) 12px calc(24px + env(safe-area-inset-bottom));
  }
  .auth-card { padding: 20px 16px; border-radius: 18px; }
  .login-theme-toggle { top: calc(10px + env(safe-area-inset-top)); right: 12px; width: 44px; min-width: 44px; height: 44px; }
  .admin-page .site-shell {
    padding-top: var(--header-safe-top);
    padding-inline: 0;
  }
  .admin-page .admin-panel {
    width: 100%;
    max-width: none;
    margin-inline: 0;
  }
  .admin-heading { padding: 4px calc(var(--page-gutter) + 2px) 14px; }
  .admin-heading p { line-height: 1.45; }
  .admin-summary {
    width: 100%;
    margin-inline: 0;
    padding: 10px calc(var(--page-gutter) + 2px);
    background: transparent;
  }
  .admin-summary button { min-height: 44px; }
  .user-row { gap: 10px; padding: 14px calc(var(--page-gutter) + 2px); }
  .admin-page #adminStatus { margin-inline: calc(var(--page-gutter) + 2px); }
  .user-actions { display: grid; grid-template-columns: repeat(2, 44px); }
  .icon-action { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
  .choice-card { min-height: 56px; }
  .nested-access { margin-left: 9px; padding-left: 10px; }
  .nested-access-heading { gap: 8px; }
  .compact-actions button { min-height: 38px; }
}

/* The area below iOS's initial standalone visual viewport is painted by the
   root canvas, not body. This final rule must follow the mobile tool resets. */
@media (display-mode: standalone) and (max-width: 900px) {
  html:has(body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page)) {
    background: color-mix(in srgb, var(--panel-strong) 55%, var(--bg));
  }
}

/* Canonical app-header geometry. Keep this after tool and breakpoint rules so
   the NUTTERTOOLS brand has identical sizing and spacing on every page. */
.site-header {
  padding-inline: max(var(--page-gutter), calc((100vw - var(--content-width)) / 2 + var(--page-gutter)));
}
.site-header .brand {
  gap: 10px;
  min-height: 40px;
  max-width: none;
  padding: 4px 10px 4px 6px;
}
.site-header .brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}
.site-header .brand-mark {
  display: block;
  font-size: .94rem;
  letter-spacing: .04em;
}

/* Unified visual language --------------------------------------------------
   Every module uses the same three edge roles: outline for containers and
   controls, separator for content rows, and accent for interaction state. */
.site-header,
.mobile-module-nav {
  border-color: var(--separator);
}

.site-header {
  border-bottom: 1px solid var(--separator) !important;
}

.panel,
.tool-card,
.hero,
.profile-tabs-panel,
.stat-card,
.plc-workspace-block,
.plc-compiler-card,
.cnc-device-list,
.cnc-history-dialog,
.g10-settings-dialog,
.confirmation-dialog,
dialog,
.permission-details,
.listener-project,
.choice-card,
.listener-grid .listener-choice {
  border-color: var(--outline);
  box-shadow: none;
}

.panel,
.tool-card,
.hero {
  background: var(--surface-raised);
}

/* User management uses one continuous application canvas rather than the
   shared page gradient plus a raised content surface. */
.admin-page {
  background: var(--bg);
}

.admin-page .admin-panel {
  background: transparent;
}

input,
select,
textarea,
.button,
button,
.account-trigger,
.icon-action,
.g10-config-trigger,
.g10-action-button.icon-action,
.g10-bulk-reorder button,
.write-composer,
.write-byte-settings,
.write-bit-button,
.bit-chip,
.hex-box,
.output,
.log-surface {
  border-color: var(--outline);
  box-shadow: none;
}

.button:hover,
button:hover,
.button-secondary:hover,
button.secondary:hover,
.tool-card:hover,
.profile-tab:hover {
  border-color: var(--outline-strong);
}

input:focus,
select:focus,
textarea:focus,
.g10-register-table input:not([type="checkbox"]):focus,
.g10-register-table textarea.g10-name:focus,
.g10-register-table .g10-config-trigger:focus-visible,
.g10-register-table .g10-action-button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.section-heading,
.output-header,
.write-composer-summary,
.write-composer-column-head,
.write-composer-row,
.cnc-device-row,
.cnc-history-header,
.cnc-history-timeline,
.cnc-history-timeline-heading,
.cnc-history-entry,
.cnc-history-compare-controls,
.cnc-history-summary,
.g10-register-table th,
.g10-register-table td,
.g10-raw-response,
.g10-bulk-select-all,
.admin-summary,
.user-row,
.meta-table td,
.value-table th,
.value-table td {
  border-color: var(--separator);
}

.site-nav,
.account-popover {
  border-color: color-mix(in srgb, var(--nav-glass-line) 62%, transparent);
}

/* Buttons share one footprint and state model; icon-only controls use the
   same outline and radius without inheriting text-button padding. */
.button,
button {
  min-height: 38px;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.g10-toolbar-button,
.profile-add-btn,
.compact-actions button,
.request-copy-actions button,
.controls-row-actions button,
.dialog-actions button,
.toolbar-actions button {
  border-color: var(--outline);
  border-radius: var(--radius-sm);
}

#presetActions .g10-toolbar-button.is-delete {
  border-color: color-mix(in srgb, var(--danger) 56%, var(--outline));
  color: color-mix(in srgb, var(--danger) 82%, var(--muted));
  background: color-mix(in srgb, var(--danger) 9%, var(--panel-strong));
}

#presetActions .g10-toolbar-button.is-delete:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--danger) 72%, var(--outline));
  color: color-mix(in srgb, var(--danger) 90%, var(--ink));
  background: color-mix(in srgb, var(--danger) 14%, var(--panel-strong));
}

#presetActions .g10-toolbar-button.is-save {
  border-color: color-mix(in srgb, var(--accent) 56%, var(--outline));
  color: color-mix(in srgb, var(--accent-strong) 82%, var(--muted));
  background: color-mix(in srgb, var(--accent) 9%, var(--panel-strong));
}

#presetActions .g10-toolbar-button.is-save:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 72%, var(--outline));
  color: color-mix(in srgb, var(--accent-strong) 90%, var(--ink));
  background: color-mix(in srgb, var(--accent) 14%, var(--panel-strong));
}

:is(.dialog-close, .cnc-history-close, .icon-action, .g10-action-button.icon-action) {
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--button-secondary-bg);
  box-shadow: none;
}

:is(.dialog-close, .cnc-history-close) {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.plc-import-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

:is(.dialog-close, .cnc-history-close):hover {
  border-color: var(--outline-strong);
  color: var(--ink);
  background: var(--surface);
}

/* Dialogs now present the same shell in every tool. Native Escape dismissal,
   shared backdrop dismissal, and focus restoration are handled app-wide. */
dialog,
.cnc-history-dialog,
.g10-settings-dialog,
.confirmation-dialog,
.cnc-editor-dialog,
.account-dialog {
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(165%);
  -webkit-backdrop-filter: blur(24px) saturate(165%);
}

dialog::backdrop {
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.confirmation-form,
.user-form,
.plc-import-dialog {
  padding: var(--space-5);
}

.dialog-actions,
.controls-row-actions,
.plc-import-footer {
  gap: var(--space-2);
}

@media (max-width: 900px) {
  /* The glass canvas owns the mobile header separator. A border on both the
     canvas and header doubles its visual weight. */
  .site-header {
    border-bottom: 0 !important;
  }

  body::before {
    border-bottom: 1px solid var(--separator);
  }

  .mobile-module-nav {
    border-top: 1px solid var(--separator);
  }

  .panel,
  .tool-card,
  .hero {
    border-color: var(--outline);
  }
}

@media (max-width: 1350px) {
  .site-header { padding-inline: 12px; }
}

@media (max-width: 900px) {
  .site-header .brand {
    min-height: 44px;
    padding: 4px;
  }
}

/* Mobile tool scrollports extend beneath both glass bars. The document stays
   locked; only the active module scrolls. Insets on that module keep its first
   and last content reachable without reserving opaque space around the bars. */
@media (max-width: 900px) {
  html:has(body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page)) {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) {
    position: relative;
    width: 100%;
    height: var(--app-mobile-height);
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page)::before,
  body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) .site-header {
    position: absolute;
  }

  body:is(.modbus-page, .plc-builder-page, .g10-page) .site-shell,
  .plc-builder-page .plc-builder-layout,
  .g10-page .g10-layout {
    height: var(--app-mobile-height);
  }

  body:is(.modbus-page, .plc-builder-page, .g10-page)
    :is(.modbus-layout, .plc-builder-layout, .g10-layout) {
    padding-top: 0;
    padding-bottom: 0;
  }

  .modbus-page :is(.modbus-pane-scroll, .modbus-profile-sidebar).mobile-module-active,
  .plc-builder-page :is(.plc-pane-scroll, .plc-palette-panel).mobile-module-active,
  .g10-page :is(.g10-sidebar, .g10-workspace > .panel, .g10-workspace > details).mobile-module-active {
    box-sizing: border-box;
    height: 100%;
    padding-top: calc(var(--app-header-height) + env(safe-area-inset-top) + 12px);
    padding-bottom: calc(var(--mobile-module-nav-height) + 8px);
    scroll-padding-top: calc(var(--app-header-height) + env(safe-area-inset-top) + 12px);
    scroll-padding-bottom: calc(var(--mobile-module-nav-height) + 8px);
  }

  .plc-builder-page .plc-builder-layout > .mobile-module-active,
  .plc-builder-page .plc-builder-workspace > .mobile-module-active {
    padding-top: calc(var(--app-header-height) + env(safe-area-inset-top) + 12px);
  }

  /* Android standalone uses two real layout rows instead of overlaying the
     bottom tabs. The first row is the tool viewport and the second is the nav,
     so content cannot extend behind the bar. */
  @media (display-mode: standalone) {
    :root:not(.pwa-ios-standalone) body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) {
      display: grid;
      grid-template-rows: minmax(0, 1fr) auto;
    }

    :root:not(.pwa-ios-standalone) body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) .site-shell,
    :root:not(.pwa-ios-standalone) .modbus-page .modbus-layout,
    :root:not(.pwa-ios-standalone) .log-viewer-page .log-viewer-layout,
    :root:not(.pwa-ios-standalone) .plc-builder-page .plc-builder-layout,
    :root:not(.pwa-ios-standalone) .g10-page .g10-layout {
      height: 100%;
      min-height: 0;
    }

    :root:not(.pwa-ios-standalone) .mobile-module-nav {
      grid-row: 2;
      align-self: end;
    }

    :root:not(.pwa-ios-standalone) .modbus-page :is(.modbus-pane-scroll, .modbus-profile-sidebar).mobile-module-active,
    :root:not(.pwa-ios-standalone) .plc-builder-page :is(.plc-pane-scroll, .plc-palette-panel).mobile-module-active,
    :root:not(.pwa-ios-standalone) .g10-page :is(.g10-sidebar, .g10-workspace > .panel, .g10-workspace > details).mobile-module-active {
      padding-bottom: 8px;
      scroll-padding-bottom: 8px;
    }
  }

  :root.pwa-android-standalone body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  :root.pwa-android-standalone body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) .site-shell,
  :root.pwa-android-standalone .modbus-page .modbus-layout,
  :root.pwa-android-standalone .log-viewer-page .log-viewer-layout,
  :root.pwa-android-standalone .plc-builder-page .plc-builder-layout,
  :root.pwa-android-standalone .g10-page .g10-layout {
    height: 100%;
    min-height: 0;
  }

  :root.pwa-android-standalone .mobile-module-nav {
    position: static;
    grid-row: 2;
    align-self: end;
  }

  :root.pwa-android-standalone .modbus-page :is(.modbus-pane-scroll, .modbus-profile-sidebar).mobile-module-active,
  :root.pwa-android-standalone .plc-builder-page :is(.plc-pane-scroll, .plc-palette-panel).mobile-module-active,
  :root.pwa-android-standalone .g10-page :is(.g10-sidebar, .g10-workspace > .panel, .g10-workspace > details).mobile-module-active {
    padding-bottom: 8px;
    scroll-padding-bottom: 8px;
  }

  :root.pwa-android-standalone.mobile-keyboard-open body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) {
    grid-template-rows: minmax(0, 1fr);
  }

  :root.pwa-android-standalone.mobile-keyboard-open .mobile-module-nav {
    display: none;
  }
}

/* Data Composer operations use one balanced control system at every size. */
.modbus-page .write-byte-actions {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr 1.15fr;
  width: 100%;
  gap: 8px;
}

.modbus-page .write-operation-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
}

.modbus-page .write-operation-group:first-child {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.modbus-page .write-operation-symbols {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.modbus-page .write-byte-actions button,
.modbus-page .write-operation-symbols button {
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}

@media (min-width: 521px) and (max-width: 1350px) {
  .modbus-page .write-byte-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modbus-page .write-operation-group:first-child,
  .modbus-page .write-operation-symbols {
    grid-column: 1 / -1;
  }
}

/* Canonical mobile Data Composer: use the full card width and prioritize touch.
   These rules intentionally live after the generic responsive layout. */
@media (max-width: 900px) {
  .modbus-page .write-composer-summary {
    min-height: 52px;
    padding: 9px 12px;
  }

  .modbus-page .write-composer-row,
  .modbus-page .write-composer.single-write .write-composer-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) 36px;
    gap: 10px;
    padding: 12px;
    align-items: end;
  }

  .modbus-page .write-composer.single-write .write-composer-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modbus-page .write-composer-index {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 20px;
    place-items: center start;
  }

  .modbus-page .write-composer-row label:nth-of-type(1) {
    grid-column: 1;
    grid-row: 2;
  }

  .modbus-page .write-composer-row label:nth-of-type(2) {
    grid-column: 2;
    grid-row: 2;
  }

  .modbus-page .write-composer-row label:nth-of-type(3) {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .modbus-page .write-composer-row input,
  .modbus-page .write-composer-row input.mono {
    min-height: 44px;
    padding: 9px 10px;
    font-size: 0.84rem;
  }

  .modbus-page .write-byte-settings,
  .modbus-page .write-byte-settings[open] {
    grid-column: 1 / -1;
    grid-row: 4;
    width: 100%;
    min-width: 0;
    justify-self: stretch;
  }

  .modbus-page .write-byte-settings summary,
  .modbus-page .write-byte-settings[open] summary {
    width: 100%;
    min-height: 42px;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  .modbus-page .write-byte-panel {
    grid-column: 1 / -1;
    grid-row: 5;
    width: 100%;
    min-width: 0;
    padding: 10px;
    border: 1px solid color-mix(in srgb, var(--line) 72%, transparent 28%);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--panel-strong) 38%, transparent 62%);
  }

  .modbus-page .write-composer-remove {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .modbus-page .write-byte-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
    margin: 0 0 12px;
  }

  .modbus-page .write-operation-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    padding: 4px;
  }

  .modbus-page .write-operation-group:first-child,
  .modbus-page .write-operation-symbols {
    grid-column: 1 / -1;
  }

  .modbus-page .write-operation-group:first-child {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .modbus-page .write-operation-symbols {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .modbus-page .write-byte-actions button,
  .modbus-page .write-operation-symbols button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 7px 5px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .modbus-page .write-operation-symbols button {
    font-size: 1rem;
  }

  .modbus-page .write-bit-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    max-width: none;
    gap: 8px;
  }

  .modbus-page .write-bit-button {
    width: 100%;
    min-width: 0;
    min-height: 52px;
    height: 52px;
  }
}

/* Final composer geometry: the value controls are one stable toolbar in both
   collapsed and expanded states. Only the editor panel is allowed to wrap. */
.modbus-page .write-composer-column-head,
.modbus-page .write-composer-row,
.modbus-page .write-composer.single-write .write-composer-column-head,
.modbus-page .write-composer.single-write .write-composer-row {
  grid-template-columns:
    24px
    minmax(58px, 0.62fr)
    minmax(76px, 0.76fr)
    minmax(120px, 1.45fr)
    64px
    34px;
  gap: 6px;
}

.modbus-page .write-composer.single-write .write-composer-column-head,
.modbus-page .write-composer.single-write .write-composer-row {
  grid-template-columns:
    24px
    minmax(58px, 0.62fr)
    minmax(76px, 0.76fr)
    minmax(120px, 1.45fr)
    64px;
}

.modbus-page .write-composer-row label,
.modbus-page .write-composer-row label:nth-of-type(1),
.modbus-page .write-composer-row label:nth-of-type(2),
.modbus-page .write-composer-row label:nth-of-type(3) {
  grid-row: 1;
}

.modbus-page .write-composer-row label:nth-of-type(1) {
  grid-column: 2;
}

.modbus-page .write-composer-row label:nth-of-type(2) {
  grid-column: 3;
}

.modbus-page .write-composer-row label:nth-of-type(3) {
  grid-column: 4;
}

.modbus-page .write-byte-settings,
.modbus-page .write-byte-settings[open] {
  grid-column: 5;
  grid-row: 1;
  width: 100%;
  min-width: 0;
  justify-self: stretch;
}

.modbus-page .write-byte-settings summary,
.modbus-page .write-byte-settings[open] summary {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.modbus-page .write-composer-remove {
  grid-column: 6;
  grid-row: 1;
}

.modbus-page .write-byte-panel {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  min-width: 0;
}

@media (max-width: 900px) {
  .modbus-page .write-composer-column-head {
    display: none;
  }

  .modbus-page .write-composer-row,
  .modbus-page .write-composer.single-write .write-composer-row {
    grid-template-columns:
      18px
      minmax(42px, 0.58fr)
      minmax(58px, 0.72fr)
      minmax(92px, 1.5fr)
      54px
      32px;
    gap: 4px;
    padding: 9px 7px;
    align-items: end;
  }

  .modbus-page .write-composer.single-write .write-composer-row {
    grid-template-columns:
      18px
      minmax(42px, 0.58fr)
      minmax(58px, 0.72fr)
      minmax(92px, 1.5fr)
      54px;
  }

  .modbus-page .write-composer-index {
    grid-column: 1;
    grid-row: 1;
    min-height: 40px;
    place-items: center;
    font-size: 0.62rem;
  }

  .modbus-page .write-composer-row label,
  .modbus-page .write-composer-row label:nth-of-type(1),
  .modbus-page .write-composer-row label:nth-of-type(2),
  .modbus-page .write-composer-row label:nth-of-type(3) {
    grid-row: 1;
  }

  .modbus-page .write-composer-row label:nth-of-type(1) {
    grid-column: 2;
  }

  .modbus-page .write-composer-row label:nth-of-type(2) {
    grid-column: 3;
  }

  .modbus-page .write-composer-row label:nth-of-type(3) {
    grid-column: 4;
  }

  .modbus-page .write-composer-row label span {
    margin-left: 2px;
    font-size: 0.58rem;
  }

  .modbus-page .write-composer-row input,
  .modbus-page .write-composer-row input.mono {
    min-height: 40px;
    padding: 7px 6px;
    font-size: clamp(0.58rem, 2.8vw, 0.72rem);
  }

  .modbus-page .write-byte-settings,
  .modbus-page .write-byte-settings[open] {
    grid-column: 5;
    grid-row: 1;
  }

  .modbus-page .write-byte-settings summary,
  .modbus-page .write-byte-settings[open] summary {
    min-height: 40px;
    justify-content: center;
    padding: 5px 4px;
    font-size: 0.64rem;
  }

  .modbus-page .write-composer-remove {
    grid-column: 6;
    grid-row: 1;
    width: 32px;
    min-width: 32px;
    height: 40px;
    min-height: 40px;
  }

  .modbus-page .write-byte-panel {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 4px;
    padding: 8px;
  }

  .modbus-page .write-byte-actions {
    gap: 6px;
  }

  .modbus-page .write-byte-actions button,
  .modbus-page .write-operation-symbols button {
    min-height: 38px;
    font-size: 0.68rem;
  }

  .modbus-page .write-bit-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
  }

  .modbus-page .write-bit-button {
    min-height: 44px;
    height: 44px;
    padding-inline: 2px;
  }

  .modbus-page .write-bit-button span {
    font-size: 0.56rem;
  }

  .modbus-page .write-bit-button strong {
    font-size: 0.76rem;
  }
}

@media (max-width: 900px) {
  .modbus-page .write-composer-row,
  .modbus-page .write-composer.single-write .write-composer-row {
    grid-template-columns: 16px 40px 54px minmax(82px, 1fr) 48px 30px;
    gap: 3px;
    padding-inline: 5px;
  }

  .modbus-page .write-composer.single-write .write-composer-row {
    grid-template-columns: 16px 40px 54px minmax(82px, 1fr) 48px;
  }

  .modbus-page .write-byte-settings summary,
  .modbus-page .write-byte-settings[open] summary {
    font-size: 0.6rem;
  }
}

.modbus-page .write-byte-settings,
.modbus-page .write-byte-settings[open] {
  align-self: end;
}

@media (max-width: 1100px) {
  .g10-config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .g10-config-grid > .form-field:first-child {
    grid-column: 1 / -1;
  }

  .g10-preset-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .g10-timeout-field {
    max-width: none;
  }

  #presetActions {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  #presetActions > button {
    width: 100%;
    min-width: 0;
    padding-inline: 6px;
  }

  #newPreset { grid-column: 1 / 3; grid-row: 1; }
  #duplicatePreset { grid-column: 3 / 5; grid-row: 1; }
  #resetPreset { grid-column: 5 / 7; grid-row: 1; }
  #deletePreset { grid-column: 1 / 4; grid-row: 2; }
  #savePreset { grid-column: 4 / 7; grid-row: 2; }
  #deletePreset[hidden] ~ #savePreset { grid-column: 1 / 7; }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .g10-section-heading {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: start;
  }

  .g10-section-heading > h2 {
    white-space: nowrap;
  }

  .g10-config-grid > .form-field:first-child,
  .g10-config-grid > .form-field:first-child > .g10-preset-picker {
    display: contents;
  }

  .g10-config-grid > .form-field:first-child > label {
    grid-column: 1 / -1;
  }

  .g10-registers-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
    padding-top: 0;
  }


  .g10-register-summary-actions {
    display: grid;
    grid-template-columns: max-content max-content minmax(78px, 1fr) minmax(96px, 1fr) minmax(68px, .8fr);
    width: 100%;
    margin-left: 0;
    padding-right: 0;
    gap: 6px;
  }

  .g10-register-summary-actions > .g10-poll-all-label { grid-column: 1; grid-row: 1; }
  .g10-register-summary-actions > .inline-checkbox:not(.g10-poll-all-label) { grid-column: 2; grid-row: 1; }
  .g10-register-summary-actions > #pollInterval { grid-column: 3; grid-row: 1; width: 100%; }
  .g10-register-summary-actions > .g10-toolbar { display: contents; }
  .g10-register-summary-actions #bulkEditRegisters { grid-column: 4; grid-row: 1; width: 100%; padding-inline: 8px; }
  .g10-register-summary-actions #addRegister { grid-column: 5; grid-row: 1; width: 100%; padding-inline: 8px; }
}

@media (max-width: 900px) {
  .g10-config-grid,
  .g10-preset-picker {
    grid-template-columns: minmax(0, 1fr);
  }

  .g10-config-grid > .form-field:first-child {
    grid-column: auto;
  }

  .g10-config-grid :is(input, select, .input-with-unit),
  .g10-config-grid .input-with-unit > input {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
  }

  .g10-config-grid .input-with-unit {
    display: block;
  }
}

/* Mobile scrollports must reach the viewport edge. Horizontal breathing room
   belongs to the scrollport's padding, not to margins on the scrolling block;
   otherwise the native scrollbar is stranded inside the page gutter. */
@media (max-width: 900px) {
  body:is(.modbus-page, .log-viewer-page, .plc-builder-page, .g10-page) .site-shell {
    padding-inline: 0;
  }

  .modbus-page :is(.modbus-pane-scroll, .modbus-profile-sidebar).mobile-module-active,
  .log-viewer-page .log-control-panel.mobile-module-active,
  .plc-builder-page :is(.plc-pane-scroll, .plc-palette-panel).mobile-module-active,
  .g10-page :is(.g10-sidebar, .g10-workspace > .panel, .g10-workspace > details).mobile-module-active {
    width: 100%;
    max-width: none;
    margin-inline: 0;
    padding-inline: var(--page-gutter);
  }

  .log-viewer-page .log-viewer-results.mobile-module-active {
    width: 100%;
    max-width: none;
    margin-inline: 0;
  }

  /* The registers table is a horizontal data surface and should use every
     available pixel; its heading and controls keep their own content padding. */
  .g10-page .g10-workspace > .g10-registers-panel.mobile-module-active {
    padding-right: 0;
    padding-left: 0;
  }

  .plc-builder-page #workspaceScrollArea.mobile-module-active .plc-workspace-panel {
    margin-bottom: 0;
    padding-bottom: 8px;
  }
}

/* CNC Builder owns an inner tablet scrollport, unlike the document-scrolling
   Modbus tool. Let that scrollport reach the viewport edge and keep the visual
   left gutter as layout padding so the scrollbar is not inset. */
@media (min-width: 901px) and (max-width: 1350px) {
  .plc-builder-page .site-shell-plc-builder {
    padding-inline: 0;
  }

  .plc-builder-page .plc-builder-layout {
    padding-left: var(--page-gutter);
  }
}

/* A desktop column may be narrower than a tablet viewport. Reflow the editor
   by its own width so operation labels never become cramped. */
@container (max-width: 680px) {
  .modbus-page .write-byte-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modbus-page .write-operation-group:first-child,
  .modbus-page .write-operation-symbols {
    grid-column: 1 / -1;
  }
}

/* Keep keyboard focus visible without leaving rings after clicks or dialogs. */
html:not([data-keyboard-focus="true"]) :is(button, .button, [role="button"]):focus {
  outline: none !important;
  box-shadow: none !important;
}
html[data-keyboard-focus="true"] :is(button, .button, [role="button"]):focus-visible {
  outline: 2px solid currentColor !important;
  outline-offset: 2px;
}

.plc-port-control input.has-warning {
  border-color: color-mix(in srgb, var(--warn) 72%, var(--line) 28%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 13%, transparent 87%);
}

.plc-block-form:has(.plc-port-control) {
  align-items: start;
}
.plc-port-control select.has-error {
  border-color: color-mix(in srgb, var(--danger) 78%, var(--line) 22%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent 86%);
}

.plc-port-binding-form {
  grid-template-columns: 5rem minmax(0, 1fr);
}
.plc-port-control {
  grid-template-columns: minmax(0, 1fr);
  column-gap: var(--space-2);
}
.plc-port-control.is-custom {
  grid-template-columns: minmax(0, 1fr) 5rem;
}
.plc-port-select-field,
.plc-custom-port-field {
  display: grid;
  gap: var(--field-label-gap);
  min-width: 0;
}
.plc-port-control > small,
.plc-port-control > [data-port-warning] {
  grid-column: 1 / -1;
}
.plc-port-control select,
.plc-port-control input {
  min-width: 0;
  width: 100%;
}

.plc-event-action-row select,
.plc-condition-action-row select {
  width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
}

/* Give action targets and values equal space, including on narrow screens. */
.plc-event-action-row,
.plc-condition-action-row {
  grid-template-columns: repeat(2, minmax(0, 1fr)) var(--plc-row-icon-button-size);
}
.plc-block-form:has([data-field="value"]) {
  grid-template-columns: 5rem minmax(0, 1fr);
}

.plc-workspace-block.has-binding-warning {
  border-color: color-mix(in srgb, var(--warn) 72%, var(--line) 28%);
}
.plc-workspace-block.has-binding-warning select.has-warning {
  border-color: color-mix(in srgb, var(--warn) 72%, var(--line) 28%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 13%, transparent 87%);
}
.plc-binding-warnings { margin-top: var(--space-2); }

.cnc-generation-methods {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  border: 0;
  padding: 0;
  margin: 0;
}
.cnc-generation-methods legend {
  padding: 0;
  margin-bottom: var(--field-label-gap);
  color: var(--muted);
  font-size: var(--control-font-size);
  font-weight: 600;
}
.form-grid.cnc-generation-layout {
  grid-template-columns: minmax(0, 1fr);
}
.cnc-generation-methods.listener-grid {
  gap: 7px;
  max-height: none;
  overflow: visible;
}

.plc-condition-branch :is(input, select).has-warning:not(.has-error),
.plc-condition-action-row :is(input, select).has-warning:not(.has-error) {
  border-color: color-mix(in srgb, var(--warn) 72%, var(--line) 28%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 13%, transparent 87%);
}
.plc-condition-action-row > .plc-variable-use-warning {
  grid-column: 1 / -1;
  width: 100%;
}
.plc-condition-branch > div > .plc-variable-use-warning {
  margin-top: var(--space-2);
}

.cnc-code-comparison-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}
@media (max-width: 900px) {
  .plc-code-panel > .toolbar {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }
  .plc-code-panel > .toolbar .toolbar-block {
    flex: 1 1 auto;
    min-width: 0;
  }
  .plc-code-panel > .toolbar h2 {
    font-size: .9rem;
    white-space: normal;
  }
  .plc-code-panel .cnc-code-comparison-controls {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    width: auto;
    gap: 8px;
  }
  .cnc-code-comparison-controls .inline-checkbox {
    min-height: 44px;
    gap: 5px;
    font-size: .75rem;
    white-space: nowrap;
  }
  .cnc-code-comparison-controls button {
    min-height: 44px;
    min-width: 0;
    padding-inline: 8px;
    font-size: .75rem;
  }
}
.cnc-code-comparison-controls label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}
.cnc-generated-diff-frame {
  position: relative;
  margin-top: var(--space-3);
  margin-bottom: 0;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent 18%);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cnc-generated-diff {
  padding: var(--space-4) 0;
  max-height: calc(100dvh - 260px);
}
.cnc-generated-diff-counts {
  position: absolute;
  top: 8px;
  right: 12px;
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--log-bg) 82%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: .78rem;
  font-weight: 700;
  z-index: 1;
  pointer-events: none;
}
.cnc-generated-diff .cnc-diff-line {
  position: relative;
  grid-template-columns: 44px minmax(max-content, 1fr);
  min-height: 0;
  font-size: .84rem;
  line-height: 1.55;
}
.cnc-generated-diff .cnc-diff-line-number {
  padding: 0 10px;
}
.cnc-generated-diff .cnc-diff-marker {
  position: absolute;
  left: 44px;
  width: var(--space-4);
  padding: 0;
}
.cnc-generated-diff .cnc-diff-line code {
  padding: 0 var(--space-4);
}
.plc-condition-branch select.has-error,
.plc-condition-action-row select.has-error {
  border-color: color-mix(in srgb, var(--danger) 78%, var(--line) 22%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent 86%);
}

.plc-builder-page .plc-compiler-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}
.plc-builder-page .plc-compiler-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
}
.plc-builder-page .plc-compiler-header .status {
  flex-shrink: 0;
  margin-top: 0;
}
.cnc-mobile-code-spacer { display: none; }
@media (max-width: 900px) {
  .cnc-mobile-code-spacer {
    display: block;
    height: var(--cnc-mobile-code-spacer, 0px);
    pointer-events: none;
  }
  .plc-builder-page .plc-code-viewer {
    max-height: var(--cnc-mobile-code-height, calc(100dvh - 260px));
  }
  .plc-builder-page .cnc-generated-diff {
    max-height: calc(var(--cnc-mobile-code-height, calc(100dvh - 260px)) - 2px);
  }
}
@media (max-width: 600px) {
  .plc-builder-page .plc-compiler-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


.g10-traffic-header-actions {
  display: none;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  pointer-events: auto;
}
.g10-traffic-panel[open] > summary .g10-traffic-header-actions { display: flex; }
.g10-collapsible-panel[open] > summary:has(.g10-panel-header-actions)::before { margin-left: 6px; }
.g10-traffic-header-actions .inline-checkbox { white-space: nowrap; font-size: .8rem; }
.g10-traffic-header-actions button { min-height: 38px; }
.g10-traffic-content > .toolbar { margin-bottom: var(--space-3); }
.g10-traffic-entries { max-height: 60dvh; overflow: auto; }
@media (min-width: 901px) {
  .g10-traffic-entries { max-height: var(--g10-traffic-five-entry-height, 350px); }
}
.g10-traffic-entry { padding: 8px 10px; border: 0; }
.g10-traffic-entry + .g10-traffic-entry { border-top: 1px solid var(--line); }
.g10-traffic-entry > div { color: var(--muted); font-size: .75rem; margin-bottom: 4px; }
.g10-traffic-entry code { display: block; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8rem; }
.g10-traffic-entry.tx > div { color: var(--accent); }
.g10-traffic-entry.error > div { color: var(--danger); }

.g10-traffic-entry.rx > div { color: #60a5fa; }
.g10-traffic-entry.tx { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.g10-traffic-entry.rx { background: color-mix(in srgb, #60a5fa 4%, transparent); }
.g10-traffic-entry.error { background: color-mix(in srgb, var(--danger) 7%, transparent); }
.g10-page .g10-raw-response .hex-box,
.g10-page .g10-traffic-entries {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: .9rem;
  line-height: 1.65;
}
.g10-page .g10-traffic-entries {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.g10-traffic-entry > div { overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .g10-page .g10-traffic-panel.mobile-module-active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .g10-traffic-panel.mobile-module-active > summary {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 0;
    pointer-events: none;
    list-style: none;
  }
  .g10-traffic-panel.mobile-module-active > summary::before,
  .g10-traffic-panel.mobile-module-active > summary::after { display: none; }
  .g10-traffic-panel.mobile-module-active > summary::-webkit-details-marker { display: none; }
  .g10-traffic-panel.mobile-module-active .g10-traffic-header-actions {
    flex: 0 0 auto;
    gap: 8px;
    margin-left: auto;
  }
  .g10-traffic-panel.mobile-module-active .g10-traffic-header-actions .inline-checkbox {
    gap: 5px;
    font-size: .75rem;
  }
  .g10-traffic-panel.mobile-module-active .g10-traffic-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 10px;
  }
  .g10-traffic-panel.mobile-module-active .toolbar {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    margin-bottom: 0;
  }
  .g10-traffic-panel.mobile-module-active .toolbar .field-note {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: .72rem;
  }
  .g10-traffic-panel.mobile-module-active #clearTrafficLog { min-height: 44px; flex-shrink: 0; }
  .g10-traffic-panel.mobile-module-active .g10-traffic-entries {
    flex: 0 0 auto;
    min-height: 0;
    height: var(--g10-mobile-traffic-height, 50dvh);
    max-height: var(--g10-mobile-traffic-height, 50dvh);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

/* Response uses the same field and action pattern as the send controls. */
.g10-raw-response { grid-template-columns: 170px minmax(0, 1fr) auto; align-items: end; gap: var(--space-2); }
.g10-response-field { min-width: 0; }
.g10-response-label > label { margin: 0; }
.g10-raw-content > #rawStatus { margin-top: var(--space-2); }
.g10-response-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.g10-response-label .muted { font-size: .75rem; line-height: 1; }
.g10-page .g10-raw-response .g10-response-data { display: block; min-height: 38px; max-height: 280px; overflow: auto; padding: 7px 9px; background: var(--panel-strong); border-color: var(--line); font-size: .9rem; line-height: 1.5; }
.g10-response-data > code { display: block; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.g10-raw-response > .g10-toolbar-button { min-width: 85px; height: 38px; min-height: 38px; }
.g10-raw-response #rawOutputFormat { height: 38px; min-height: 38px; }
@media (max-width: 900px) {
  .g10-raw-response { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .g10-raw-response > .form-field:first-child { grid-column: 1; grid-row: 1; }
  .g10-raw-response > .g10-toolbar-button { grid-column: 2; grid-row: 1; width: 100%; height: 44px; min-height: 44px; }
  .g10-raw-response #rawOutputFormat { height: 44px; min-height: 44px; }
  .g10-response-field { grid-column: 1 / -1; grid-row: 2; }
  .g10-page .g10-raw-response .g10-response-data { min-height: 80px; max-height: 35dvh; }
}

/* Permission summaries and checkbox labels share one typography hierarchy. */
#userForm .choice-card {
  margin: 0;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 400;
  line-height: 1.3;
}
#userForm .choice-card > span:not(.permission-chevron) {
  display: grid;
  gap: 3px;
}
#userForm .choice-card strong {
  color: var(--ink);
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.3;
}
#userForm .choice-card small {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 400;
  line-height: 1.35;
}
#userForm .tool-choice {
  border: 0;
  min-height: 60px;
  padding: 11px 12px;
}
#userForm .listener-choice {
  margin: 0;
  color: var(--ink);
  font-size: .82rem;
  font-weight: 500;
  line-height: 1.3;
}
#userForm .project-summary-main strong {
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.3;
}

/* The stack owns row spacing; labels must not add their own bottom margin. */
#userForm {
  row-gap: 12px;
}
#userForm .permission-stack {
  gap: 8px;
}
#userForm .permission-stack > .permission-group {
  margin: 0;
  padding: 0;
  border: 1px solid var(--outline);
  border-radius: 11px;
  overflow: clip;
}
#userForm .tools-access-section {
  margin: 0;
}
#userForm > .danger-choice {
  margin-top: 8px;
}
