.reading-progress { position: fixed; top: 0; left: 0; height: 3px; width: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, #007aff, #5856d6, #af52de); box-shadow: 0 1px 8px rgba(0, 122, 255, 0.45); z-index: 80; }
.reading-layout { width: min(1140px, calc(100% - 64px)); margin: auto; padding: 44px 0 88px; }
.article-header {
  max-width: 860px;
  margin-bottom: 32px;
  background: var(--raised-bg);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 24px;
  padding: 34px 40px;
  box-shadow: var(--panel-bevel), var(--shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.article-header h1 {
  margin: 16px 0 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif;
  font-size: clamp(30px, 3.8vw, 44px);
  line-height: 1.3;
  letter-spacing: -0.025em;
  font-weight: 750;
  color: var(--ink);
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12.5px;
}
.article-meta a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
  line-height: 1.2;
  padding: 3px 10px;
  border-radius: 9999px;
  background: var(--soft);
  border: 1px solid var(--line);
  transition: all 0.18s var(--ease-spring);
}
.article-meta a:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.description {
  font-size: 16.5px;
  line-height: 1.85;
  color: var(--muted);
  margin-top: 14px;
}
.reading-grid {
  display: grid;
  grid-template-columns: minmax(0, 770px) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
.reading-main {
  min-width: 0;
  background: var(--raised-bg);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 24px;
  padding: 44px 48px;
  box-shadow: var(--panel-bevel), var(--shadow);
}
.reading-sidebar {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 100px);
  z-index: 10;
}
.toc {
  position: static;
  max-height: calc(100vh - 240px);
  overflow: auto;
  background: var(--raised-bg);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 20px;
  padding: 20px 22px;
  font-size: 12.5px;
  box-shadow: var(--panel-bevel), var(--shadow-small);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.reading-sidebar > .toc:only-child { max-height: calc(100vh - 120px); }
.toc summary {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
  user-select: none;
}
.toc ol { margin: 0; padding: 0; list-style: none; }
.toc li { margin: 6px 0; line-height: 1.6; }
.toc .toc-sub { padding-left: 12px; font-size: 11.5px; }
.toc a {
  color: var(--muted);
  display: block;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.16s ease;
}
.toc a:hover {
  color: var(--ink);
  background: var(--soft);
}
.toc a[aria-current="location"] {
  color: var(--accent-dark);
  background: var(--soft);
  font-weight: 650;
}
.content {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  font-size: 17px;
  line-height: 1.85;
  overflow-wrap: anywhere;
  color: var(--content-copy);
}
.content > :first-child { margin-top: 0; }
.content h2 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-size: 26px;
  letter-spacing: -0.025em;
  font-weight: 750;
  margin: 48px 0 20px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.content h3 {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  font-size: 21px;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 32px 0 16px;
  color: var(--ink);
}
.content h4 {
  font-size: 18px;
  font-weight: 650;
  margin-top: 28px;
  color: var(--ink);
}
.content :is(h2,h3,h4) { scroll-margin-top: 130px; }
.content p { margin-bottom: 22px; }
.content li { margin-bottom: 8px; }
.content :is(ul,ol) { padding-left: 1.4em; }
.content a {
  color: var(--accent-dark);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.content a:hover {
  color: var(--accent);
  border-color: transparent;
}
.content img {
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: var(--shadow-small);
}
.content blockquote {
  margin: 28px 0;
  padding: 18px 24px;
  border-left: 4px solid var(--accent);
  background: var(--soft);
  font-size: 15.5px;
  color: var(--body-copy);
  border-radius: 16px;
  box-shadow: var(--panel-bevel), var(--shadow-small);
}
.content blockquote p:last-child { margin-bottom: 0; }
.content code {
  font-size: .85em;
  color: var(--inline-code);
  background: var(--alt-bg);
  padding: 3px 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
}
.content pre {
  margin: 0;
  padding: 20px 22px;
  overflow-x: auto;
  max-width: 100%;
  background: var(--code-bg);
  color: var(--code-ink);
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre;
  overflow-wrap: normal;
  border-radius: 0 0 18px 18px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.45);
}
.content pre code {
  padding: 0;
  color: inherit;
  background: none;
  font-size: inherit;
  white-space: pre;
  overflow-wrap: normal;
}
.content .highlighter-rouge { min-width: 0; margin: 28px 0; }
.code-block {
  min-width: 0;
  margin: 28px 0;
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--panel-bevel), var(--shadow);
}
.highlighter-rouge .code-block { margin: 0; }
.code-toolbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #181c24;
  color: #94a3b8;
  padding: 10px 16px;
  border-radius: 18px 18px 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font: 11.5px/1.5 var(--font-mono);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
/* macOS / iOS Sequoia Traffic Lights */
.code-toolbar::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 14px;
  border-radius: 50%;
  background: #ff5f56;
  box-shadow:
    16px 0 0 #ffbd2e,
    32px 0 0 #27c93f;
  flex: 0 0 auto;
}
.code-toolbar > span:first-of-type {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: #cbd5e1;
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
  max-width: 36%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.code-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  position: relative;
  z-index: 1;
}
.copy-code,
.code-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9999px;
  padding: 4px 11px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  min-height: 26px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.16s var(--ease-spring), background 0.16s ease, border-color 0.16s ease;
  user-select: none;
}
.copy-code:hover,
.code-toggle:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}
.copy-code:active,
.code-toggle:active {
  transform: scale(0.96) translateY(1px);
}
.copy-code:focus-visible,
.code-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.code-toggle-icon {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.code-block.is-collapsed .code-toggle-icon {
  transform: rotate(180deg);
}
.code-block.is-collapsed {
  margin: 18px 0;
}
.code-block.is-collapsed .code-toolbar {
  border-radius: 18px;
  border-bottom-color: transparent;
  cursor: pointer;
}
.code-block.is-collapsed .code-toolbar:hover {
  background: #1e232d;
}
.code-block.is-collapsed pre {
  display: none !important;
}
.content .table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin: 28px 0;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.content table {
  display: block;
  overflow: auto;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.7;
}
.content .table-scroll table {
  display: table;
  min-width: 100%;
}
.content th,
.content td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  min-width: 100px;
}
.content th {
  background: var(--alt-bg);
  color: var(--ink);
  font-weight: 650;
  font-size: 13px;
  letter-spacing: -0.01em;
}
.content tr:last-child td {
  border-bottom: 0;
}
.article-navigation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  border-top: 1px solid var(--line);
  margin-top: 50px;
  padding-top: 30px;
}
.article-navigation a {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: var(--raised-bg);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  padding: 18px 22px;
  box-shadow: var(--panel-bevel), var(--shadow-small);
  transition: transform 0.2s var(--ease-spring), border-color 0.2s ease, box-shadow 0.2s ease;
}
.article-navigation a:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--panel-bevel), var(--shadow);
}
.article-navigation a:active {
  transform: scale(0.98);
}
.article-navigation a:last-child { text-align: right; }
.article-navigation small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.article-context {
  margin-top: 36px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
  font-size: 13px;
}
.article-context p { margin-bottom: 12px; color: var(--muted); }
.article-context a {
  display: inline-block;
  color: var(--accent-dark);
  margin: 0 16px 10px 0;
  font-weight: 500;
  text-decoration: none;
}
.article-context a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  color: var(--accent-dark);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 9999px;
  background: var(--soft);
  border: 1px solid var(--line);
  transition: all 0.18s var(--ease-spring);
}
.back:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
@media(max-width:1000px) {
  .reading-grid { display: flex; flex-direction: column; gap: 28px; }
  .reading-sidebar { position: static; order: -1; width: 100%; max-height: none; display: flex; flex-direction: column; gap: 14px; }
  .toc {
    position: static;
    max-height: 350px;
    width: 100%;
    border-radius: 18px;
    padding: 16px 20px;
  }
  .toc summary { margin: 0; }
  .toc[open] summary { margin-bottom: 12px; }
  .reading-main { width: 100%; }
  .content { max-width: 760px; }
}
@media(max-width:620px) {
  .reading-layout { width: calc(100% - 24px); padding-top: 28px; }
  .article-header { padding: 24px 20px; border-radius: 20px; }
  .article-header h1 { font-size: 28px; }
  .description { font-size: 15px; }
  .reading-main { padding: 26px 20px; border-radius: 20px; }
  .content { font-size: 16px; line-height: 1.85; }
  .content h2 { font-size: 22px; }
  .content h3 { font-size: 19px; }
  .content pre { font-size: 12px; padding: 16px; border-radius: 0 0 14px 14px; }
  .code-block { border-radius: 14px; }
  .code-toolbar { border-radius: 14px 14px 0 0; }
  .code-block.is-collapsed .code-toolbar { border-radius: 14px; }
  .article-navigation { grid-template-columns: 1fr; gap: 12px; }
  .content blockquote { padding: 14px 18px; font-size: 14.5px; border-radius: 12px; }
}

