/* =============================================================
   Fokus — Editorial Stillness
   A paper-meets-ink aesthetic. Fraunces serif headlines anchored
   by Hanken Grotesk UI. Clay-rust accent as a signature stamp.
   ============================================================= */

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Design Tokens ---------- */
:root {
  /* Light — warm paper */
  --paper:       #faf7f1;
  --paper-deep:  #f4efe4;
  --surface:     #ffffff;
  --surface-2:   #f1ece1;
  --surface-3:   #e8e2d4;

  --ink:         #141210;
  --ink-2:       #2a2622;
  --ink-muted:   #6b6459;
  --ink-faint:   #9a928a;
  --ink-ghost:   #c7c0b4;

  --line:        #e2dccd;
  --line-soft:   #eee7d8;

  --accent:      #c44a28;     /* clay / rust */
  --accent-ink:  #ffffff;
  --accent-soft: #f3e6dd;
  --accent-line: #e7c4b3;

  --gold:        #b5831f;
  --moss:        #5d7046;
  --warn:        #a6361b;
  --warn-soft:   #f5d9d2;

  --radius-1: 6px;
  --radius-2: 10px;
  --radius-3: 16px;
  --radius-4: 24px;

  --shadow-sm: 0 1px 2px rgba(34, 27, 17, 0.05);
  --shadow-md: 0 4px 16px -2px rgba(34, 27, 17, 0.08), 0 1px 2px rgba(34, 27, 17, 0.04);
  --shadow-lg: 0 24px 48px -12px rgba(34, 27, 17, 0.18), 0 4px 10px rgba(34, 27, 17, 0.06);

  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --sans:  'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:  'JetBrains Mono', 'SF Mono', ui-monospace, monospace;

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.6, 0, 0.4, 1);

  /* Legacy variable aliases (for inline-styles in app.js) */
  --txt:         var(--ink);
  --txt-2:       var(--ink-muted);
  --txt-3:       var(--ink-faint);
  --bg:          var(--paper);
  --bg-1:        var(--surface);
  --bg-2:        var(--surface-2);
  --bg-3:        var(--surface-3);
  --akzent:      var(--accent);
  --akzent-2:    var(--accent);
  --warn-color:  var(--warn);
  --gut:         var(--moss);
  --gelb:        var(--gold);

  --safe-top: env(safe-area-inset-top);
  --safe-bot: env(safe-area-inset-bottom);
  --safe-l: env(safe-area-inset-left);
  --safe-r: env(safe-area-inset-right);

  --nav-h: calc(66px + var(--safe-bot));
  --kopf-h: calc(72px + var(--safe-top));
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #0d0e10;
    --paper-deep:  #090a0c;
    --surface:     #17181b;
    --surface-2:   #1f2124;
    --surface-3:   #282a2e;

    --ink:         #eeeae0;
    --ink-2:       #d4cec1;
    --ink-muted:   #96907f;
    --ink-faint:   #6b6557;
    --ink-ghost:   #3d3a34;

    --line:        #2a2c30;
    --line-soft:   #1c1e21;

    --accent:      #e8664a;
    --accent-ink:  #0d0e10;
    --accent-soft: #2a1c15;
    --accent-line: #4b2c1e;

    --gold:        #d4a53d;
    --moss:        #8ea676;
    --warn:        #e87960;
    --warn-soft:   #3a1a15;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
    --shadow-md: 0 6px 20px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
    --shadow-lg: 0 32px 60px -20px rgba(0,0,0,.8), 0 6px 12px rgba(0,0,0,.4);
  }
}

/* ---------- Base ---------- */
html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.005em;
  min-height: 100vh;
}

body {
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  position: relative;
}

