:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #f6f6f6;
  --text: #222222;
  --muted: #666666;
  --border: #dddddd;
  --primary: #b03024;
  --primary-2: #8f241b;
  --accent: #4f6f3a;
  --warning: #8a5a13;
  --danger: #b03024;
  --focus: rgba(176, 48, 36, .16);
  --shadow: none;
  --radius: 6px;
  --radius-sm: 4px;
  --content-shell-width: min(1600px, calc(100% - 36px));
  --sticky-header-offset: 112px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

[hidden] {
  display: none !important;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17130f;
  --surface: #221b14;
  --surface-2: #2d241a;
  --text: #f7efe3;
  --muted: #c8b9a5;
  --border: #403529;
  --primary: #e6a08d;
  --primary-2: #f0b7a7;
  --accent: #bec68e;
  --warning: #e0bc72;
  --danger: #f09186;
  --focus: rgba(230, 160, 141, .28);
  --shadow: 0 12px 28px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; overflow-wrap: anywhere; }
button, input, textarea, select { font: inherit; }
textarea, input, select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea:focus, input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}
textarea {
  min-height: 180px;
  resize: vertical;
  padding: 14px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
}
input, select { min-height: 44px; padding: 0 12px; }
input[type="color"] { padding: 4px; }
input[type="file"] { min-height: 46px; padding: 9px 12px; }
input[type="range"] { padding: 0; }
label { display: block; font-weight: 700; margin-bottom: 8px; }
small, .muted { color: var(--muted); }
code, pre { font-family: var(--mono); }
pre {
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  white-space: pre-wrap;
  word-break: break-word;
}
img, canvas, iframe, svg { max-width: 100%; }
main, section, article, aside, .page, .static-page, .tool-page, .tool-content { min-width: 0; }

:where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

#app:focus {
  outline: none;
}

