/* KI-Logbuch – paper, lilac and a bit of hand-made wobble. No external fonts, no scripts needed for layout. */

:root {
  --paper: #f1ebe2;
  --paper-2: #e6ddcf;
  --sheet: #fffdf8;
  --edge: #d6cabb;
  --ink: #2d2536;
  --soft: #6a6074;
  --lilac-50: #f6f1fb;
  --lilac-100: #e9dff4;
  --lilac-200: #d8c7ea;
  --lilac-300: #c6abe1;
  --lilac-400: #a98acd;
  --lilac-600: #7a5aa0;
  --lilac-800: #47315f;
  --brick: #a2412f;
  --brick-bg: #f1d9d2;
  --ochre: #8f6212;
  --ochre-bg: #f3e4bd;
  --sage: #4a7556;
  --sage-bg: #d9e8d6;
  --slate: #56648a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --wobble-a: 14px 20px 13px 18px / 18px 13px 20px 14px;
  --wobble-b: 20px 13px 19px 14px / 13px 19px 14px 20px;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .28  0 0 0 0 .2  0 0 0 0 .38  0 0 0 .085 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  --wave: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='96' height='9'><path d='M2 4.5Q12 -1 22 4.5T42 4.5T62 4.5T82 4.5' fill='none' stroke='%237a5aa0' stroke-width='2.2' stroke-linecap='round'/></svg>");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 var(--sans);
  color: var(--ink);
  background: var(--paper) var(--grain);
}
a { color: var(--lilac-800); text-decoration-color: var(--lilac-400); text-underline-offset: 3px; }
a:hover { color: var(--lilac-600); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 2.1rem; letter-spacing: -.01em; }
h1::after { content: ""; display: block; width: 96px; height: 9px; margin-top: 6px; background: var(--wave) no-repeat; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; margin-top: 1.6em; }
p { margin: 0 0 .8em; }
small { display: block; }
.muted { color: var(--soft); }
.mono { font-family: var(--mono); font-size: .88em; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 1.15em; height: 1.15em; vertical-align: -.2em; margin-right: .4em; flex: none; }
.ico.ok { color: var(--sage); }
.spin { animation: turn 2.4s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } * { transition: none !important; } }

/* --- Frame: lilac menu with a few layers behind it ------------------------ */

.shell { display: grid; grid-template-columns: 262px minmax(0, 1fr); min-height: 100vh; }
body.out .shell { display: block; }

.side {
  position: sticky; top: 0; height: 100vh; z-index: 3;
  display: flex; flex-direction: column; gap: 28px;
  padding: 28px 30px 24px 22px;
  background: var(--lilac-300) var(--grain);
  border-radius: 0 34px 26px 0 / 0 46px 30px 0;
  box-shadow: 7px 0 0 -1px var(--lilac-200), 15px 0 0 -3px var(--lilac-100), 4px 14px 28px -16px rgba(71, 49, 95, .55);
}
.brand { display: flex; flex-direction: column; align-items: flex-start; text-decoration: none; color: var(--lilac-800); }
.logo { width: 46px; height: 54px; margin: 0 0 6px 4px; transform: rotate(-4deg); overflow: visible; }
.logo .stem { fill: none; stroke: var(--lilac-800); stroke-width: 1.8; stroke-linecap: round; }
.logo .blossoms circle { fill: var(--lilac-50); stroke: var(--lilac-800); stroke-width: 1.2; }
.brand-name { font: 600 1.45rem/1.1 var(--serif); }
.brand-sub { font-size: .82rem; opacity: .8; }

.links { display: flex; flex-direction: column; gap: 7px; }
.links a {
  display: flex; align-items: center; padding: 10px 14px; text-decoration: none; font-weight: 600;
  color: var(--lilac-800); border-radius: 12px 16px 12px 15px / 15px 12px 16px 12px;
  transition: background .12s, transform .12s;
}
.links a:nth-child(2) { border-radius: 16px 11px 15px 12px / 12px 15px 11px 16px; }
.links a:hover { background: var(--lilac-200); transform: translateX(2px); }
.links a.on {
  background: var(--sheet); margin-right: -26px; padding-right: 30px; border-radius: 14px 4px 4px 18px / 16px 4px 4px 14px;
  box-shadow: 0 1px 0 #fff inset, 3px 4px 0 rgba(71, 49, 95, .28);
}
.who { margin-top: auto; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--lilac-800); }
.who-name { font-weight: 700; }
.linklike {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; color: inherit; font-size: .9rem;
  text-decoration: underline; text-decoration-color: var(--lilac-600); text-underline-offset: 3px;
}
.linklike:hover { color: var(--lilac-600); }
.linklike.danger { color: var(--brick); }
.linklike:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2.5px solid var(--lilac-600); outline-offset: 2px; }