/* ==========================================================================
   Article Interactive Widgets (FSM, NOR Flash 2PC, Ring Buffer Scheduler)
   ========================================================================== */
.article-interactive-widget {
  margin: 36px 0;
  border: 1px solid var(--glass-edge);
  border-radius: 20px;
  background: var(--raised-bg);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: var(--panel-bevel), var(--shadow);
  overflow: hidden;
  font-family: inherit;
}

.aiw-header {
  padding: 18px 24px;
  background: var(--alt-bg);
  border-bottom: 1px solid var(--line);
}

.aiw-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  color: var(--accent-dark);
  background: var(--panel);
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid var(--line);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.aiw-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 750;
  color: var(--ink);
  line-height: 1.35;
}

.aiw-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.aiw-body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.aiw-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  background: var(--subtle-bg);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.aiw-stat-item {
  display: flex;
  flex-direction: column;
  min-width: 100px;
  flex: 1 1 0;
}

.aiw-stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 2px;
}

.aiw-stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  font-family: ui-monospace, Consolas, monospace;
}

.aiw-stat-value.accent { color: var(--accent-dark); }
.aiw-stat-value.warn { color: var(--warm); }

.aiw-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.aiw-section-title .aiw-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.aiw-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.aiw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 9999px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--panel-bevel), 0 1.5px 3px rgba(0, 0, 0, 0.06);
  transition: all 0.18s var(--ease-spring);
  user-select: none;
}

.aiw-btn:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--soft);
  transform: translateY(-1px);
  box-shadow: var(--panel-bevel), 0 3px 8px rgba(0, 0, 0, 0.1);
}

.aiw-btn:active {
  transform: scale(0.96) translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.14);
}

.aiw-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.aiw-btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.aiw-btn.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: var(--on-accent);
}

.aiw-btn.warn {
  border-color: var(--warm);
  color: var(--warm);
}

.aiw-btn.warn:hover {
  background: rgba(217, 130, 43, 0.1);
}

.aiw-btn.danger {
  border-color: #d32f2f;
  color: #d32f2f;
}

.aiw-btn.danger:hover {
  background: rgba(211, 47, 47, 0.1);
}

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

.aiw-log-panel {
  display: flex;
  flex-direction: column;
}

.aiw-log {
  height: 135px;
  overflow-y: auto;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
  padding: 10px 14px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  scroll-behavior: smooth;
  border: 1px solid var(--line);
}

.aiw-log-line {
  margin-bottom: 2px;
  word-break: break-all;
}

.aiw-log-time {
  color: #78d5dc;
  margin-right: 6px;
}

.aiw-log-event {
  color: #f1a65a;
  font-weight: 600;
}

.aiw-log-success { color: #5fdba7; }
.aiw-log-warn { color: #f39c12; }
.aiw-log-error { color: #ff6b6b; font-weight: 700; }

/* FSM Specific Styles */
.fsm-states-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.fsm-state-card {
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  text-align: center;
  transition: all 180ms ease;
  position: relative;
}

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

.fsm-state-card.is-active .fsm-state-name {
  color: var(--accent-dark);
  font-weight: 800;
}

.fsm-state-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.fsm-state-loop {
  font-size: 10.5px;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
}

.fsm-active-tag {
  display: none;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--on-accent);
  margin-bottom: 4px;
}

.fsm-state-card.is-active .fsm-active-tag {
  display: inline-block;
}

.fsm-queue-box {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--subtle-bg);
}

.fsm-queue-slots {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.fsm-slot {
  min-height: 52px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  padding: 4px 2px;
  text-align: center;
  position: relative;
  font-family: ui-monospace, Consolas, monospace;
}

.fsm-slot.has-item {
  border-style: solid;
  border-color: var(--accent);
  background: var(--soft);
  font-weight: 600;
  color: var(--accent-dark);
}

.fsm-slot-idx {
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 2px;
}

.fsm-slot-ptr {
  position: absolute;
  top: -16px;
  font-size: 9px;
  font-weight: 800;
  color: var(--accent-dark);
  white-space: nowrap;
}

.fsm-table-container {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.fsm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-family: ui-monospace, Consolas, monospace;
}

.fsm-table th {
  position: sticky;
  top: 0;
  background: var(--alt-bg);
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-weight: 650;
  color: var(--ink);
}

.fsm-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--body-copy);
}

.fsm-table tr.is-matched {
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 750;
  outline: 1px solid var(--accent);
}