::selection {
  color: var(--surface);
  background: var(--primary);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 50;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--surface);
}
.skip-link:focus { left: 8px; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.app-shell { width: var(--content-shell-width); max-width: none; padding: 28px 0 46px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 24px;
}
.hero-card, .panel, .category-card, .tool-card, .tool-workbench, .side-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hero-card { padding: 34px; position: relative; overflow: hidden; }
.hero-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: transparent;
}
.hero-card > * {
  position: relative;
  z-index: 1;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-2);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
}
h1 { margin: 14px 0 10px; font-size: clamp(30px, 4vw, 42px); line-height: 1.18; letter-spacing: 0; overflow-wrap: anywhere; }
h2 { margin: 0 0 14px; font-size: clamp(22px, 3vw, 30px); letter-spacing: 0; line-height: 1.2; }
h3 { margin: 0 0 10px; font-size: 18px; line-height: 1.35; }
.hero p { max-width: 720px; margin: 0 0 20px; color: var(--muted); font-size: 17px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stats-card { padding: 24px; display: grid; gap: 12px; }
.stat {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat strong { display: block; font-size: 28px; line-height: 1; }
.stat span { color: var(--muted); font-size: 13px; }

.btn, .primary-btn, .secondary-btn, .danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  min-width: 0;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease;
}
.btn:hover, .primary-btn:hover, .secondary-btn:hover, .danger-btn:hover { transform: translateY(-1px); box-shadow: none; }
.primary-btn { background: var(--primary); border-color: var(--primary); color: var(--surface); }
.primary-btn:hover { background: var(--primary-2); }
.secondary-btn { background: var(--surface-2); }
.danger-btn { color: var(--danger); }
.icon-btn { min-width: 44px; padding: 0; }

[data-theme="dark"] .primary-btn { color: #1f1712; }

.search-panel { padding: 18px; margin-bottom: 22px; }
.search-line { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.search-input { font-size: 16px; min-height: 52px; border-radius: var(--radius); }
.app-shell.is-home {
  width: min(1600px, calc(100% - 36px));
}
.home-page {
  font-size: 14px;
}
.home-channel-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  grid-template-areas:
    "brand search"
    "nav nav";
  align-items: center;
  gap: 12px;
  width: min(1600px, calc(100% - 36px));
  min-width: 0;
  max-width: none;
  margin: 0 auto;
  padding: 8px 10px 10px;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .07);
}
.home-channel-bar::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: linear-gradient(90deg, var(--primary) 0 22%, #4f78c7 22% 42%, #2e9f74 42% 60%, #d4a11f 60% 78%, var(--danger) 78% 100%);
  pointer-events: none;
}
.home-channel-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  white-space: nowrap;
}
.home-channel-brand:hover { color: var(--primary); }
.home-channel-brand strong { color: var(--primary); font-size: 18px; }
.home-channel-brand span { color: var(--muted); font-size: 12px; }
.home-nav-toggle {
  grid-area: toggle;
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}
.home-nav-toggle-bars {
  position: relative;
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}
.home-nav-toggle-bars::before,
.home-nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}
.home-nav-toggle-bars::before { top: -6px; }
.home-nav-toggle-bars::after { top: 6px; }
.home-channel-links {
  grid-area: nav;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  overflow: visible;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  scrollbar-width: none;
}
.home-channel-links::-webkit-scrollbar {
  display: none;
}
.home-channel-links a {
  flex: 0 0 auto;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
}
.home-channel-links a:hover,
.home-channel-links a[aria-current] {
  color: var(--primary);
  background: var(--surface-2);
}
.home-channel-links a[aria-current] {
  font-weight: 800;
}
.home-search-box {
  grid-area: search;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  min-width: 0;
}
.home-search-input {
  min-height: 38px;
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}
.home-search-clear {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}
.home-search-clear:hover,
.home-nav-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.home-search-clear:disabled {
  opacity: .46;
  cursor: not-allowed;
}
.home-theme-toggle {
  min-width: 58px;
}
.home-channel-bar > .home-search-clear {
  grid-area: search;
  justify-self: end;
}
.home-layout {
  display: grid;
  grid-template-columns: minmax(188px, 220px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}
.home-sidebar {
  position: sticky;
  top: var(--sticky-header-offset);
  display: grid;
  gap: 4px;
  max-height: calc(100vh - var(--sticky-header-offset) - 12px);
  min-width: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.home-sidebar-title {
  padding: 4px 8px 8px;
  color: var(--text);
  font-weight: 900;
}
.home-sidebar a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  line-height: 1.25;
}
.home-sidebar a span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.home-sidebar a span + span,
.home-sidebar a small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.home-sidebar a:hover {
  color: var(--primary);
  background: var(--surface-2);
}
.home-sidebar a:hover span + span,
.home-sidebar a:hover small {
  color: var(--primary);
}
.home-content {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.home-overview,
.home-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.home-overview {
  padding: 16px 18px;
}
.home-overview h1 {
  margin: 0 0 4px;
  font-size: 26px;
}
.home-overview p {
  margin: 0;
  color: var(--muted);
}
.home-stat-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.home-stat-line span {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
}
.home-stat-line strong {
  color: var(--primary);
}
.home-section {
  scroll-margin-top: 140px;
  padding: 12px;
}
.home-section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.home-section-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}
.home-section-more {
  margin-left: auto;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.home-section-more:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.home-section-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 3px;
  background: #ffc107;
  color: #5c3900;
  font-size: 12px;
  font-weight: 900;
}
.home-section-badge.muted {
  background: #6c757d;
  color: #ffffff;
}
.home-link-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: 68px;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.home-link-wall > li {
  min-width: 0;
  height: 100%;
}
.home-link {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  height: 100%;
  min-height: 0;
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid #e4e4e4;
  border-radius: 4px;
  background: #fbfbfb;
  color: var(--text);
}
.home-link:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  color: var(--primary);
  background: #ffffff;
}
.home-link-icon {
  width: 32px;
  height: 32px;
  padding: 3px;
  border: 1px solid #eeeeee;
  border-radius: 6px;
  background: #ffffff;
  object-fit: contain;
}
.home-link-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.home-link-title {
  min-width: 0;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-link small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  display: -webkit-box;
  height: 2.5em;
  min-width: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.home-link.is-entry {
  color: var(--muted);
}
.home-link.external .home-link-title::after {
  content: " ↗";
  color: var(--muted);
  font-weight: 400;
}
.home-reference-search {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.home-reference-search-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.home-reference-search-tabs button {
  display: grid;
  gap: 2px;
  min-height: 44px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
}
.home-reference-search-tabs button span {
  font-weight: 750;
}
.home-reference-search-tabs button small {
  font-size: 9px;
  font-weight: 500;
  opacity: .78;
}
.home-reference-search-tabs button:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
  color: var(--text);
}
.home-reference-search-tabs button.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}
.home-reference-search-tabs button.is-active small {
  color: #ffffff;
  opacity: .9;
}
.home-reference-search-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.home-reference-search-line input {
  min-height: 42px;
  background: var(--surface);
}
.home-other-matrix {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.home-other-row {
  display: grid;
  grid-template-columns: minmax(108px, 126px) minmax(0, 1fr);
  border-top: 1px solid var(--border);
  scroll-margin-top: 96px;
}
.home-other-row:first-child {
  border-top: 0;
}
.home-other-label {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
  padding: 6px 8px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 78%, #ffffff);
  color: var(--text);
}
.home-other-label span {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 3px;
  background: #f47b20;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}
.home-other-label small {
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-other-label small[data-tooltip] {
  cursor: help;
}
.has-auto-tooltip {
  cursor: help;
}
.home-other-links {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-auto-rows: 28px;
  align-items: center;
  gap: 0 8px;
  min-width: 0;
  margin: 0;
  padding: 6px 10px;
  list-style: none;
  overflow: hidden;
}
.home-other-links > li {
  display: flex;
  align-items: center;
  min-width: 0;
}
@media (min-width: 561px) {
  .home-other-more-item {
    grid-column: -2 / -1;
    grid-row: 1;
    justify-content: flex-end;
  }
}
.home-other-link {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 26px;
  padding: 2px 3px;
  border-radius: 3px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
}
.home-other-link:hover {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, transparent);
}
.home-other-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}
.home-other-link span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-other-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  margin-top: 0;
  padding: 0 8px;
  border-radius: 999px;
  background: #8b8f85;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.home-other-more:hover {
  background: var(--primary);
  color: #ffffff;
}
.home-empty {
  grid-column: 1 / -1;
  padding: 12px;
  color: var(--muted);
}
.site-tooltip {
  position: fixed;
  z-index: 1200;
  left: 0;
  top: 0;
  max-width: min(280px, calc(100vw - 16px));
  padding: 7px 9px;
  border-radius: 4px;
  background: #1f2933;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  overflow-wrap: anywhere;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  visibility: hidden;
}
.site-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}
.site-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: var(--tooltip-arrow-left, 50%);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2933;
}
.site-tooltip.is-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #1f2933;
}