.page { padding: 34px clamp(18px, 4vw, 48px) 30px; max-width: 1240px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: .25em; }
.crumb { font-size: .85rem; margin: 0 0 4px; }
.foot { margin-top: 48px; font-size: .78rem; color: var(--soft); text-align: right; }

/* --- Paper ---------------------------------------------------------------- */

.sheet {
  position: relative; background: var(--sheet); border: 1px solid var(--edge); border-radius: var(--wobble-a);
  padding: 22px 28px 24px;
  box-shadow: 0 1px 0 #fff inset, 3px 4px 0 -1px var(--paper-2), 6px 8px 0 -2px var(--edge), 0 20px 26px -20px rgba(71, 49, 95, .45);
}
.sheet:nth-child(even) { border-radius: var(--wobble-b); }
.stack > .sheet, .page > .sheet { margin-bottom: 30px; }
.sheet.slim { padding: 18px 24px 20px; }
.sheet h2 { padding-bottom: .35em; border-bottom: 1px dashed var(--edge); margin-bottom: .8em; }
.sheet.empty { text-align: center; padding: 44px 20px; max-width: 560px; margin: 30px auto; }
.good { color: var(--sage); font-weight: 600; margin: 0; }
.notes ul { margin: 0; padding-left: 1.2em; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 34px; align-items: start; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 26px 22px; margin-bottom: 26px; }
.tile {
  position: relative; background: var(--sheet); border: 1px solid var(--edge); padding: 22px 18px 14px; display: flex;
  flex-direction: column; border-radius: 4px 12px 5px 10px / 10px 5px 12px 4px;
  box-shadow: 2px 3px 0 var(--paper-2), 4px 6px 0 var(--edge);
}
.tile:nth-child(even) { border-radius: 10px 4px 12px 5px / 5px 12px 4px 10px; }
.tile::before {
  content: ""; position: absolute; top: -9px; left: 20px; width: 56px; height: 18px; background: rgba(198, 171, 225, .75);
  transform: rotate(-3deg); box-shadow: 0 1px 2px rgba(71, 49, 95, .2);
  clip-path: polygon(0 12%, 4% 0, 8% 14%, 12% 0, 100% 0, 96% 50%, 100% 100%, 8% 100%, 4% 86%, 0 100%, 3% 50%);
}
.tile:nth-child(even)::before { left: auto; right: 18px; transform: rotate(2.5deg); }
.tile .num { font: 600 2.6rem/1 var(--serif); }
.tile .lbl { font-size: .86rem; color: var(--soft); margin-top: 4px; }
.tile.alarm .num { color: var(--brick); }
.tile.warn .num { color: var(--ochre); }

