/* ---------------------------------------------------------------------------
   x.wenkmedia — Notizen
   Bild: ein Werkstattbuch. Links eine Randspalte mit Uhrzeiten in Schreibmaschine,
   rechts der Eintrag. Keine externen Schriften, keine CDN — laedt auch bei
   zaeher Leitung sofort.
   ------------------------------------------------------------------------- */

:root {
  --bg:       #f1f3f2;
  --surface:  #ffffff;
  --sunk:     #e7eae9;
  --ink:      #151b20;
  --muted:    #5f6c74;
  --line:     #d9dfe0;
  --accent:   #0d6f60;
  --accent-ink: #ffffff;
  --signal:   #b8511a;
  --danger:   #9c2f2f;
  --radius:   14px;
  --rail:     58px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #101518;
    --surface: #182025;
    --sunk:    #131a1e;
    --ink:     #e4ebee;
    --muted:   #8b989f;
    --line:    #242e34;
    --accent:  #2fae99;
    --accent-ink: #06231f;
    --signal:  #d4813f;
    --danger:  #d9736c;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
mark { background: color-mix(in srgb, var(--signal) 28%, transparent); color: inherit; border-radius: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

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

/* ------------------------------------------------------------------ Kopf */

.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 8px;
  padding-top: max(10px, env(safe-area-inset-top));
}

.find { display: flex; gap: 6px; align-items: center; }

.find input[type="search"] {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
}

.find button,
.find .clear {
  font: 500 13px/1 var(--sans);
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 0 2px;
  margin: 0 -12px;
  padding-left: 12px;
  padding-right: 12px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  font: 500 13px/1 var(--sans);
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip span { font: 500 11px/1 var(--mono); opacity: .65; }
.chip.ghost { margin-left: auto; opacity: .6; }
.tagchip { font-family: var(--mono); font-size: 12px; }

.result { margin: 8px 2px 0; font: 500 13px/1.3 var(--mono); color: var(--muted); }

.top.slim { display: flex; align-items: baseline; gap: 12px; }
.top.slim .back { font: 500 14px/1 var(--sans); text-decoration: none; }
.top.slim .when { font: 400 12px/1 var(--mono); color: var(--muted); }

/* -------------------------------------------------------------- Zeitleiste */

.stream {
  max-width: 780px;
  margin: 0 auto;
  padding: 8px 12px 132px;
  position: relative;
}

/* die Randspalte des Werkstattbuchs */
.stream::before {
  content: "";
  position: absolute;
  left: calc(12px + var(--rail) - 13px);
  top: 0;
  bottom: 132px;
  width: 1px;
  background: var(--line);
}

.daymark {
  position: relative;
  margin: 22px 0 12px;
  text-align: center;
}
.daymark span {
  position: relative;
  background: var(--bg);
  padding: 0 10px;
  font: 500 11px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  align-items: start;
  margin: 0 0 10px;
  scroll-margin-top: 96px;
}

.stamp {
  padding-top: 12px;
  font: 400 12px/1 var(--mono);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.stamp .pin { color: var(--signal); font-size: 10px; }

.bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-top-left-radius: 4px;
  padding: 10px 12px 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.card.pinned .bubble { border-color: color-mix(in srgb, var(--signal) 45%, var(--line)); }
.card.done .bubble { background: var(--sunk); }
.card.done .text, .card.done .ctitle { color: var(--muted); }

.ctitle { margin: 0 0 4px; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.text { margin: 0; }
.text a.tag, .ctitle a.tag { font-family: var(--mono); font-size: .92em; text-decoration: none; }

.cardbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}
.cardbar .clip,
.cardbar .edited { font: 400 11px/1 var(--mono); color: var(--muted); }
.cardbar .edited { font-style: normal; opacity: .8; }

.chipbtn {
  font: 500 12px/1 var(--sans);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}
.chipbtn:hover { color: var(--ink); border-color: var(--muted); }
.chipbtn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chipbtn.danger { color: var(--danger); }
.chipbtn.on { border-color: var(--accent); color: var(--accent); }
.inline { display: inline; margin: 0; }

.pinnedbar { margin: 6px 0 18px; }
.railtitle {
  font: 500 11px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}
.pinrow {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--signal);
  border-radius: 8px;
  margin-bottom: 6px;
  text-decoration: none;
  color: var(--ink);
}
.pinwhen { font: 400 12px/1.4 var(--mono); color: var(--muted); }
.pintext { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

.more { text-align: center; margin: 14px 0; }
.more a { font: 500 13px/1 var(--sans); color: var(--muted); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 15px;
}

/* ---------------------------------------------------------------- Anhaenge */

.gallery { display: grid; gap: 4px; margin: 8px 0 4px; }
.gallery.n1 { grid-template-columns: 1fr; }
.gallery.n2 { grid-template-columns: 1fr 1fr; }
.gallery.n3, .gallery.n4 { grid-template-columns: 1fr 1fr; }

.shot { display: block; overflow: hidden; border-radius: 8px; background: var(--sunk); }
.shot img { display: block; width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4 / 3; }
.gallery.n1 .shot img { aspect-ratio: auto; max-height: 62vh; object-fit: contain; }

.files { list-style: none; margin: 8px 0 2px; padding: 0; display: grid; gap: 4px; }
.files a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: var(--sunk);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
}
.ext {
  font: 600 10px/1 var(--mono);
  letter-spacing: .06em;
  padding: 5px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
}
.fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.fsize { font: 400 11px/1 var(--mono); color: var(--muted); }

/* --------------------------------------------------------------- Composer */

.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.composer .row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 780px;
  margin: 0 auto;
}

.iconbtn {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 19px;
  cursor: pointer;
}
.iconbtn:active { background: var(--sunk); }

.composer textarea {
  flex: 1;
  min-width: 0;
  font: inherit;
  resize: none;
  max-height: 40vh;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
}

.send {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  cursor: pointer;
}

.picked {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  max-width: 780px;
  margin: 0 auto 8px;
  scrollbar-width: none;
}
.picked::-webkit-scrollbar { display: none; }
.picked figure {
  position: relative;
  margin: 0;
  flex: 0 0 auto;
  width: 66px; height: 66px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--sunk);
  border: 1px solid var(--line);
}
.picked img { width: 100%; height: 100%; object-fit: cover; }
.picked .doc {
  display: grid; place-items: center;
  height: 100%;
  font: 600 10px/1.3 var(--mono);
  text-align: center;
  color: var(--muted);
  padding: 4px;
  overflow: hidden;
}