[data-theme="dark"] .home-link {
  border-color: var(--border);
  background: var(--surface-2);
}
[data-theme="dark"] .home-link:hover {
  background: var(--surface);
}
[data-theme="dark"] .home-link-icon {
  border-color: var(--border);
  background: #ffffff;
}
[data-theme="dark"] .home-other-matrix,
[data-theme="dark"] .home-other-label {
  background: var(--surface-2);
}
.resource-page {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.resource-hero {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.resource-hero h1 {
  margin: 8px 0 4px;
  font-size: 30px;
  line-height: 1.2;
}
.resource-hero p {
  max-width: 880px;
  margin: 0;
  color: var(--muted);
}
.resource-detail-layout {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}
.resource-anchor-panel {
  position: sticky;
  top: 85px;
  display: grid;
  gap: 4px;
  max-height: calc(100vh - 112px);
  min-width: 0;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.resource-anchor-title {
  padding: 4px 8px 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
.resource-anchor-panel a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
}
.resource-anchor-panel a:hover {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, transparent);
}
.resource-anchor-panel span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resource-anchor-panel small {
  color: var(--muted);
  font-size: 12px;
}
.resource-detail-content {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.resource-summary {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}
.resource-summary strong {
  color: var(--text);
}
.resource-detail-section {
  min-width: 0;
  scroll-margin-top: 96px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.resource-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 72%, #ffffff);
}
.resource-detail-head h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}
.resource-detail-head h2 span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 3px;
  background: #f47b20;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}
.resource-detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.resource-section-anchor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 900;
}
.resource-section-anchor:hover {
  color: #ffffff;
  background: var(--primary);
}
.resource-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  min-width: 0;
  padding: 10px;
}
.resource-detail-card {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 58px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.resource-detail-card:hover {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 32%, var(--border));
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}
.resource-detail-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 5px;
  background: #ffffff;
}
.resource-detail-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.resource-detail-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  line-height: 1.25;
}
.resource-detail-card small {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.resource-meta,
.tool-capability-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.resource-domain,
.resource-kind,
.tool-capability {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 100%;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.resource-kind,
.tool-capability[data-capability="local"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.tool-capability[data-capability="network"],
.tool-capability[data-capability="permission"],
.tool-capability[data-capability="sandbox"] {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 35%, var(--border));
  background: color-mix(in srgb, var(--warning) 9%, var(--surface));
}
[data-theme="dark"] .resource-detail-head {
  background: var(--surface-2);
}
[data-theme="dark"] .resource-detail-icon {
  background: #ffffff;
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.25;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.chip:hover, .chip.is-active { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }

.grid { display: grid; gap: 16px; }
.category-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.tool-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.category-card, .tool-card { padding: 18px; min-height: 126px; overflow: hidden; }
.category-card:hover, .tool-card:hover { border-color: color-mix(in srgb, var(--primary) 38%, var(--border)); transform: translateY(-1px); box-shadow: none; }
.category-card, .tool-card { transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; min-width: 0; }
.card-title { min-width: 0; font-weight: 800; font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--border));
  white-space: nowrap;
}
.badge.ok { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 22%, var(--border)); }
.badge.todo { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 22%, var(--border)); }
.card-desc { margin: 10px 0 0; color: var(--muted); font-size: 14px; }

[data-theme="dark"] .badge.ok { color: #cbd8a5; background: rgba(190, 198, 142, .14); }
[data-theme="dark"] .badge.todo { color: #e0bc72; background: rgba(224, 188, 114, .16); }

.layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(188px, 220px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-height: calc(100vh + var(--sticky-header-offset));
  min-width: 0;
}
.layout.is-side-collapsed { grid-template-columns: minmax(0, 1fr); }
.layout.is-side-collapsed > section { grid-column: 1; min-width: 0; }
.layout.is-side-collapsed .side-panel { display: none; }
.layout.is-side-collapsed .tool-header { min-height: 44px; padding-left: 52px; }
.layout > section {
  align-self: start;
  min-width: 0;
}
.side-panel {
  position: sticky;
  top: var(--sticky-header-offset);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 4px;
  height: auto;
  max-height: calc(100vh - var(--sticky-header-offset) - 12px);
  min-width: 0;
  padding: 10px;
  font-size: 14px;
  overflow: hidden;
}
.side-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; }
.side-title { min-width: 0; padding: 4px 8px 8px; font-weight: 900; }
.side-scroll {
  display: grid;
  gap: 4px;
  min-height: 0;
  min-width: 0;
  overflow: auto;
}
.side-toggle,
.side-expand-toggle {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1;
}
.side-toggle-icon { display: inline-block; transform: translateY(-1px); }
.side-expand-toggle { display: none; }
.layout.is-side-collapsed .side-expand-toggle {
  display: inline-flex;
  position: fixed;
  top: var(--sticky-header-offset);
  left: 62px;
  z-index: 25;
}
.side-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  line-height: 1.25;
}
.side-link:hover, .side-link.is-active { background: var(--surface-2); color: var(--text); }
.side-link span:first-child { min-width: 0; overflow-wrap: anywhere; }
.side-link span:last-child {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.side-link:hover span:last-child,
.side-link.is-active span:last-child {
  color: var(--text);
}

.tool-header, .page-header { margin-bottom: 16px; }
.breadcrumb { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.breadcrumb a { color: var(--primary); }
.tool-workbench { padding: 20px; }
.tool-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.tool-toolbar > * { min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }
.textarea-field { min-width: 0; }
.textarea-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-bottom: 8px;
}
.textarea-label-row label {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}
.textarea-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}
.textarea-copy-btn,
.textarea-expand-btn {
  flex: 0 0 auto;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}
.textarea-expand-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, .42);
}
body.textarea-expanded { overflow: hidden; }
.textarea-field.is-expanded {
  position: fixed;
  inset: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .28);
}
.textarea-field.is-expanded textarea {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  resize: none;
}
.code-textarea-field {
  --code-editor-padding: 14px;
  --code-editor-font-size: 14px;
  --code-editor-line-height: 1.55;
  --code-editor-bg: var(--surface);
  --code-editor-text: var(--text);
  --code-token-comment: #57606a;
  --code-token-keyword: #cf222e;
  --code-token-number: #0550ae;
  --code-token-string: #0a3069;
  --code-token-title: #8250df;
  --code-token-attr: #953800;
  --code-token-muted: #57606a;
  --code-token-deletion: #cf222e;
  --code-token-addition: #1a7f37;
  position: relative;
  min-width: 0;
}
.code-textarea-field > .textarea-label-row {
  position: relative;
  z-index: 3;
  background: var(--surface);
}
.code-textarea-wrap {
  position: relative;
  min-width: 0;
}
.code-highlight-layer {
  position: absolute;
  inset: 1px;
  z-index: 1;
  min-width: 0;
  overflow: hidden;
  border-radius: calc(var(--radius-sm) - 1px);
  background: var(--code-editor-bg);
  pointer-events: none;
}
.code-highlight-scroll,
.code-highlight-scroll.hljs {
  width: 100%;
  height: 100%;
  min-height: 100%;
  max-width: 100%;
  margin: 0;
  padding: var(--code-editor-padding);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--code-editor-text);
  overflow: hidden;
  font-family: var(--mono);
  font-size: var(--code-editor-font-size);
  line-height: var(--code-editor-line-height);
  letter-spacing: 0;
  font-variant-ligatures: none;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}
