:root {
  color-scheme: light;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
    sans-serif;
  line-height: 1.5;
  font-weight: 400;
  --color-bg: #fdfbf3;
  --color-surface: #fffdf6;
  --color-border: #e5dcc3;
  --color-text: #1f2937;
  --color-muted: #8a7f66;
  --color-accent: #8c733a;
  --color-accent-soft: rgba(140, 115, 58, 0.12);
  --color-danger: #dc2626;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 4px 12px rgba(17, 24, 39, 0.08);
}

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  color: var(--color-text);
}

p {
  margin: 0;
  color: var(--color-muted);
}

[hidden] {
  display: none !important;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px clamp(24px, 5vw, 48px) 24px;
  background: linear-gradient(135deg, #f8f1da 0%, #fdf7e3 100%);
  border-bottom: 1px solid var(--color-border);
}

body {
  transition: background-color 0.3s ease;
}

body.modal-open {
  overflow: hidden;
}

body.state-connected {
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-border: #d9dfe7;
  --color-text: #1f2937;
  --color-muted: #6b7280;
  --color-accent: #2563eb;
  --color-accent-soft: rgba(37, 99, 235, 0.1);
}

body.state-connected .topbar {
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
}

.app-title h1 {
  font-size: clamp(24px, 4vw, 32px);
}

.app-title p {
  margin-top: 6px;
}

.connection-panel {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  border: 1px solid transparent;
  color: var(--color-muted);
}

.status-pill--disconnected {
  background: #fef2f2;
  border-color: rgba(220, 38, 38, 0.25);
  color: #b91c1c;
}

.status-pill--connecting {
  background: #fefce8;
  border-color: rgba(250, 204, 21, 0.35);
  color: #b45309;
}

.status-pill--disconnecting {
  background: #f0f9ff;
  border-color: rgba(56, 189, 248, 0.35);
  color: #0369a1;
}

.status-pill--connected {
  background: #ecfdf3;
  border-color: rgba(34, 197, 94, 0.35);
  color: #15803d;
}

.status-pill .status-indicator {
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}

.connection-actions {
  display: flex;
  gap: 8px;
}

.language-switcher {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.language-switcher label {
  font-size: 12px;
  color: var(--color-muted);
}

.language-switcher select {
  min-width: 140px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: inherit;
}

.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 32px;
  padding: 32px clamp(24px, 5vw, 48px) 64px;
}

.side-panel {
  background: var(--color-surface);
  padding: 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.side-panel h2 {
  font-size: 18px;
}

.tab-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tab-button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 14px 16px;
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.tab-button .tab-label {
  font-weight: 600;
}

.tab-button .tab-desc {
  font-size: 13px;
  color: var(--color-muted);
}

.tab-button:hover {
  border-color: rgba(37, 99, 235, 0.5);
  transform: translateX(2px);
}

.tab-button.is-active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-soft);
  background: var(--color-accent-soft);
}

.tab-list li.is-hidden {
  display: none !important;
}

.tab-button.is-hidden {
  display: none !important;
}

.content-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 24px;
}

.tab-content.is-active {
  display: flex;
}

/* Hide the raw paste area and the parse/fetch buttons when controls should be hidden
   while keeping the rendered command area visible. */
.user-commands-section.hidden-controls .user-commands-controls {
  display: none !important;
}

.tab-content.is-hidden {
  display: none !important;
}

.tab-header h2 {
  font-size: 24px;
}

.tab-header p {
  margin-top: 8px;
  /* max-width: 640px; */
}

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

.command-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.command-tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--color-surface);
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(17, 24, 39, 0.05);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.command-tab {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.command-tab:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.command-tab.is-active {
  background: var(--color-accent);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid rgba(17, 24, 39, 0.05);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 200px;
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card.command-panel {
  display: none;
}

.card.command-panel.is-active {
  display: flex;
}

.storage-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.storage-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.storage-actions select {
  max-width: 240px;
}

.storage-actions small {
  font-size: 12px;
  color: var(--color-muted);
}

.filesystem-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.config-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.config-table-wrapper {
  margin-top: 8px;
}

.config-table {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  overflow: hidden;
}

.config-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(200px, 1.2fr) minmax(220px, 1.6fr) minmax(160px, 1fr);
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  align-items: flex-start;
}

.config-row.config-header {
  background: #f3f4f6;
  border-top: none;
  font-weight: 600;
  color: var(--color-muted);
}

.config-row.config-header .config-cell {
  flex-direction: row;
  align-items: center;
}

.config-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.config-name {
  font-weight: 600;
  word-break: break-all;
}

.config-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.config-status--stored {
  background: var(--color-accent);
  color: #ffffff;
}

.config-status--default {
  background: var(--color-border);
  color: var(--color-muted);
}

.config-input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
}

.config-input:disabled {
  background: #f3f4f6;
  color: var(--color-muted);
}

