/* =============================================================================
   BV Lab shell — design tokens, layout, hub, tools
   Palette aligns with bvlab.no (#292929 chrome, #306b97 accent, #009a46 mark)
   ============================================================================= */

:root {
  /* Color */
  --shell-page-bg: #e5e5e5;
  --shell-chrome: #292929;
  --shell-chrome-2: #3a3a3a;
  --shell-chrome-3: #444444;
  --shell-chrome-border: #444444;
  --shell-chrome-text: #ffffff;
  --shell-chrome-muted: #b5b5b5;
  --shell-accent: #306b97;
  --shell-accent-soft: rgba(48, 107, 151, 0.35);
  --shell-brand-green: #009a46;
  --shell-content-bg: #ffffff;
  --shell-content-text: #292929;
  --shell-content-muted: #5a5a5a;
  --shell-card-border: #d4d4d4;
  --shell-field-bg: #ffffff;
  --shell-field-border: #c8c8c8;
  --shell-panel-bg: #f4f4f4;
  --shell-btn-secondary-bg: #e8e8e8;

  /* Space & layout */
  --shell-space-xs: 0.35rem;
  --shell-space-sm: 0.5rem;
  --shell-space-md: 1rem;
  --shell-space-lg: 1.5rem;
  --shell-space-xl: 2rem;
  --shell-gutter: clamp(1rem, 3vw, 1.75rem);
  --shell-radius: 8px;
  --shell-radius-sm: 6px;
  --shell-header-h: 3.75rem;
  --shell-header-h-app: 2.55rem;
  --shell-sidebar-w: 17rem;
  --shell-content-max: 900px;
  --shell-content-max-hub: 1120px;

  /* Type */
  --shell-font: Arial, Helvetica, system-ui, "Segoe UI", sans-serif;
  --shell-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --shell-line-height: 1.55;
  --shell-line-tight: 1.3;

  /* Elevation */
  --shell-main-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.06);
  --shell-main-border: rgba(41, 41, 41, 0.09);
  --shell-card-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.08);
}

body[data-shell-active] {
  --shell-header-h: var(--shell-header-h-app);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body.shell {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--shell-font);
  background: var(--shell-page-bg);
  color: var(--shell-content-text);
  line-height: var(--shell-line-height);
  -webkit-font-smoothing: antialiased;
}

/* --- Accessibility --- */
.shell-skip {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 10000;
  padding: 0.5rem 1rem;
  background: var(--shell-accent);
  color: #ffffff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  border-radius: var(--shell-radius-sm);
  text-decoration: none;
  border: none;
}

.shell-skip:focus {
  left: var(--shell-space-md);
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

#shell-main:focus {
  outline: none;
}

/* --- App frame --- */
.shell-body {
  display: flex;
  flex: 1;
  width: 100%;
  min-height: calc(100vh - var(--shell-header-h));
  padding-top: var(--shell-header-h);
  align-items: stretch;
}

/* --- Header --- */
.shell-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--shell-header-h);
  display: flex;
  align-items: stretch;
  background: var(--shell-chrome);
  color: var(--shell-chrome-text);
  border-bottom: 1px solid var(--shell-chrome-border);
  z-index: 30;
}

.shell-header-rest {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: var(--shell-space-sm);
  padding-right: var(--shell-gutter);
}

.shell-header-lead {
  min-width: 0;
  pointer-events: none;
}

.shell-header-center {
  justify-self: center;
  text-align: center;
}

.shell-header-end {
  justify-self: end;
  min-width: 0;
  max-width: min(46vw, 26rem);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.shell-header-end-spacer {
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  visibility: hidden;
  pointer-events: none;
}

.shell-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  flex: 0 0 3rem;
  height: auto;
  min-height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--shell-accent);
  color: #ffffff;
  cursor: pointer;
  box-sizing: border-box;
}

.shell-burger:hover {
  filter: brightness(1.08);
}

.shell-burger:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.shell-burger-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 1.125rem;
}

.shell-burger-bar {
  display: block;
  height: 2px;
  border-radius: 1px;
  background: #ffffff;
  width: 100%;
}

body[data-shell-active] .shell-tagline {
  display: none !important;
}

body[data-shell-active] .shell-main {
  padding-top: var(--shell-space-md);
}