.code-highlight-scroll code.code-highlight-code,
.code-highlight-code,
.code-highlight-code.hljs {
  display: block;
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: 0;
  white-space: inherit;
  overflow-wrap: inherit;
  word-break: inherit;
}
textarea.code-textarea {
  position: relative;
  z-index: 2;
  display: block;
  min-width: 0;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  padding: var(--code-editor-padding);
  font-family: var(--mono);
  font-size: var(--code-editor-font-size);
  line-height: var(--code-editor-line-height);
  letter-spacing: 0;
  font-variant-ligatures: none;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}
textarea.code-textarea[wrap="off"] {
  white-space: pre;
  overflow-wrap: normal;
}
.code-textarea-field.is-expanded .code-textarea-wrap {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}
.code-textarea-field.is-expanded textarea.code-textarea {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  resize: none;
}
textarea.code-textarea::placeholder {
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  opacity: .68;
}
textarea.code-textarea::selection {
  background: color-mix(in srgb, var(--primary) 24%, transparent);
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.code-highlight-code .hljs-comment,
.code-highlight-code .hljs-quote {
  color: var(--code-token-comment);
  font-style: italic;
}
.code-highlight-code .hljs-keyword,
.code-highlight-code .hljs-selector-tag,
.code-highlight-code .hljs-subst {
  color: var(--code-token-keyword);
}
.code-highlight-code .hljs-literal,
.code-highlight-code .hljs-number,
.code-highlight-code .hljs-tag .hljs-attr,
.code-highlight-code .hljs-template-variable,
.code-highlight-code .hljs-variable {
  color: var(--code-token-number);
}
.code-highlight-code .hljs-string,
.code-highlight-code .hljs-doctag,
.code-highlight-code .hljs-regexp,
.code-highlight-code .hljs-title.class_ {
  color: var(--code-token-string);
}
.code-highlight-code .hljs-title,
.code-highlight-code .hljs-title.function_,
.code-highlight-code .hljs-name,
.code-highlight-code .hljs-section,
.code-highlight-code .hljs-selector-id {
  color: var(--code-token-title);
}
.code-highlight-code .hljs-attr,
.code-highlight-code .hljs-attribute,
.code-highlight-code .hljs-built_in,
.code-highlight-code .hljs-symbol,
.code-highlight-code .hljs-selector-class {
  color: var(--code-token-attr);
}
.code-highlight-code .hljs-meta,
.code-highlight-code .hljs-operator,
.code-highlight-code .hljs-punctuation {
  color: var(--code-token-muted);
}
.code-highlight-code .hljs-deletion { color: var(--code-token-deletion); }
.code-highlight-code .hljs-addition { color: var(--code-token-addition); }
[data-theme="dark"] .code-textarea-field {
  --code-editor-bg: var(--surface);
  --code-editor-text: #c9d1d9;
  --code-token-comment: #8b949e;
  --code-token-keyword: #ff7b72;
  --code-token-number: #79c0ff;
  --code-token-string: #a5d6ff;
  --code-token-title: #d2a8ff;
  --code-token-attr: #ffa657;
  --code-token-muted: #8b949e;
  --code-token-deletion: #ffa198;
  --code-token-addition: #7ee787;
}
.output-box {
  min-height: 52px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  line-height: 1.55;
}
.output-box.large { min-height: 160px; }
.table-wrap { overflow: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; min-width: 580px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.preview-frame { width: 100%; min-height: 360px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: white; }

.local-tools-shell {
  --local-stage-height: clamp(420px, 62vh, 680px);
  display: grid;
  gap: 16px;
  width: 100%;
  min-width: 0;
}
.local-tools-shell > *,
.local-tools-grid > *,
.local-tools-controls > * {
  min-width: 0;
}
.local-tools-shell :disabled {
  opacity: .52;
  cursor: not-allowed;
}
.local-tools-shell button:disabled:hover {
  transform: none;
}
.local-tools-inline-check {
  display: flex;
  align-items: center;
  min-height: 44px;
}
.local-tools-inline-check label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.local-tools-inline-check input[type="checkbox"] {
  flex: 0 0 20px;
  width: 20px;
  min-height: 20px;
  accent-color: var(--primary);
}
.local-tools-tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.local-tools-tool-row [aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--surface);
}
.local-tools-result {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.local-tools-result .output-box.large {
  min-height: 96px;
  font-size: 16px;
}
.local-tools-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.local-tools-progress progress {
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}
.local-tools-status {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  min-width: 0;
  min-height: 40px;
  padding: 9px 11px;
  border-left: 3px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2);
  color: var(--text);
  overflow-wrap: anywhere;
}
.local-tools-status:empty {
  visibility: hidden;
}
.local-tools-status::before {
  content: "i";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}
.local-tools-status[data-tone="success"] {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, var(--surface));
}
.local-tools-status[data-tone="success"]::before {
  content: "+";
}
.local-tools-status[data-tone="error"] {
  border-left-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  color: var(--text);
}
.local-tools-status[data-tone="error"]::before {
  content: "!";
}

