:root {
  color-scheme: dark;
  --page: #07111b;
  --panel: #0a1723;
  --panel-strong: #0d1d2b;
  --line: #284052;
  --line-strong: #3f6870;
  --ink: #e6f0f5;
  --muted: #849cab;
  --cyan: #70e2d0;
  --green: #7bd59f;
  --violet: #b695da;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); background: var(--page); font-family: var(--sans); letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
a { color: inherit; }
.skip-link { position: fixed; z-index: 20; top: 8px; left: 8px; padding: 9px 12px; color: #061019; background: var(--cyan); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.source-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px clamp(18px, 3vw, 44px); background: #091722; border-bottom: 1px solid var(--line-strong); }
.source-brand { min-width: 0; display: flex; align-items: center; gap: 14px; }
.source-brand p { margin: 0 0 4px; color: var(--green); font-family: var(--mono); font-size: 9px; }
.source-brand h1 { margin: 0; color: #f2f7fa; font-size: clamp(17px, 2vw, 24px); line-height: 1.15; }
.source-signal { width: 34px; height: 34px; display: grid; grid-template-columns: repeat(3, 6px); align-items: end; justify-content: center; gap: 3px; padding: 7px; border: 1px solid #477078; }
.source-signal i { display: block; background: var(--cyan); }
.source-signal i:nth-child(1) { height: 8px; }
.source-signal i:nth-child(2) { height: 15px; background: var(--violet); }
.source-signal i:nth-child(3) { height: 11px; background: var(--green); }
.source-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.source-actions a, .source-file-actions a, .source-file-actions button, .source-binary a { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 7px 11px; color: #b9d0dc; background: #0c202d; border: 1px solid #385567; border-radius: 2px; font-family: var(--mono); font-size: 9px; text-decoration: none; cursor: pointer; }
.source-actions a:last-child, .source-binary a { color: #092018; background: var(--green); border-color: #a3ebbd; font-weight: 700; }
.source-actions a:hover, .source-file-actions a:hover, .source-file-actions button:hover, .source-binary a:hover { color: #061019; background: var(--cyan); border-color: #aaf6eb; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid #b7fff3; outline-offset: 2px; }

.source-workbench { min-height: calc(100vh - 118px); display: grid; grid-template-columns: minmax(278px, 340px) minmax(0, 1fr); }
.source-sidebar { min-width: 0; display: flex; flex-direction: column; background: #08141f; border-right: 1px solid var(--line); }
.project-preview { position: relative; height: 168px; margin: 0; overflow: hidden; background: #dfe6e5; border-bottom: 1px solid var(--line); }
.project-preview img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: 50% 52%; }
.project-preview::after { content: ""; position: absolute; right: 0; bottom: 0; left: 0; height: 58px; background: rgba(4, 12, 19, .9); pointer-events: none; }
.project-preview figcaption { position: absolute; z-index: 1; right: 15px; bottom: 13px; left: 15px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.project-preview strong { color: #f2f7f8; font-size: 14px; }
.project-preview span { color: #bad0d8; font-family: var(--mono); font-size: 8px; }
.source-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-bottom: 1px solid var(--line); }
.source-stats div { min-width: 0; padding: 12px 8px 10px; text-align: center; }
.source-stats div + div { border-left: 1px solid var(--line); }
.source-stats dt { color: var(--cyan); font-family: var(--mono); font-size: 13px; font-weight: 700; }
.source-stats dd { margin: 3px 0 0; color: #728b9b; font-family: var(--mono); font-size: 7px; }
.source-search { position: relative; padding: 14px; border-bottom: 1px solid var(--line); }
.source-search label { display: block; margin-bottom: 7px; color: #9db2be; font-family: var(--mono); font-size: 8px; }
.source-search input { width: 100%; height: 36px; padding: 7px 34px 7px 10px; color: #dce9ef; background: #06101a; border: 1px solid #385264; border-radius: 2px; font-family: var(--mono); font-size: 10px; }
.source-search input::placeholder { color: #536b7a; }
.source-search kbd { position: absolute; right: 23px; bottom: 23px; color: #6f8795; font-family: var(--mono); font-size: 9px; }
.source-tree { min-height: 280px; max-height: calc(100vh - 389px); padding: 7px 0 18px; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #345363 #08141f; scrollbar-width: thin; }
.source-tree-state { margin: 14px; color: var(--muted); font-size: 11px; }
.source-tree details { min-width: 0; }
.source-tree > .source-group { border-bottom: 1px solid rgba(40, 64, 82, .62); }
.source-tree summary { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 14px; color: #b5c9d3; font-family: var(--mono); font-size: 9px; cursor: pointer; list-style: none; }
.source-tree summary::-webkit-details-marker { display: none; }
.source-tree summary::before { content: "+"; flex: 0 0 12px; width: 12px; color: var(--green); }
.source-tree details[open] > summary::before { content: "-"; }
.source-tree summary span:first-of-type { flex: 1; overflow-wrap: anywhere; }
.source-tree summary small { color: #607987; font-size: 8px; }
.source-tree .source-directory { border: 0; }
.source-tree .source-directory > summary { min-height: 31px; padding-block: 5px; color: #92abb7; }
.source-tree .source-directory > summary::before { color: #7794a1; }
.source-tree-list { margin: 0; padding: 0 0 7px; list-style: none; }
.source-tree-list .source-tree-list { margin-left: 14px; padding-bottom: 2px; border-left: 1px solid #203847; }
.source-tree button { appearance: none; width: 100%; min-height: 31px; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 5px; padding: 6px 14px; color: #8098a6; text-align: left; background: transparent; border: 0; border-left: 2px solid transparent; font-family: var(--mono); font-size: 9px; cursor: pointer; }
.source-tree button span { color: #58717f; font-size: 7px; text-transform: uppercase; }
.source-tree button b { min-width: 0; font-weight: 400; line-height: 1.45; overflow-wrap: anywhere; }
.source-tree button:hover { color: #dcebf0; background: #0d202c; }
.source-tree button[aria-current="true"] { color: #effbf7; background: #12302f; border-left-color: var(--green); }
.source-tree mark { color: #061019; background: var(--cyan); }
.source-search-results { padding-top: 7px; }
.source-tree .source-search-result { grid-template-columns: 34px minmax(0, 1fr); min-height: 38px; padding-block: 7px; }
.source-tree .source-search-result b { color: #b9ccd5; }

.source-viewer { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr); background: var(--panel); }
.source-viewer-header { min-width: 0; min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px clamp(16px, 2.4vw, 32px); background: var(--panel-strong); border-bottom: 1px solid var(--line); }
.source-file-title { min-width: 0; }
.source-file-title p { margin: 0 0 5px; color: var(--green); font-family: var(--mono); font-size: 8px; }
.source-file-title h2 { margin: 0; color: #eef6f8; font-family: var(--mono); font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.source-file-actions { flex: 0 0 auto; display: flex; gap: 6px; }
.source-file-actions button { appearance: none; }
.source-file-actions [hidden] { display: none; }
.source-view-switch { flex: 0 0 auto; display: inline-grid; grid-template-columns: repeat(2, minmax(70px, 1fr)); border: 1px solid #385567; border-radius: 2px; overflow: hidden; }
.source-file-actions .source-view-switch button { min-height: 32px; padding: 6px 10px; color: #7794a1; background: #071721; border: 0; border-radius: 0; }
.source-file-actions .source-view-switch button + button { border-left: 1px solid #385567; }
.source-file-actions .source-view-switch button[aria-pressed="true"] { color: #082017; background: var(--green); font-weight: 700; }
.source-file-meta { min-height: 36px; display: flex; align-items: center; gap: 18px; padding: 7px clamp(16px, 2.4vw, 32px); color: #718b99; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 8px; }
.source-file-meta span + span::before { content: "/"; margin-right: 18px; color: #365264; }
.source-content { min-width: 0; min-height: 520px; height: calc(100vh - 190px); overflow: auto; overscroll-behavior: contain; background: #07121c; scrollbar-color: #345363 #07121c; scrollbar-width: thin; }
.source-content > [hidden] { display: none !important; }
.source-code { min-width: 100%; width: max-content; min-height: 100%; margin: 0; padding: 23px clamp(18px, 3vw, 42px) 48px; color: #c8d8df; background: #07121c; font-family: var(--mono); font-size: 12px; line-height: 1.7; tab-size: 2; white-space: pre; }
.source-image { min-height: 100%; margin: 0; padding: clamp(18px, 4vw, 48px); background: #dfe7e6; }
.source-image img { max-width: min(100%, 1120px); max-height: calc(100vh - 295px); display: block; margin: 0 auto; object-fit: contain; box-shadow: 0 0 0 1px rgba(5, 17, 27, .25), 10px 10px 0 rgba(5, 17, 27, .14); }
.source-image figcaption { width: fit-content; max-width: 100%; margin: 18px auto 0; padding: 6px 9px; color: #21343d; background: rgba(247, 250, 249, .88); font-family: var(--mono); font-size: 9px; overflow-wrap: anywhere; }
.source-model { position: relative; width: 100%; height: 100%; min-height: 520px; overflow: hidden; background: #071721; isolation: isolate; }
.source-model canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.source-model canvas[hidden] { display: none; }
.source-model-fallback { width: 100%; height: 100%; display: block; object-fit: contain; background: #dfe7e6; }
.source-model-fallback[hidden] { display: none; }
.source-model-meta { position: absolute; z-index: 2; top: 14px; right: 14px; left: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; pointer-events: none; }
.source-model-meta span { min-width: 0; max-width: min(560px, calc(100% - 52px)); padding: 7px 9px; color: #a9c5cf; background: rgba(5, 18, 27, .86); border: 1px solid #2c4a58; font-family: var(--mono); font-size: 8px; line-height: 1.4; overflow-wrap: anywhere; }
.source-model-meta button { pointer-events: auto; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; color: #b9d0dc; background: #0c202d; border: 1px solid #385567; border-radius: 2px; font-size: 20px; line-height: 1; cursor: pointer; }
.source-model-meta button:hover { color: #061019; background: var(--cyan); border-color: #aaf6eb; }
.source-binary { min-height: 100%; display: grid; place-content: center; justify-items: center; padding: 40px 24px; text-align: center; }
.source-binary > span { width: 92px; aspect-ratio: 1; display: grid; place-items: center; color: var(--green); border: 1px solid #4c746c; font-family: var(--mono); font-size: 18px; box-shadow: 8px 8px 0 #030a10; }
.source-binary h3 { margin: 24px 0 0; color: #edf7f3; font-size: 20px; }
.source-binary p { max-width: 420px; margin: 9px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.source-footer { min-height: 42px; display: flex; align-items: center; gap: 24px; padding: 8px clamp(18px, 3vw, 44px); color: #607b89; background: #07121b; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 8px; }
.source-footer a { color: #88cdb8; text-decoration: none; }
.source-footer a:first-of-type { margin-left: auto; }
.source-status { position: fixed; z-index: 10; right: 16px; bottom: 16px; max-width: min(360px, calc(100vw - 32px)); padding: 10px 13px; color: #07131c; background: var(--cyan); border: 1px solid #b7fff3; font-size: 11px; box-shadow: 5px 5px 0 rgba(0, 0, 0, .55); }

@media (max-width: 820px) {
  .source-header { align-items: flex-start; flex-direction: column; gap: 11px; padding-block: 14px; }
  .source-actions { width: 100%; justify-content: flex-start; }
  .source-workbench { min-height: 0; grid-template-columns: 1fr; }
  .source-sidebar { border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .project-preview { height: 190px; }
  .source-tree { max-height: 42vh; }
  .source-content { height: min(68vh, 700px); min-height: 440px; }
  .source-model { min-height: 440px; }
  .source-footer { flex-wrap: wrap; gap: 9px 18px; }
  .source-footer a { width: auto; margin-left: 0; }
  .source-footer a:first-of-type { width: 100%; margin-left: 0; }
}

@media (max-width: 520px) {
  .source-header { padding-inline: 14px; }
  .source-brand { align-items: flex-start; }
  .source-brand h1 { font-size: 17px; }
  .source-actions a { flex: 1 1 0; min-width: 0; }
  .project-preview { height: 162px; }
  .project-preview figcaption { align-items: flex-start; flex-direction: column; gap: 4px; }
  .source-viewer-header { align-items: flex-start; flex-direction: column; padding: 13px 14px; }
  .source-file-actions { width: 100%; overflow-x: auto; }
  .source-file-actions a, .source-file-actions button { flex: 1 0 auto; }
  .source-file-meta { flex-wrap: wrap; gap: 6px 12px; padding-inline: 14px; }
  .source-file-meta span + span::before { margin-right: 12px; }
  .source-content { height: 62vh; min-height: 390px; }
  .source-model { min-height: 390px; }
  .source-model-meta { top: 10px; right: 10px; left: 10px; }
  .source-code { padding: 18px 14px 36px; font-size: 11px; }
  .source-image { padding: 18px 12px 30px; }
  .source-image img { max-height: 50vh; }
  .source-footer { padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