.shell-brand {
  font-weight: 700;
  font-size: 1.5rem;
  line-height: var(--shell-line-tight);
  text-decoration: none;
  letter-spacing: -0.02em;
  color: var(--shell-chrome-text);
  display: inline-flex;
  align-items: baseline;
  border-radius: 4px;
}

.shell-brand:focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: 3px;
}

.shell-brand-bv {
  color: var(--shell-chrome-text);
}

.shell-brand-lab {
  color: var(--shell-brand-green);
}

.shell-brand:hover {
  opacity: 0.92;
}

.shell-brand:hover .shell-brand-lab {
  filter: brightness(1.06);
}

.shell-tagline {
  min-width: 0;
  font-size: 0.8125rem;
  line-height: var(--shell-line-tight);
  color: var(--shell-chrome-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
  text-align: right;
}

@media (min-width: 720px) {
  .shell-hub .shell-tagline {
    display: block;
  }
}

/* --- Sidebar --- */
@media (min-width: 901px) {
  body.shell-sidebar-collapsed .shell-sidebar {
    width: 0;
    min-width: 0;
    border-right-width: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

.shell-sidebar {
  width: var(--shell-sidebar-w);
  flex-shrink: 0;
  background: var(--shell-chrome);
  color: var(--shell-chrome-text);
  border-right: 1px solid var(--shell-chrome-border);
  position: sticky;
  top: var(--shell-header-h);
  align-self: stretch;
  min-height: calc(100vh - var(--shell-header-h));
  overflow: auto;
  transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
  visibility: visible;
  scrollbar-width: thin;
  scrollbar-color: var(--shell-chrome-3) var(--shell-chrome);
}

.shell-sidebar-inner {
  padding: var(--shell-space-md) var(--shell-space-md) var(--shell-space-lg);
}

.shell-sidebar-title {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--shell-chrome-muted);
  margin: 0 0 var(--shell-space-sm) var(--shell-space-xs);
}

.shell-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (prefers-reduced-motion: reduce) {
  .shell-sidebar {
    transition: none;
  }
}

.shell-nav-group {
  padding-top: var(--shell-space-sm);
}

.shell-nav-group:first-child {
  padding-top: 0;
}

.shell-nav-group + .shell-nav-group {
  margin-top: var(--shell-space-md);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: var(--shell-space-md);
}

.shell-nav-heading {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--shell-chrome-muted);
  padding: var(--shell-space-xs) var(--shell-space-sm);
  margin-bottom: 2px;
}

.shell-nav-item {
  margin: 0;
}

.shell-nav-link {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: var(--shell-radius-sm);
  color: var(--shell-chrome-text);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: var(--shell-line-tight);
  border-left: 3px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.shell-nav-link:hover {
  background: var(--shell-chrome-2);
  color: #ffffff;
}

.shell-nav-link:focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: 1px;
}

.shell-nav-link.is-active {
  background: var(--shell-chrome-3);
  color: #ffffff;
  font-weight: 600;
  border-left-color: var(--shell-brand-green);
}

/* --- Main column --- */
.shell-main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: none;
  margin: var(--shell-space-md) var(--shell-gutter) var(--shell-space-lg);
  padding: var(--shell-space-lg) var(--shell-space-lg) var(--shell-space-xl);
  background: var(--shell-content-bg);
  color: var(--shell-content-text);
  border-radius: var(--shell-radius);
  border: 1px solid var(--shell-main-border);
  box-shadow: var(--shell-main-shadow);
}