/* ------------------------------------------------------------- Bearbeiten */

.sheet {
  max-width: 780px;
  margin: 0 auto;
  padding: 18px 14px 60px;
}
.sheet.narrow { max-width: 380px; padding-top: 18vh; }
.sheet.wide { max-width: 820px; }

body.plain { background: var(--bg); }
.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.sheet h1 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 16px; }
.sheet h2 { font-size: 15px; margin: 22px 0 8px; }

.stack { display: grid; gap: 10px; }
.stack input, .titlefield, .bodyfield {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.stack button {
  font: 500 15px/1 var(--sans);
  padding: 11px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.editform { display: grid; gap: 8px; }
.titlefield { font-weight: 650; }
.bodyfield { min-height: 160px; resize: vertical; line-height: 1.55; }
.editbar { display: flex; gap: 8px; align-items: center; }

.attgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.att {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.att img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.filebox { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--sunk); }
.att figcaption { display: grid; gap: 2px; padding: 6px 8px; }
.att .fname { font-size: 12px; }
.attbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 8px; }

.statusbar { display: flex; flex-wrap: wrap; gap: 8px; }
.taglist { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }

.checks { list-style: none; padding: 0; margin: 0 0 8px; font-size: 14px; display: grid; gap: 4px; }
.checks li.ok { color: var(--accent); }
.checks li.warn { color: var(--signal); }
.ok { color: var(--accent); }
.warn { color: var(--signal); }
.meta { font: 400 12px/1.4 var(--mono); color: var(--muted); }
.code, pre.code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: 400 12px/1.5 var(--mono);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* -------------------------------------------------------------- Meldungen */

.flash {
  position: fixed;
  left: 50%;
  top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 60;
  max-width: 92vw;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0,0,0,.22);
  animation: flashout 4.5s forwards;
}
@keyframes flashout {
  0%, 78% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

/* -------------------------------------------------------------- Lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8,11,13,.94);
  display: grid;
  place-items: center;
  padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 88vh; object-fit: contain; border-radius: 6px; }
.lightbox .lbclose {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  font-size: 26px;
  color: #fff;
  background: none;
  border: 0;
  cursor: pointer;
}
.lightbox .lbnav {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
}
.lightbox .lbnav button, .lightbox .lbnav a {
  font: 500 13px/1 var(--sans);
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

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

@media (min-width: 620px) {
  :root { --rail: 66px; }
  .gallery.n3 { grid-template-columns: repeat(3, 1fr); }
  .gallery.n4 { grid-template-columns: repeat(4, 1fr); }
}
