/* Base: reset, typography, controls and shared components. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  /* UI scale: every size is in rem. 1rem grows from 100% at 1280px-wide viewports to 125% at 1600px and up,
     which keeps the effective layout width at 1280 CSS px across that range (so no breakpoint changes) and
     makes big screens read like browser zoom 125%. Phones and tablets stay at 100%; browser zoom still works. */
  font-size: clamp(100%, calc(100% + (100vw - 1280px) / 80), 125%);
}
body {
  font: 400 .875rem/1.45 var(--font-ui);
  font-feature-settings: "ss01" 0, "cv11" 1;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
img, svg, canvas, video { display: block; }
h1, h2, h3, p { margin: 0; }
[hidden], .hidden { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: var(--accent-soft); }
.mono, code, kbd { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.grow { flex: 1 1 auto; min-width: 0; }
.error-text { color: var(--removed-text); }
.noscript { padding: 1.5rem; }

/* Scrollbars: thin and quiet. */
/* Scrollbars: thick enough to grab (14px at 100% UI scale, grows with rem), a visible thumb that widens on hover/drag,
   and a minimum thumb length so very long lines still give something to hold. Chromium ignores ::-webkit-scrollbar
   on elements that set the standard scrollbar-* properties, so those are applied to Firefox only (where "auto" is the
   thick option). Bars that are hidden on purpose (breadcrumbs, filter bar, toolbars) opt out with scrollbar-width: none. */
@supports (-moz-appearance: none) {
  * { scrollbar-width: auto; scrollbar-color: var(--scroll-thumb) var(--scroll-track); }
}
::-webkit-scrollbar { width: .875rem; height: .875rem; }
::-webkit-scrollbar-track { background: var(--scroll-track); }
::-webkit-scrollbar-thumb {
  min-width: 3rem; min-height: 3rem; border-radius: 62.4375rem;
  background-color: var(--scroll-thumb); border: .1875rem solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); border-width: .125rem; }
::-webkit-scrollbar-thumb:active { background-color: var(--scroll-thumb-active); border-width: .125rem; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; }

.skip-link {
  position: fixed; left: .75rem; top: -3rem; z-index: 100; padding: .5rem .875rem; border-radius: var(--r-sm);
  background: var(--text); color: var(--ink-inverse); font-weight: 600; transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: .625rem; }

kbd {
  display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .3125rem;
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: .3125rem;
  background: var(--surface-2); color: var(--text-2); font-size: .6875rem; line-height: 1;
}

.icon { display: inline-grid; place-items: center; flex: none; }
.file-icon { display: inline-grid; place-items: center; flex: none; width: 1.25rem; height: 1.25rem; }
.file-icon svg { width: 1.125rem; height: 1.125rem; }
.cat-folder { color: var(--cat-folder); }
.cat-model { color: var(--cat-model); }
.cat-texture { color: var(--cat-texture); }
.cat-material { color: var(--cat-material); }
.cat-particle { color: var(--cat-particle); }
.cat-sound { color: var(--cat-sound); }
.cat-script { color: var(--cat-script); }
.cat-panorama { color: var(--cat-panorama); }
.cat-animation { color: var(--cat-animation); }
.cat-video { color: var(--cat-video); }
.cat-map { color: var(--cat-other); }
.cat-other { color: var(--cat-other); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; height: 2.125rem; padding: 0 .875rem;
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  font-weight: 550; font-size: .8125rem; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--text); color: var(--ink-inverse); border-color: var(--text); }
.btn-primary:hover { background: var(--text); border-color: var(--text); opacity: .9; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover { color: var(--text); }
.btn-sm { height: 1.75rem; padding: 0 .625rem; font-size: .7812rem; gap: .375rem; }
.btn-lg { height: 2.625rem; padding: 0 1.125rem; font-size: .875rem; border-radius: .5rem; }

.icon-btn {
  display: inline-grid; place-items: center; width: 2.125rem; height: 2.125rem; border-radius: var(--r-sm); color: var(--text-2); flex: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn[aria-pressed="true"], .icon-btn[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: .4; pointer-events: none; }
.icon-btn.sm { width: 1.75rem; height: 1.75rem; }

.input, .select {
  height: 2.125rem; padding: 0 .625rem; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text); min-width: 0;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.select { padding-right: 1.75rem; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23878f9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .5rem center; background-size: .875rem; }
.select option { background: var(--surface-1); color: var(--text); }

/* ------------------------------------------------------------ segmented */
.segmented {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: .5rem;
  background: var(--surface-2); border: 1px solid var(--line); flex: none;
}
.seg {
  display: inline-flex; align-items: center; gap: .375rem; height: 1.75rem; padding: 0 .625rem; border-radius: .375rem;
  color: var(--text-2); font-size: .8125rem; font-weight: 500; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.seg:hover { color: var(--text); }
.seg[aria-pressed="true"] { background: var(--surface-4); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
:root[data-theme="light"] .seg[aria-pressed="true"] { background: var(--surface-1); box-shadow: 0 1px 2px rgba(20, 22, 28, .12), 0 0 0 1px var(--line); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .seg[aria-pressed="true"] { background: var(--surface-1); box-shadow: 0 1px 2px rgba(20, 22, 28, .12), 0 0 0 1px var(--line); } }
.seg:disabled { opacity: .45; }
.seg-count { font-family: var(--font-mono); font-size: .7188rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.seg[aria-pressed="true"] .seg-count { color: var(--text-2); }
.seg-sm .seg { height: 1.625rem; padding: 0 .5rem; font-size: .7812rem; }
.seg.k-added::before, .seg.k-modified::before, .seg.k-removed::before { content: ""; width: .4375rem; height: .4375rem; border-radius: 2px; flex: none; }
.seg.k-added::before { background: var(--added); }
.seg.k-modified::before { background: var(--modified); }
.seg.k-removed::before { background: var(--removed); }

/* ------------------------------------------------------------ change marks */
.change-counts { display: inline-flex; gap: .375rem; font-family: var(--font-mono); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.change-counts.compact { gap: .3125rem; font-size: .6875rem; }
.cc-added { color: var(--added-text); }
.cc-modified { color: var(--modified-text); }
.cc-removed { color: var(--removed-text); }
.change-bar { display: flex; gap: 2px; height: .375rem; border-radius: .1875rem; overflow: hidden; min-width: 0; }
.change-bar > span { min-width: 2px; height: 100%; }
.change-bar > span:first-child { border-radius: .1875rem 0 0 .1875rem; }
.change-bar > span:last-child { border-radius: 0 .1875rem .1875rem 0; }
.change-bar > span:only-child { border-radius: .1875rem; }
.seg-added { background: var(--added); }
.seg-modified { background: var(--modified); }
.seg-removed { background: var(--removed); }
.seg-rest { background: var(--surface-4); }
.seg-single { background: var(--accent); opacity: .85; }
.change-bar.mini { width: 2.75rem; height: .25rem; gap: 1px; }

.kind-badge {
  display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .3125rem; border-radius: .3125rem;
  font: 700 .6875rem/1 var(--font-mono); letter-spacing: .02em; flex: none;
}
.kind-badge.long { height: 1.375rem; padding: 0 .5rem; font: 650 .6875rem/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; }
.kind-added { color: var(--added-text); background: var(--added-soft); }
.kind-modified { color: var(--modified-text); background: var(--modified-soft); }
.kind-removed { color: var(--removed-text); background: var(--removed-soft); }
.dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; flex: none; }
.dot-old { background: var(--removed); }
.dot-new { background: var(--added); }

.ext-chip {
  display: inline-block; max-width: 100%; padding: 1px .375rem; border-radius: var(--r-xs); background: var(--surface-3);
  color: var(--text-2); font: 500 .6875rem/1.125rem var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag {
  display: inline-flex; align-items: center; height: 1.25rem; padding: 0 .4375rem; border-radius: 62.4375rem; border: 1px solid var(--line-2);
  color: var(--text-2); font-size: .6875rem; font-weight: 550; letter-spacing: .02em; white-space: nowrap;
}
.tag-accent { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------ popovers & menus */
.popover {
  position: fixed; z-index: 60; min-width: 13.75rem; max-width: min(26.25rem, calc(100vw - 1rem)); overflow: auto;
  background: var(--surface-1); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(-.25rem) scale(.98); transform-origin: top left;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.popover.show { opacity: 1; transform: none; }
.popover:focus-visible { outline: none; }
.popover-scrim { position: fixed; inset: 0; z-index: 59; background: var(--scrim); }
.popover.as-sheet {
  left: 0 !important; right: 0; bottom: 0; top: auto !important; max-width: none; max-height: 82vh;
  border-radius: var(--r-lg) var(--r-lg) 0 0; transform: translateY(1.5rem); padding-bottom: env(safe-area-inset-bottom);
}
.popover.as-sheet.show { transform: none; }
.menu { display: flex; flex-direction: column; padding: .375rem; }
.menu-item {
  display: flex; align-items: center; gap: .625rem; min-height: 2.125rem; padding: .375rem .625rem; border-radius: var(--r-sm);
  text-align: left; color: var(--text); font-size: .8125rem; width: 100%;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item[aria-disabled="true"] { color: var(--text-3); pointer-events: none; }
.menu-item .icon { color: var(--text-2); }
.menu-label { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.menu-label small { color: var(--text-3); font-size: .7188rem; }
.menu-hint { color: var(--text-3); font-size: .75rem; }
.menu-check { width: 1rem; display: inline-grid; place-items: center; color: var(--accent); }
.menu-sep { height: 1px; background: var(--line); margin: .375rem .25rem; }
.menu-heading { padding: .5rem .625rem .25rem; color: var(--text-3); font-size: .6875rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

/* ------------------------------------------------------------ dialog */
.dialog {
  width: min(30rem, calc(100vw - 2rem)); padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-lg);
  background: var(--surface-1); color: var(--text); box-shadow: var(--shadow-pop);
}
.dialog::backdrop { background: var(--scrim); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .5rem 1.25rem; }
.dialog-head h2 { font: 600 .9375rem/1.3 var(--font-display); letter-spacing: -.01em; }
.shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: .625rem 1.125rem; margin: 0; padding: .5rem 1.25rem 1.375rem; align-items: center; }
.shortcut-list dt { display: flex; gap: .25rem; align-items: center; justify-content: flex-end; }
.shortcut-list dd { margin: 0; color: var(--text-2); }

/* ------------------------------------------------------------ toasts */
.toasts {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: .5rem;
  transform: translateX(-50%); pointer-events: none; width: max-content; max-width: calc(100vw - 2rem);
}
.toast {
  display: flex; align-items: center; gap: .625rem; padding: .625rem .875rem; border-radius: var(--r-md);
  background: var(--text); color: var(--ink-inverse); box-shadow: var(--shadow-pop); font-size: .8125rem; font-weight: 500;
  opacity: 0; transform: translateY(.625rem); transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--removed); color: #fff; }

/* ------------------------------------------------------------ skeletons, spinner, states */
.skeleton {
  display: block; border-radius: .3125rem; background: var(--skeleton);
  background-image: linear-gradient(90deg, transparent 0, var(--skeleton-hi) 50%, transparent 100%);
  background-size: 200% 100%; background-repeat: no-repeat; animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.skeleton-lines { display: flex; flex-direction: column; padding: .375rem 0; }
.skeleton-line { display: flex; align-items: center; gap: .75rem; height: var(--row-h); padding: 0 1rem; }
.sk-icon { width: 1.125rem; height: 1.125rem; border-radius: .3125rem; flex: none; }
.sk-text { height: .625rem; }
.sk-line { height: .75rem; }
.sk-title { width: 16.25rem; max-width: 70%; height: 2.75rem; border-radius: .5rem; }
.sk-summary { width: 13.75rem; height: .625rem; }
.skeleton-text { color: transparent !important; background: var(--skeleton); border-radius: .375rem; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.spinner {
  width: 1.125rem; height: 1.125rem; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; text-align: center;
  padding: 3rem 1.5rem; margin: auto; max-width: 26.25rem; color: var(--text-2);
}
.state-icon {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: .75rem; margin-bottom: .25rem;
  background: var(--surface-3); color: var(--text-2);
}
.state-error .state-icon { background: var(--removed-soft); color: var(--removed-text); }
.state-title { color: var(--text); font-weight: 600; font-size: .9062rem; }
.state-body { font-size: .8125rem; overflow-wrap: anywhere; }
.state .btn { margin-top: .5rem; }

.notice {
  display: flex; align-items: center; gap: .5rem; padding: .5625rem .875rem; font-size: .7812rem; color: var(--text-2);
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}

.legend { display: inline-flex; flex-wrap: wrap; gap: .375rem .875rem; font-size: .75rem; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: .375rem; }
.legend-swatch { width: .625rem; height: .625rem; border-radius: .1875rem; }

.link-arrow { display: inline-flex; align-items: center; gap: .25rem; color: var(--accent); font-size: .8125rem; font-weight: 550; white-space: nowrap; }
.link-arrow:hover { text-decoration: underline; text-underline-offset: .1875rem; }
.link-arrow .icon { transition: transform var(--t-fast) var(--ease); }
.link-arrow:hover .icon { transform: translateX(2px); }

.checker {
  background-color: var(--checker-b);
  background-image: conic-gradient(var(--checker-a) 25%, transparent 0 50%, var(--checker-a) 0 75%, transparent 0);
  background-size: 1rem 1rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .skeleton { animation: none; }
}
@media (pointer: coarse) {
  .hide-touch { display: none !important; }
}
