/* Convergence – utseende i stil med moderna wikiverktyg: vit yta, blå accent och färgkodade spaces. */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f8f9;
  --bg-sunken: #f1f2f4;
  --bg-hover: #091e420f;
  --bg-pressed: #091e4224;
  --border: #dcdfe4;
  --border-strong: #b7bec9;
  --text: #172b4d;
  --text-subtle: #44546f;
  --muted: #626f86;
  --accent: #0c66e4;
  --accent-dark: #0055cc;
  --accent-soft: #e9f2ff;
  --danger: #c9372c;
  --danger-soft: #ffeceb;
  --ok-soft: #dcfff1;
  --warn-soft: #fff7d6;
  --radius: 4px;
  --radius-lg: 8px;
  --topbar: 56px;
  --shadow: 0 1px 1px #091e4240, 0 0 1px #091e424f;
  --shadow-raised: 0 8px 12px #091e4226, 0 0 1px #091e424f;
  font-size: 15px;
}

/* Färgpalett: varje c-* sätter --c (stark), --c-soft (bakgrund) och --c-text. */
.c-blue    { --c: #1d7afc; --c-soft: #e9f2ff; --c-text: #0055cc; --c-grad: #579dff; }
.c-purple  { --c: #8270db; --c-soft: #f3f0ff; --c-text: #5e4db2; --c-grad: #9f8fef; }
.c-teal    { --c: #1d9aaa; --c-soft: #e7f9ff; --c-text: #206a83; --c-grad: #6cc3e0; }
.c-green   { --c: #22a06b; --c-soft: #dcfff1; --c-text: #216e4e; --c-grad: #4bce97; }
.c-orange  { --c: #e56910; --c-soft: #fff3eb; --c-text: #a54800; --c-grad: #fea362; }
.c-magenta { --c: #cd519d; --c-soft: #ffecf8; --c-text: #943d73; --c-grad: #e774bb; }
.c-red     { --c: #e34935; --c-soft: #ffeceb; --c-text: #ae2e24; --c-grad: #f87168; }
.c-yellow  { --c: #b38600; --c-soft: #fff7d6; --c-text: #7f5f01; --c-grad: #e2b203; }
.c-gray    { --c: #626f86; --c-soft: #f1f2f4; --c-text: #44546f; --c-grad: #8590a2; }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; font-weight: 600; margin: .2em 0 .5em; line-height: 1.25; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
h1 > .icon { width: 26px; height: 26px; color: var(--accent); }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .6em; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 1rem; font-weight: 600; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; color: var(--text-subtle); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
code { background: var(--bg-sunken); padding: 1px 5px; border-radius: 3px; }
.upper { text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 1.05rem; margin-right: 8px; }
.brand a { color: inherit; }
.brand a:hover { text-decoration: none; }
.brand > a:first-child { border-radius: 7px; transition: transform .15s; }
.brand > a:first-child:hover { transform: scale(1.08); }
/* Loggan (assets/logo.svg, genererad med logo-gen.py): färgade linjer som strålar samman i en punkt. */
.logo { display: block; width: 30px; height: 30px; flex: none; border-radius: 7px; box-shadow: 0 2px 6px #07080d40; }
.auth-logo .logo { width: 40px; height: 40px; border-radius: 9px; }
.mainnav { display: flex; gap: 2px; height: 100%; }
.mainnav a {
  display: flex; align-items: center; height: 100%;
  color: var(--text-subtle); padding: 0 10px; font-weight: 500; font-size: .93rem;
  border-bottom: 3px solid transparent; border-top: 3px solid transparent;
}
.mainnav a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.mainnav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.btn-create { margin-left: 6px; }
.search { position: relative; flex: 1; max-width: 300px; margin-left: auto; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { width: 100%; padding-left: 34px; background: var(--bg-soft); border-color: var(--border-strong); }
.search input:focus { background: var(--bg); }
.usermenu > summary { cursor: pointer; border-radius: 50%; padding: 2px; }
.usermenu > summary:hover { box-shadow: 0 0 0 3px var(--bg-pressed); }
.menu-user { display: flex; gap: 10px; align-items: center; padding: 8px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-user small { display: block; color: var(--muted); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-grad, #8270db), var(--c, #8270db)); color: #fff;
  font-weight: 600; font-size: .78rem; letter-spacing: .02em;
}
.avatar.small { width: 24px; height: 24px; font-size: .62rem; }
.avatar.big { width: 40px; height: 40px; font-size: .95rem; }
.avatar.huge { width: 72px; height: 72px; font-size: 1.6rem; }

/* Layout */
.wrap { display: block; }
.wrap.with-sidebar { display: grid; grid-template-columns: 290px minmax(0, 1fr); }
.main { padding: 28px 40px 80px; max-width: 1100px; width: 100%; margin: 0 auto; }
.with-sidebar .main { margin: 0; max-width: 1060px; padding-left: 56px; }
.narrow { max-width: 640px; }

/* Sidopanel */
.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  position: sticky; top: var(--topbar);
  height: calc(100vh - var(--topbar));
  overflow-y: auto;
}
.sb-space { display: flex; gap: 10px; align-items: center; padding: 4px 8px 12px; color: var(--text); font-weight: 700; font-size: 1rem; line-height: 1.25; }
.sb-space:hover { text-decoration: none; }
.sb-space .space-icon { width: 28px; height: 28px; font-size: .9rem; }
.sb-nav { display: flex; flex-direction: column; gap: 1px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.sb-nav a { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius); color: var(--text-subtle); font-size: .92rem; font-weight: 500; }
.sb-nav a .icon { color: var(--muted); }
.sb-nav a:hover { background: var(--bg-hover); text-decoration: none; color: var(--text); }
.sb-nav a.active { background: var(--accent-soft); color: var(--accent); }
.sb-nav a.active .icon { color: var(--accent); }
.sb-nav a.active::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
/* Hopfällbara rubriker (INNEHÅLL, SPACES) */
.sb-section { margin-top: 10px; }
.sb-section > .sb-head {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  margin: 0 0 4px; padding: 4px 4px 4px 6px; border-radius: var(--radius);
  font-size: .74rem; font-weight: 700; text-transform: uppercase; color: var(--text-subtle); letter-spacing: .04em;
}
.sb-section > .sb-head::-webkit-details-marker { display: none; }
.sb-section > .sb-head:hover { background: var(--bg-hover); }
.sb-label { flex: 1; }
.sb-chev { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--text-subtle); }
.sb-chev .icon { width: 13px; height: 13px; stroke-width: 2.4; transition: transform .12s; }
.sb-section[open] > .sb-head .sb-chev .icon { transform: rotate(90deg); }
.sb-add { display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--radius); color: var(--text-subtle); }
.sb-add:hover { background: var(--bg-pressed); color: var(--text); }
.sb-add .icon { width: 16px; height: 16px; }
.sb-empty { padding: 0 10px; }
.sb-toggle { margin-right: -4px; }
.sb-hidden .wrap.with-sidebar { grid-template-columns: minmax(0, 1fr); }
.sb-hidden .sidebar { display: none; }
.sb-hidden .with-sidebar .main { margin: 0 auto; padding-left: 40px; }

/* Spacen i sidopanelen, vart och ett med sitt sidträd */
.sb-spaces { list-style: none; margin: 0; padding: 0; }
.sb-sp > details > summary { list-style: none; display: flex; align-items: center; gap: 2px; cursor: pointer; border-radius: var(--radius); }
.sb-sp > details > summary::-webkit-details-marker { display: none; }
.sb-sp > details > summary::before {
  content: "›"; width: 16px; flex: none; text-align: center; color: var(--muted); font-size: 1.1rem; line-height: 1; transition: transform .12s;
}
.sb-sp > details[open] > summary::before { transform: rotate(90deg); }
.sb-sp > details > summary:hover { background: var(--bg-hover); }
.sb-sp-link { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 5px 4px; color: var(--text-subtle); font-weight: 500; font-size: .92rem; }
.sb-sp-link:hover { text-decoration: none; }
.sb-sp-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-sp > details > .tree { padding-left: 16px; margin-bottom: 6px; }
.sb-section > .tree { padding-left: 0; }
.sb-sp > details > .sb-empty { padding-left: 46px; margin: 2px 0 8px; }
.space-icon.tiny { width: 22px; height: 22px; font-size: .72rem; border-radius: 5px; }

.space-icon {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 6px;
  background: linear-gradient(135deg, var(--c-grad, #579dff), var(--c, #1d7afc)); color: #fff; font-weight: 700;
}
.space-icon.big { width: 44px; height: 44px; font-size: 1.3rem; border-radius: 8px; }
.space-icon.huge { width: 72px; height: 72px; font-size: 2rem; border-radius: 12px; margin-bottom: 8px; }
.space-icon .icon { width: 22px; height: 22px; }

/* Sidträd */
.tree { list-style: none; margin: 0; padding: 0 0 0 14px; }
.tree li { margin: 0; }
.tree a {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: var(--radius);
  color: var(--text-subtle); font-size: .92rem;
}
.tree a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree a .icon { width: 15px; height: 15px; color: var(--muted); }
.tree a:hover { background: var(--bg-hover); text-decoration: none; color: var(--text); }
.tree a.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree a.current .icon { color: var(--accent); }
.tree summary { list-style: none; display: flex; align-items: center; cursor: pointer; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before {
  content: "›"; width: 16px; flex: none; text-align: center; color: var(--muted); font-size: 1.1rem; line-height: 1; transition: transform .12s;
}
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary a { flex: 1; min-width: 0; }
.tree li.leaf > a::before { content: "•"; width: 16px; margin: 0 -7px 0 -8px; flex: none; text-align: center; color: var(--muted); }
.tree summary a { padding-left: 2px; }

/* Knappar och formulär */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 12px; height: 32px; border-radius: var(--radius);
  border: 0; background: var(--bg-hover); color: var(--text-subtle);
  font: inherit; font-size: .92rem; font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background .12s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:hover { background: var(--bg-pressed); color: var(--text); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-subtle { background: transparent; }
.btn-subtle:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ae2e24; color: #fff; }
.btn-subtle.danger:hover { color: var(--danger); background: var(--danger-soft); }
.btn-small { height: 28px; padding: 0 10px; font-size: .85rem; }
.btn-icon { width: 32px; padding: 0; }
.btn-small.btn-icon { width: 28px; }
.btn-block { width: 100%; height: 40px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linklike { color: var(--accent); cursor: pointer; font-weight: 600; }
.linklike:hover { text-decoration: underline; }
input, select, textarea {
  font: inherit; color: var(--text);
  padding: 7px 10px; border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--bg); transition: border-color .12s, background .12s;
}
input:hover, select:hover, textarea:hover { background: var(--bg-soft); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--bg); }
input:disabled { background: var(--bg-sunken); color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .85rem; color: var(--text-subtle); }
.form label input, .form label textarea, .form label select { font-weight: 400; font-size: 1rem; color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; align-items: end; margin-bottom: 14px; }
.form-row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; }
.radio-group { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.radio-group legend { font-weight: 600; font-size: .85rem; color: var(--text-subtle); margin-bottom: 6px; }
.radio { flex-direction: row !important; gap: 12px !important; align-items: center; padding: 12px 14px; border: 2px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; font-weight: 400 !important; font-size: .95rem !important; color: var(--text) !important; transition: border-color .12s, background .12s; }
.radio:hover { background: var(--bg-soft); }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio small { display: block; color: var(--muted); }
.radio-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; flex: none; }
.radio-icon.v-open { background: #dcfff1; color: #216e4e; }
.radio-icon.v-read { background: #e7f9ff; color: #206a83; }
.radio-icon.v-restricted { background: #fff3eb; color: #a54800; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Kort, rubriker och listor */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 30px 0 14px; }
.section-head h2 { margin: 0; }
.section-head h2 .icon { color: var(--accent); }

.hero {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap;
  padding: 32px 36px; border-radius: 12px; color: #fff; margin-bottom: 8px;
  background:
    radial-gradient(circle at 85% 20%, #ffffff2e 0 80px, transparent 81px),
    radial-gradient(circle at 95% 90%, #ffffff1f 0 120px, transparent 121px),
    linear-gradient(120deg, #0c66e4 0%, #5e4db2 60%, #943d73 100%);
  box-shadow: 0 10px 30px #0c66e433;
}
.hero h1 { color: #fff; font-size: 2.1rem; margin: 0 0 4px; }
.hero p { margin: 0; opacity: .9; }
.hero .hero-kicker { text-transform: uppercase; font-size: .78rem; font-weight: 700; letter-spacing: .08em; opacity: .75; margin-bottom: 6px; }
.hero-search { position: relative; flex: 0 1 360px; }
.hero-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.hero-search input { width: 100%; height: 44px; padding-left: 40px; border: 0; border-radius: var(--radius-lg); box-shadow: 0 4px 14px #091e4233; }

.space-grid, .template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.space-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
  padding: 46px 18px 16px; min-height: 170px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text); box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .15s;
}
.space-card:hover { text-decoration: none; box-shadow: var(--shadow-raised); transform: translateY(-2px); }
.space-card-band {
  position: absolute; inset: 0 0 auto 0; height: 64px;
  background: linear-gradient(120deg, var(--c-soft), color-mix(in srgb, var(--c-grad) 35%, white));
}
.space-card .space-icon { position: relative; border: 3px solid #fff; box-shadow: 0 2px 6px #091e4226; margin-bottom: 4px; }
.space-card strong { font-size: 1.02rem; }
.space-card-new { border-style: dashed; box-shadow: none; padding-top: 18px; justify-content: center; align-items: center; text-align: center; background: var(--bg-soft); }
.space-card-new .space-icon { background: var(--bg-hover); color: var(--accent); border: 0; box-shadow: none; }
.space-meta { margin-top: auto; padding-top: 10px; font-size: .8rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.template-card {
  display: flex; flex-direction: column; gap: 6px; color: var(--text); margin: 0; padding: 18px;
  transition: box-shadow .15s, transform .15s;
}
.template-card:hover { text-decoration: none; box-shadow: var(--shadow-raised); transform: translateY(-2px); }
.template-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--c-soft, var(--accent-soft)); color: var(--c, var(--accent)); margin-bottom: 4px; }
.template-icon .icon { width: 22px; height: 22px; }

.feed { list-style: none; margin: 0; padding: 4px 0; }
.feed.card { padding: 6px 8px; }
.feed li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--radius); }
.feed li:hover { background: var(--bg-soft); }
.feed-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--c-soft); color: var(--c); flex: none; }
.feed-main { flex: 1; min-width: 0; }
.feed-title { display: block; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-who { display: flex; gap: 8px; align-items: center; text-align: left; color: var(--muted); line-height: 1.3; flex: none; min-width: 150px; }

.empty-state { text-align: center; padding: 56px 20px; }
.empty-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }
.empty-icon .icon { width: 30px; height: 30px; }
.error-code {
  font-size: 5rem; font-weight: 800; line-height: 1;
  background: linear-gradient(120deg, #0c66e4, #8270db, #cd519d); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.empty-state h1 { justify-content: center; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--bg-hover); font-size: .78rem; font-weight: 600; }
.badge-blue { background: var(--accent-soft); color: var(--accent); }
.lozenge {
  display: inline-block; padding: 0 6px; border-radius: 3px; line-height: 1.6;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  background: var(--c-soft, var(--bg-sunken)); color: var(--c-text, var(--text-subtle));
  white-space: nowrap; vertical-align: middle;
}
.count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 11px; background: var(--bg-sunken); color: var(--text-subtle); font-size: .78rem; text-align: center; }
.person { display: inline-flex; align-items: center; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 14px; background: var(--bg-sunken); color: var(--text); font-size: .85rem; }
.tag:hover { background: var(--bg-pressed); text-decoration: none; }

.table { width: 100%; border-collapse: collapse; padding: 0; }
.table.card { padding: 0; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.table th { text-align: left; font-size: .75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; background: var(--bg-soft); }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: var(--bg-soft); }
.table tr:last-child td { border-bottom: 0; }
.table tr.inactive td { color: var(--muted); }
.row-actions { text-align: right; }
.row-actions form { display: inline; }

/* Meddelanden och paneler */
.flash { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; padding: 12px 16px 12px 14px; border-radius: var(--radius); margin-bottom: 16px; background: var(--ok-soft); border-left: 4px solid #22a06b; }
.flash-error { background: var(--danger-soft); border-left-color: var(--danger); }
.flash-warn { background: var(--warn-soft); border-left-color: #e2b203; }
.flash > div { width: 100%; }
.flash .check { margin-top: 8px; width: 100%; }
.info-panel { padding: 12px 16px; border-radius: var(--radius); background: var(--accent-soft); border-left: 4px solid var(--accent); margin-bottom: 14px; font-size: .93rem; }
.role-legend { display: flex; flex-direction: column; gap: 4px; font-size: .87rem; color: var(--text-subtle); margin-bottom: 6px; }
.role-legend .lozenge { min-width: 104px; text-align: center; margin-right: 8px; }
.danger-zone { border-color: #f5b8b2; border-top: 4px solid var(--danger); }

/* Rullgardinsmeny */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 230px; padding: 6px 0;
  background: var(--bg); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  display: flex; flex-direction: column; text-align: left;
}
.menu-body.wide { min-width: 300px; padding: 12px; gap: 10px; }
.menu-body > a, .menu-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; color: var(--text); font: inherit; font-size: .93rem;
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer; border-left: 2px solid transparent;
}
.menu-body > a .icon, .menu-link .icon { color: var(--muted); }
.menu-body > a:hover, .menu-link:hover { background: var(--bg-hover); border-left-color: var(--accent); text-decoration: none; }
.menu-body > a.danger, .menu-body > a.danger .icon { color: var(--danger); }
.menu-body > form { display: flex; gap: 6px; }
.menu-body .inline-form, .menu-body form:not(.form) { padding: 4px 12px; }
.menu-body .btn { justify-content: flex-start; }
.inline-form input { flex: 1; min-width: 180px; }

/* Sidvy */
.crumbs { font-size: .88rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.page-title { font-size: 2.2rem; font-weight: 600; margin-bottom: .3em; }
.page-actions { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.byline { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .87rem; margin: 0 0 28px; }
.byline strong { color: var(--text-subtle); font-weight: 600; }
.byline .icon { width: 14px; height: 14px; }
.ql-snow .ql-editor.page-body { padding: 0; overflow: visible; height: auto; font-size: 1rem; line-height: 1.7; }
.ql-snow .ql-editor h1 { font-size: 1.7rem; margin: .8em 0 .3em; display: block; }
.ql-snow .ql-editor h2 { font-size: 1.4rem; margin: .8em 0 .3em; display: block; }
.ql-snow .ql-editor h3 { font-size: 1.15rem; margin: .7em 0 .3em; display: block; color: var(--text); }
.ql-snow .ql-editor > :first-child { margin-top: 0; }
.page-body img { max-width: 100%; height: auto; border-radius: var(--radius); }
.page-body table, .ql-editor table { border-collapse: collapse; margin: .8em 0; width: 100%; }
.page-body td, .ql-editor td { border: 1px solid var(--border); padding: 8px 12px; }
.page-body tr:first-child td { background: var(--bg-soft); font-weight: 600; }
.page-body blockquote { border-left: 4px solid var(--c, #8270db) !important; background: #f3f0ff; padding: 10px 16px !important; color: var(--text-subtle); border-radius: 0 var(--radius) var(--radius) 0; }
.page-body pre.ql-syntax, .page-body pre { background: #f1f2f4 !important; color: var(--text) !important; border-radius: var(--radius); padding: 12px 16px !important; }
.page-section { margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--border); }
.page-section > h2 .icon { color: var(--muted); }
.child-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.child-list a { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.child-list a .icon { color: var(--accent); }
.child-list a:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }

/* Bilagor */
.attachments { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.attachments li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.attachments li:last-child { border-bottom: 0; }
.attachments li:hover { background: var(--bg-soft); }
.file-badge {
  display: grid; place-items: center; width: 40px; height: 44px; flex: none;
  border-radius: 4px 12px 4px 4px; background: var(--c); color: #fff;
  font-size: .62rem; font-weight: 800; letter-spacing: .03em;
}
.att-main { flex: 1; min-width: 0; }
.att-name { display: block; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-main small { color: var(--muted); }
.dropzone {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--bg-soft); color: var(--text-subtle); transition: border-color .12s, background .12s;
}
.dropzone > .icon { width: 28px; height: 28px; color: var(--accent); }
.dropzone small { display: block; color: var(--muted); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { opacity: .6; pointer-events: none; }
.dropzone.busy strong::after { content: " – laddar upp…"; font-weight: 400; }

/* Kommentarer */
.comment { display: flex; gap: 12px; margin-bottom: 18px; }
.comment-main { flex: 1; }
.comment-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 2px; }
.comment-head form { margin-left: auto; }
.comment-body { background: var(--bg-soft); padding: 10px 14px; border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg); }
.comment-form { display: flex; gap: 12px; margin-top: 14px; }
.comment-form > div { flex: 1; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.comment-form textarea { width: 100%; }

/* Editor */
.editor-form .title-input {
  width: 100%; border: 0; font-size: 2.2rem; font-weight: 600; padding: 6px 0; margin-bottom: 10px; background: transparent;
}
.editor-form .title-input:focus { outline: none; }
.editor-form .ql-toolbar.ql-snow {
  position: sticky; top: var(--topbar); z-index: 10; background: var(--bg-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-color: var(--border);
}
.editor-form .ql-container.ql-snow { border-color: var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); font-size: 1rem; font-family: inherit; }
.editor-form .ql-editor { min-height: 420px; line-height: 1.7; padding: 24px 28px; }
.editor-form .ql-editor img { max-width: 100%; }
.ql-snow .ql-toolbar button.ql-tbl, .ql-toolbar.ql-snow button.ql-tbl { width: auto; padding: 3px 6px; font-size: .78rem; color: #444; }
.ql-toolbar.ql-snow button.ql-tbl:hover { color: var(--accent); }
.editor-meta { display: flex; gap: 20px; flex-wrap: wrap; margin: 18px 0; }
.editor-meta label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .85rem; color: var(--text-subtle); flex: 1; min-width: 240px; }
.editor-meta input, .editor-meta select { font-weight: 400; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--border); margin-top: 10px; box-shadow: 0 -6px 12px -8px #091e4226; }

/* Diff */
.diff { padding: 8px 0; font-size: .92rem; overflow-x: auto; }
.diff-line { padding: 2px 16px 2px 8px; white-space: pre-wrap; color: var(--muted); }
.diff-line.add { background: #dcfff1; color: #164b35; }
.diff-line.del { background: #ffeceb; color: #5d1f1a; text-decoration: line-through; text-decoration-color: rgba(93, 31, 26, .4); }
.diff-op { display: inline-block; width: 20px; font-weight: 700; }
ins { background: #dcfff1; text-decoration: none; padding: 0 3px; }
del { background: #ffeceb; padding: 0 3px; }

/* Sök */
.search-big { display: flex; gap: 8px; margin-bottom: 16px; }
.search-big input { flex: 1; font-size: 1.05rem; padding: 10px 14px; }
.search-big .btn { height: auto; }
.results { list-style: none; padding: 0; }
.results li { padding: 16px 0; border-bottom: 1px solid var(--border); }
.results p { margin: 6px 0 0; color: var(--text-subtle); }
.result-title { display: inline-flex; align-items: center; gap: 8px; font-size: 1.1rem; font-weight: 600; }
mark { background: #f8e6a0; padding: 0 1px; border-radius: 2px; }

/* Grupper */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.group-card { border-top: 4px solid var(--c); margin-bottom: 0; }
.group-grid { margin-bottom: 20px; }
.group-title { display: flex; gap: 12px; align-items: center; }
.group-title h2 { margin: 0; }
.group-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--c-soft); color: var(--c); flex: none; }
.group-chip { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.group-chip .icon { color: var(--accent); }
.group-spaces { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.member-list { list-style: none; margin: 0 0 12px; padding: 0; }
.member-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--bg-sunken); }
.member-list li.inactive { opacity: .55; }
.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; min-width: 0; }

/* Konto */
.profile-head { display: flex; gap: 18px; align-items: center; margin-bottom: 20px; }
.profile-head h1 { margin: 0; }
.profile-head p { margin: 2px 0 0; }

/* Sidan med bara loggan */
.logo-page { margin: 0; min-height: 100vh; display: grid; place-items: center; background: #07080d; }
.logo-page img { display: block; width: min(80vmin, 720px); height: auto; border-radius: 12%; box-shadow: 0 20px 80px #c0267a33, 0 0 0 1px #ffffff10; }

/* Inloggning */
.guest { background: #07080d; }
.auth-bg {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  /* Loggan som bakgrund, utan ram (assets/logo-bg.svg, se logo-gen.py). */
  background: #07080d url("logo-bg.svg") 70% 45% / cover no-repeat;
}
.auth-card { backdrop-filter: blur(2px); }
.auth-card { width: 100%; max-width: 420px; padding: 36px 40px; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow-raised); }
.auth-card h1 { justify-content: center; font-size: 1.4rem; }
.auth-logo { display: flex; gap: 10px; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem; margin-bottom: 18px; }
.guest .main { max-width: none; padding: 0; }

a.mobile-only { display: none !important; }

@media (max-width: 960px) {
  .btn-create span, .brand-name { display: none; }
}
@media (max-width: 860px) {
  .wrap.with-sidebar { display: flex; }
  .sidebar { display: none; }
  .sb-open .sidebar {
    display: block; flex: none; width: min(300px, 85%); margin-right: max(-300px, -85%); z-index: 15;
    align-self: flex-start; box-shadow: var(--shadow-raised);
  }
  .with-sidebar .main { flex: 1; min-width: 0; }
  .main, .with-sidebar .main { padding: 20px 16px 60px; }
  .mainnav { display: none; }
  a.mobile-only { display: flex !important; }
  .topbar { gap: 8px; padding: 0 12px; }
  .hero { padding: 24px; }
  .feed-who { display: none; }
}

/* Temaväljare under Mitt konto */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.theme-picker { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.theme-option { display: flex !important; flex-direction: column; gap: 4px !important; padding: 10px; border: 2px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; color: var(--text) !important; font-size: .95rem !important; transition: border-color .12s, background .12s; }
.theme-option:hover { background: var(--bg-soft); }
.theme-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-option small { color: var(--muted); font-weight: 400; line-height: 1.35; }
/* Förhandsbild: topprad (i), tre "kort" (b) på en bakgrund. */
.theme-swatch { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; align-content: end; height: 74px; padding: 22px 8px 8px; border-radius: 6px; margin-bottom: 6px; border: 1px solid #091e4226; overflow: hidden; }
.theme-swatch i { position: absolute; inset: 0 0 auto 0; height: 14px; }
.theme-swatch b { height: 30px; border-radius: 3px; }
.sw-standard { background: #f7f8f9; } .sw-standard i { background: #fff; border-bottom: 1px solid #dcdfe4; }
.sw-standard b { background: #fff; box-shadow: 0 0 0 1px #dcdfe4; } .sw-standard b:first-of-type { background: #0c66e4; }
.sw-dark { background: #161a1d; } .sw-dark i { background: #1d2125; border-bottom: 1px solid #38414a; }
.sw-dark b { background: #22272b; box-shadow: 0 0 0 1px #38414a; } .sw-dark b:first-of-type { background: #579dff; }
.sw-gray { background: #e9eaeb; } .sw-gray i { background: #3a3d43; }
.sw-gray b { background: #fbfbfb; box-shadow: 0 0 0 1px #d6d7d9; } .sw-gray b:first-of-type { background: #4f5663; }
.sw-colorful { background: linear-gradient(135deg, #ffd6ec, #d9e4ff, #d8fbe9); } .sw-colorful i { background: linear-gradient(90deg, #ff5f6d, #ff9a3c, #c0267a, #6a3df0, #1d9aaa); }
.sw-colorful b { background: #fff; } .sw-colorful b:nth-of-type(1) { background: #c0267a; } .sw-colorful b:nth-of-type(2) { background: #ff9a3c; } .sw-colorful b:nth-of-type(3) { background: #1d9aaa; }
.sw-mobile { background: #d5d9df; grid-template-columns: 1fr; justify-items: center; padding: 6px; }
.sw-mobile i { display: none; }
.sw-mobile b { display: none; }
.sw-mobile b:first-of-type { display: block; width: 34px; height: 60px; border-radius: 6px; background: linear-gradient(#fff 0 9px, #f7f8f9 9px); box-shadow: 0 0 0 2px #172b4d; }
