/* checklista.online — ett enda ark, mobilen först.
   Tillgänglighet (spec §10.4): synlig fokusmarkering, status aldrig bara med
   färg, träffytor minst 44 px. */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --line: #e0e0d8;
  --text: #1b1c18;
  --muted: #66675e;
  --accent: #2f6f4f;
  --accent-soft: #e6f0ea;
  --danger: #a63d2f;
  --warn: #8a6a1f;
  --warn-soft: #fbf3de;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 8px 24px -18px rgb(0 0 0 / 30%);
  --maxw: 720px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12140f;
    --surface: #1b1e18;
    --surface-2: #23271f;
    --line: #333829;
    --text: #eceee6;
    --muted: #9ba193;
    --accent: #7cc79b;
    --accent-soft: #1e2c24;
    --danger: #e08b7d;
    --warn: #d8b664;
    --warn-soft: #2b2617;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.015em;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 0.75rem;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: inherit;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}

/* --- Skelett --- */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom));
}

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .brand__mark {
    color: #12140f;
  }
}

.brand__dot {
  color: var(--muted);
  font-weight: 400;
}

.who {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-decoration: none;
  line-height: 1.2;
}

.who__score {
  font-weight: 650;
  color: var(--accent);
}

.who__name {
  font-size: 0.78rem;
  color: var(--muted);
}

/* --- Bottennavigering --- */

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  gap: 0.25rem;
  padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.nav__item {
  flex: 1;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0.25rem;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.7rem;
  color: var(--muted);
}

.nav__item--active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav__item--cta {
  color: var(--accent);
  font-weight: 600;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

/* --- Byggblock --- */

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

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

.section-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 650;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.row--between {
  justify-content: space-between;
}

.row--end {
  justify-content: flex-end;
}

.row--wrap {
  flex-wrap: wrap;
}

.row--tight {
  gap: 0.35rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.loading,
.gate,
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2rem 1rem;
  color: var(--muted);
  text-align: center;
}

.gate {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.backlink {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* --- Knappar --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 11px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .btn--primary {
    color: #10130e;
  }
}

.btn--secondary {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.btn--ghost {
  background: transparent;
  border-color: var(--line);
}

.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.btn--small {
  min-height: 36px;
  padding: 0 0.7rem;
  font-size: 0.85rem;
}

/* --- Fält --- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

.field__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input--area {
  min-height: 76px;
  resize: vertical;
}

.input--flat {
  border-color: transparent;
  background: var(--surface-2);
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 0;
}

.hint--ok {
  color: var(--accent);
}

.hint--warn {
  color: var(--warn);
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
}

.searchbar .input {
  border: 0;
  background: transparent;
  padding-left: 0;
}

/* --- Radkort --- */

.row-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
}

a.row-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.row-card--me {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.row-card__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.row-card__title {
  font-weight: 600;
  text-decoration: none;
}

.row-card__meta,
.row-card__desc {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-card__side {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.rank {
  width: 1.8rem;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- Etiketter --- */

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}

.badge--neutral {
  background: var(--surface-2);
  color: var(--muted);
}

.badge--public,
.badge--ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--variant {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill {
  background: var(--surface-2);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* --- Banderoller --- */

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: var(--maxw);
  width: calc(100% - 2rem);
  margin: 0.75rem auto 0;
  padding: 0.6rem 0.9rem;
  border-radius: 11px;
  font-size: 0.9rem;
}

.banner--offline {
  background: var(--warn-soft);
  color: var(--warn);
}

.banner--error {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  color: var(--danger);
}

.banner--ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.banner__close {
  background: none;
  border: 0;
  color: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  min-width: 32px;
  min-height: 32px;
}

/* --- Hero --- */

.hero {
  padding: 1.5rem 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.hero__lead {
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 46ch;
}

.hero__actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* --- Mallfamiljens huvud --- */

.familyhead__title {
  font-size: 1.35rem;
}

.canonical {
  align-self: flex-start;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  background: var(--surface-2);
  color: var(--muted);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.canonical--link {
  text-decoration: none;
}

.lineage {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.82rem;
}

.lineage__step {
  display: flex;
  gap: 0.35rem;
  color: var(--muted);
}

.lineage__link {
  color: var(--muted);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--line);
}

.stats__item {
  display: flex;
  flex-direction: column;
}

.stats__value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stats__label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Förhandsvisning av en version --- */

.preview {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.preview__heading {
  font-weight: 650;
  margin-top: 0.6rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.preview__item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.preview__box {
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 0.25rem;
  border: 1.5px solid var(--line);
  border-radius: 4px;
}

.preview__optional {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 0.35rem;
}

/* --- Redigeraren --- */

.items {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.item--heading .input {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.item__tools {
  display: flex;
  gap: 0.15rem;
}

.iconbtn {
  min-width: 36px;
  min-height: 36px;
  padding: 0 0.4rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.iconbtn:hover:not(:disabled) {
  background: var(--surface-2);
}

.iconbtn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.iconbtn--on {
  color: var(--accent);
  background: var(--accent-soft);
}

.iconbtn--danger:hover {
  color: var(--danger);
}

/* --- Avbockning --- */

.checks {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.checks__heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.9rem 0 0.2rem;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.6rem 0.4rem;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
}

.check:hover {
  background: var(--surface-2);
}

.check--locked {
  cursor: default;
  opacity: 0.75;
}

.check__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.check__box {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 6px;
  color: #fff;
}

.check--done .check__box {
  background: var(--accent);
  border-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  .check--done .check__box {
    color: #10130e;
  }
}

.check__input:focus-visible + .check__box {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.check--done .check__label {
  color: var(--muted);
  text-decoration: line-through;
}

.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.confirm {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border-radius: 11px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* --- Flikar --- */

.tabs {
  display: flex;
  gap: 0.3rem;
  background: var(--surface-2);
  padding: 0.25rem;
  border-radius: 11px;
}

.tab {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.tab--active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* --- Spinner --- */

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Större skärmar --- */

@media (min-width: 720px) {
  .main {
    padding-bottom: 2rem;
  }

  /* På bredare skärmar flyttas menyn upp under sidhuvudet i stället för att
     ligga kvar längst ned. DOM-ordningen behålls för tangentbord och
     skärmläsare eftersom bara två syskon byter plats. */
  .header {
    order: -2;
  }

  .nav {
    position: sticky;
    top: 3.4rem;
    max-width: var(--maxw);
    width: calc(100% - 2rem);
    margin: 0.75rem auto 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.3rem;
    order: -1;
  }

  .nav__item {
    flex-direction: row;
    gap: 0.4rem;
    font-size: 0.85rem;
  }
}
