/* backsAIde: calm and modern. Cool neutral greys with one blue accent, light and dark. All colours are tokens, the user can change accent, font, density and corner radius. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #edf0f4;
  --text: #1b2130;
  --muted: #5b6477;
  --line: #dde1e8;
  --accent: #2f6fde;
  --on-accent: #ffffff;
  --accent-soft: rgba(47, 111, 222, 0.1);
  --danger: #c22f3b;
  --danger-soft: rgba(194, 47, 59, 0.08);
  --ok: #1d8756;
  --radius: 10px;
  --note-font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ui-font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --gap: 16px;
  --shadow: 0 1px 2px rgba(20, 28, 45, 0.05), 0 4px 14px rgba(20, 28, 45, 0.05);
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #12151b;
  --surface: #1a1e26;
  --surface-2: #232834;
  --text: #e6e9ef;
  --muted: #99a2b2;
  --line: #2c3340;
  --accent: #6e9bff;
  --on-accent: #0d1117;
  --accent-soft: rgba(110, 155, 255, 0.14);
  --danger: #f0716b;
  --danger-soft: rgba(240, 113, 107, 0.14);
  --ok: #5fcf9b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    --bg: #12151b;
    --surface: #1a1e26;
    --surface-2: #232834;
    --text: #e6e9ef;
    --muted: #99a2b2;
    --line: #2c3340;
    --accent: #6e9bff;
    --on-accent: #0d1117;
    --accent-soft: rgba(110, 155, 255, 0.14);
    --danger: #f0716b;
    --danger-soft: rgba(240, 113, 107, 0.14);
    --ok: #5fcf9b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-density='compact'] { --gap: 8px; }

* { box-sizing: border-box; }
html, body, #app { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--ui-font); }
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 12px; cursor: pointer; min-height: 36px;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
a.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none; }
a.btn:hover { border-color: var(--accent); }
a.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; min-height: 0; text-decoration: underline; }
input[type='text'], input[type='search'], input[type='password'], input:not([type]) {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; min-height: 40px; width: 100%;
}
.muted { color: var(--muted); }
.tiny { font-size: 0.8rem; }
.err { color: var(--danger); }
.pad { padding: var(--gap); }
.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); padding: 24px; box-shadow: var(--shadow); }
.login { width: min(420px, 100%); display: grid; gap: 10px; }
.login h1 { margin: 0; }
.login .more-ways { justify-self: center; }

/* Frame: top bar, banners, body, footer */
.shell { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100%; }
.top { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { border: 0; background: none; font: 700 1.2rem var(--ui-font); color: var(--accent); padding: 0; min-height: 0; }
.search { flex: 1 1 200px; max-width: 520px; }
.top .actions { display: flex; gap: 8px; margin-left: auto; align-items: center; position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 2px); box-shadow: var(--shadow);
  display: grid; gap: 2px;
}
.menu button { text-align: left; border: 0; background: none; min-height: 40px; }
.menu button:hover, .menu button.on { background: var(--accent-soft); color: var(--text); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

.banners { display: grid; }
.banner {
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 8px 16px; cursor: default;
  background: var(--accent-soft); color: var(--text); border-bottom: 1px solid var(--line);
}
.banner.warn { background: var(--danger-soft); }
.banner button { padding: 2px 12px; min-height: 32px; }
.banner > span { flex: 1 1 260px; }

.body { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 0; }
.body.wide { grid-template-columns: minmax(0, 1fr); }
.nav { overflow: auto; border-right: 1px solid var(--line); padding: 12px 8px; background: var(--surface); }
.nav h3 { margin: 4px 10px 8px; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.navitem {
  display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; border: 0; border-radius: var(--radius);
  background: none; padding: 6px 10px; min-height: 34px;
}
.navitem:hover { background: var(--surface-2); }
.navitem.cur { background: var(--accent-soft); font-weight: 600; }
.navitem .n { color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.navitem span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: none; gap: 6px; overflow-x: auto; padding: 10px 16px 0; }
.chip { flex: 0 0 auto; border-radius: 999px; min-height: 34px; padding: 4px 14px; }
.chip.cur { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.main { overflow: auto; min-width: 0; }
.welcome { padding: 48px 24px; max-width: 36rem; margin: 0 auto; }
.page { padding: 24px; max-width: 46rem; margin: 0 auto; display: grid; gap: var(--gap); align-content: start; }
.page h2, .page h3, .page p, .sub p, .emptybox p { margin: 0; }
.page h3 { margin-top: 8px; font-size: 1.05rem; }
.page .sub { gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.field { display: grid; gap: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sw { width: 36px; height: 36px; border-radius: 50%; padding: 0; border: 2px solid var(--line); }
.sw.on { outline: 3px solid var(--text); outline-offset: 2px; }
input[type='color'] { width: 40px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: none; }
.qr { width: 220px; max-width: 100%; background: #fff; padding: 6px; border-radius: var(--radius); margin: 8px 0; }
.qr svg { width: 100%; height: auto; display: block; }
.secret { display: block; word-break: break-all; background: var(--surface-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 8px 12px; margin: 8px 0; font-family: ui-monospace, Consolas, monospace; }
.pill { border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; border: 1px solid var(--line); }
.pill.licensed { color: var(--ok); }
.pill.expired { color: var(--danger); }

/* Tabs on the settings and key pages */
.tabs { scrollbar-width: none; display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 0 -4px; padding: 0 4px; }
.tab { flex: 0 0 auto; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 8px 14px; min-height: 40px; color: var(--muted); }
.tab:hover { border-color: var(--line); color: var(--text); }
.tab.on { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; background: none; }
.sub { display: grid; gap: var(--gap); align-content: start; }
details.more { font-size: 0.9rem; color: var(--muted); }
details.more summary { cursor: pointer; color: var(--accent); width: fit-content; }
details.more p { margin: 6px 0 0; }

/* Notes: big list of cards in the main area */
.notes { padding: 20px 24px 32px; max-width: 72rem; margin: 0 auto; display: grid; gap: 14px; align-content: start; }
.notes-head { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.notes-head h2 { margin: 0; font-size: 1.4rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.ncard {
  display: grid; align-content: start; gap: 4px; text-align: left; padding: 11px 13px; min-height: 92px;
  background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 2px); box-shadow: var(--shadow);
}
.ncard:hover { border-color: var(--accent); }
.ncard .t { font-weight: 650; font-size: 0.97rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ncard .x { color: var(--muted); font-size: 0.85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ncard .m { color: var(--muted); font-size: 0.75rem; margin-top: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.emptybox { padding: 40px 24px; text-align: center; border: 1px dashed var(--line); border-radius: calc(var(--radius) + 2px); }

.editor { display: grid; grid-template-rows: auto 1fr auto auto; height: 100%; }
.bar { display: flex; gap: 8px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--surface); }
.bar .path { flex: 1 1 120px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state { font-size: 0.85rem; color: var(--muted); }
.state.dirty, .state.remote { color: var(--accent); }
.paper {
  width: 100%; height: 100%; border: 0; resize: none; background: var(--surface); color: var(--text);
  font-family: var(--note-font); font-size: 1.1rem; line-height: 1.75; padding: 32px max(16px, calc(50% - 22rem));
}
.paper.read { overflow: auto; }
.read h1, .read h2, .read h3 { line-height: 1.25; }
.read blockquote { margin: 1em 0; padding: 0.2em 1em; border-left: 3px solid var(--accent); color: var(--muted); }
.read code { background: var(--surface-2); border-radius: 6px; padding: 1px 6px; font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }
.read pre { background: var(--surface-2); border-radius: var(--radius); padding: 12px 16px; overflow: auto; }
.read pre code { padding: 0; background: none; }
.read hr { border: 0; border-top: 1px solid var(--line); }
.read .task { list-style: none; margin-left: -1.2em; }
.read a.wiki { cursor: pointer; text-decoration: underline dotted; }
.panel, .backlinks { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--bg); display: grid; gap: 4px; max-height: 40vh; overflow: auto; }
.backlinks { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.foot { padding: 6px 16px; font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface); }

@media (max-width: 760px) {
  .body { grid-template-columns: minmax(0, 1fr); }
  .nav { display: none; }
  .chips { display: flex; }
  .notes { padding: 12px 16px 24px; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .top { gap: 8px; padding: 8px 12px; flex-wrap: wrap; }
  .search { order: 5; flex: 1 1 100%; max-width: none; }
  .hback + .brand { display: none; }
  .banner { font-size: 0.92rem; }
  .paper { padding: 20px 16px; font-size: 1.05rem; }
  .page { padding: 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background 0.15s, border-color 0.15s; }
}

.overview { padding: 16px; max-width: 46rem; margin: 0 auto; display: grid; gap: 12px; }
.overview h2, .overview p { margin: 0; }
.overview svg { width: 100%; height: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.overview .node { cursor: pointer; }
.overview .count { fill: #fff; font-weight: 700; font-size: 18px; pointer-events: none; }
.overview .name { fill: var(--text); font-size: 17px; pointer-events: none; }

/* Legal pages and first-run setup */
.legal { white-space: pre-line; }
.setup { max-height: 100vh; overflow-y: auto; }
.setup details { margin: 4px 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.9rem; }
.check input { width: auto; margin-top: 4px; }

/* Dialog (login: more ways) */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 22, 0.5); display: grid; place-items: center; padding: 16px; }
.dialog { width: min(460px, 100%); max-height: 90vh; overflow: auto; display: grid; gap: 14px; }
.dialog h2 { margin: 0; font-size: 1.2rem; }
.dialog section { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.dialog section:first-of-type { border-top: 0; padding-top: 0; }
.dialog h3 { margin: 0; font-size: 1rem; }

.lost { font-size: .9rem; display: grid; gap: 8px; }
.lost input { width: 100%; }

/* attachments in a note */
.paper.read img.att { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 8px 0; }
.paper.read a.att::before { content: "\1F4CE\00a0"; }

.tabs::-webkit-scrollbar { display: none; }

/* Graph view ("Vernetzung") */
.graph { display: flex; flex-direction: column; gap: 10px; }
.graphbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.graphbar select, .graphbar input[type="search"] { width: auto; min-width: 10em; }
.graphpick { gap: 10px; align-items: center; }
.graphcanvas { width: 100%; height: min(70vh, 720px); min-height: 320px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); touch-action: none; cursor: grab; }

.row.phone { flex-wrap: nowrap; }
.row.phone select { width: auto; flex: 0 0 auto; }

/* Licence packages (menu, prices) */
.prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.price { display: flex; flex-direction: column; gap: 6px; padding: 16px; }
.price .amount { font-size: 1.4em; font-weight: 600; }
