/* kurznotiz — handgeschriebenes CSS, kein Framework.
   Eine Spalte mit begrenzter Lesebreite (~70 Zeichen), ruhige Farben,
   helle und dunkle Darstellung ueber CSS-Variablen. */

:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-ruhig: #f1efe9;
  --text: #23262b;
  --muted: #6b7280;
  --border: #e3e0d7;
  --accent: #2f6b5f;
  --accent-text: #ffffff;
  --accent-soft: #e7f1ee;
  --mark: #fff1a8;
  --mark-text: #23262b;
  --danger: #a32318;
  --danger-soft: #fdecea;
  --radius: 10px;
  --lesebreite: 70ch;
  --schatten: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px rgb(0 0 0 / 4%);
}

/* Dunkle Farbwelt.
   Absichtlich zweimal aufgefuehrt: einmal erzwungen per Schalter, einmal fuer die
   Systemeinstellung bei "auto". CSS-Variablen lassen sich nicht per Selektor
   zwischen einer Medienabfrage und einem Attribut teilen. */
[data-darstellung="dunkel"] {
  --bg: #15171b;
  --surface: #1d2025;
  --surface-ruhig: #23272d;
  --text: #e7e7e4;
  --muted: #9ba1a8;
  --border: #2e333a;
  --accent: #7fc9b4;
  --accent-text: #10201c;
  --accent-soft: #1f302c;
  --mark: #6d5c00;
  --mark-text: #fff8d6;
  --danger: #ff9a90;
  --danger-soft: #3a1f1c;
  --schatten: none;
}

@media (prefers-color-scheme: dark) {
  [data-darstellung="auto"] {
    --bg: #15171b;
    --surface: #1d2025;
    --surface-ruhig: #23272d;
    --text: #e7e7e4;
    --muted: #9ba1a8;
    --border: #2e333a;
    --accent: #7fc9b4;
    --accent-text: #10201c;
    --accent-soft: #1f302c;
    --mark: #6d5c00;
    --mark-text: #fff8d6;
    --danger: #ff9a90;
    --danger-soft: #3a1f1c;
    --schatten: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

/* --- Kopfzeile ----------------------------------------------------------- */

.kopf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  max-width: calc(var(--lesebreite) + 20rem);
  margin: 0 auto;
  padding: 1.25rem 0 1rem;
  border-bottom: 1px solid var(--border);
}

.marke {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}

.kopf nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-left: auto;
}

.kopf nav form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.kopf input[type="search"] {
  width: 15rem;
}

/* Umschalter fuer die Darstellung */
.darstellung {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.darstellung .hinweis {
  color: var(--muted);
  font-size: 0.85rem;
}

.darstellung button {
  padding: 0.3rem 0.55rem;
  font-size: 0.85rem;
}

.darstellung button.aktiv {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.kopf nav label {
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- Grundriss ----------------------------------------------------------- */

.shell {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 2.5rem;
  max-width: calc(var(--lesebreite) + 20rem);
  margin: 2rem auto 0;
}

.content {
  flex: 1 1 var(--lesebreite);
  min-width: 0;
  max-width: var(--lesebreite);
}

.sidebar {
  flex: 0 0 15rem;
  position: sticky;
  top: 1.5rem;
}

/* Ohne Inhalt (z. B. auf der Suchseite) nimmt die Seitenleiste keinen Platz ein. */
.sidebar:empty {
  display: none;
}

@media (max-width: 62rem) {
  .shell {
    flex-direction: column;
    gap: 1.5rem;
  }

  .sidebar {
    flex: 0 0 auto;
    position: static;
    order: 2;
    width: 100%;
  }
}

/* --- Ueberschriften und Text --------------------------------------------- */

h1 {
  font-size: 1.7rem;
  line-height: 1.25;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
}

h3 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.5rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

.hinweis,
.hint,
.meta,
.empty {
  color: var(--muted);
}

.empty {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* --- Formulare und Knoepfe ----------------------------------------------- */

label {
  font-weight: 600;
}

input,
textarea,
button {
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="search"],
input[type="password"],
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

textarea {
  line-height: 1.5;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

button {
  padding: 0.45rem 0.9rem;
  background: var(--surface-ruhig);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button[type="submit"].primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.primary:hover {
  filter: brightness(1.06);
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.knopfreihe {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
}

/* --- Listen -------------------------------------------------------------- */

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

.note-list li {
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
}

.note-list li > a {
  font-weight: 600;
}

.note-list time {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* --- Tags ---------------------------------------------------------------- */

.tags,
.tag-cloud ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}

.tags a,
.tag-cloud a {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.82rem;
  text-decoration: none;
}

.tags a:hover,
.tag-cloud a:hover {
  border-color: var(--accent);
}

.tag-cloud {
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tag-cloud h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.tag-cloud li {
  color: var(--muted);
  font-size: 0.8rem;
}

/* --- Notiztext (gerendertes Markdown) ------------------------------------ */

.body {
  margin: 1.5rem 0;
}

.body > :first-child {
  margin-top: 0;
}

.body h1,
.body h2,
.body h3 {
  margin-top: 1.75rem;
}

.body ul,
.body ol {
  padding-left: 1.4rem;
}

.body li {
  margin: 0.2rem 0;
}

.body blockquote {
  margin: 1rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.body code {
  padding: 0.1rem 0.35rem;
  background: var(--surface-ruhig);
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.body pre {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  background: var(--surface-ruhig);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.body pre code {
  padding: 0;
  background: none;
}

.body table {
  width: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.body th,
.body td {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  text-align: left;
}

.body th {
  background: var(--surface-ruhig);
}

.body hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* Suchtreffer */
.excerpt {
  margin-top: 0.5rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
  font-size: 0.95rem;
}

.excerpt > :first-child {
  margin-top: 0;
}

.excerpt > :last-child {
  margin-bottom: 0;
}

.excerpt table,
.excerpt ul {
  margin: 0.25rem 0;
}

mark {
  padding: 0 0.15rem;
  background: var(--mark);
  color: var(--mark-text);
  border-radius: 3px;
}

/* --- Aufklappbereiche ---------------------------------------------------- */

details {
  margin: 1.25rem 0;
  padding: 0.6rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

summary {
  cursor: pointer;
  font-weight: 600;
}

summary::marker {
  color: var(--muted);
}

details > *:not(summary) {
  margin-top: 0.85rem;
}

.delete {
  border-color: var(--danger);
}

.delete summary {
  color: var(--danger);
}

/* Kurzhilfe im Editor */
.markdown-help table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.markdown-help th,
.markdown-help td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.markdown-help th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.markdown-help td:last-child {
  width: 40%;
}

.markdown-help pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
}

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

.error {
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.9rem;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-left-width: 4px;
  border-radius: 8px;
  color: var(--danger);
  font-weight: 600;
}

.hinweis,
.hint {
  font-size: 0.9rem;
}

/* --- Anmeldung ---------------------------------------------------------- */

.anmeldung {
  max-width: 24rem;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--schatten);
}

.anmeldung h1 {
  margin-bottom: 1.25rem;
}

.anmeldung p {
  margin-bottom: 0;
}

/* --- Kleinkram ----------------------------------------------------------- */

.sprungmarke {
  position: absolute;
  left: -9999px;
}

.sprungmarke:focus {
  position: static;
  display: inline-block;
  margin-bottom: 1rem;
}

.export {
  color: var(--muted);
  font-size: 0.9rem;
}