.shell-main.shell-hub {
  max-width: var(--shell-content-max-hub);
  margin-left: auto;
  margin-right: auto;
  padding: var(--shell-space-lg) var(--shell-gutter) var(--shell-space-xl);
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

/* --- Footer --- */
.shell-footer {
  border-top: 1px solid var(--shell-chrome-border);
  background: var(--shell-chrome);
  color: var(--shell-chrome-text);
  padding: var(--shell-space-md) var(--shell-gutter);
  margin-top: auto;
}

.shell-footer-inner {
  max-width: var(--shell-content-max-hub);
  margin: 0 auto;
  font-size: 0.84375rem;
  line-height: var(--shell-line-tight);
  color: var(--shell-chrome-muted);
  text-align: center;
}

.shell-footer-inner code {
  font-family: var(--shell-mono);
  font-size: 0.88em;
  background: var(--shell-chrome-2);
  color: var(--shell-chrome-text);
  padding: 0.12em 0.4em;
  border-radius: 4px;
}

.shell-error {
  margin: 0;
  padding: var(--shell-space-md);
  color: #ffb4a8;
}

/* --- Mobile drawer --- */
@media (max-width: 900px) {
  .shell-sidebar {
    position: fixed;
    left: 0;
    top: var(--shell-header-h);
    bottom: 0;
    z-index: 20;
    transform: translateX(-100%);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.25);
  }

  body.shell-sidebar-open .shell-sidebar {
    transform: translateX(0);
  }

  body.shell-sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 15;
  }

  .shell-main {
    margin-inline: var(--shell-gutter);
  }
}

/* =============================================================================
   Hub (index) — floating cards on page background
   ============================================================================= */

.hub-intro {
  margin-bottom: var(--shell-space-lg);
}

.hub-intro h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: var(--shell-line-tight);
  margin: 0 0 var(--shell-space-sm);
  letter-spacing: -0.03em;
  color: var(--shell-content-text);
}

.hub-intro p {
  margin: 0;
  color: var(--shell-content-muted);
  max-width: 40rem;
  font-size: 1.03125rem;
  line-height: var(--shell-line-height);
}

.hub-intro code,
.shell-main .tool-lead code {
  font-family: var(--shell-mono);
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  border: 1px solid rgba(41, 41, 41, 0.12);
  background: rgba(255, 255, 255, 0.65);
  color: var(--shell-content-text);
}

.shell-main kbd,
.hub-intro kbd {
  font-family: var(--shell-mono);
  font-size: 0.85em;
  padding: 0.12em 0.4em;
  border-radius: 4px;
  border: 1px solid rgba(41, 41, 41, 0.12);
  background: rgba(255, 255, 255, 0.65);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.hub-toolbar {
  margin: 0 0 var(--shell-space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--shell-space-sm);
}

.hub-search-row {
  width: 100%;
  max-width: 28rem;
}

.hub-search {
  width: 100%;
  padding: 0.8rem 1rem;
  font: inherit;
  font-size: 1rem;
  color: var(--shell-content-text);
  background: var(--shell-content-bg);
  border: 1px solid rgba(41, 41, 41, 0.1);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hub-search::placeholder {
  color: #888888;
}

.hub-search:hover {
  border-color: rgba(41, 41, 41, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.hub-search:focus {
  outline: none;
  border-color: var(--shell-accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 0 0 3px var(--shell-accent-soft);
}

.hub-meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--shell-content-muted);
}

.hub-empty {
  margin: 0 0 var(--shell-space-md);
  padding: var(--shell-space-md);
  background: var(--shell-content-bg);
  border-radius: var(--shell-radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  font-size: 0.9rem;
  color: var(--shell-content-muted);
}

.hub-sections {
  display: flex;
  flex-direction: column;
  gap: var(--shell-space-xl);
}

.hub-category-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 var(--shell-space-md);
  padding: 0.15rem 0.25rem 0.15rem 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--shell-content-muted);
}

.hub-category-toggle::-webkit-details-marker {
  display: none;
}

.hub-category-toggle::marker {
  content: "";
}

.hub-category-toggle::before {
  content: "";
  width: 0.38rem;
  height: 0.38rem;
  flex-shrink: 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.hub-category[open] .hub-category-toggle::before {
  transform: rotate(45deg);
}

.hub-category:not([open]) .hub-category-toggle {
  margin-bottom: 0;
}

.hub-category-toggle:hover {
  color: var(--shell-content-text);
}

.hub-category-toggle:focus {
  outline: none;
}

.hub-category-toggle:focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.hub-category-title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: var(--shell-line-tight);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: inherit;
}

@media (prefers-reduced-motion: reduce) {
  .hub-category-toggle::before {
    transition: none;
  }
}

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--shell-space-lg);
}

@media (min-width: 900px) {
  .hub-grid {
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  }
}