/* Soft radial warmth in upper-right — page atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 700px 500px at 85% -10%, color-mix(in oklab, var(--accent) 8%, transparent) 0%, transparent 60%),
    radial-gradient(ellipse 900px 700px at -10% 110%, color-mix(in oklab, var(--moss) 5%, transparent) 0%, transparent 60%);
  z-index: 0;
}

/* Subtle paper grain overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.15  0 0 0 0 0.13  0 0 0 0 0.10  0 0 0 0.12 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  z-index: 0;
}

@media (prefers-color-scheme: dark) {
  body::after {
    opacity: 0.35;
    mix-blend-mode: screen;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.6  0 0 0 0 0.58  0 0 0 0 0.52  0 0 0 0.08 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  }
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color .2s var(--ease-out);
}
a:hover { text-decoration: underline; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  letter-spacing: inherit;
}

input, textarea, select {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-2);
  padding: 12px 14px;
  width: 100%;
  outline: none;
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out), box-shadow .2s var(--ease-out);
  appearance: none;
  -webkit-appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  background: var(--paper);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 14%, transparent);
}
textarea { resize: vertical; min-height: 96px; font-family: inherit; }

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236b6459' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
@media (prefers-color-scheme: dark) {
  select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%2396907f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  }
}

input[type="date"] { text-transform: uppercase; letter-spacing: 0.02em; font-size: 14px; }
input[type="color"] {
  border: 1px solid var(--line);
  padding: 4px;
  width: 56px; height: 48px;
  border-radius: var(--radius-2);
  cursor: pointer;
  background: var(--surface);
}

::selection { background: color-mix(in oklab, var(--accent) 25%, transparent); color: var(--ink); }

/* ---------- Layout ---------- */
#app {
  position: relative;
  z-index: 1;
  padding-bottom: calc(var(--nav-h) + 20px);
  min-height: 100vh;
}

/* ---------- Kopf (Header) ---------- */
.kopf {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-top) + 22px) 22px 16px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background:
    linear-gradient(180deg,
      color-mix(in oklab, var(--paper) 96%, transparent) 0%,
      color-mix(in oklab, var(--paper) 92%, transparent) 70%,
      transparent 100%);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
}

.kopf h1 {
  font-family: var(--serif);
  font-variation-settings: "opsz" 144, "SOFT" 20;
  font-weight: 500;
  font-size: clamp(34px, 9.5vw, 44px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: var(--ink);
  flex: 1;
  padding-bottom: 2px;
  word-break: break-word;
}

.kopf h1 small {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 10px;
  padding-bottom: 4px;
}

.kopf-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  font-weight: 400;
  border: 1px solid var(--line);
  transition: transform .15s var(--ease-out), background .2s var(--ease-out), border-color .2s var(--ease-out);
  align-self: center;
  margin-bottom: 4px;
}
.kopf-btn:hover { background: var(--surface-2); border-color: var(--ink-ghost); }
.kopf-btn:active { transform: scale(0.92); }

/* ---------- Bottom-Nav ---------- */
.nav {
  position: fixed;
  left: max(14px, var(--safe-l));
  right: max(14px, var(--safe-r));
  bottom: max(14px, var(--safe-bot));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px;
  gap: 2px;
  background: color-mix(in oklab, var(--surface) 85%, transparent);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
}

.nav a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 2px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-radius: 999px;
  transition: color .2s var(--ease-out), background .25s var(--ease-out);
}
.nav a .ic {
  font-size: 18px;
  line-height: 1;
  filter: grayscale(0.2);
  transition: transform .25s var(--ease-out), filter .2s var(--ease-out);
}
.nav a:hover { color: var(--ink); }
.nav a:hover .ic { transform: translateY(-1px); }
.nav a.aktiv {
  color: var(--accent-ink);
  background: var(--ink);
}
.nav a.aktiv .ic { filter: grayscale(0.3) brightness(1.2); }

@media (prefers-color-scheme: dark) {
  .nav a.aktiv { background: var(--ink); color: var(--paper); }
}

/* ---------- Content wrapper ---------- */
.inhalt {
  padding: 8px 0 40px;
  animation: seiteEin .4s var(--ease-out) both;
}

@keyframes seiteEin {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Abschnittstitel (Editorial labels) ---------- */
.abschnitt-titel {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-muted);
  padding: 24px 22px 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}
.abschnitt-titel::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  margin-left: 4px;
}

/* ---------- Aufgabenliste ---------- */
.aufgabe {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line-soft);
  transition: background .2s var(--ease-out);
  position: relative;
  cursor: pointer;
  animation: aufgabeEin .4s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}