/* Flash Storage Specific Styles */
.flash-sector-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.flash-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.flash-slot {
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  cursor: pointer;
  text-align: center;
  transition: all 120ms ease;
  font-size: 11px;
  font-family: ui-monospace, Consolas, monospace;
}

.flash-slot:hover,
.flash-slot.is-selected {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
}

.flash-slot.erased {
  border-style: dashed;
  color: var(--muted);
  background: var(--subtle-bg);
}

.flash-slot.valid {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.flash-slot.pending {
  border-color: var(--warm);
  background: rgba(217, 130, 43, 0.08);
  color: var(--warm);
}

.flash-slot.tombstone {
  border-color: var(--line);
  color: var(--muted);
  text-decoration: line-through;
  opacity: 0.65;
}

.flash-slot.dirty {
  border-color: #d32f2f;
  background: rgba(211, 47, 47, 0.08);
  color: #d32f2f;
  font-weight: 700;
}

.flash-slot-num {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
}

.flash-slot-status {
  font-size: 9.5px;
  font-weight: 700;
}

.flash-inspector {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--subtle-bg);
}

.flash-fields-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: ui-monospace, Consolas, monospace;
  margin-top: 6px;
}

.flash-fields-table th,
.flash-fields-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

/* Scheduler Specific Styles */
.sched-levels-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.sched-level-card {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  position: relative;
  transition: all 120ms ease;
}

.sched-level-card.is-firing {
  border-color: var(--accent);
  background: var(--soft);
}

.sched-level-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sched-level-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  transition: all 80ms ease;
}

.sched-level-card.is-firing .sched-level-indicator {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.sched-level-title {
  font-size: 12px;
  font-weight: 750;
  color: var(--ink);
}

.sched-level-func {
  font-size: 10.5px;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--muted);
  margin-bottom: 4px;
}

.sched-level-meta {
  font-size: 10px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.sched-ring-box {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--subtle-bg);
}

.sched-ring-track {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.sched-ring-slot {
  min-height: 50px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  position: relative;
  font-family: ui-monospace, Consolas, monospace;
  padding: 2px;
  text-align: center;
}

.sched-ring-slot.has-item {
  border-style: solid;
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 600;
}

.sched-strip-box {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.sched-strip-bar {
  height: 10px;
  width: 100%;
  border-radius: 5px;
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  overflow: hidden;
  margin: 6px 0;
}

.sched-strip-fill {
  height: 100%;
  background: var(--accent);
  transition: width 100ms ease;
}

@media(max-width: 768px) {
  .fsm-states-grid,
  .sched-levels-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .fsm-queue-slots,
  .sched-ring-track {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media(max-width: 500px) {
  .fsm-states-grid,
  .sched-levels-grid {
    grid-template-columns: 1fr;
  }
  .fsm-queue-slots,
  .sched-ring-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ==========================================================================
   EEPROM Page Wrap-around & A/B Dual Slot Widget Styles
   ========================================================================== */
.eeprom-matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--subtle-bg);
  padding: 10px 12px;
}

.eeprom-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 530px;
}

.eeprom-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.eeprom-page-label {
  font-size: 10.5px;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--muted);
  width: 68px;
  flex-shrink: 0;
}

.eeprom-cell {
  width: 25px;
  height: 23px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-family: ui-monospace, Consolas, monospace;
  cursor: pointer;
  transition: all 120ms ease;
  user-select: none;
}

.eeprom-cell:hover,
.eeprom-cell.is-selected {
  outline: 2px solid var(--accent);
  z-index: 2;
}

.eeprom-cell.is-slot-a {
  border-left: 2px solid var(--accent);
}

.eeprom-cell.is-slot-b {
  border-left: 2px solid var(--warm);
}

.eeprom-cell.is-written {
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.eeprom-cell.is-corrupted {
  background: rgba(211, 47, 47, 0.15);
  color: #d32f2f;
  border-color: #d32f2f;
  font-weight: 750;
  animation: pulse-corrupt 1s infinite alternate;
}

@keyframes pulse-corrupt {
  from { background: rgba(211, 47, 47, 0.15); }
  to { background: rgba(211, 47, 47, 0.35); }
}

.eeprom-slot-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.eeprom-slot-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 650;
}

.eeprom-slot-badge.slot-a {
  border: 1px solid var(--accent);
  background: var(--soft);
  color: var(--accent-dark);
}

.eeprom-slot-badge.slot-b {
  border: 1px solid var(--warm);
  background: rgba(217, 130, 43, 0.1);
  color: var(--warm);
}

.eeprom-slot-badge.active-indicator {
  box-shadow: 0 0 0 2px var(--accent);
  font-weight: 800;
}

/* ==========================================================================
   RGB565 Diagnostic Laboratory Widget Styles
   ========================================================================== */
.rgb-lab-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.rgb-color-boxes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.rgb-color-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--panel);
  text-align: center;
}

.rgb-swatch {
  width: 100%;
  height: 68px;
  border-radius: 4px;
  border: 1px solid var(--line);
  margin: 8px 0;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.15);
  transition: background-color 150ms ease;
}

.rgb-bits-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  margin: 6px 0;
  flex-wrap: wrap;
}

.rgb-bit-pill {
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
}