.hub-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--shell-space-sm);
  padding: var(--shell-space-lg) var(--shell-space-md) var(--shell-space-md);
  background: var(--shell-content-bg);
  border: none;
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.05),
    0 6px 20px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hub-card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.hub-card-link:focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: 3px;
}

.hub-card-media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 7rem;
  padding: var(--shell-space-sm) 0 var(--shell-space-xs);
}

.hub-card-icon {
  display: block;
  width: auto;
  max-width: 100%;
  height: 7rem;
  border-radius: 14px;
  object-fit: contain;
}

.hub-card:hover {
  transform: translateY(-5px);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.06),
    0 12px 32px rgba(0, 0, 0, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  .hub-card {
    transition: none;
  }

  .hub-card:hover {
    transform: none;
  }
}

.hub-card-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: var(--shell-line-tight);
  color: var(--shell-content-text);
  text-align: center;
}

.hub-card:hover .hub-card-title {
  color: var(--shell-accent);
}

.hub-card-desc {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--shell-content-muted);
  text-align: center;
  flex: 1;
}

.hub-card-desc--muted {
  font-style: italic;
}

.hub-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 0.15rem;
}

.hub-card-badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--shell-accent);
  background: rgba(48, 107, 151, 0.1);
  border-radius: 999px;
}

/* =============================================================================
   Tool pages
   ============================================================================= */

.tool-page h1 {
  font-size: 1.3125rem;
  line-height: var(--shell-line-tight);
  margin: 0;
  color: var(--shell-content-text);
}

.tool-page-header {
  display: flex;
  align-items: center;
  gap: var(--shell-space-sm);
  margin-bottom: var(--shell-space-sm);
}

.tool-page-icon {
  width: auto;
  max-width: 14rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: 8px;
  object-fit: contain;
}

.tool-page .tool-lead {
  margin: 0 0 var(--shell-space-md);
  color: var(--shell-content-muted);
  max-width: 60ch;
  font-size: 0.96875rem;
}

.tool-panel {
  background: var(--shell-panel-bg);
  border: 1px solid var(--shell-card-border);
  border-radius: var(--shell-radius);
  padding: var(--shell-space-md);
}

.tool-panel label {
  display: block;
  font-size: 0.84375rem;
  font-weight: 600;
  margin-bottom: var(--shell-space-xs);
  color: var(--shell-content-text);
}

.tool-panel input[type="text"],
.tool-panel textarea {
  width: 100%;
  font: inherit;
  font-size: 0.96875rem;
  color: var(--shell-content-text);
  background: var(--shell-field-bg);
  border: 1px solid var(--shell-field-border);
  border-radius: var(--shell-radius-sm);
  padding: 0.5rem 0.65rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tool-panel input[type="text"]:focus,
.tool-panel textarea:focus {
  outline: none;
  border-color: var(--shell-accent);
  box-shadow: 0 0 0 3px var(--shell-accent-soft);
}

.tool-panel textarea {
  min-height: 200px;
  resize: vertical;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--shell-space-sm);
  margin-top: var(--shell-space-md);
}

.tool-btn {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--shell-radius-sm);
  border: 1px solid var(--shell-card-border);
  background: var(--shell-btn-secondary-bg);
  color: var(--shell-content-text);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.tool-btn:hover {
  border-color: var(--shell-accent);
  color: var(--shell-accent);
  background: #f0f4f8;
}

.tool-btn:focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: 2px;
}

.tool-btn--primary {
  background: var(--shell-accent);
  color: #ffffff;
  border-color: transparent;
  font-weight: 600;
}

.tool-btn--primary:hover {
  filter: brightness(1.06);
  color: #ffffff;
  background: var(--shell-accent);
}

.timer-display {
  font-variant-numeric: tabular-nums;
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  margin: var(--shell-space-sm) 0 var(--shell-space-md);
  color: var(--shell-content-text);
}

.timer-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--shell-space-sm);
  justify-content: center;
  margin-bottom: var(--shell-space-md);
}

.timer-presets button {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--shell-radius-sm);
  border: 1px solid var(--shell-field-border);
  background: var(--shell-field-bg);
  color: var(--shell-content-text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.timer-presets button:hover {
  border-color: var(--shell-accent);
  background: #f5f9fc;
}

.timer-presets button:focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: 2px;
}