.aufgabe:hover { background: color-mix(in oklab, var(--surface-2) 50%, transparent); }
.aufgabe:active { background: var(--surface-2); }

@keyframes aufgabeEin {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: none; }
}

/* Stagger via nth-child (animation works without JS changes) */
.aufgabe:nth-child(1) { --i: 1; }
.aufgabe:nth-child(2) { --i: 2; }
.aufgabe:nth-child(3) { --i: 3; }
.aufgabe:nth-child(4) { --i: 4; }
.aufgabe:nth-child(5) { --i: 5; }
.aufgabe:nth-child(6) { --i: 6; }
.aufgabe:nth-child(7) { --i: 7; }
.aufgabe:nth-child(8) { --i: 8; }
.aufgabe:nth-child(9) { --i: 9; }
.aufgabe:nth-child(10) { --i: 10; }
.aufgabe:nth-child(n+11) { --i: 11; }

/* The check circle — a hand-drawn feel */
.haken {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-faint);
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 12px;
  font-weight: 700;
  background: transparent;
  transition: all .25s var(--ease-out);
  position: relative;
}
.haken::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform .25s var(--ease-out);
}
.aufgabe:hover .haken { border-color: var(--accent); }
.aufgabe:hover .haken::before { transform: scale(0.35); }

.aufgabe.erledigt .haken {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 14%, transparent);
}
.aufgabe.erledigt .haken::before { transform: scale(0); }
.aufgabe.erledigt .titel {
  color: var(--ink-faint);
  text-decoration: line-through;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
}
.aufgabe.prio-hoch .haken { border-color: var(--accent); border-width: 2px; }
.aufgabe.prio-hoch .titel::before {
  content: "!";
  color: var(--accent);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  margin-right: 6px;
  font-size: 1em;
}

.aufgabe-body { flex: 1; min-width: 0; }
.titel {
  font-family: var(--sans);
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.38;
  word-break: break-word;
  letter-spacing: -0.005em;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  align-items: center;
  letter-spacing: 0.01em;
}
.meta > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.meta .chip {
  background: var(--surface-2);
  color: var(--ink-muted);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: var(--mono);
  border: 1px solid var(--line);
}
.meta .faellig-heute {
  color: var(--gold);
  font-weight: 600;
}
.meta .faellig-ueberfaellig {
  color: var(--warn);
  font-weight: 700;
}
.meta .faellig-ueberfaellig::before {
  content: "";
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--warn);
  display: inline-block;
  margin-right: 2px;
  animation: puls 1.8s var(--ease-in-out) infinite;
}

@keyframes puls {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

.tag {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid var(--accent-line);
}
.tag::before { content: "#"; opacity: 0.55; margin-right: 1px; }

/* ---------- Leer-Zustand (empty state) ---------- */
.leer {
  padding: 72px 28px 40px;
  text-align: center;
  color: var(--ink-muted);
}
.leer .ic {
  font-size: 44px;
  margin-bottom: 18px;
  opacity: 0.8;
  filter: saturate(0.7);
  display: inline-block;
  animation: schweben 4s var(--ease-in-out) infinite;
}
@keyframes schweben {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.leer .t {
  font-family: var(--serif);
  font-variation-settings: "opsz" 144, "SOFT" 40;
  font-size: 28px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 8px;
}
.leer .u {
  font-size: 14px;
  color: var(--ink-muted);
  max-width: 32ch;
  margin: 0 auto;
  line-height: 1.5;
}

/* ---------- Schnell-Add (FAB) ---------- */
.schnell-add {
  position: fixed;
  bottom: calc(var(--nav-h) + 18px);
  right: max(22px, var(--safe-r));
  z-index: 25;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 30px;
  font-weight: 200;
  line-height: 1;
  padding-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in oklab, var(--ink) 30%, transparent);
  transition: transform .2s var(--ease-out), background .2s var(--ease-out);
  font-family: var(--serif);
}
.schnell-add:hover { background: var(--accent); color: var(--accent-ink); transform: translateY(-1px); }
.schnell-add:active { transform: scale(0.94); }

@media (prefers-color-scheme: dark) {
  .schnell-add { background: var(--ink); color: var(--paper-deep); }
}

/* ---------- Listen-Zeile (Bereich/Projekt/Tag rows) ---------- */
.liste-zeile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--sans);
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  transition: background .2s var(--ease-out), padding-left .2s var(--ease-out);
  animation: aufgabeEin .35s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 20ms);
}
.liste-zeile:hover {
  background: color-mix(in oklab, var(--surface-2) 50%, transparent);
  padding-left: 26px;
}
.liste-zeile:active { background: var(--surface-2); }
.liste-zeile .zaehler {
  margin-left: auto;
  font-family: var(--mono);
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
}
.liste-zeile .punkt {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
  flex-shrink: 0;
}