.chips { display: flex; gap: 8px; margin-bottom: 22px; }
.chip {
  padding: 4px 14px; border: 1.5px solid var(--lilac-400); border-radius: 14px 9px 13px 10px; text-decoration: none;
  font-size: .9rem; color: var(--lilac-800); background: var(--lilac-50);
}
.chip.on { background: var(--lilac-300); border-color: var(--lilac-800); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 34px 30px; padding-right: 8px; }
.card {
  /* No stacking context here (no transform/isolation), so the z-index:-1 layers below sit behind the paper. */
  position: relative; top: 0; background: var(--sheet); border: 1px solid var(--edge);
  border-radius: var(--wobble-a); padding: 18px 22px 14px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 1px 0 #fff inset, 0 16px 22px -18px rgba(71, 49, 95, .5); transition: top .14s;
}
.card:nth-child(3n+2) { border-radius: var(--wobble-b); }
.card::before, .card::after { content: ""; position: absolute; z-index: -1; border-radius: inherit; }
.card::before { inset: 7px -7px -8px 7px; background: var(--lilac-100); border: 1px solid var(--lilac-200); transform: rotate(1.2deg); }
.card::after { inset: 3px -3px -4px 3px; background: var(--paper-2); transform: rotate(-.7deg); }
.card:hover { top: -3px; }
.card.lv-alarm::before, .card.lv-error::before { background: var(--brick-bg); border-color: #e2b9ae; }
.card.lv-warn::before { background: var(--ochre-bg); border-color: #e3cd96; }
.card.lv-ok::before { background: var(--sage-bg); border-color: #bfd5bb; }
.card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 1.3rem; }
.card h2 a { text-decoration: none; color: var(--ink); }
.card h2 a::before { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card .repo { margin: 0; font: .82rem var(--mono); color: var(--soft); display: flex; align-items: center; overflow-wrap: anywhere; }
.card footer { margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--edge); font-size: .82rem; color: var(--soft); }

.facts { margin: 0; display: grid; gap: 10px; }
.facts > div { display: grid; grid-template-columns: 8.4em minmax(0, 1fr); gap: 10px; align-items: baseline; }
.facts dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--soft); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts.wide { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px 40px; }

/* --- Ink stamps instead of traffic lights --------------------------------- */

.stamp {
  display: inline-block; padding: .3em .6em .26em; font: 700 .68rem/1.1 var(--sans); text-transform: uppercase;
  letter-spacing: .09em; color: var(--soft); border: 1.5px solid currentColor; outline: 1px solid currentColor;
  outline-offset: 2px; border-radius: 6px 3px 7px 4px; transform: rotate(-2deg); vertical-align: middle; white-space: nowrap;
  margin: 3px 4px 3px 3px;
}
.stamp:nth-of-type(even) { transform: rotate(1.5deg); }
.lv-alarm.stamp, .lv-error.stamp, .sev-high.stamp, .bump-major.stamp { color: var(--brick); }
.lv-warn.stamp, .sev-medium.stamp, .bump-minor.stamp { color: var(--ochre); }
.lv-note.stamp, .sev-low.stamp, .bump-patch.stamp { color: var(--slate); }
.lv-ok.stamp { color: var(--sage); }
.sev-critical.stamp { color: #fff; background: var(--brick); border-color: var(--brick); outline-color: var(--brick); }
.sevtxt { font-weight: 700; }
.sevtxt.sev-critical, .sevtxt.sev-high { color: var(--brick); }
.sevtxt.sev-medium { color: var(--ochre); }
.sevtxt.sev-low, .sevtxt.sev-unknown { color: var(--slate); }

.agebar { margin-top: 5px; vertical-align: middle; }
.agebar .track { fill: var(--paper-2); stroke: var(--edge); }
.agebar .fill { fill: var(--sage); opacity: .85; }
.agebar.late .fill { fill: var(--ochre); }
.agebar .tick { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 2 2; opacity: .55; }

/* --- Buttons and forms ---------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; padding: .6em 1.15em; cursor: pointer; text-decoration: none;
  font: 600 .95rem var(--sans); color: var(--lilac-800); background: var(--lilac-300); border: 1.5px solid var(--lilac-800);
  border-radius: 10px 14px 11px 13px / 13px 10px 14px 11px; box-shadow: 3px 3px 0 var(--lilac-800);
  transition: transform .08s, box-shadow .08s, background .12s;
}
.btn:hover { background: var(--lilac-200); color: var(--lilac-800); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--lilac-800); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--lilac-800); }
.btn.ghost { background: var(--sheet); }
.btn.ghost:hover { background: var(--lilac-50); }
.btn.danger { color: var(--brick); border-color: var(--brick); box-shadow: 3px 3px 0 var(--brick); background: var(--sheet); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.actions form { margin: 0; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.field > span { font-weight: 600; font-size: .9rem; }
input:not([type=checkbox]), select, textarea {
  width: 100%; padding: .6em .8em; font: inherit; color: var(--ink); background: #fff; border: 1.5px solid var(--edge);
  border-radius: 8px 11px 9px 12px / 11px 8px 12px 9px; box-shadow: inset 0 2px 3px rgba(71, 49, 95, .09);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2.5px solid var(--lilac-400); outline-offset: 1px; border-color: var(--lilac-600); }
.field.bad input { border-color: var(--brick); }
.err { color: var(--brick); font-weight: 600; }
.check { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.check input { width: 1.1em; height: 1.1em; accent-color: var(--lilac-600); }
.help p { font-size: .92rem; }
.help .actions { margin-top: 18px; }
.keybox { margin: 0; padding: 12px 14px; background: var(--lilac-50); border: 1px dashed var(--lilac-400); border-radius: 8px; font: .8rem/1.4 var(--mono); white-space: pre-wrap; word-break: break-all; user-select: all; }
.users { list-style: none; margin: 0 0 8px; padding: 0; }
.users li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dotted var(--edge); }
.users form { margin: 0; }

.flash { display: flex; align-items: center; gap: 4px; margin: 0 0 22px; padding: 11px 16px; border-left: 5px solid; border-radius: 4px 12px 10px 4px; }
.flash-ok { background: var(--sage-bg); border-color: var(--sage); }
.flash-err { background: var(--brick-bg); border-color: var(--brick); }
.flash-info { background: var(--lilac-100); border-color: var(--lilac-400); }
.flash .ico { margin-right: 6px; }

/* --- Tables --------------------------------------------------------------- */

.scroll { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--lilac-800); background: var(--lilac-50); padding: 8px 10px; white-space: nowrap; }
th:first-child { border-radius: 8px 0 0 8px; }
th:last-child { border-radius: 0 10px 10px 0; }
td { padding: 9px 10px; border-bottom: 1px dotted var(--edge); vertical-align: top; }
td.wrap { min-width: 220px; max-width: 420px; }
tbody tr:hover td { background: var(--lilac-50); }
details summary { cursor: pointer; font: 600 1.15rem var(--serif); list-style: none; }
details summary::before { content: "▸"; display: inline-block; width: 1.2em; color: var(--lilac-600); transition: transform .12s; }
details[open] summary::before { transform: rotate(90deg); }
details[open] summary { margin-bottom: 12px; }
.history { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.history li { padding: 4px 0; border-bottom: 1px dotted var(--edge); }
.history .h-error { color: var(--brick); }

/* --- Login ---------------------------------------------------------------- */

body.out { min-height: 100vh; background: var(--lilac-200) var(--grain); }
body.out .page { max-width: none; padding: 0 18px; }
.login { min-height: 100vh; display: grid; place-items: center; }
.login-sheet { width: min(400px, 100%); padding-top: 54px; box-shadow: 0 1px 0 #fff inset, 8px -6px 0 -1px var(--lilac-300), -8px 10px 0 -2px var(--lilac-400), 0 24px 30px -18px rgba(71, 49, 95, .6); }
.login-sheet h1 { text-align: center; }
.login-sheet h1::after { margin-left: auto; margin-right: auto; }
.login-sheet .muted { text-align: center; }
.login-sheet .btn { width: 100%; }
.login-logo { position: absolute; top: -34px; left: 50%; width: 76px; height: 76px; margin-left: -38px; display: grid; place-items: center; background: var(--lilac-300); border: 1.5px solid var(--lilac-800); border-radius: 46% 54% 50% 50% / 52% 46% 54% 48%; box-shadow: 3px 3px 0 var(--lilac-800); }
.login-logo .logo { margin: 0; width: 38px; height: 46px; }
.login .foot { display: none; }
body.out .foot { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; margin: 0; }

/* --- Small screens: the menu becomes a lilac strip on top ----------------- */

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 18px;
    padding: 14px 18px 18px; border-radius: 0 0 26px 18px / 0 0 22px 28px; box-shadow: 0 7px 0 -1px var(--lilac-200), 0 14px 0 -3px var(--lilac-100);
  }
  .brand { flex-direction: row; align-items: center; gap: 10px; }
  .logo { width: 30px; height: 36px; margin: 0; }
  .brand-sub { display: none; }
  .links { flex-direction: row; flex-wrap: wrap; }
  .links a.on { margin-right: 0; padding-right: 14px; border-radius: 12px; }
  .who { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: 12px; }
  .split { grid-template-columns: 1fr; }
  .page { padding-top: 26px; }
  .grid { padding-right: 0; }
  .facts > div { grid-template-columns: 1fr; gap: 0; }
}

/* --- Coverage ------------------------------------------------------------- */

.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 26px 22px; margin-bottom: 34px; }
.cov-card {
  position: relative; background: var(--lilac-50); border: 1px solid var(--lilac-200); padding: 18px 20px 16px;
  border-radius: 6px 14px 5px 12px / 12px 5px 14px 6px; box-shadow: 2px 3px 0 var(--paper-2), 4px 6px 0 var(--edge);
}
.cov-card:nth-child(even) { border-radius: 12px 5px 14px 6px / 6px 14px 5px 12px; transform: rotate(.3deg); }
.cov-card:nth-child(odd) { transform: rotate(-.3deg); }
.cov-card h3 { margin: 0 0 .4em; color: var(--lilac-800); }
.cov-card p { margin: 0; font-size: .92rem; }
code { font: .85em ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; background: var(--paper); padding: 1px 5px; border-radius: 3px; overflow-wrap: anywhere; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 5px 0; }
.plain li + li { border-top: 1px dotted var(--edge); }
.cov-app + .cov-app { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--edge); }
.cov-app h3 { margin: 0 0 .4em; }
.notes-inline { margin-top: 8px; color: var(--soft); }