.rgb-bit-r { background: rgba(235, 77, 75, 0.15); color: #d63031; }
.rgb-bit-g { background: rgba(46, 204, 113, 0.15); color: #27ae60; }
.rgb-bit-b { background: rgba(9, 132, 227, 0.15); color: #0984e3; }

.rgb-diag-box {
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--subtle-bg);
  font-size: 12.5px;
  line-height: 1.6;
}

.rgb-diag-box.alert {
  border-left: 4px solid var(--warm);
}

.rgb-fault-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rgb-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

/* ==========================================================================
   LCD Strip Rendering & Frame Snapshot Widget Styles
   ========================================================================== */
.strip-memory-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.strip-mem-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.strip-mem-card.bad {
  border-color: rgba(211, 47, 47, 0.4);
  background: rgba(211, 47, 47, 0.05);
}

.strip-mem-card.good {
  border-color: var(--accent);
  background: var(--soft);
}

.strip-mem-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.strip-mem-pill {
  font-size: 10px;
  font-weight: 750;
  font-family: ui-monospace, Consolas, monospace;
  padding: 2px 7px;
  border-radius: 999px;
}

.strip-mem-pill.bad {
  background: rgba(211, 47, 47, 0.14);
  color: #d32f2f;
}

.strip-mem-pill.good {
  background: var(--panel);
  color: var(--accent-dark);
  border: 1px solid var(--raised-border);
}

.strip-mem-val {
  font-size: 18px;
  font-weight: 800;
  font-family: ui-monospace, Consolas, monospace;
  margin: 2px 0;
}

.strip-mem-val small {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
}

.strip-mem-card.bad .strip-mem-val { color: #d32f2f; }
.strip-mem-card.good .strip-mem-val { color: var(--accent-dark); }

.strip-mem-bar {
  height: 6px;
  width: 100%;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.18);
  overflow: hidden;
  margin: 2px 0 4px;
}

.strip-mem-fill {
  height: 100%;
  border-radius: inherit;
}

.strip-mem-fill.bad { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.strip-mem-fill.good { background: var(--accent); }

.strip-mem-note {
  font-size: 11px;
  line-height: 1.45;
}

.strip-mem-note.bad { color: #d32f2f; }
.strip-mem-note.good { color: var(--accent-dark); }

.strip-reg-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 4px;
}

.strip-reg-item {
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.strip-reg-label {
  font-size: 10.5px;
  color: var(--muted);
}

.strip-reg-value {
  font-size: 12.5px;
  font-weight: 700;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--ink);
}

.strip-reg-value.accent { color: var(--accent-dark); }
.strip-reg-value.warn { color: #e84118; }
.strip-reg-value.pending { color: #f39c12; }

.strip-sim-container {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.strip-hardware-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 268px;
  flex-shrink: 0;
}

.strip-bezel-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 2px;
}

.strip-bezel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.strip-dma-badge {
  font-size: 9.5px;
  font-family: ui-monospace, monospace;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--soft);
  color: var(--accent-dark);
  border: 1px solid var(--raised-border);
  font-weight: 650;
  transition: all 150ms ease;
}

.strip-dma-badge.active {
  background: rgba(0, 229, 255, 0.2);
  color: #00e5ff;
  border-color: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.35);
}

.strip-screen-bezel {
  width: 260px;
  padding: 8px;
  background: linear-gradient(145deg, #18222b, #0d141a);
  border: 2px solid #283745;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  box-sizing: border-box;
}

.strip-screen-viewport {
  width: 240px;
  height: 320px;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #060b10;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
  margin: 0 auto;
  cursor: crosshair;
}

.strip-screen-canvas {
  width: 240px;
  height: 320px;
  display: block;
}

.strip-scan-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 8px;
  background: rgba(0, 229, 255, 0.26);
  border-top: 1px solid #00e5ff;
  border-bottom: 1px solid #00e5ff;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
  z-index: 10;
  transition: top 28ms linear;
}

.strip-scan-pill {
  position: absolute;
  right: 4px;
  top: -17px;
  font-size: 8.5px;
  font-weight: 700;
  color: #00e5ff;
  background: rgba(6, 11, 16, 0.94);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid rgba(0, 229, 255, 0.55);
  font-family: ui-monospace, monospace;
  white-space: nowrap;
  line-height: 1.3;
}

.strip-scan-pill.flip-below {
  top: 9px;
}

.strip-tear-seam {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  border-top: 1px dashed rgba(255, 71, 87, 0.9);
  z-index: 12;
  pointer-events: none;
}

.strip-tear-badge {
  position: absolute;
  right: 6px;
  top: -16px;
  font-size: 8.5px;
  font-weight: 750;
  color: #ff6b6b;
  background: rgba(9, 21, 34, 0.94);
  border: 1px solid rgba(255, 71, 87, 0.7);
  padding: 1.5px 6px;
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  line-height: 1.3;
  pointer-events: none;
}

.strip-tear-badge.flip-below {
  top: 3px;
}

.strip-sram-box {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-sizing: border-box;
}

.strip-sram-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 4px;
}

.strip-sram-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.strip-sram-tag {
  font-size: 9.5px;
  font-family: ui-monospace, monospace;
  color: var(--accent-dark);
  background: var(--soft);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.strip-sram-viewport {
  position: relative;
  width: 100%;
  height: 40px;
  border: 1px solid #283745;
  border-radius: 4px;
  background: #060b10;
  overflow: hidden;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
}

.strip-sram-viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 4px,
    rgba(255, 255, 255, 0.06) 4px,
    rgba(255, 255, 255, 0.06) 5px
  );
  pointer-events: none;
}

.strip-sram-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.strip-clip-diag {
  margin-top: 7px;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--ink);
  font-family: ui-monospace, Consolas, monospace;
}

.strip-sram-desc {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.45;
}

.strip-controls-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.strip-card-panel {
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

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

.strip-toggle-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--body-copy);
  cursor: pointer;
  user-select: none;
}

.strip-toggle-label input[type="checkbox"] {
  margin-top: 3.5px;
  flex-shrink: 0;
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.strip-toggle-label strong {
  color: var(--ink);
  font-weight: 700;
}

.strip-progress-grid {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr));
  gap: 3px;
  margin: 6px 0 8px;
}

.strip-prog-cell {
  height: 14px;
  border-radius: 2px;
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.strip-prog-cell:hover {
  transform: scaleY(1.25);
  border-color: var(--accent);
}

.strip-prog-cell.is-scanned {
  background: var(--soft);
  border-color: var(--raised-border);
}

.strip-prog-cell.is-current {
  background: #00e5ff;
  border-color: #00e5ff;
  box-shadow: 0 0 6px rgba(0, 229, 255, 0.65);
  transform: scaleY(1.25);
  z-index: 2;
}

.strip-prog-cell.is-torn-after {
  background: rgba(232, 65, 24, 0.22);
  border-color: rgba(232, 65, 24, 0.65);
}

.strip-prog-cell.is-tear-seam {
  background: #ff4757;
  border-color: #ff4757;
  box-shadow: 0 0 6px rgba(255, 71, 87, 0.8);
}

.strip-pipeline-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 6px 0;
}

.strip-stage {
  font-size: 10.5px;
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 5px;
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s ease;
}

.strip-stage.is-active {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 750;
}

.strip-ctrl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.strip-speed-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.strip-speed-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.aiw-select {
  padding: 4px 8px;
  font-size: 12px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  outline: none;
}

.aiw-select:focus {
  border-color: var(--accent);
}

/* Fallback & legacy styles */
.strip-screen {
  width: 240px;
  height: 320px;
  border: 2px solid var(--deep);
  border-radius: 6px;
  background: #000000;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  user-select: none;
  flex-shrink: 0;
}
.strip-band {
  position: absolute;
  left: 0;
  width: 100%;
  height: 8px;
  background: rgba(0, 229, 255, 0.28);
  border-top: 1px solid #00e5ff;
  border-bottom: 1px solid #00e5ff;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
  z-index: 10;
}
.strip-screen-val {
  font-size: 38px;
  font-weight: 800;
  font-family: ui-monospace, Consolas, monospace;
}
.strip-screen-val.is-torn {
  color: #e84118;
}

