:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f3f3f1;
  --text: #1d1d1b;
  --muted: #666663;
  --line: #d6d6d2;
  --line-dark: #aaa9a3;
  --accent: #9d2f2f;
  --accent-dark: #742323;
  --focus: #1f5fa8;
  --radius-sm: 4px;
  --radius-md: 7px;
  --shadow: 0 5px 14px rgba(0, 0, 0, .06);
  --shell: 1220px;
  --font: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 100;
  transform: translateY(-150%);
  background: var(--text);
  color: #fff;
  padding: .7rem 1rem;
}
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.shell {
  width: min(calc(100% - 2rem), var(--shell));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -.01em;
}
.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--text);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .03em;
}
.desktop-nav { display: none; align-items: center; gap: 1.5rem; }
.desktop-nav > a:not(.timer-button), .nav-search {
  text-decoration: none;
  font-size: .94rem;
  font-weight: 600;
  background: none;
  border: 0;
  padding: .4rem 0;
  cursor: pointer;
}
.desktop-nav > a:not(.timer-button):hover, .nav-search:hover { text-decoration: underline; text-underline-offset: 4px; }
.timer-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: .65rem .9rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.timer-button:hover { background: var(--accent-dark); }
.timer-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.menu-toggle {
  width: 44px;
  height: 44px;
  display: grid;
  place-content: center;
  gap: 5px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.menu-toggle span { width: 23px; height: 2px; background: var(--text); display: block; }
.mobile-menu { border-top: 1px solid var(--line); background: #fff; }
.mobile-menu-inner { display: grid; gap: .3rem; padding-block: .8rem 1rem; }
.mobile-menu a, .mobile-menu button {
  min-height: 46px;
  display: flex;
  align-items: center;
  border: 0;
  background: none;
  text-decoration: none;
  font-weight: 600;
  padding: .5rem 0;
  cursor: pointer;
}
.mobile-menu .mobile-timer { justify-content: center; padding-inline: 1rem; margin-top: .4rem; background: var(--accent); color: #fff; }

.hero {
  padding-block: clamp(2.7rem, 6vw, 5rem) clamp(2.4rem, 5vw, 4rem);
  display: grid;
  gap: 2rem;
}
.hero-copy { max-width: 720px; }
.eyebrow {
  margin: 0 0 .55rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 700;
  font-size: .72rem;
}
h1, h2, h3 { margin-top: 0; line-height: 1.15; }
h1 { font-size: clamp(2.1rem, 4.4vw, 3.8rem); margin-bottom: 1rem; max-width: 820px; letter-spacing: -.025em; }
h2 { font-size: clamp(1.65rem, 2.6vw, 2.35rem); margin-bottom: 0; letter-spacing: -.015em; }
h3 { font-size: 1.08rem; }
.hero-text { max-width: 650px; font-size: clamp(1rem, 1.45vw, 1.16rem); color: var(--muted); margin: 0; }

.search-panel { max-width: 760px; }
.search-panel > label { display: block; margin-bottom: .6rem; font-size: .86rem; font-weight: 700; }
.search-field {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: .7rem;
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-sm);
  padding: .4rem .5rem .4rem .9rem;
}
.search-field:focus-within { border-color: var(--text); }
.search-field svg { width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 1rem; color: var(--text); }
.search-field input::placeholder { color: #8a8984; }
.clear-search { border: 1px solid var(--line); background: #f5f5f3; border-radius: var(--radius-sm); min-height: 36px; padding-inline: .8rem; cursor: pointer; font-weight: 600; }

.section { padding-block: clamp(2.5rem, 5vw, 4.5rem); }
.subject-section { background: var(--surface-soft); border-block: 1px solid #e8e8e4; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: clamp(1.25rem, 2.5vw, 1.9rem); }
.subject-grid { display: grid; grid-template-columns: 1fr; gap: .7rem; }
.subject-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 1rem;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  min-height: 105px;
  padding: 1rem;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.subject-card:hover { border-color: #8f8e88; box-shadow: var(--shadow); }
.subject-name { align-self: end; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.subject-meta { color: var(--muted); font-size: .84rem; align-self: start; margin-top: .25rem; }
.subject-arrow { grid-row: 1 / -1; grid-column: 2; align-self: center; font-size: 1.1rem; color: var(--accent); }

.filter-bar {
  padding: .9rem 0 1.1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.3rem;
}
.filter-label { display: block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .55rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  min-height: 36px;
  border: 1px solid var(--line-dark);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: .45rem .7rem;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: #fff; }

.result-count { color: var(--muted); margin: 0; white-space: nowrap; font-size: .9rem; }
.tool-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tool-card {
  min-width: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.tool-card:hover { border-color: #aaa9a3; box-shadow: var(--shadow); }
.tool-preview-link { display: block; text-decoration: none; border-bottom: 1px solid var(--line); }
.tool-preview-wrap { aspect-ratio: 16 / 10; background: #efefec; overflow: hidden; position: relative; }
.tool-preview { width: 100%; height: 100%; object-fit: cover; }
.preview-placeholder { position: absolute; inset: 0; display: grid; place-items: center; background: #efefec; color: #777771; font-size: .82rem; }
.tool-preview-wrap.has-image .preview-placeholder { display: none; }
.tool-card-body { padding: 1rem 1rem 1.05rem; }
.tool-overline { margin: 0 0 .5rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; font-size: .68rem; }
.tool-card h3 { margin-bottom: .5rem; }
.tool-title-link { text-decoration: none; }
.tool-title-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.tool-description { color: var(--muted); font-size: .92rem; margin: 0 0 1rem; min-height: 2.7em; }
.tool-bottom { display: flex; justify-content: flex-end; border-top: 1px solid #ecece8; padding-top: .85rem; }
.tool-open { font-size: .9rem; text-decoration: none; font-weight: 700; color: var(--accent); white-space: nowrap; }
.tool-open span { margin-left: .2rem; }
.empty-state { text-align: center; padding: 3rem 1rem; border: 1px dashed var(--line-dark); background: #fafafa; }
.empty-state h3 { margin-bottom: .4rem; }
.empty-state p { color: var(--muted); margin-top: 0; }
.button-secondary { min-height: 42px; border: 1px solid var(--text); background: #fff; border-radius: var(--radius-sm); padding: .55rem .9rem; cursor: pointer; font-weight: 700; }

.site-footer { border-top: 1px solid var(--line); padding-block: 2rem; background: #f7f7f5; }
.footer-inner { display: flex; flex-direction: column; gap: .25rem; color: var(--muted); font-size: .88rem; }
.footer-inner p { margin: 0; }
.footer-inner p:first-child { color: var(--text); font-weight: 700; }

@media (min-width: 560px) {
  .subject-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 760px) {
  .shell { width: min(calc(100% - 3rem), var(--shell)); }
  .subject-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 940px) {
  .desktop-nav { display: flex; }
  .menu-toggle, .mobile-menu { display: none !important; }
  .hero { grid-template-columns: minmax(0, 1.05fr) minmax(340px, .75fr); align-items: end; gap: clamp(2rem, 5vw, 4.5rem); }
  .subject-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1180px) {
  .subject-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tool-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

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

/* Timer-knappen bruger det faktiske timer-preview frem for et generisk urikon. */
.timer-button-preview {
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  object-fit: cover;
  object-position: center;
  border-radius: 5px;
  background: #fff;
  border: 1px solid rgba(255,255,255,.55);
}
.mobile-timer .timer-button-preview {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}


/* Automatisk fallback-preview: hvis der ikke findes et PNG/JPG/WEBP,
   vises selve HTML-redskabet som et ikke-interaktivt miniature-preview. */
.tool-live-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  pointer-events: none;
}
.tool-preview-wrap.has-live-preview .preview-placeholder { display: none; }
