:root {
  --font-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Menlo, monospace;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.06);
  --shadow-float: 0 8px 30px rgba(15, 23, 42, 0.1);
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.75rem;
  --line: 1px solid var(--border);
  --focus: 0 0 0 3px var(--ring);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f4f6;
    --bg-card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --danger: #dc2626;
    --ring: rgba(37, 99, 235, 0.35);
    --overlay: rgba(17, 24, 39, 0.4);
    --search-bg: #ffffff;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1419;
    --bg-card: #1a222d;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --border: #2d3748;
    --accent: #60a5fa;
    --accent-soft: rgba(96, 165, 250, 0.15);
    --danger: #f87171;
    --ring: rgba(96, 165, 250, 0.4);
    --overlay: rgba(0, 0, 0, 0.55);
    --search-bg: #1a222d;
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --bg-card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --danger: #dc2626;
  --ring: rgba(37, 99, 235, 0.35);
  --overlay: rgba(17, 24, 39, 0.4);
  --search-bg: #ffffff;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --bg-card: #1a222d;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --border: #2d3748;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --danger: #f87171;
  --ring: rgba(96, 165, 250, 0.4);
  --overlay: rgba(0, 0, 0, 0.55);
  --search-bg: #1a222d;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body.hub-body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

body.hub-body--shell {
  padding-bottom: var(--space-10);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.hub-skip {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.hub-skip:focus {
  left: var(--space-4);
  top: var(--space-4);
  width: auto;
  height: auto;
  padding: var(--space-2) var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  z-index: 1000;
  box-shadow: var(--focus);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hub-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-10);
}

@media (min-width: 640px) {
  .hub-shell {
    padding: var(--space-8) var(--space-8) var(--space-10);
  }
}

.hub-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.hub-top__brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.hub-logo {
  flex-shrink: 0;
}

.hub-logo__svg {
  display: block;
}

.hub-top__titles {
  min-width: 0;
}

.hub-top__title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.hub-top__subtitle {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
  font-weight: 400;
}

.hub-top__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  justify-content: flex-end;
  min-width: min(100%, 320px);
}

.hub-search-pill {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 420px;
  min-width: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--search-bg);
  border: var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  gap: var(--space-2);
}

.hub-search-pill:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.hub-search-pill__icon {
  color: var(--muted);
  flex-shrink: 0;
  display: flex;
}

.hub-search-pill__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--text);
  outline: none;
}

.hub-search-pill__input::placeholder {
  color: var(--muted);
}

.hub-more {
  position: relative;
  flex-shrink: 0;
}

.hub-more__trigger {
  list-style: none;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  border: var(--line);
  background: var(--bg-card);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}

.hub-more__trigger::-webkit-details-marker {
  display: none;
}

.hub-more__trigger:hover {
  color: var(--text);
  border-color: var(--border);
}

.hub-more__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  padding: var(--space-2);
  background: var(--bg-card);
  border: var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  z-index: 40;
}

.hub-more__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-3) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.hub-more__link {
  color: var(--accent);
}

.hub-more__item:hover {
  background: var(--accent-soft);
}

.hub-ad-slot {
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
}

.hub-recent {
  margin-bottom: var(--space-8);
}

.hub-recent__heading {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 var(--space-3);
  letter-spacing: 0.02em;
}

.hub-recent__pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.hub-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  border: var(--line);
  background: var(--bg-card);
  font: inherit;
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.hub-pill:hover {
  border-color: var(--accent);
}

.hub-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hub-main--modern {
  min-height: 40vh;
}

.hub-status--inline {
  font-size: var(--text-xs);
  color: var(--muted);
  margin: 0 0 var(--space-4);
  min-height: 1em;
}

.hub-section {
  margin-bottom: var(--space-10);
}

.hub-section__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.hub-section__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hub-section__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hub-section__count {
  margin-left: auto;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  padding: var(--space-1) var(--space-3);
  background: var(--bg-card);
  border: var(--line);
  border-radius: var(--radius-pill);
}

.hub-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-5);
}

.hub-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-5);
  border: var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.hub-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #d1d5db;
}

.hub-card:focus {
  outline: none;
  box-shadow: var(--focus);
}

.hub-card:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.hub-card__iconbox {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  font-size: 1.25rem;
  line-height: 1;
}

html[data-theme="dark"] .hub-card__iconbox {
  background: #252f3d;
}

.hub-card__iconbox svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.hub-card__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hub-card__desc {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hub-card__tag {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  padding: var(--space-1) var(--space-3);
  background: #f9fafb;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

html[data-theme="dark"] .hub-card__tag {
  background: #252f3d;
}

.hub-empty {
  text-align: center;
  padding: var(--space-10);
  color: var(--muted);
  font-size: var(--text-sm);
}

.hub-scroll-hint {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: var(--line);
  background: var(--bg-card);
  box-shadow: var(--shadow-float);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  opacity: 0.92;
}

.hub-scroll-hint:hover {
  color: var(--accent);
}

.hub-scroll-hint.is-hidden {
  display: none;
}

.hub-palette-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 80;
  display: none;
}

.hub-palette-backdrop.is-open {
  display: block;
}

.hub-palette {
  position: fixed;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 2rem));
  max-height: min(400px, 65vh);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  border: var(--line);
  z-index: 90;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.hub-palette.is-open {
  display: flex;
}

.hub-palette__input {
  width: 100%;
  padding: var(--space-4);
  border: 0;
  border-bottom: var(--line);
  font: inherit;
  background: var(--bg-card);
  color: var(--text);
}

.hub-palette__input:focus {
  outline: none;
}

.hub-palette__list {
  margin: 0;
  padding: var(--space-2);
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.hub-palette__item {
  width: 100%;
  text-align: left;
  padding: var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hub-palette__item:hover,
.hub-palette__item.is-active {
  background: var(--accent-soft);
}

.hub-palette__item small {
  color: var(--muted);
  font-size: var(--text-xs);
}

.hub-viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: none;
  flex-direction: column;
}

.hub-viewer.is-open {
  display: flex;
}

.hub-viewer.is-max .hub-viewer__chrome {
  display: none !important;
}

.hub-viewer__chrome {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--line);
  background: var(--bg-card);
  flex-wrap: wrap;
}

.hub-viewer__title {
  font-weight: 600;
  flex: 1;
  min-width: 120px;
}

.hub-viewer__hint {
  font-size: var(--text-xs);
  color: var(--muted);
  font-family: var(--font-mono);
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: var(--line);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.hub-btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.hub-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.hub-viewer__frame-wrap {
  flex: 1;
  position: relative;
  background: var(--bg);
}

.hub-viewer__frame {
  border: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #fff;
}

.hub-viewer__loading,
.hub-viewer__error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  text-align: center;
  color: var(--muted);
}

.hub-viewer__error {
  color: var(--danger);
}

body.hub-body--landing {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
}

.hub-landing {
  max-width: 560px;
  background: var(--bg-card);
  border: var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
}

.hub-landing__path {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--muted);
}

@media (max-width: 768px) {
  .hub-viewer__hint {
    display: none;
  }

  .hub-top__actions {
    width: 100%;
    justify-content: stretch;
  }

  .hub-search-pill {
    max-width: none;
  }
}