@media(max-width: 768px) {
  .rgb-lab-grid,
  .strip-sim-container,
  .strip-memory-compare {
    grid-template-columns: 1fr;
  }
  .strip-reg-stats,
  .strip-pipeline-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .strip-hardware-col {
    width: 100%;
  }
  .strip-screen-bezel {
    margin: 0 auto;
  }
}



/* ========================================================
   Interactive Widget: 1-bit Bitmap Font Pipeline Simulator
   ======================================================== */
.font-demo-root {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.font-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 1.2rem;
  overflow-x: auto;
}

.font-tab-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.font-tab-btn:hover {
  color: var(--ink);
}

.font-tab-btn.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.font-tab-panel {
  display: none;
}

.font-tab-panel.active {
  display: block;
}

/* Tab 1: Editor & Generator */
.font-editor-grid {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.font-grid-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.font-grid-16 {
  display: grid;
  grid-template-columns: repeat(16, 17px);
  grid-template-rows: repeat(16, 17px);
  gap: 1px;
  background: var(--line);
  padding: 2px;
  border: 2px solid var(--line);
  border-radius: 6px;
  user-select: none;
}

.font-pixel {
  width: 17px;
  height: 17px;
  background: var(--panel);
  cursor: pointer;
  transition: background 0.1s;
}

.font-pixel:hover {
  background: rgba(16, 185, 129, 0.25);
}

.font-pixel.on {
  background: #10b981;
}

.font-palette-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  justify-content: center;
}

.font-palette-btn {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 4px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}

.font-palette-btn:hover {
  background: var(--soft);
  border-color: var(--accent);
}

.font-preview-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--soft);
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  width: 100%;
  box-sizing: border-box;
}

.font-preview-canvas {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: #000;
  image-rendering: pixelated;
}

.font-preview-info {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
}

.font-preview-info span {
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 700;
  color: var(--accent-dark);
}

.font-c-export {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 12px;
  color: var(--code-ink);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  border: 1px solid var(--line);
}

.font-c-export pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Tab 2: Comparison */
.font-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.font-compare-card {
  padding: 1rem;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.font-compare-card.bad {
  border-top: 4px solid #ef4444;
}

.font-compare-card.good {
  border-top: 4px solid #10b981;
}

.font-compare-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.font-compare-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.font-compare-badge.bad {
  background: rgba(239, 68, 68, 0.15);
  color: var(--note);
}

.font-compare-badge.good {
  background: var(--soft);
  color: var(--accent-dark);
}

.font-zoom-canvas {
  width: 128px;
  height: 128px;
  border: 2px solid var(--line);
  margin: 0 auto;
  background: #111;
  image-rendering: pixelated;
  border-radius: 4px;
}

.font-compare-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* Tab 3: Binary Search */
.font-bsearch-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.font-bsearch-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.font-bsearch-input {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 14px;
  width: 100px;
}

.font-bsearch-bar-wrap {
  position: relative;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 10px;
  overflow: hidden;
}

.font-bsearch-bar {
  display: flex;
  gap: 2px;
  height: 36px;
  align-items: center;
}

.font-bsearch-cell {
  flex: 1;
  height: 100%;
  background: var(--line);
  border-radius: 2px;
  position: relative;
  transition: all 0.2s;
  cursor: pointer;
}

.font-bsearch-cell.active-range {
  background: rgba(16, 185, 129, 0.3);
}

.font-bsearch-cell.mid {
  background: #3b82f6 !important;
}

.font-bsearch-cell.found {
  background: #10b981 !important;
}

.font-bsearch-cell.eliminated {
  opacity: 0.25;
}

.font-bsearch-log {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 10px 14px;
  border-radius: 6px;
  line-height: 1.6;
  min-height: 80px;
}

/* ========================================================
   Interactive Widget: EtherCAT State Machine (ESM) Console
   ======================================================== */
.ecat-demo-root {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.esm-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  position: relative;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 4px;
}

.esm-node {
  flex: 1;
  min-width: 110px;
  background: var(--soft);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
  transition: all 0.25s ease;
  position: relative;
}

.esm-node.active {
  border-color: var(--accent);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

.esm-node.error {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.esm-node-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.esm-node-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 4px 0;
}

.esm-node-ch {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.esm-arrow {
  font-size: 18px;
  color: var(--muted);
  font-weight: 700;
}

.ecat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.ecat-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.ecat-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ecat-status-val {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--line);
  color: var(--ink);
}

.ecat-status-val.error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  font-weight: 700;
}

.ecat-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.ecat-btn {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

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

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

.ecat-btn.danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.ecat-btn.danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
}

.ecat-sm-table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
  margin-top: 8px;
}

.ecat-sm-table th,
.ecat-sm-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.ecat-sm-table th {
  color: var(--muted);
  font-weight: 600;
}

.ecat-sm-active {
  color: #10b981;
  font-weight: 700;
}

.ecat-sm-inactive {
  color: var(--muted);
}

.ecat-modules-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.ecat-module-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.ecat-module-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--ink);
}