.config-default-hint {
  font-size: 12px;
  color: var(--color-muted);
}

.config-description-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
}

.config-description-text--empty {
  color: var(--color-muted);
  font-style: italic;
}

.config-description-lang {
  font-size: 11px;
  color: var(--color-muted);
  letter-spacing: 0.5px;
}

.config-cell--actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.config-cell--actions .btn {
  font-size: 13px;
  padding: 8px 14px;
}

.config-empty {
  margin-top: 16px;
  font-size: 14px;
  color: var(--color-muted);
}

@media (max-width: 960px) {
  .config-row {
    grid-template-columns: 1fr;
  }

  .config-cell--actions {
    justify-content: flex-start;
  }
}

.fs-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fs-list-header {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.fs-steps {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.6;
}

.fs-tree {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: white;
  padding: 12px;
  min-height: 180px;
  overflow: auto;
}

.fs-empty {
  margin: 0;
  color: var(--color-muted);
  font-size: 14px;
}

.fs-tree-list {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.fs-tree-item {
  margin: 2px 0;
}

.fs-node {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text);
}

.fs-node:hover {
  background: var(--color-accent-soft);
}

.fs-node.is-active {
  background: var(--color-accent);
  color: white;
}

.fs-tree-item.is-dir>.fs-node::before {
  content: '📁';
  font-size: 14px;
}

.fs-tree-item.is-file>.fs-node::before {
  content: '📄';
  font-size: 14px;
}

.fs-tree-item.is-dir>ul {
  margin-left: 16px;
  border-left: 1px dashed var(--color-border);
  padding-left: 12px;
}

.fs-detail-section {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fs-detail-section:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.fs-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fs-preview-text {
  margin: 0;
}

.fs-preview-image {
  align-self: flex-start;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: white;
}

.fs-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.fs-b64write-uploader {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fs-b64write-dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
  transition: border-color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.fs-b64write-dropzone p {
  margin: 0;
}

.fs-b64write-dropzone.is-active {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.08);
}

.fs-b64write-dropzone.is-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.fs-b64write-dropzone:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-soft);
}

.fs-b64write-filename {
  margin-top: 8px;
  font-size: 13px;
  color: var(--color-muted);
  word-break: break-word;
}

.fs-b64write-upload-actions {
  display: flex;
  justify-content: flex-end;
}

.fs-selected-path {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular,
    Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 14px;
  margin: 0;
}

.fs-hint {
  margin: 0;
  font-size: 13px;
  color: var(--color-muted);
}

.fs-hint--warning {
  background: #fef3c7;
  color: #b45309;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.result-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #f8fafc;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--color-muted);
}

.result-header-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.result-title {
  font-weight: 600;
  color: var(--color-text);
}

.result-raw {
  margin: 0;
  padding: 12px;
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular,
    Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow: auto;
}

[data-fs-b64-raw] {
  max-height: 320px;
}

.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.kv-table tr:nth-child(even) {
  background: #f3f4f6;
}

.kv-table th,
.kv-table td {
  padding: 8px 12px;
  text-align: left;
}

.kv-table th {
  width: 40%;
  font-weight: 600;
  color: var(--color-muted);
}

.card h3 {
  font-size: 18px;
}

.card p {
  font-size: 15px;
}