.local-tools-split {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  min-width: 0;
  min-height: 440px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.local-tools-list {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  max-height: 640px;
  overflow: auto;
  padding: 10px 12px 10px 0;
  border-right: 1px solid var(--border);
  scrollbar-gutter: stable;
}
.local-tools-list-item {
  display: grid;
  gap: 2px;
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 8px 10px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.local-tools-list-item:hover {
  background: var(--surface-2);
}
.local-tools-list-item.is-active,
.local-tools-list-item[aria-current="true"] {
  border-left-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
}
.local-tools-list-item:focus-visible {
  outline-offset: -3px;
}
.local-tools-list-item span,
.local-tools-list-item small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.local-tools-list-item span {
  font-weight: 800;
}
.local-tools-list > .muted {
  margin: 0;
  padding: 16px 10px;
}
.local-tools-panel {
  min-width: 0;
  overflow-wrap: anywhere;
}
.local-tools-split > .local-tools-panel {
  padding: 18px 0 18px 18px;
}
.local-tools-photo-editor > .local-tools-panel {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.local-tools-panel > :first-child {
  margin-top: 0;
}
.local-tools-panel > :last-child {
  margin-bottom: 0;
}
.local-tools-panel h2 {
  font-size: 22px;
}
.local-tools-panel textarea {
  min-height: 180px;
}
.local-tools-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-bottom: 10px;
}
.local-tools-panel-head h2 {
  min-width: 0;
  margin: 0;
}
.local-tools-preview {
  display: block;
  width: 100%;
  min-height: 280px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.local-tools-quiz-card {
  min-width: 0;
  min-height: 280px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.local-tools-quiz-card[hidden] {
  display: none;
}
.local-tools-quiz-card fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.local-tools-quiz-card legend {
  width: 100%;
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.local-tools-quiz-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.local-tools-choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}
.local-tools-choice {
  width: 100%;
  min-height: 54px;
  justify-content: flex-start;
  text-align: left;
  overflow-wrap: anywhere;
}
.local-tools-choice:disabled {
  opacity: 1;
  cursor: default;
}
.local-tools-choice.primary-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}
.local-tools-choice.danger-btn {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--danger);
}
.local-tools-feedback {
  min-width: 0;
  min-height: 24px;
  margin-top: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.local-tools-palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  min-width: 0;
}
.local-tools-swatch {
  display: grid;
  grid-template-rows: 88px auto;
  min-width: 0;
  min-height: 128px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.local-tools-swatch:hover {
  border-color: var(--primary);
}
.local-tools-swatch-color {
  min-height: 88px;
  background: var(--local-swatch, transparent);
}
.local-tools-swatch strong {
  min-width: 0;
  padding: 8px 9px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-tools-mode-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.local-tools-mode-panel[hidden] {
  display: none;
}
.local-tools-file-list {
  display: grid;
  gap: 0;
  min-width: 0;
  max-width: 100%;
}
.local-tools-file-list > .muted {
  min-height: 72px;
  margin: 0;
  padding: 22px 0;
  text-align: center;
}
.local-tools-file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "body actions";
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 72px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.local-tools-file-item:last-child {
  border-bottom: 0;
}
.local-tools-file-item > :first-child {
  grid-area: body;
  display: grid;
  gap: 3px;
  min-width: 0;
}
.local-tools-file-item > :first-child strong,
.local-tools-file-item > :first-child small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.local-tools-item-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}
.local-tools-item-actions > * {
  min-height: 44px;
}
.local-tools-item-actions [aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--surface);
}

.local-tools-pdf-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  min-width: 0;
}
.local-tools-pdf-preview {
  display: grid;
  grid-template-rows: minmax(180px, 260px) auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.local-tools-pdf-preview > img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: #ffffff;
}
.local-tools-pdf-preview > div {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.local-tools-pdf-preview strong {
  overflow-wrap: anywhere;
}
.local-tools-pdf-preview .secondary-btn {
  width: 100%;
}

.local-tools-canvas-wrap {
  width: 100%;
  min-width: 0;
  height: var(--local-stage-height);
  min-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}
.local-tools-canvas {
  display: block;
}
.local-tools-shell :where(button, [tabindex]):focus-visible {
  outline-color: var(--primary);
}
.local-tools-shell .local-tools-canvas:focus-visible {
  outline: 3px solid #111111;
  outline-offset: -3px;
}
@supports selector(:has(*)) {
  .local-tools-shell .local-tools-canvas:focus-visible {
    outline: 0;
  }
  .local-tools-canvas-wrap:has(> .local-tools-canvas:focus-visible) {
    outline: 3px solid #111111;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px #ffffff;
  }
}
.local-tools-diagram-canvas {
  width: 1200px;
  max-width: none;
  height: 720px;
  background: #ffffff;
  touch-action: none;
}
.local-tools-pdf [data-pdf-edit-canvas] {
  touch-action: none;
}
.local-tools-pdf .local-tools-canvas-wrap {
  display: grid;
  place-items: center;
}
.local-tools-photo-editor .local-tools-canvas-wrap {
  display: grid;
  place-items: center;
  padding: 16px;
}
.local-tools-photo-canvas {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  background: #ffffff;
}

.local-tools-mind-stage {
  width: 100%;
  min-width: 0;
  height: var(--local-stage-height);
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.local-tools-mind-stage:focus-visible,
.local-tools-mind-stage .jsmind-inner:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}
.local-tools-mind-stage .jsmind-inner {
  width: 100%;
  height: 100%;
  min-height: inherit;
  overflow: auto;
  background: var(--surface-2);
  overscroll-behavior: contain;
}
.local-tools-mind-stage jmnodes.theme-primary jmnode {
  max-width: 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
  overflow-wrap: anywhere;
}
.local-tools-mind-stage jmnodes.theme-primary jmnode:hover {
  border-color: var(--primary);
  background: var(--surface-2);
  color: var(--text);
  box-shadow: none;
}
.local-tools-mind-stage jmnodes.theme-primary jmnode.selected,
.local-tools-mind-stage jmnodes.theme-primary jmnode.selected:hover {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--surface);
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.local-tools-mind-stage jmnodes.theme-primary jmexpander {
  width: 16px;
  height: 16px;
  overflow: visible;
  border-color: var(--muted);
  background: var(--surface);
  color: var(--text);
  line-height: 14px;
}
.local-tools-mind-stage jmnodes.theme-primary jmexpander::before {
  content: "";
  position: absolute;
  inset: -14px;
}

.local-tools-empty {
  display: grid;
  place-items: center;
  min-height: 160px;
  gap: 6px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}
.local-tools-empty strong,
.local-tools-empty span {
  display: block;
}

@media (max-width: 1180px) {
  .home-channel-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand toggle"
      "search search"
      "nav nav";
    align-items: center;
  }
  .home-nav-toggle {
    display: inline-flex;
  }
  .home-channel-links {
    display: none;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
    overflow: visible;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .home-channel-bar.is-nav-open .home-channel-links {
    display: flex;
  }
  .home-channel-links a {
    flex: 0 1 auto;
  }
}

@media (max-width: 900px) {
  .local-tools-split {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }
  .local-tools-list {
    max-height: 280px;
    padding: 8px 0 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .local-tools-split > .local-tools-panel {
    padding: 16px 0 0;
  }
}

@media (max-width: 560px) {
  .local-tools-shell {
    --local-stage-height: clamp(320px, 58vh, 520px);
    gap: 12px;
  }
  .local-tools-canvas-wrap,
  .local-tools-mind-stage {
    min-height: 320px;
  }
  .local-tools-file-item {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "body"
      "actions";
    min-height: 0;
  }
  .local-tools-item-actions {
    justify-content: flex-start;
  }
  .local-tools-item-actions > *,
  .local-tools-tool-row > * {
    flex: 1 1 calc(50% - 8px);
  }
  .local-tools-choice-list,
  .local-tools-pdf-preview-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .local-tools-preview {
    min-height: 240px;
  }
}

@media (max-width: 380px) {
  .local-tools-item-actions > *,
  .local-tools-tool-row > * {
    flex-basis: 100%;
    width: 100%;
  }
  .local-tools-progress {
    grid-template-columns: minmax(0, 1fr);
  }
  .local-tools-panel-head,
  .local-tools-quiz-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}
.tool-workbench.html-run-workbench {
  padding: 0;
  overflow: hidden;
}
.html-run-shell {
  display: grid;
  grid-template-columns: minmax(0, var(--html-run-editor-ratio, 50%)) 12px minmax(0, calc(100% - var(--html-run-editor-ratio, 50%) - 12px));
  gap: 0;
  min-height: 560px;
  height: clamp(560px, calc(100vh - 245px), 860px);
}
.html-run-shell.is-resizing,
.html-run-shell.is-resizing * {
  cursor: col-resize;
  user-select: none;
}
.html-run-pane {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.html-run-editor-pane,
.html-run-preview-pane {
  flex-direction: column;
}
.html-run-toolbar,
.html-run-preview-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 58px;
  padding: 10px 20px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.html-run-toolbar {
  flex-wrap: wrap;
}
.html-run-preview-toolbar {
  justify-content: space-between;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px 14px;
}
.html-run-preview-actions,
.html-run-preview-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  gap: 8px;
}
.html-run-preview-actions {
  flex: 1 1 270px;
}
.html-run-preview-controls {
  flex: 1 1 420px;
  justify-content: flex-end;
}
.html-run-btn,
.html-run-preview-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  max-width: 100%;
  padding: 0 12px;
  border: 1px solid #42bf86;
  border-radius: var(--radius-sm);
  color: #39ad78;
  background: var(--surface);
  line-height: 1.2;
  white-space: nowrap;
}
.html-run-btn {
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.html-run-btn.compact {
  min-height: 36px;
}
.html-run-preview-toolbar .html-run-btn,
.html-run-preview-toolbar .html-run-preview-tab {
  min-height: 36px;
}
.html-run-btn:hover {
  color: #23845a;
  border-color: #23845a;
  background: color-mix(in srgb, #42bf86 8%, var(--surface));
}
.html-run-btn.danger {
  color: #ef4055;
  border-color: #ef4055;
}
.html-run-btn.danger:hover {
  color: #bf2638;
  border-color: #bf2638;
  background: color-mix(in srgb, #ef4055 8%, var(--surface));
}
.html-run-preview-tab {
  color: var(--muted);
  border-color: color-mix(in srgb, var(--muted) 65%, var(--border));
}
.html-run-live-toggle,
.html-run-select {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  max-width: 100%;
  padding: 0 10px;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}
.html-run-live-toggle {
  position: relative;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.html-run-live-toggle input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}
.html-run-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--muted) 45%, var(--surface));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 9%, transparent);
}
.html-run-live-toggle:has(input:checked) {
  color: #23845a;
  border-color: #42bf86;
  background: color-mix(in srgb, #42bf86 7%, var(--surface));
}
.html-run-live-toggle:has(input:checked) .html-run-live-dot {
  background: #42bf86;
  box-shadow: 0 0 0 4px color-mix(in srgb, #42bf86 14%, transparent);
}
.html-run-border-toggle .html-run-live-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: transparent;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--muted) 56%, var(--border));
}
.html-run-border-toggle:has(input:checked) .html-run-live-dot {
  background: transparent;
  box-shadow: inset 0 0 0 2px #42bf86;
}
.html-run-sandbox-toggle:not(:has(input:checked)) {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 65%, var(--border));
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}
.html-run-sandbox-toggle:not(:has(input:checked)) .html-run-live-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent);
}
.html-run-live-toggle:focus-within {
  border-color: #23845a;
  box-shadow: 0 0 0 3px color-mix(in srgb, #42bf86 12%, transparent);
}
.html-run-select select {
  max-width: 116px;
  min-height: 28px;
  border: 0;
  color: var(--text);
  background: transparent;
  font: inherit;
}
.html-run-status {
  flex: 1 1 130px;
  min-width: 128px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
  overflow-wrap: anywhere;
}
.html-run-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 12px;
  min-height: 0;
  cursor: col-resize;
  outline: none;
}
.html-run-divider::before {
  content: "";
  width: 4px;
  height: 68px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 72%, var(--muted));
  transition: background .14s ease, height .14s ease;
}
.html-run-divider:hover::before,
.html-run-divider:focus-visible::before,
.html-run-shell.is-resizing .html-run-divider::before {
  height: 112px;
  background: #42bf86;
}
.html-run-editor-body {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  background: var(--surface);
}
.html-run-line-numbers {
  padding: 14px 10px 14px 0;
  overflow: hidden;
  border-right: 1px solid #e8edf2;
  background: color-mix(in srgb, var(--surface-2) 50%, var(--surface));
  color: #9aa0a6;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  text-align: right;
  user-select: none;
}
.html-run-line-numbers span {
  display: block;
  min-height: 1.55em;
}
.html-run-editor-field {
  min-width: 0;
  min-height: 0;
}
.html-run-editor-field.code-textarea-field {
  --code-editor-padding: 14px;
  --code-editor-font-size: 14px;
  --code-editor-line-height: 1.55;
  height: 100%;
}
.html-run-editor-field .code-textarea-wrap {
  height: 100%;
  min-height: 0;
}
.html-run-editor-field .code-highlight-layer {
  inset: 0;
  border-radius: 0;
}
.html-run-editor-field textarea.code-textarea {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.html-run-editor-field textarea.code-textarea:focus {
  border-color: transparent;
  box-shadow: none;
}
.html-run-count {
  position: absolute;
  right: 14px;
  bottom: 8px;
  z-index: 4;
  color: #9aa0a6;
  font-family: var(--mono);
  font-size: 13px;
  pointer-events: none;
}
.html-run-preview-viewport {
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  align-items: stretch;
  min-height: 0;
  overflow: auto;
  background: color-mix(in srgb, var(--surface-2) 70%, #ffffff);
}
.html-run-preview-viewport[data-preview-width="auto"] {
  background: #ffffff;
}
.html-run-frame {
  box-sizing: border-box;
  display: block;
  flex: 0 0 var(--html-run-preview-width, 100%);
  width: var(--html-run-preview-width, 100%);
  min-width: var(--html-run-preview-width, 100%);
  height: 100%;
  min-height: 100%;
  border: 1px solid transparent;
  background: #ffffff;
}
.html-run-preview-viewport[data-preview-border="true"] .html-run-frame {
  border-color: color-mix(in srgb, #42bf86 58%, var(--border));
}
.html-run-preview-viewport[data-preview-width="auto"] .html-run-frame {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}
.canvas-preview { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.gradient-preview {
  min-height: 110px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.button-preview {
  display: grid;
  place-items: center;
  min-height: 130px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.barcode-preview svg {
  max-width: 100%;
  height: auto;
}
.game-panel {
  display: grid;
  gap: 12px;
  max-width: 620px;
  margin: 0 auto;
}
.game-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 20px;
}
.merge-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  background: #b9aa9d;
}
.merge-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 5px;
  background: #cdc1b4;
  color: #4a4038;
  font-size: clamp(20px, 5vw, 34px);
  font-weight: 900;
}
.merge-cell:not(.v-0) { background: #eee4da; }
.merge-cell.v-8, .merge-cell.v-16, .merge-cell.v-32, .merge-cell.v-64, .merge-cell.v-128, .merge-cell.v-256, .merge-cell.v-512, .merge-cell.v-1024, .merge-cell.v-2048 {
  color: #ffffff;
  background: var(--primary);
}
.gomoku-board {
  display: grid;
  grid-template-columns: repeat(15, minmax(18px, 1fr));
  gap: 1px;
  padding: 8px;
  border: 1px solid #b98a4a;
  border-radius: var(--radius);
  background: #d7a85c;
}
.gomoku-cell {
  aspect-ratio: 1;
  min-height: 18px;
  border: 0;
  border-radius: 50%;
  background: #ecc77d;
  cursor: pointer;
}
.gomoku-cell.black { background: #222222; }
.gomoku-cell.white { background: #ffffff; box-shadow: inset 0 0 0 1px #999999; }
.spinner-stage {
  display: grid;
  place-items: center;
  min-height: 260px;
}
.spinner-wheel {
  display: grid;
  place-items: center;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  color: #ffffff;
  background: conic-gradient(#b03024, #f0c612, #22c994, #5199d3, #8d426c, #b03024);
  font-weight: 900;
  box-shadow: inset 0 0 0 16px rgba(255,255,255,.25);
}
.keyboard-key {
  display: inline-grid;
  place-items: center;
  min-width: 56px;
  max-width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  margin: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.color-swatch { height: 70px; border-radius: var(--radius); border: 1px solid var(--border); }

.notice {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  color: var(--text);
  overflow-wrap: anywhere;
}
.html-run-workbench .notice.danger {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}
.success {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.error-text { color: var(--danger); font-weight: 700; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); background: var(--surface); }
.footer-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 14px 24px; padding: 20px 0; }
.footer-summary { display: grid; gap: 4px; min-width: 0; }
.footer-summary strong { color: var(--text); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 14px; }
.footer-links a { color: var(--muted); font-size: 13px; font-weight: 700; }
.footer-links a:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.footer-filing { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; text-align: center; }

.legal-page {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.legal-nav {
  position: sticky;
  top: 85px;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.legal-nav a { padding: 8px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 700; }
.legal-nav a:hover,
.legal-nav a[aria-current="page"] { color: var(--primary); background: var(--surface-2); }
.legal-document {
  min-width: 0;
  padding: clamp(20px, 4vw, 42px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.legal-document h1 { margin-top: 0; }
.legal-document h2 { margin-top: 30px; font-size: 21px; }
.legal-document p,
.legal-document li { max-width: 78ch; }
.legal-document table { width: 100%; min-width: 0; border-collapse: collapse; margin: 18px 0; }
.legal-document th,
.legal-document td { padding: 10px; border: 1px solid var(--border); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.legal-document th { background: var(--surface-2); }
.legal-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.legal-meta span { padding: 4px 8px; border-radius: var(--radius-sm); color: var(--muted); background: var(--surface-2); font-size: 12px; }

[data-theme="dark"] .toast {
  color: #1f1712;
  background: #f7efe3;
}
[data-theme="dark"] .html-run-btn,
[data-theme="dark"] .html-run-preview-tab {
  background: var(--surface);
}
[data-theme="dark"] .html-run-live-toggle,
[data-theme="dark"] .html-run-select {
  background: var(--surface);
}
[data-theme="dark"] .html-run-line-numbers {
  border-right-color: var(--border);
  color: #8b949e;
}
[data-theme="dark"] .html-run-preview-viewport {
  background: color-mix(in srgb, var(--surface-2) 75%, #000000);
}
[data-theme="dark"] .html-run-preview-viewport[data-preview-width="auto"] {
  background: #ffffff;
}

.prose, .seo-content {
  max-width: 76ch;
  color: var(--text);
}
.prose p, .seo-content p { margin: 0 0 1em; }
.prose a, .seo-content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.page-grid, .tool-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

@media (max-width: 900px) {
  :root { --content-shell-width: min(100% - 20px, 1600px); }
  .hero, .layout { grid-template-columns: 1fr; }
  .layout { min-height: 0; }
  .app-shell.is-home { width: min(100% - 20px, 1600px); }
  .home-channel-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand toggle"
      "search search"
      "nav nav";
    align-items: center;
    width: min(100% - 20px, 1600px);
  }
  .home-nav-toggle {
    display: inline-flex;
  }
  .home-channel-links {
    display: none;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
    overflow: visible;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .home-channel-bar.is-nav-open .home-channel-links {
    display: flex;
  }
  .home-channel-links a {
    flex: 0 1 auto;
  }
  .home-layout {
    grid-template-columns: 1fr;
  }
  .home-sidebar {
    position: static;
    display: flex;
    align-items: stretch;
    gap: 6px;
    min-width: 0;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .home-sidebar-title {
    flex: 0 0 auto;
    padding: 7px 8px;
  }
  .home-sidebar a {
    flex: 0 0 clamp(132px, 34vw, 178px);
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    white-space: normal;
  }
  .resource-detail-layout {
    grid-template-columns: 1fr;
  }
  .resource-anchor-panel {
    position: static;
    display: flex;
    align-items: stretch;
    gap: 6px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .resource-anchor-title {
    flex: 0 0 auto;
    padding: 7px 8px;
  }
  .resource-anchor-panel a {
    flex: 0 0 clamp(132px, 34vw, 178px);
  }
  .html-run-shell {
    grid-template-columns: 1fr;
    gap: 12px;
    height: auto;
  }
  .html-run-divider {
    display: none;
  }
  .html-run-pane {
    min-height: 480px;
  }
  .html-run-preview-pane {
    min-height: 420px;
  }
  .layout > .side-panel,
  .layout > .side-expand-toggle { order: 1; }
  .layout > section { order: 2; }
  .layout.is-side-collapsed { grid-template-columns: 1fr; }
  .layout.is-side-collapsed .tool-header { min-height: 0; padding-left: 0; }
  .layout.is-side-collapsed .side-expand-toggle {
    position: static;
    justify-self: start;
    margin-bottom: 10px;
  }
  .side-panel {
    position: static;
    display: flex;
    align-items: stretch;
    gap: 6px;
    height: auto;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .side-header {
    flex: 0 0 auto;
    margin: 0;
  }
  .side-title {
    padding: 7px 8px;
  }
  .side-scroll {
    display: contents;
  }
  .side-link {
    flex: 0 0 clamp(132px, 34vw, 178px);
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    white-space: normal;
  }
  .form-grid, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
  .hero-card { padding: 24px; }
}

@media (max-width: 560px) {
  :root { --content-shell-width: calc(100% - 20px); }
  .shell { width: min(100% - 20px, 1180px); }
  .home-channel-brand {
    white-space: normal;
  }
  .home-search-box {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }
  .home-link-wall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .home-link {
    grid-template-columns: 32px minmax(0, 1fr);
    min-height: 62px;
    padding: 8px;
  }
  .home-link-icon {
    width: 30px;
    height: 30px;
  }
  .home-other-row {
    grid-template-columns: 1fr;
  }
  .home-other-label {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .home-other-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
  }
  .home-other-link {
    min-height: 30px;
  }
  .home-reference-search-line {
    grid-template-columns: 1fr;
  }
  .resource-hero {
    padding: 14px;
  }
  .resource-hero h1 {
    font-size: 26px;
  }
  .resource-detail-head {
    padding: 10px;
  }
  .resource-detail-grid {
    grid-template-columns: 1fr;
    padding: 8px;
  }
  .resource-detail-card {
    min-height: 56px;
  }
  .footer-inner,
  .legal-page {
    grid-template-columns: 1fr;
  }
  .footer-links { justify-content: flex-start; }
  .legal-nav { position: static; }
  .merge-board {
    gap: 6px;
  }
  .gomoku-board {
    padding: 5px;
  }
  .search-line { grid-template-columns: 1fr; }
  .tool-workbench { padding: 14px; }
  .app-shell { padding-top: 18px; }
  .hero { gap: 14px; margin-bottom: 18px; }
  .hero-card { padding: 22px; }
  h1 { font-size: clamp(28px, 10vw, 38px); }
  .hero p { font-size: 15px; }
  .hero-actions > *, .search-line > button { width: 100%; }
  .stats-card { padding: 0; }
  .stat { padding: 14px; }
  .textarea-field.is-expanded {
    inset: 8px;
    padding: 10px;
  }
  .code-textarea-field {
    --code-editor-padding: 12px;
    --code-editor-font-size: 16px;
  }
  .tool-toolbar .btn,
  .tool-toolbar .primary-btn,
  .tool-toolbar .secondary-btn,
  .tool-toolbar .danger-btn {
    flex: 1 1 calc(50% - 10px);
  }
  .html-run-toolbar,
  .html-run-preview-toolbar {
    padding: 10px;
  }
  .html-run-preview-actions,
  .html-run-preview-controls {
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  .html-run-preview-actions .html-run-preview-tab,
  .html-run-preview-actions .html-run-btn {
    flex: 1 1 calc(33.333% - 6px);
  }
  .html-run-btn {
    flex: 0 0 calc(50% - 5px);
    white-space: normal;
  }
  .html-run-live-toggle,
  .html-run-select,
  .html-run-status {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
  }
  .html-run-select {
    justify-content: space-between;
  }
  .html-run-select select {
    min-width: 0;
    max-width: 100%;
  }
  .html-run-status {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    flex-basis: 100%;
    text-align: left;
  }
  .html-run-editor-body {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .html-run-line-numbers {
    padding-right: 8px;
  }
  .toast {
    width: min(calc(100% - 22px), 420px);
    border-radius: var(--radius-sm);
    text-align: center;
  }
}

@media (max-width: 380px) {
  :root { --content-shell-width: calc(100% - 20px); }
  .shell { width: min(100% - 20px, 1180px); }
  .home-search-clear { padding: 0 9px; }
  .tool-toolbar .btn,
  .tool-toolbar .primary-btn,
  .tool-toolbar .secondary-btn,
  .tool-toolbar .danger-btn {
    flex-basis: 100%;
  }
  .html-run-btn {
    flex-basis: 100%;
  }
  .html-run-preview-actions .html-run-preview-tab,
  .html-run-preview-actions .html-run-btn {
    flex-basis: 100%;
  }
  .html-run-live-toggle,
  .html-run-select,
  .html-run-status {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