.ecat-calc-summary {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.ecat-calc-summary strong {
  color: var(--accent-dark);
  font-family: ui-monospace, Consolas, monospace;
}

/* ========================================================
   Interactive Widget: W25Q128 Non-blocking Simulator
   ======================================================== */
.w25q-demo-root {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.w25q-meter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.25rem;
}

.w25q-meter-card {
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.w25q-meter-title {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.w25q-meter-val {
  font-size: 20px;
  font-weight: 800;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--ink);
}

.w25q-meter-bar {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.w25q-meter-fill {
  height: 100%;
  width: 0%;
  background: #10b981;
  transition: width 0.1s linear, background 0.2s ease;
}

.w25q-meter-fill.warn {
  background: #f59e0b;
}

.w25q-meter-fill.danger {
  background: #ef4444;
}

.w25q-chip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--subtle-bg);
  border-radius: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  color: var(--ink);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 10px;
}

.w25q-chip-state {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.w25q-led {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #555;
}

.w25q-led.active {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.w25q-led.busy {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.w25q-chip-flags {
  display: flex;
  gap: 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
}

.w25q-flag {
  color: #888;
}

.w25q-flag.on {
  color: #10b981;
  font-weight: 700;
}

.w25q-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 1.25rem;
}

.w25q-ctrl-card {
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.w25q-ctrl-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

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

.w25q-chunk-box {
  background: var(--soft);
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 1.25rem;
}

.w25q-chunk-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.w25q-chunk-track {
  display: flex;
  gap: 4px;
  height: 24px;
}

.w25q-chunk-segment {
  height: 100%;
  background: var(--line);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--ink);
  transition: all 0.2s;
}

.w25q-chunk-segment.active {
  background: #10b981;
  color: #fff;
  font-weight: 700;
}

@media(max-width: 768px) {
  .font-editor-grid,
  .font-compare-grid,
  .ecat-grid,
  .w25q-meter-grid,
  .w25q-actions-grid {
    grid-template-columns: 1fr;
  }
}
/* ==========================================================================
   N32G455 SPI & DMA 硬件仿真实验室 (spi-dma-demo-app)
   ========================================================================== */

.spi-dma-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.spi-dma-tab-btn {
  padding: 8px 16px;
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.spi-dma-tab-btn:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.spi-dma-tab-btn.is-active {
  background: var(--panel);
  color: var(--accent-dark);
  border-color: var(--accent);
  box-shadow: inset 0 2px 0 var(--accent), var(--shadow-small);
}

.spi-dma-view {
  display: block;
}

.spi-dma-view[hidden] {
  display: none !important;
}

/* 时钟拓扑 */
.spi-clock-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px;
  background: var(--alt-bg);
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-bottom: 22px;
  font-size: 13px;
  color: var(--ink);
}

.spi-clock-pill {
  padding: 4px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.spi-clock-pill strong {
  color: var(--accent-dark);
  font-family: ui-monospace, Consolas, monospace;
}

.spi-clock-arrow {
  color: var(--muted);
  font-weight: bold;
}

.spi-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.spi-card {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-small);
  transition: border-color 0.2s ease;
}

.spi-card:hover {
  border-color: var(--accent);
}

.spi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.spi-chip-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.spi-card-header h4 {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
}

.spi-mode-tag {
  font-size: 11px;
  font-family: ui-monospace, Consolas, monospace;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

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

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

.spi-select {
  padding: 6px 10px;
  font-size: 13px;
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.spi-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--raised-border);
}

.spi-metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  background: var(--subtle-bg);
  border-radius: 6px;
  border: 1px solid var(--line);
}

.spi-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spi-metric-label {
  font-size: 11px;
  color: var(--muted);
}

.spi-metric-val {
  font-size: 16px;
  font-weight: 750;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--ink);
}

.spi-eval {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--alt-bg);
}

.spi-eval-icon {
  font-size: 10px;
  margin-top: 2px;
}

.spi-eval-icon.success { color: #10b981; }
.spi-eval-icon.warn { color: var(--warm); }
.spi-eval-icon.danger { color: #ef4444; }

/* DMA 仲裁 */
.arbiter-overview {
  margin-bottom: 18px;
}

.dma-channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.dma-channel-card {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-small);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
}

.dma-channel-card.is-active-bus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--raised-border), 0 4px 12px rgba(15, 129, 141, 0.2);
  background: var(--soft);
}

.dma-ch-badge {
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  width: fit-content;
}

.prio-vhigh .dma-ch-badge { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.prio-high .dma-ch-badge { background: rgba(245, 158, 11, 0.15); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.3); }
.prio-med .dma-ch-badge { background: rgba(15, 129, 141, 0.15); color: var(--accent); border: 1px solid var(--raised-border); }

.dma-ch-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.dma-ch-meta {
  font-size: 11px;
  color: var(--muted);
}

.dma-progress-track {
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin: 4px 0;
}

.dma-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.15s ease;
}

.prio-vhigh .dma-progress-bar { background: #ef4444; }
.prio-high .dma-progress-bar { background: #f59e0b; }

.dma-ch-stat {
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
}

.dma-ch-stat span {
  font-weight: 700;
  color: var(--ink);
}

.dma-bus-section {
  padding: 16px;
  background: var(--alt-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
}

.dma-bus-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
}

.dma-current-owner {
  font-family: ui-monospace, Consolas, monospace;
  color: var(--accent-dark);
  font-size: 12px;
  background: var(--panel);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.dma-bus-slots {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
  height: 32px;
}

.dma-bus-slot {
  border-radius: 3px;
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--muted);
  transition: all 0.15s ease;
}

.dma-bus-slot.slot-ch4 { background: #ef4444; color: #fff; font-weight: 700; border-color: #dc2626; }
.dma-bus-slot.slot-ch5 { background: #f59e0b; color: #fff; font-weight: 700; border-color: #d97706; }
.dma-bus-slot.slot-ch2 { background: var(--accent); color: #fff; font-weight: 700; border-color: var(--accent-dark); }
.dma-bus-slot.slot-ch1 { background: #3b82f6; color: #fff; font-weight: 700; border-color: #2563eb; }

/* 避坑实验 */
.pitfall-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.pitfall-choice {
  text-align: left;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s ease;
}

.pitfall-choice strong {
  font-size: 14px;
  color: var(--ink);
}

.pitfall-choice span {
  font-size: 12px;
  color: var(--muted);
}

.pitfall-choice:hover {
  border-color: var(--accent);
}

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

.pitfall-display {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
}

.pitfall-registers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.reg-pill {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--code-ink);
}

.reg-pill.active {
  background: #10b981;
  color: #ffffff;
  border-color: #059669;
}

.reg-pill.danger.active {
  background: #ef4444;
  color: #ffffff;
  border-color: #dc2626;
  animation: pulse-danger 1s infinite alternate;
}

.reg-pill.warn.active {
  background: #f59e0b;
  color: #ffffff;
  border-color: #d97706;
}

@keyframes pulse-danger {
  from { opacity: 0.8; }
  to { opacity: 1; transform: scale(1.05); }
}

.pitfall-diagram {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.pitfall-desc {
  font-size: 13px;
  line-height: 1.7;
  color: var(--code-ink);
  opacity: 0.9;
  max-width: 650px;
}

@media(max-width: 768px) {
  .spi-cards-grid,
  .dma-channels-grid {
    grid-template-columns: 1fr;
  }
  .dma-bus-slots {
    grid-template-columns: repeat(8, 1fr);
    height: auto;
    gap: 4px;
  }
  .dma-bus-slot {
    height: 24px;
  }
}



/* ==========================================================================
   专题/系列阅读导航与紧凑分段进度条 (Series Context & Segmented Progress Bar)
   Inspired by Steph Ango & Eli Bendersky
   ========================================================================== */

.series-nav-top {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.series-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.series-nav-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.series-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--soft);
  color: var(--accent-dark);
  border: 1px solid var(--raised-border);
}

.series-title-link {
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: color 0.15s ease;
}

.series-title-link:hover {
  color: var(--accent);
}

.series-arrow {
  font-size: 11px;
  color: var(--muted);
}

.series-title-static {
  font-weight: 700;
  color: var(--ink);
}

.series-nav-status {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.series-progress-count strong {
  color: var(--accent-dark);
  font-weight: 750;
}

/* 下拉菜单 (Details) */
.series-dropdown {
  position: relative;
  display: inline-block;
}

.series-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 5px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  box-shadow: var(--shadow-small);
  transition: all 0.15s ease;
}

.series-dropdown-toggle::-webkit-details-marker {
  display: none;
}

.series-dropdown-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--alt-bg);
}

.series-dropdown[open] .series-dropdown-toggle {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent-dark);
}

.series-chevron {
  transition: transform 0.2s ease;
}

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

.series-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, calc(100vw - 48px));
  max-height: 380px;
  overflow-y: auto;
  background: var(--raised-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--panel-bevel), var(--shadow);
  padding: 12px;
  z-index: 100;
  animation: series-fade-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes series-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.series-dropdown-heading {
  font-size: 11px;
  font-weight: 750;
  color: var(--muted);
  text-transform: uppercase;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.series-dropdown-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.series-dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.45;
  transition: background 0.12s ease;
}

.series-dropdown-item:hover {
  background: var(--subtle-bg);
}

.series-dropdown-item.is-active {
  background: var(--soft);
  border-left: 2px solid var(--accent);
}

.series-item-num {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
  margin-top: 1px;
}

.series-dropdown-item.is-active .series-item-num {
  color: var(--accent-dark);
}

.series-item-link {
  color: var(--ink);
  text-decoration: none;
  flex: 1;
}

.series-item-link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.series-item-current {
  color: var(--ink);
  font-weight: 700;
  flex: 1;
}

.series-now-badge {
  display: inline-block;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
}

/* 分段式进度条 (Segmented Progress Track) */
.series-bar-container {
  width: 100%;
}

.series-segments-track {
  display: flex;
  gap: 5px;
  width: 100%;
  height: 8px;
  padding: 2px 0;
}

.series-segment {
  flex: 1;
  height: 100%;
  border-radius: 3px;
  background: var(--line);
  position: relative;
  display: block;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.series-segment-inner {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: inherit;
}

/* 已读/先前文章 */
.series-segment.is-completed {
  background: var(--soft);
  border: 1px solid var(--raised-border);
}

.series-segment.is-completed .series-segment-inner {
  background: var(--accent);
  opacity: 0.65;
}

.series-segment.is-completed:hover {
  transform: translateY(-1.5px);
  background: var(--accent);
}

.series-segment.is-completed:hover .series-segment-inner {
  opacity: 1;
}

/* 当前阅读中文章 (显著高亮与脉冲动效) */
.series-segment.is-current {
  background: var(--accent);
  cursor: default;
  box-shadow: 0 0 8px rgba(15, 129, 141, 0.45);
  transform: scaleY(1.25);
  z-index: 2;
}

.series-segment.is-current .series-segment-inner {
  background: linear-gradient(90deg, var(--accent), var(--warm));
}

/* 未读/后续文章 */
.series-segment.is-upcoming {
  background: var(--subtle-bg);
  border: 1px solid var(--line);
  opacity: 0.85;
}

.series-segment.is-upcoming:hover {
  transform: translateY(-1.5px);
  border-color: var(--accent);
  background: var(--soft);
}

/* 底部系列阅读路线与下一篇导引卡片 */
.series-nav-bottom {
  margin: 36px 0 24px;
  padding: 22px 24px;
  background: var(--alt-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-small);
}

.series-bottom-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.series-bottom-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.series-bottom-title-group h4 {
  margin: 0;
  font-size: 15px;
  color: var(--ink);
  font-weight: 750;
}

.series-bottom-title-group h4 small {
  font-weight: normal;
  color: var(--muted);
  font-size: 13px;
  margin-left: 4px;
}

.series-all-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-dark);
  text-decoration: none;
}