/* ---------- Dialog / Bottom-Sheet ---------- */
dialog {
  border: none;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-4) var(--radius-4) 0 0;
  padding: 22px 22px calc(var(--safe-bot) + 22px);
  width: 100%;
  max-width: 540px;
  margin: auto auto 0;
  box-shadow: var(--shadow-lg);
  border-top: 1px solid var(--line);
}
dialog[open] {
  animation: dlgEin .3s var(--ease-out);
}
dialog::backdrop {
  background: color-mix(in oklab, var(--ink) 55%, transparent);
  backdrop-filter: blur(6px);
  animation: dlgBgEin .25s var(--ease-out);
}
@keyframes dlgEin {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: none; }
}
@keyframes dlgBgEin {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (min-width: 640px) {
  dialog {
    margin: auto;
    border-radius: var(--radius-3);
    padding: 28px;
    border: 1px solid var(--line);
  }
  dialog[open] { animation: dlgEinDesktop .3s var(--ease-out); }
  @keyframes dlgEinDesktop {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: none; }
  }
}

.dlg-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.dlg-kopf h2 {
  font-family: var(--serif);
  font-variation-settings: "opsz" 144, "SOFT" 30;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.dlg-zu {
  background: var(--surface-2);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  transition: all .2s var(--ease-out);
  flex-shrink: 0;
}
.dlg-zu:hover { background: var(--warn-soft); color: var(--warn); }

.feld { margin-bottom: 14px; }
.feld label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.feld-reihe {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ---------- Buttons ---------- */
.btn-leiste {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.btn {
  flex: 1;
  padding: 13px 18px;
  border-radius: var(--radius-2);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--surface-2);
  color: var(--ink);
  text-align: center;
  border: 1px solid var(--line);
  transition: all .18s var(--ease-out);
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover { background: var(--surface-3); border-color: var(--ink-ghost); }
.btn:active { transform: scale(0.985); }

.btn.primaer {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn.primaer:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.btn.danger {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in oklab, var(--warn) 30%, var(--line));
}
.btn.danger:hover {
  background: var(--warn);
  color: var(--paper);
  border-color: var(--warn);
}

/* ---------- Chip-Wahl ---------- */
.chip-wahl {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-wahl button {
  padding: 8px 14px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  transition: all .15s var(--ease-out);
  font-family: var(--sans);
}
.chip-wahl button:hover { background: var(--surface-3); color: var(--ink); }
.chip-wahl button.an {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.chip-wahl button.tag-chip.an {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.chip-wahl button.tag-chip:not([data-neu])::before { content: "#"; opacity: 0.5; margin-right: 2px; }
.chip-wahl button[data-neu] {
  font-style: italic;
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink-muted);
  padding: 5px 14px 7px;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 32px) 24px calc(var(--safe-bot) + 32px);
  background: linear-gradient(160deg, var(--paper) 0%, var(--paper-deep) 100%);
  position: relative;
}
.login-karte {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  padding: 44px 32px 32px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  animation: loginEin .7s var(--ease-out);
}
.login-karte::before {
  content: "";
  position: absolute;
  top: -50%; right: -30%;
  width: 420px; height: 420px;
  background: radial-gradient(circle, color-mix(in oklab, var(--accent) 12%, transparent) 0%, transparent 60%);
  pointer-events: none;
}
@keyframes loginEin {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.login-karte h1 {
  font-family: var(--serif);
  font-variation-settings: "opsz" 144, "SOFT" 20;
  font-size: 68px;
  font-weight: 400;
  font-style: italic;
  text-align: center;
  color: var(--ink);
  margin-bottom: 2px;
  line-height: 0.95;
  letter-spacing: -0.04em;
  position: relative;
}
.login-karte h1::after {
  content: "est. MMXXVI";
  display: block;
  font-family: var(--sans);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 14px;
}
.login-karte .unter {
  text-align: center;
  color: var(--ink-muted);
  margin: 14px 0 28px;
  font-size: 14px;
  font-style: italic;
  font-family: var(--serif);
  font-variation-settings: "opsz" 32, "SOFT" 60;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
  z-index: 100;
  max-width: 85vw;
}
.toast.an {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Detail-Ansicht ---------- */
.detail-notizen {
  min-height: 140px;
  font-family: var(--serif);
  font-variation-settings: "opsz" 14;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--surface);
  border-radius: var(--radius-2);
}

.detail-abschnitt {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.detail-abschnitt h3 {
  font-family: var(--sans);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink-muted);
  margin-bottom: 14px;
  font-weight: 700;
}

/* Inline-Titel-Input in der Detail-Ansicht: groß, Fraunces-Italic */
#det-titel {
  font-family: var(--serif) !important;
  font-variation-settings: "opsz" 144, "SOFT" 40;
  font-size: 26px !important;
  font-weight: 500 !important;
  font-style: italic;
  padding: 10px 0 !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 1px solid var(--line-soft) !important;
  border-radius: 0 !important;
  color: var(--ink);
  letter-spacing: -0.015em;
}
#det-titel:focus { box-shadow: none !important; border-bottom-color: var(--accent) !important; background: transparent !important; }

.sub-liste .aufgabe {
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.sub-liste .aufgabe:last-child { border-bottom: none; }
.sub-liste .titel { font-size: 14.5px; }

/* ---------- Anhänge ---------- */
.anhang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.anhang-kachel {
  aspect-ratio: 1/1;
  border-radius: var(--radius-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  font-size: 22px;
  transition: transform .2s var(--ease-out);
}
.anhang-kachel:hover { transform: scale(1.03); border-color: var(--accent-line); }
.anhang-kachel img { width: 100%; height: 100%; object-fit: cover; }
.anhang-kachel a { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; color: inherit; }
.anhang-loeschen {
  position: absolute;
  top: 5px; right: 5px;
  background: color-mix(in oklab, var(--ink) 80%, transparent);
  color: var(--paper);
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  transition: background .15s var(--ease-out);
}
.anhang-loeschen:hover { background: var(--warn); }

/* ---------- Spinner (editorial dot-pair) ---------- */
.spinner {
  position: relative;
  width: 48px;
  height: 12px;
  margin: 80px auto;
  border: none;
  background: none;
  animation: none;
  display: block;
}
.spinner::before,
.spinner::after {
  content: "";
  position: absolute;
  top: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  animation: zweipunkt 1.2s var(--ease-in-out) infinite;
}
.spinner::before { left: 0; }
.spinner::after  { right: 0; animation-delay: -0.6s; }

@keyframes zweipunkt {
  0%, 100% { transform: scale(0.4); opacity: 0.35; }
  50%       { transform: scale(1);   opacity: 1; }
}

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  #app {
    max-width: 760px;
    margin: 0 auto;
    padding-left: 8px;
    padding-right: 8px;
  }
  .kopf { padding-left: 28px; padding-right: 28px; }
  .aufgabe, .liste-zeile, .abschnitt-titel { padding-left: 28px; padding-right: 28px; }
  .nav { max-width: 560px; margin: 0 auto; }
  .schnell-add { right: max(32px, calc(50% - 380px)); }
}

/* ---------- Accessibility / Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Focus-visible ring ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, a:focus-visible { outline-offset: 3px; }

/* ---------- Print (why not, it's editorial after all) ---------- */
@media print {
  .nav, .schnell-add, .toast, .kopf-btn { display: none !important; }
  body::before, body::after { display: none; }
  body { background: white; color: black; }
}
