:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1d1f23;
  --muted: #5d636d;
  --border: #e2e0da;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --accent-soft: #e3eef6;
  --beta-bg: #fdf0d5;
  --beta-text: #7a4b00;
  --dev-bg: #ececec;
  --dev-text: #4a4a4a;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --surface: #1e2126;
    --text: #eceef1;
    --muted: #a0a6b0;
    --border: #2f333a;
    --accent: #6fb0e0;
    --accent-text: #0e1a24;
    --accent-soft: #1d3446;
    --beta-bg: #3d2f12;
    --beta-text: #f3cf85;
    --dev-bg: #2c2f35;
    --dev-text: #c3c7cd;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

a {
  color: var(--accent);
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 16px;
  z-index: 20;
  padding: 8px 12px;
  border-radius: 0 0 8px 8px;
  background: var(--accent);
  color: var(--accent-text);
}

.skip-link:focus {
  top: 0;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  display: block;
  border-radius: 9px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-tag {
  color: var(--muted);
  font-size: 0.75rem;
}

.site-nav {
  display: flex;
  gap: 4px;
}

.site-nav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--accent-soft);
}

.site-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.menu-toggle {
  display: none;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
  }

  .menu-toggle {
    display: block;
  }

  .site-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    padding-bottom: 12px;
  }

  .site-nav-open {
    display: flex;
  }
}

/* Page sections */

.home-hero {
  padding: 72px 0 56px;
  background:
    radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 45%),
    radial-gradient(circle at 10% 90%, color-mix(in srgb, #f3c969 18%, transparent), transparent 40%);
}

.home-hero h1 {
  max-width: 18ch;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

a.button {
  display: inline-block;
  text-decoration: none;
}

.section {
  padding: 48px 0;
}

.section-alt {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.5rem;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.feature {
  display: block;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.feature:hover {
  border-color: var(--accent);
}

.feature h3 {
  margin: 14px 0 6px;
  font-size: 1.1rem;
}

.feature p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.page-header {
  padding: 48px 0 28px;
  border-bottom: 1px solid var(--border);
}

.page-body {
  padding-top: 28px;
}

.prose {
  max-width: 44rem;
  font-size: 1.05rem;
}

.prose h2 {
  margin: 28px 0 8px;
  font-size: 1.3rem;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose p {
  margin: 0 0 14px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 8px;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.1;
}

.lead {
  margin: 0;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}

.filters {
  display: flex;
  gap: 8px;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.search {
  flex: 0 1 260px;
}

.count {
  margin: 20px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  font-size: 1.5rem;
}

.card h3 {
  margin: 14px 0 6px;
  font-size: 1.15rem;
}

.description {
  flex: 1;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.badge {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-beta {
  background: var(--beta-bg);
  color: var(--beta-text);
}

.badge-dev {
  background: var(--dev-bg);
  color: var(--dev-text);
}

.tags {
  display: flex;
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.tag {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.open {
  display: block;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.open:hover {
  filter: brightness(1.1);
}

.open-disabled {
  background: var(--dev-bg);
  color: var(--muted);
  font-weight: 500;
}

.chip:focus-visible,
.open:focus-visible,
.search input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.empty {
  padding: 32px 0;
  color: var(--muted);
  text-align: center;
}

/* Footer */

.site-footer {
  margin-top: 64px;
  padding: 32px 0 40px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px 32px;
}

.footer-inner p {
  margin: 8px 0 0;
}

.brand-small .brand-name {
  font-size: 1rem;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: flex-start;
}

.footer-nav a {
  color: var(--text);
  text-decoration: none;
}

.footer-nav a:hover {
  text-decoration: underline;
}

.footer-meta {
  grid-column: 1 / -1;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.section-alt + .site-footer,
main:has(> .section-alt:last-child) + .site-footer {
  margin-top: 0;
}

@media (max-width: 640px) {
  .footer-inner {
    grid-template-columns: 1fr;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.admin-link {
  float: right;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Admin */

h1.admin-title-h {
  margin-bottom: 16px;
  font-size: 1.8rem;
}

.admin-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.admin-nav a,
.link-button {
  color: var(--accent);
  font: inherit;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  text-decoration: underline;
  cursor: pointer;
}

.panel {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
}

.login {
  max-width: 380px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
  min-width: 0;
}

.field > span,
.field legend {
  padding: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.field small {
  color: var(--muted);
  font-size: 0.8rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

.field-row .field-icon {
  flex: 0 0 72px;
}

.field-icon input {
  text-align: center;
  font-size: 1.2rem;
  padding: 5px;
}

.check {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-right: 20px;
}

.field .check input {
  width: auto;
  margin: 0;
}

fieldset.field {
  display: block;
}

fieldset.field legend {
  margin-bottom: 6px;
}

.button {
  padding: 9px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.button-secondary {
  background: var(--dev-bg);
  color: var(--text);
}

.form-error {
  min-height: 1.2em;
  margin: 0 0 12px;
  color: #c0392b;
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
  .form-error {
    color: #ff8a7a;
  }
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-row {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.admin-row .icon {
  flex: none;
}

.admin-info {
  flex: 1;
  min-width: 0;
}

.admin-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-url {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-actions {
  display: flex;
  flex: none;
  gap: 4px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-button:focus-visible,
.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.badge-live {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-utveckling {
  background: var(--dev-bg);
  color: var(--dev-text);
}

.editor {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
}

.editor::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  margin: 0;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  background: #c0392b;
  color: #fff;
}

@media (max-width: 560px) {
  .admin-row {
    flex-wrap: wrap;
  }

  .admin-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