.series-all-link:hover {
  text-decoration: underline;
}

.series-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.series-step-card {
  padding: 14px 18px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  box-shadow: var(--shadow-small);
  transition: all 0.16s ease;
}

.series-step-card:not(.is-disabled):hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.series-step-card.is-disabled {
  opacity: 0.65;
  background: var(--subtle-bg);
  border-style: dashed;
  cursor: default;
}

.series-step-sub {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.series-step-card:not(.is-disabled):hover .series-step-sub {
  color: var(--accent-dark);
}

.series-step-title {
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  font-weight: 650;
}

@media(max-width: 640px) {
  .series-bottom-grid {
    grid-template-columns: 1fr;
  }
  .series-nav-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Small screens keep the reading column wide and auxiliary controls compact. */
@media (max-width: 620px) {
  .reading-layout { width: calc(100% - 24px); padding-top: 20px; }
  .article-header { padding: 20px 16px; margin-bottom: 18px; }
  .article-header h1 { font-size: 26px; line-height: 1.45; margin: 12px 0; overflow-wrap: anywhere; }
  .article-header .eyebrow { display: inline-flex; align-items: center; min-height: 36px; }
  .description { font-size: 14px; line-height: 1.8; margin-bottom: 16px; }
  .article-meta { gap: 8px 12px; overflow-wrap: anywhere; }
  .reading-grid { gap: 16px; }
  .reading-main { padding: 22px 16px; }
  .reading-sidebar .article-robot-card { display: none; }
  .toc { padding: 4px 14px; max-height: 55svh; }
  .toc summary { display: list-item; min-height: 44px; padding-block: 12px; }
  .toc[open] summary { margin-bottom: 4px; }
  .toc li { margin: 0; }
  .toc a { min-height: 44px; padding-block: 10px; font-size: 13px; }
  .content h2 { font-size: 22px; margin-top: 34px; padding-top: 18px; }
  .content h3 { font-size: 19px; }
  .content :is(h2,h3,h4) { scroll-margin-top: 125px; }
  .content pre { font-size: 13px; padding: 14px; overscroll-behavior-x: contain; }
  .copy-code,
  .code-toggle { min-height: 40px; padding-inline: 10px; }
  .code-actions { gap: 6px; }
  .code-toolbar { padding: 4px 10px; }
  .code-toolbar > span::after { content: " · 横滑查看"; color: var(--code-ink); opacity: .7; }
  .code-block.is-collapsed .code-toolbar > span::after { display: none; }
  .content .table-scroll { overscroll-behavior-x: contain; }
  .content th, .content td { padding: 10px; min-width: 110px; }
  .article-navigation { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .article-navigation a, .article-navigation a:last-child { text-align: left; padding: 12px 0; line-height: 1.7; }
  .article-navigation > span:empty { display: none; }
  .article-context a, .back { min-height: 44px; padding-block: 10px; }
  .series-nav-top { margin-top: 16px; padding-top: 12px; gap: 8px; }
  .series-nav-status { width: 100%; justify-content: space-between; }
  .series-dropdown-toggle { min-height: 44px; padding-inline: 12px; }
  .series-item-link { min-height: 44px; padding-block: 6px; }
  .series-dropdown-panel { max-height: 50svh; }
  .series-nav-bottom { padding: 16px 12px; }
  .series-bottom-title-group { flex-wrap: wrap; }
  .series-step-card { padding: 14px 12px; }
  .aiw-header, .aiw-body { padding: 14px 12px; }
  .aiw-section-title { flex-wrap: wrap; gap: 6px; }
  .aiw-btn { min-height: 44px; }
  .aiw-controls .aiw-btn { flex: 1 1 130px; }
  .ecat-demo-root, .font-demo-root { padding: 14px 12px; }
  .ecat-grid, .font-editor-grid { grid-template-columns: minmax(0, 1fr); }
  .ecat-card, .font-grid-wrap { min-width: 0; }
  .ecat-card { padding: 12px; }
  .ecat-card-title, .ecat-module-row { flex-wrap: wrap; gap: 8px; }
  .ecat-module-row label { min-width: 0; min-height: 44px; }
  .ecat-module-row input { flex-shrink: 0; }
  .ecat-btn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ecat-btn, .font-btn, .font-tab-btn, .font-palette-btn { min-height: 44px; }
  .font-grid-wrap { overflow-x: auto; align-items: stretch; overscroll-behavior-x: contain; }
  .font-grid-16 { align-self: flex-start; flex-shrink: 0; }
}

@media print {
  .code-block pre { display: block !important; }
  .site-header,
  .site-footer,
  .reading-progress,
  .toc,
  .article-robot-card,
  .code-toolbar button,
  .code-actions,
  .back-to-top,
  .article-navigation,
  .back,
  .theme-spectrum,
  .skip-link,
  .article-interactive-widget .aiw-controls,
  .aiw-actions,
  .w25q-actions-grid,
  .ecat-btn,
  .font-btn {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #111111 !important;
  }

  .reading-layout {
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .reading-grid {
    display: block !important;
  }

  .content {
    font-size: 11pt !important;
    line-height: 1.6 !important;
    color: #111111 !important;
  }

  .content h1,
  .content h2,
  .content h3 {
    page-break-after: avoid;
    break-after: avoid;
    color: #000000 !important;
  }

  .content pre,
  .content table,
  .article-interactive-widget {
    page-break-inside: avoid;
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #d0d7de !important;
  }

  .content pre {
    background: #f6f8fa !important;
    color: #24292f !important;
    white-space: pre-wrap !important;
    word-break: break-all;
  }

  .content a {
    text-decoration: underline !important;
    color: #0969da !important;
  }
}

/* Quiet reading surfaces; the interactive examples keep their own panels. */
.article-header { max-width: none; padding: 0 0 28px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
.article-header h1 { max-width: 22em; font-size: clamp(28px, 3.2vw, 40px); }
.article-header .description { max-width: 48em; }
.reading-main { padding: 8px 28px 36px 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
.reading-grid { grid-template-columns: minmax(0, 760px) minmax(220px, 1fr); gap: 40px; }
.toc { max-height: calc(100vh - 180px); box-shadow: none; font-size: 13px; }
.toc .toc-sub { font-size: 12px; }
.toc summary { font-size: 14px; }
.reading-sidebar > .article-robot-card { flex: 0 0 auto; box-shadow: none; overflow: visible; }
.robot-stage-article { height: 104px; overflow: visible; }
.robot-stage-article .robot-speech {
  top: auto;
  bottom: calc(100% + 6px);
  left: 50%;
  width: max-content;
  max-width: 250px;
  transform: translate(-50%, 4px);
  white-space: normal;
}
.robot-stage-article .robot-speech.is-active { transform: translate(-50%, 0); }
.robot-stage-article .robot-speech::after { display: block; }
@media (min-width: 1001px) {
  .reading-sidebar:has(> .article-robot-card) > .toc { max-height: calc(100vh - 240px); }
}
@media (max-width: 1000px) {
  .reading-grid { display: flex; }
  .reading-main { padding: 0; }
  .toc { max-height: 350px; }
  .layout-article .reading-sidebar > .article-robot-card { display: none; }
}
@media (max-width: 620px) {
  .reading-layout { width: calc(100% - 24px); }
  .article-header { padding: 0 0 22px; }
  .reading-main { padding: 0; }
  .article-header h1 { font-size: 28px; }
  .content h2 { font-size: 23px; }
}

.toc,
.article-interactive-widget,
.font-demo-root,
.ecat-demo-root,
.w25q-demo-root,
.article-robot-card {
  background: var(--raised-bg);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.article-interactive-widget,
.font-demo-root,
.ecat-demo-root,
.w25q-demo-root {
  border-color: var(--glass-edge);
}

/* iOS 18 Interactive Motion for Article View */
.toc a {
  transition:
    color 0.18s ease,
    background-color 0.18s ease,
    transform 0.32s var(--ease-spring-bounce);
}

@media (hover: hover) {
  .toc a:hover {
    transform: translateX(3px);
  }
}

.toc a:active,
.toc a.is-pressing {
  transform: scale(0.96) !important;
  transition-duration: 80ms !important;
}

.copy-button {
  transition:
    transform 0.34s var(--ease-spring-bounce),
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

@media (hover: hover) {
  .copy-button:hover {
    transform: scale(1.05);
  }
}

.copy-button:active,
.copy-button.is-pressing {
  transform: scale(0.9) !important;
  transition-duration: 80ms !important;
}

.article-navigation a {
  transition:
    transform 0.38s var(--ease-spring-bounce),
    border-color 0.22s ease,
    box-shadow 0.28s var(--ease-spring),
    background-color 0.22s ease;
}

@media (hover: hover) {
  .article-navigation a:hover {
    transform: translateY(-3px) scale(1.01);
  }
}

.article-navigation a:active,
.article-navigation a.is-pressing {
  transform: scale(0.975) !important;
  transition-duration: 85ms !important;
}

/* Waline 评论区适配 */
.article-comments {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.comments-header {
  margin-bottom: 24px;
}

.comments-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px;
  border: 0;
  padding: 0;
  color: var(--ink);
}

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

#waline {
  --waline-theme-color: var(--accent);
  --waline-active-color: var(--accent-dark);
  --waline-badge-color: var(--accent);
  --waline-color: var(--body-copy);
  --waline-bg-color: var(--surface, rgba(255, 255, 255, 0.6));
  --waline-bg-color-light: var(--alt-bg);
  --waline-border-color: var(--line);
  --waline-disable-bg-color: var(--soft);
  --waline-info-bg-color: var(--soft);
  --waline-info-color: var(--muted);
  --waline-font-size: 14.5px;
  --waline-border: 1px solid var(--line);
  --waline-avatar-radius: 50%;
}

@media (prefers-reduced-motion: reduce) {
  .code-toggle-icon { transition: none !important; }
}