.card-actions {
  margin-top: auto;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  opacity: 1;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn.btn--inactive {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-primary {
  color: white;
  background: var(--color-accent);
}

.btn.btn-state-connecting {
  background: #facc15;
  color: #1f2937;
}

.btn.btn-state-disconnecting {
  background: #38bdf8;
  color: #082f49;
}

.btn.btn-state-connected {
  background: #22c55e;
  color: #052e16;
}

.btn.btn-state-idle {
  background: var(--color-accent);
  color: white;
}

.btn.btn-state-unsupported {
  background: #d1d5db;
  color: #111827;
}

.btn-outline {
  color: var(--color-accent);
  background: white;
  border: 1px solid var(--color-accent);
}

.btn-secondary {
  color: var(--color-muted);
  background: #e5e7eb;
}

.btn-danger {
  color: white;
  background: var(--color-danger);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
}

.form-field select,
.form-field input[type='range'],
.form-field input[type='text'],
.form-field input[type='number'],
.form-field textarea {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #f8fafc;
  font-size: 14px;
  color: var(--color-muted);
  resize: vertical;
}

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

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.peripherals-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.peripherals-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 16px;
}

@media (min-width: 640px) {
  .peripherals-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.peripherals-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.peripherals-card .card-actions {
  margin-top: 8px;
}

.peripherals-result {
  margin: 0;
  margin-top: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #f8fafc;
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  min-height: 48px;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular,
    Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.peripherals-result.is-content {
  color: var(--color-text);
}

.peripherals-result.is-pending {
  color: var(--color-accent);
}

.peripherals-result.is-error {
  color: var(--color-danger);
}

.peripherals-card h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.peripherals-placeholder {
  color: var(--color-muted);
  font-size: 13px;
}

.peripherals-value {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.peripherals-meta {
  margin: 0;
  font-size: 12px;
  color: var(--color-muted);
}

.peripherals-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip--muted {
  background: #e2e8f0;
  color: var(--color-muted);
}

.peripherals-alias-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.peripherals-alias-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.peripherals-alias-row.is-deny {
  border-style: solid;
  border-color: rgba(220, 38, 38, 0.4);
  background: rgba(254, 226, 226, 0.4);
}

.alias-pin {
  font-weight: 600;
  color: var(--color-text);
}

.alias-name {
  color: var(--color-muted);
}

.peripherals-alias-row.is-deny .alias-name {
  color: var(--color-danger);
}

.command-list {
  margin: 0;
  padding-left: 20px;
  color: var(--color-muted);
}

.placeholder-chart {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  background: repeating-linear-gradient(45deg,
      rgba(37, 99, 235, 0.04),
      rgba(37, 99, 235, 0.04) 10px,
      rgba(37, 99, 235, 0.08) 10px,
      rgba(37, 99, 235, 0.08) 20px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.data-table tr.is-mounted {
  background: var(--color-accent-soft);
}

.console-area {
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  padding: 16px;
  min-height: 140px;
  background: #0f172a;
  color: #f8fafc;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular,
    Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.console-area .console-output {
  width: 100%;
  text-align: left;
  white-space: pre-wrap;
  margin: 0;
  background: transparent;
  color: inherit;
}

.console-area--light {
  background: #f1f5f9;
  color: var(--color-muted);
  border-style: dashed;
}

.console-area--log {
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
  white-space: pre-wrap;
  overflow-y: auto;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.console-area--log .log-entry {
  width: 100%;
}

.console-area--log .log-entry--tx {
  color: #38bdf8;
}

.console-area--log .log-entry--rx {
  color: #f8fafc;
}

.console-area--log .log-entry--info {
  color: #cbd5f5;
}

.console-area--log .log-entry--error {
  color: #fca5a5;
}

.file-input-label {
  display: inline-flex;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border);
  background: #f8fafc;
  color: var(--color-muted);
  cursor: not-allowed;
}

.file-input-label input {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 2000;
}

.modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(88vh, 720px);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(17, 24, 39, 0.08);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}

.modal__header h2 {
  margin: 0;
  font-size: 20px;
}

.modal__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--color-text);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.modal__detail {
  font-size: 14px;
  color: var(--color-muted);
  word-break: break-word;
}

.modal__detail.is-hidden {
  display: none;
}

.modal__footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal__footer .btn {
  min-width: 120px;
}

.field-hint {
  margin-top: 4px;
  font-size: 13px;
  color: var(--color-muted);
}

.checkbox-field .checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
}

.checkbox-field input[type='checkbox'] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.firmware-summary,
.firmware-details,
.firmware-status {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: rgba(140, 115, 58, 0.06);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.state-connected .firmware-summary,
body.state-connected .firmware-details,
body.state-connected .firmware-status {
  background: rgba(37, 99, 235, 0.08);
}

.firmware-summary h3,
.firmware-details h3,
.firmware-details h4 {
  margin: 0;
  font-size: 16px;
  color: var(--color-text);
}

.firmware-detail-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.firmware-detail-list div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.firmware-detail-list dt {
  font-size: 13px;
  color: var(--color-muted);
}

.firmware-detail-list dd {
  margin: 0;
  font-weight: 600;
  color: var(--color-text);
}

.firmware-segments h4 {
  font-size: 15px;
  margin: 0 0 4px 0;
}

.firmware-segments ul {
  margin: 0;
  padding-left: 18px;
  color: var(--color-text);
  font-family: monospace;
  font-size: 13px;
  line-height: 1.5;
}

.flash-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text);
}

.flash-progress[hidden] {
  display: none;
}

.flash-progress progress {
  width: 100%;
  height: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.firmware-status .flash-log {
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border);
  padding: 12px;
  min-height: 120px;
  max-height: 200px;
  overflow: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  color: var(--color-text);
  white-space: pre-wrap;
}

@media (max-width: 600px) {
  .modal {
    padding: 16px;
  }

  .modal__dialog {
    padding: 20px;
    gap: 12px;
  }

  .modal__footer {
    flex-direction: column;
    align-items: stretch;
  }
}

.footer {
  padding: 24px clamp(24px, 5vw, 48px);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--color-muted);
}

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

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}

@media (max-width: 960px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: sticky;
    top: 0;
    z-index: 1;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 24px 20px 16px;
  }

  .main-layout {
    padding: 24px 20px 48px;
    gap: 24px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}
