/* abendbuch
   Idee: Tagsüber schreibt man mit Bleistift, abends mit Tinte.
   Notizen sind grafitgrau in Alegreya Sans, die Tagesseite tintenblau in Alegreya.
   Der rosa Heftrand aus dem Schulheft trennt Uhrzeit und Notiz. */

:root {
  --paper: #eceee9;
  --paper-2: #e2e5df;
  --sheet: #f8f9f6;
  --ink: #1c2a4f;
  --ink-soft: #46527a;
  --pencil: #41474f;
  --graphite: #5d636b;
  --graphite-soft: #8a9097;
  --rule: #cdd2ca;
  --margin: #dba3a9;
  --royal: #2e4bc6;
  --royal-ink: #ffffff;
  --marker: #f1e15b;
  --danger: #a3343a;
  --line: #c5d3ea;

  --serif: 'Alegreya', 'Iowan Old Style', Georgia, serif;
  --sans: 'Alegreya Sans', -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 2rem;
  --step-4: 2.5rem;
  --step-date: clamp(2.9rem, 10vw, 4.4rem);

  --nav-h: 4.25rem;
  color-scheme: light;
}

:root[data-theme='dunkel'] {
  --paper: #131a2c;
  --paper-2: #1b2339;
  --sheet: #182035;
  --ink: #e0e4ee;
  --ink-soft: #b4bdd2;
  --pencil: #c3c9d6;
  --graphite: #98a1b6;
  --graphite-soft: #6c7590;
  --rule: #2b3552;
  --margin: #7b4b5a;
  --royal: #93a6ff;
  --royal-ink: #101731;
  --marker: rgba(241, 225, 91, 0.38);
  --danger: #ff8f8f;
  --line: #27345a;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    --paper: #131a2c;
    --paper-2: #1b2339;
    --sheet: #182035;
    --ink: #e0e4ee;
    --ink-soft: #b4bdd2;
    --pencil: #c3c9d6;
    --graphite: #98a1b6;
    --graphite-soft: #6c7590;
    --rule: #2b3552;
    --margin: #7b4b5a;
    --royal: #93a6ff;
    --royal-ink: #101731;
    --marker: rgba(241, 225, 91, 0.38);
    --danger: #ff8f8f;
    --line: #27345a;
    color-scheme: dark;
  }
}

/* --- Grundlagen ------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3,
p,
ol,
ul,
figure {
  margin: 0;
}

a {
  color: var(--royal);
}

img {
  max-width: 100%;
}

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

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

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 50;
  transform: translateY(-200%);
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
}

.skip:focus {
  transform: none;
}

mark {
  background: var(--marker);
  color: inherit;
  border-radius: 2px;
  padding: 0 0.08em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* --- Aufbau ------------------------------------------------------------------------ */

.app {
  min-height: 100dvh;
}

.main {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem calc(var(--nav-h) + 2.5rem + env(safe-area-inset-bottom));
  outline: none;
}

.nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-mark {
  display: none;
}

.nav-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  height: var(--nav-h);
}

.nav-logout {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.nav-link {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  color: var(--graphite);
  text-decoration: none;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.nav-link .icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.nav-link.is-active {
  color: var(--ink);
}

.nav-link.is-active .icon {
  color: var(--royal);
}

@media (min-width: 900px) {
  .app:not(.app-auth) {
    display: grid;
    grid-template-columns: 13.5rem 1fr;
  }

  .nav {
    position: sticky;
    top: 0;
    inset: auto;
    height: 100dvh;
    padding: 2.25rem 1.25rem;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: 0;
    /* Der Heftrand */
    border-right: 1.5px solid var(--margin);
  }

  .nav-mark {
    display: block;
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.75rem;
    color: var(--ink);
    text-decoration: none;
    margin: 0 0 2.25rem 0.5rem;
  }

  .nav {
    display: flex;
    flex-direction: column;
  }

  .nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    height: auto;
    flex: 1;
  }

  .nav-logout-item {
    margin-top: auto;
  }

  .nav-link {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.55rem 0.6rem;
    border-radius: 8px;
    font-size: 1.0625rem;
  }

  .nav-link:hover {
    background: var(--paper-2);
    color: var(--ink);
  }

  .nav-link .icon svg {
    width: 1.3rem;
    height: 1.3rem;
  }

  .main {
    width: auto;
    min-width: 0;
    padding: 3.5rem 3.5rem 5rem;
    margin: 0;
    max-width: 48rem;
  }

  .main:has(.write) {
    max-width: 76rem;
  }
}

@media (min-width: 1200px) {
  .main {
    margin-left: clamp(0rem, 6vw, 6rem);
  }
}

/* --- Bausteine ----------------------------------------------------------------------- */

.icon {
  display: inline-flex;
  flex: none;
}

.icon svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}

.icon-xs svg {
  width: 0.85rem;
  height: 0.85rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.55rem 1.15rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: var(--royal);
  color: var(--royal-ink);
}

.btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--royal) 86%, var(--ink));
}

.btn-ink {
  background: var(--ink);
  color: var(--paper);
}

.btn-ink:hover {
  background: color-mix(in srgb, var(--ink) 88%, var(--royal));
}

.btn-quiet {
  border-color: var(--rule);
  color: var(--ink);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--paper-2);
}

.btn-danger-quiet {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.btn-danger-quiet:hover {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.btn-sm {
  min-height: 2.25rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.9375rem;
}

.btn-wide {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.4rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--graphite);
  cursor: pointer;
}

.icon-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.icon-btn:hover {
  background: var(--paper-2);
  color: var(--ink);
}

.input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--sheet);
  font-size: 1.0625rem;
}

.input:focus {
  outline: none;
  border-color: var(--royal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--royal) 22%, transparent);
}

.input-narrow {
  width: auto;
  min-width: 9rem;
}

textarea.input {
  line-height: 1.5;
  resize: vertical;
}

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--graphite);
}

.check {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
}

.check input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--royal);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stack-tight {
  gap: 0.6rem;
  max-width: 24rem;
}

.stack-tight .btn {
  align-self: flex-start;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
  margin-top: 0.75rem;
}

.inline-form .input {
  flex: 1 1 12rem;
  width: auto;
}

.inline-form > div:empty {
  display: none;
}

.inline-form > div {
  flex-basis: 100%;
}

.hint {
  font-size: 0.9375rem;
  color: var(--graphite);
}

.form-error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, transparent);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9375rem;
}

.view-title,
.auth-title,
.day-view-title,
.set-title,
.entry-title,
.write-title {
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}

.view-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-4);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--graphite);
  margin: 0 0 0.75rem;
}

.empty {
  padding: 2rem 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  color: var(--graphite);
  max-width: 34rem;
}

.empty-inline {
  color: var(--graphite);
  font-style: italic;
  font-family: var(--serif);
  font-size: var(--step-1);
  margin: 1.5rem 0;
}

.loading {
  padding: 3rem 0;
}

.loading-line {
  display: block;
  height: 2px;
  width: 4rem;
  background: var(--ink-soft);
  border-radius: 2px;
  animation: stroke 1.1s ease-in-out infinite alternate;
}

@keyframes stroke {
  from {
    width: 1rem;
    opacity: 0.4;
  }
  to {
    width: 6rem;
    opacity: 1;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom));
  z-index: 60;
  transform: translate(-50%, 1rem);
  opacity: 0;
  pointer-events: none;
  max-width: calc(100vw - 2rem);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  background: var(--danger);
  color: #fff;
}

@media (min-width: 900px) {
  .toast {
    bottom: 2rem;
  }
}

/* --- Chips & Tags ---------------------------------------------------------------------- */

.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0;
}

.tag-field {
  flex: 1 1 8rem;
  min-width: 6rem;
  border: 0;
  background: transparent;
  padding: 0.35rem 0;
  font-size: 1rem;
  color: var(--ink);
}

.tag-field:focus {
  outline: none;
}

.tag-field::placeholder {
  color: var(--graphite-soft);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.1rem 0.15rem 0.1rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--royal) 12%, transparent);
  color: var(--royal);
  font-size: 0.9375rem;
  font-weight: 500;
}

.chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.chip-x:hover {
  background: color-mix(in srgb, var(--royal) 18%, transparent);
}

/* --- Heute ----------------------------------------------------------------------------- */

.day-head {
  margin-bottom: 1.25rem;
}

.day-title {
  display: flex;
  flex-direction: column;
  font-family: var(--serif);
  font-weight: 500;
}

.day-weekday {
  font-style: italic;
  font-size: var(--step-2);
  color: var(--graphite);
  line-height: 1.2;
}

.day-date {
  font-size: var(--step-date);
  line-height: 0.98;
  letter-spacing: -0.02em;
}

.prompt {
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--step-1);
  color: var(--graphite);
  max-width: 34ch;
  margin-bottom: 1.5rem;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.45rem 0.45rem 0.45rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--sheet);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: var(--royal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--royal) 18%, transparent);
}

.composer-input {
  flex: 1;
  min-height: 2.6rem;
  max-height: 40vh;
  padding: 0.55rem 0;
  border: 0;
  background: transparent;
  resize: none;
  font-size: 1.0625rem;
  line-height: 1.45;
  color: var(--pencil);
}

.composer-input:focus {
  outline: none;
}

.composer-input::placeholder {
  color: var(--graphite-soft);
}

.composer-send {
  flex: none;
  min-height: 2.5rem;
  padding: 0.4rem 0.95rem;
}

/* Notizen im Heft: Uhrzeit | Heftrand | Text */
.notes {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
}

.heft .note {
  display: grid;
  grid-template-columns: 3.4rem 1fr auto;
  align-items: start;
}

.note-time {
  padding: 0.5rem 0.75rem 0.5rem 0;
  text-align: right;
  font-size: var(--step--1);
  color: var(--graphite);
  line-height: 1.55rem;
}

.note-text {
  padding: 0.45rem 0 0.45rem 0.9rem;
  border-left: 1.5px solid var(--margin);
  color: var(--pencil);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 100%;
}

.note-actions {
  display: flex;
  padding-left: 0.25rem;
  opacity: 0.55;
}

.note:hover .note-actions,
.note:focus-within .note-actions {
  opacity: 1;
}

@media (hover: hover) {
  .note-actions {
    opacity: 0;
  }
}

.note-del.is-armed {
  color: var(--danger);
  opacity: 1;
}

.note-del-text {
  font-size: 0.875rem;
}

.note.is-new {
  animation: write-in 0.35s ease-out;
}

@keyframes write-in {
  from {
    opacity: 0;
    clip-path: inset(0 100% 0 0);
  }
  to {
    opacity: 1;
    clip-path: inset(0 0 0 0);
  }
}

.notes-compact .note {
  grid-template-columns: 3rem 1fr auto;
}

.notes-compact .note-text {
  font-size: 0.9875rem;
}

/* Werte als Linealskala */
.values {
  margin-top: 2rem;
  max-width: 32rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.scale {
  display: grid;
  grid-template-columns: 6.5rem 1fr 1.75rem;
  align-items: center;
  gap: 0.75rem;
}

.scale-label {
  font-size: 0.9875rem;
  color: var(--graphite);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scale-ticks {
  display: flex;
  height: 2.6rem;
}

.scale-tick {
  position: relative;
  flex: 1;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}

button.scale-tick {
  cursor: pointer;
}

.scale-tick::after {
  content: '';
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 0.7rem;
  height: 0.45rem;
  border-radius: 2px;
  background: var(--rule);
  transition: height 0.12s, background-color 0.12s;
}

.scale-tick:nth-child(5)::after,
.scale-tick:nth-child(10)::after {
  height: 0.75rem;
}

@media (hover: hover) {
  button.scale-tick:hover::after {
    background: var(--graphite-soft);
  }
}

.scale-tick.is-on::after {
  background: var(--ink);
}

.scale-tick.is-current::after {
  background: var(--royal);
  height: 1.15rem;
}

.scale-num {
  font-family: var(--serif);
  font-size: var(--step-1);
  text-align: right;
}

.scale.is-empty .scale-num {
  color: var(--graphite-soft);
}

.values-read .scale-ticks {
  height: 2rem;
}

.values-read .scale-tick::after {
  bottom: 0.5rem;
}

/* Fotos */
.photos-wrap {
  margin-top: 1.75rem;
}

.photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.photo-tile,
.photo-add {
  width: 5.75rem;
  height: 5.75rem;
  border-radius: 10px;
  overflow: hidden;
  flex: none;
}

.photo-tile {
  padding: 0;
  border: 0;
  background: var(--paper-2);
  cursor: zoom-in;
  display: grid;
  place-items: center;
}

.photo-tile .photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-tile.is-cover {
  outline: 2.5px solid var(--royal);
  outline-offset: 2px;
}

.photo-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  border: 1.5px dashed var(--rule);
  color: var(--graphite);
  font-size: 0.8125rem;
  text-align: center;
  line-height: 1.15;
  padding: 0.4rem;
  cursor: pointer;
}

.photo-add:hover {
  border-color: var(--graphite-soft);
  color: var(--ink);
}

input[type='file']:focus-visible + .photo-add,
.photo-strip:has(input[type='file']:focus-visible) .photo-add {
  outline: 2px solid var(--royal);
  outline-offset: 2px;
}

.lightbox {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: min(94vw, 64rem);
  max-height: 94vh;
}

.lightbox::backdrop {
  background: rgba(15, 21, 38, 0.82);
}

.lightbox-img {
  display: block;
  max-height: 80vh;
  margin: 0 auto;
  border-radius: 6px;
}

.lightbox-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.75rem;
}

.lightbox-bar .btn-quiet,
.lightbox-bar .icon-btn {
  background: var(--paper);
}

/* Die Seite */
.page-cta {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.cta-hint {
  color: var(--graphite);
  font-size: 0.9375rem;
}

.is-evening .page-cta {
  margin: 0 0 2.5rem;
}

.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.sheet-link {
  display: block;
  width: 100%;
  color: inherit;
  text-decoration: none;
}

.sheet-preview {
  padding: 1.25rem 1.5rem;
  max-height: 13rem;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent);
  mask-image: linear-gradient(to bottom, #000 65%, transparent);
}

.sheet-link:hover .sheet-preview {
  border-color: var(--graphite-soft);
}

.sheet-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-2);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

/* Fließtext der Seite: Tinte */
.prose {
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.7;
  max-width: 64ch;
  color: var(--ink);
  font-variant-numeric: proportional-nums oldstyle-nums;
}

.prose > * + * {
  margin-top: 0.85em;
}

.prose h2 {
  font-weight: 500;
  font-size: var(--step-2);
  line-height: 1.25;
  margin-top: 1.4em;
}

.prose h3,
.prose h4 {
  font-weight: 700;
  font-size: var(--step-1);
  margin-top: 1.2em;
}

.prose ul,
.prose ol {
  padding-left: 1.3em;
}

.prose li + li {
  margin-top: 0.25em;
}

.prose blockquote {
  margin-left: 0;
  padding-left: 1em;
  border-left: 1.5px solid var(--margin);
  font-style: italic;
  color: var(--ink-soft);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 1.6em 0;
}

.prose-preview {
  font-size: 1.0625rem;
  line-height: 1.6;
}

/* --- Schreiben ------------------------------------------------------------------------- */

.write-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: calc(-1 * max(1.5rem, env(safe-area-inset-top))) -1.25rem 1rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 1.25rem 0.75rem;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--graphite);
  text-decoration: none;
  min-height: 2.25rem;
  margin-left: -0.35rem;
}

.back-link:hover {
  color: var(--ink);
}

.save-status {
  font-size: 0.875rem;
  color: var(--graphite);
  white-space: nowrap;
}

.save-status.is-error {
  color: var(--danger);
}

.write-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.write-aside {
  order: -1;
}

.write-sheet {
  padding: 1.25rem 1.25rem 2rem;
  border-radius: 6px;
  min-height: 70vh;
  transition: border-color 0.15s;
}

.write-sheet:focus-within {
  border-color: var(--graphite-soft);
}

.write-title {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-3);
  line-height: 1.2;
  color: var(--ink);
}

.write-title:focus {
  outline: none;
}

.write-title::placeholder,
.write-body::placeholder {
  color: var(--graphite-soft);
  font-style: italic;
}

.write-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.word-count {
  margin-left: auto;
  font-size: 0.875rem;
  color: var(--graphite);
}

.write-body {
  display: block;
  width: 100%;
  min-height: 50vh;
  border: 0;
  background: transparent;
  resize: none;
  padding: 0;
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.75;
  color: var(--ink);
  font-variant-numeric: proportional-nums oldstyle-nums;
}

.write-body:focus {
  outline: none;
}

.draft {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--royal);
  border-radius: 0 6px 6px 0;
  background: var(--paper-2);
}

.draft-head {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--graphite);
  margin-bottom: 0.5rem;
}

.draft-text {
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  white-space: pre-wrap;
  margin-bottom: 0.9rem;
}

.aside-block {
  padding: 0.25rem 0;
}

.aside-block + .aside-block {
  margin-top: 1rem;
}

.aside-block summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--graphite);
  padding: 0.4rem 0;
  list-style-position: inside;
}

.aside-title {
  font-weight: 700;
  color: var(--graphite);
  margin-bottom: 0.5rem;
}

.aside-empty {
  color: var(--graphite);
  font-size: 0.9375rem;
}

.aside-cover {
  display: none;
}

.cover-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.cover-pick button {
  width: 4rem;
  height: 4rem;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--paper-2);
}

.cover-pick img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-pick button[aria-checked='true'] {
  outline: 2.5px solid var(--royal);
  outline-offset: 2px;
}

@media (min-width: 960px) {
  .write-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 17.5rem;
    gap: 2.5rem;
    align-items: start;
  }

  .aside-cover {
    display: block;
  }

  .write-aside {
    order: 0;
    position: sticky;
    top: 4.5rem;
    max-height: calc(100dvh - 6rem);
    overflow: auto;
  }

  .write-sheet {
    padding: 2.5rem 3rem 3rem;
  }

  .write-bar {
    margin: -1rem 0 1rem;
    padding: 1rem 0;
  }
}

/* --- Journal --------------------------------------------------------------------------- */

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: -0.5rem 0 1rem;
}

.chip-link {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  color: var(--graphite);
  text-decoration: none;
  font-size: 0.9375rem;
}

.chip-link:hover {
  color: var(--ink);
  border-color: var(--graphite-soft);
}

.chip-link.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.month {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: var(--step-2);
  color: var(--graphite);
  margin: 2.25rem 0 0.25rem;
}

.entries {
  list-style: none;
  padding: 0;
}

.entries li + li {
  border-top: 1px solid var(--rule);
}

.entry {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr) auto;
  gap: 0.9rem;
  padding: 1rem 0;
  color: inherit;
  text-decoration: none;
}

.entry-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 0.1rem;
}

.entry-day {
  font-family: var(--serif);
  font-size: var(--step-3);
  line-height: 1;
  color: var(--ink);
}

.entry-wd {
  font-size: 0.8125rem;
  color: var(--graphite);
  margin-top: 0.2rem;
}

.entry-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-1);
  line-height: 1.25;
  margin-bottom: 0.2rem;
}

.entry-title.is-quiet {
  font-weight: 400;
  font-style: italic;
  color: var(--graphite);
}

@media (hover: hover) {
  .entry:hover .entry-title,
  .result:hover .result-title {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
  }
}

.entry-excerpt {
  color: var(--pencil);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  margin-top: 0.4rem;
  font-size: 0.875rem;
  color: var(--graphite);
}

.entry-meta:empty {
  display: none;
}

.entry-tag {
  color: var(--royal);
  text-decoration: none;
  font-weight: 500;
}

.mini-scale {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.7rem;
}

.mini-scale i {
  width: 4px;
  height: 0.45rem;
  border-radius: 1px;
  background: var(--rule);
}

.mini-scale i.is-on {
  background: var(--ink-soft);
}

.mini-scale i:nth-child(5),
.mini-scale i:nth-child(10) {
  height: 0.7rem;
}

.entry-thumb .photo {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}

.journal-view > .btn-wide {
  margin-top: 1.5rem;
}

/* --- Tag ------------------------------------------------------------------------------- */

.cover {
  margin: -0.25rem 0 1.5rem;
}

.cover-img {
  display: block;
  width: 100%;
  max-height: 52vh;
  object-fit: cover;
  border-radius: 6px;
}

.day-view-head {
  margin-bottom: 1.5rem;
}

.day-view-date {
  color: var(--graphite);
  margin-bottom: 0.25rem;
}

.day-view-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-4);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.day-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.6rem;
}

.day-view .values {
  margin: 0 0 2rem;
}

.day-view .photos-wrap {
  margin-top: 2rem;
}

.day-notes {
  margin-top: 2.5rem;
}

.day-notes .notes {
  margin-top: 0;
}

.day-actions {
  margin-top: 2.5rem;
}

.day-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.day-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--graphite);
  text-decoration: none;
  min-height: 2.5rem;
}

.day-nav-link:hover {
  color: var(--ink);
}

/* --- Suche ----------------------------------------------------------------------------- */

.search-input {
  width: 100%;
  padding: 0.4rem 0 0.5rem;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: var(--step-2);
  -webkit-appearance: none;
  appearance: none;
}

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-input:focus {
  outline: none;
  border-bottom-color: var(--royal);
}

.search-summary {
  margin: 0.75rem 0 1.25rem;
  color: var(--graphite);
  font-size: 0.9375rem;
}

.results {
  list-style: none;
  padding: 0;
}

.results li + li {
  border-top: 1px solid var(--rule);
}

.result {
  display: block;
  padding: 1rem 0;
  color: inherit;
  text-decoration: none;
}

.result-date {
  font-size: 0.875rem;
  color: var(--graphite);
}

.result-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-1);
  margin-top: 0.15rem;
}

.result-snippet {
  margin-top: 0.25rem;
  font-family: var(--serif);
  color: var(--ink-soft);
}

.result-snippet.is-note {
  font-family: var(--sans);
  color: var(--pencil);
}

/* --- Rückblick ------------------------------------------------------------------------- */

.stats-prose {
  font-family: var(--serif);
  font-size: var(--step-2);
  line-height: 1.35;
  max-width: 32ch;
}

.stats-prose p + p {
  margin-top: 0.5rem;
}

.stats-prose p:first-child {
  color: var(--ink);
}

.stats-prose p:not(:first-child) {
  color: var(--ink-soft);
  font-size: var(--step-1);
}

.stats-block {
  margin-top: 2.75rem;
}

.week-text {
  margin-bottom: 0.6rem;
}

.week-boxes {
  display: flex;
  gap: 0.35rem;
}

.week-box {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--graphite);
}

.week-box.is-done {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.week-box.is-today {
  outline: 2px solid var(--royal);
  outline-offset: 2px;
}

.week-box.is-future {
  opacity: 0.45;
}

.heat-wrap {
  --cell: clamp(9px, 2.55vw, 15px);
  --gap: 3px;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.heat,
.heat-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cell);
  gap: var(--gap);
}

.heat {
  grid-template-rows: repeat(7, var(--cell));
}

.heat-months {
  height: 1.2rem;
  font-size: 0.75rem;
  color: var(--graphite);
  white-space: nowrap;
}

.heat-cell {
  display: inline-block;
  width: var(--cell);
  height: var(--cell);
  border-radius: 3px;
  background: var(--paper-2);
}

.heat-cell.is-link {
  cursor: pointer;
}

.heat-cell.lv-n {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--graphite-soft);
}

.heat-cell.lv-1 {
  background: color-mix(in srgb, var(--royal) 24%, var(--paper));
}

.heat-cell.lv-2 {
  background: color-mix(in srgb, var(--royal) 50%, var(--paper));
}

.heat-cell.lv-3 {
  background: color-mix(in srgb, var(--royal) 55%, var(--ink));
}

.heat-cell.lv-4 {
  background: var(--ink);
}

.heat-legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--graphite);
}

.heat-legend .lv-1 {
  margin-left: 0.75rem;
}

.value-charts {
  display: grid;
  gap: 2rem;
}

@media (min-width: 640px) {
  .value-charts {
    grid-template-columns: 1fr 1fr;
  }
}

.value-chart figcaption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
}

.vc-label {
  font-weight: 700;
}

.vc-avg {
  font-size: 0.875rem;
  color: var(--graphite);
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid {
  stroke: var(--rule);
  stroke-width: 1;
}

.chart-avg {
  stroke: var(--royal);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-dot {
  fill: var(--ink);
}

.wd-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 0.75rem;
}

.wd {
  display: grid;
  grid-template-rows: 2.5rem auto;
  align-items: end;
  justify-items: stretch;
}

.wd-bar {
  display: block;
  height: calc(var(--v, 0) * 0.25rem);
  background: color-mix(in srgb, var(--ink) 60%, var(--paper));
  border-radius: 2px 2px 0 0;
}

.wd-label {
  font-size: 0.75rem;
  color: var(--graphite);
  text-align: center;
  padding-top: 0.2rem;
  border-top: 1px solid var(--rule);
}

.corr {
  list-style: none;
  padding: 0;
  font-family: var(--serif);
  font-size: var(--step-1);
  line-height: 1.4;
  max-width: 40ch;
}

.corr li + li {
  margin-top: 0.6rem;
}

.corr-r {
  display: block;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--graphite);
}

.stats-two {
  display: grid;
  gap: 2rem;
}

@media (min-width: 640px) {
  .stats-two {
    grid-template-columns: 1fr 1fr;
  }
}

.day-links {
  list-style: none;
  padding: 0;
}

.day-links a {
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  column-gap: 0.5rem;
  padding: 0.4rem 0;
  color: inherit;
  text-decoration: none;
}

@media (hover: hover) {
  .day-links a:hover span:nth-child(2) {
    text-decoration: underline;
  }
}

.day-links-v {
  font-family: var(--serif);
  font-size: var(--step-1);
  line-height: 1.2;
  grid-row: span 2;
}

.day-links-d {
  grid-column: 2;
  font-size: 0.8125rem;
  color: var(--graphite);
}

/* --- Einstellungen --------------------------------------------------------------------- */

.set-section {
  padding: 1.75rem 0;
  border-top: 1px solid var(--rule);
}

.settings-view .view-title + .set-section {
  border-top: 0;
  padding-top: 0;
}

.set-section > * + * {
  margin-top: 0.85rem;
}

.set-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-2);
}

.set-intro {
  color: var(--graphite);
  max-width: 60ch;
}

.set-item {
  padding-top: 1.25rem;
}

.set-item > * + * {
  margin-top: 0.5rem;
}

.set-sub {
  font-size: 1.0625rem;
  font-weight: 700;
}

.set-details summary {
  cursor: pointer;
  color: var(--graphite);
  width: fit-content;
}

.value-defs {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 26rem;
}

.value-def {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.segmented span {
  display: block;
  padding: 0.4rem 0.9rem;
  border-radius: 7px;
  color: var(--graphite);
}

.segmented input:checked + span {
  background: var(--ink);
  color: var(--paper);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--royal);
  outline-offset: 1px;
}

.template {
  font-family: var(--mono);
  font-size: 0.9375rem;
}

.qr {
  display: block;
  width: 11rem;
  height: 11rem;
  padding: 0.5rem;
  background: #fff;
  border-radius: 8px;
}

.secret {
  font-family: var(--mono);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.steps {
  padding-left: 1.25rem;
}

.steps li + li {
  margin-top: 0.25rem;
}

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

.app-auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: max(2rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom));
}

.auth-wrap {
  width: min(27rem, 100%);
}

.auth {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 2.25rem;
  color: var(--ink);
  margin-bottom: 1.25rem;
}

.auth-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-3);
  line-height: 1.15;
}

.auth-lead {
  color: var(--graphite);
}

.auth-ok {
  color: var(--ink-soft);
  font-size: 0.9375rem;
  padding-left: 0.8rem;
  border-left: 2px solid var(--royal);
}

.link-quiet {
  color: var(--graphite);
  font-size: 0.9375rem;
  text-underline-offset: 0.2em;
  width: fit-content;
}

.recovery {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.recovery-key {
  font-family: var(--mono);
  font-size: 1.125rem;
  letter-spacing: 0.04em;
  line-height: 1.7;
  text-align: center;
  padding: 1rem;
  border: 1.5px dashed var(--rule);
  border-radius: 8px;
  background: var(--sheet);
  user-select: all;
  -webkit-user-select: all;
  overflow-wrap: anywhere;
}

.btn[aria-disabled='true'] {
  opacity: 0.55;
  pointer-events: none;
}

.handoff-input {
  font-size: 1.25rem;
  letter-spacing: 0.12em;
  max-width: 10rem;
}

.handoff-code {
  font-size: 2.25rem;
  letter-spacing: 0.14em;
  user-select: all;
}

/* --- Himmel ------------------------------------------------------------------------- */

.sky {
  position: relative;
  overflow: hidden;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-bottom));
  isolation: isolate;
}

.sky-decor,
.sky-hills {
  position: absolute;
  left: 0;
  width: 100%;
  pointer-events: none;
}

.sky-decor {
  top: 0;
  height: 100%;
  z-index: -1;
}

.sky-hills {
  bottom: -1px;
  height: 34%;
  z-index: -1;
}

.sky-sun {
  fill: #fff6df;
}

.sky-sun.is-low {
  fill: #ffe3b8;
}

.sky-glow {
  fill: #fff2cf;
  opacity: 0.28;
}

.sky-moon {
  fill: #f2f0e6;
}

.sky-star {
  fill: #ffffff;
}

.sky-cloud ellipse {
  fill: #ffffff;
  opacity: 0.55;
}

.sky-cloud.is-light ellipse {
  opacity: 0.4;
}

.sky-cloud.is-heavy ellipse {
  fill: #c9ced6;
  opacity: 0.75;
}

.sky-rain {
  stroke: #e3e8ef;
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0.6;
}

/* Hügel aus Papier: der Himmel steht hinter der Seite */
.sky-hills-paper .sky-hill-back {
  fill: var(--paper);
  opacity: 0.45;
}

.sky-hills-paper .sky-hill-front {
  fill: var(--paper);
}

/* Hügel als Landschaft bei den Stimmungsbildern */
.sky-hills-land .sky-hill-back {
  fill: #2a3a5c;
  opacity: 0.45;
}

.sky-hills-land .sky-hill-front {
  fill: #1c2a4f;
  opacity: 0.7;
}

/* Kopf von "Heute" */
.sky-time.day-head {
  margin: calc(-1 * max(1.5rem, env(safe-area-inset-top))) -1.25rem 1.5rem;
  padding: max(2.25rem, calc(env(safe-area-inset-top) + 1.25rem)) 1.25rem 4.75rem;
  min-height: 15.5rem;
  display: flex;
  align-items: flex-start;
}

.sky-time .day-title {
  position: relative;
}

.sky-time.is-light .day-title {
  color: #15203f;
}

.sky-time.is-light .day-weekday {
  color: color-mix(in srgb, #15203f 72%, transparent);
}

.sky-time.is-dark .day-title {
  color: #f4f2ea;
}

.sky-time.is-dark .day-weekday {
  color: color-mix(in srgb, #f4f2ea 78%, transparent);
}

@media (min-width: 900px) {
  .sky-time.day-head {
    margin: -1.25rem 0 2rem;
    padding: 2.25rem 2.25rem 5.5rem;
    border-radius: 18px;
    min-height: 17rem;
  }
}

/* Stimmungsbilder */
.sky-tile {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 8px;
}

.sky-band {
  height: clamp(8rem, 28vw, 12rem);
  border-radius: 6px;
}

.entry-thumb {
  display: block;
}

/* --- Liniertes Papier beim Schreiben ------------------------------------------------- */

.write-sheet {
  --margin-x: 2.25rem;
  background:
    linear-gradient(to right, transparent calc(var(--margin-x) - 0.9rem), var(--margin) calc(var(--margin-x) - 0.9rem), var(--margin) calc(var(--margin-x) - 0.9rem + 1.5px), transparent calc(var(--margin-x) - 0.9rem + 1.5px)),
    var(--sheet);
  padding-left: var(--margin-x);
}

.write-body {
  background-image: linear-gradient(to bottom, transparent calc(1.75em - 1px), var(--line) calc(1.75em - 1px));
  background-size: 100% 1.75em;
  background-attachment: local;
  background-position: 0 -0.3em;
}

@media (min-width: 960px) {
  .write-sheet {
    --margin-x: 4.25rem;
  }
}

/* --- Rückfrage-Dialog ----------------------------------------------------------------- */

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 85%, #000);
}

.confirm {
  width: min(26rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--sheet);
  color: var(--ink);
}

.confirm::backdrop {
  background: rgba(15, 21, 38, 0.55);
}

.confirm-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: var(--step-2);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.confirm-text {
  color: var(--graphite);
  margin-bottom: 1.25rem;
}

.confirm-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.confirm-btn {
  width: 100%;
  flex-direction: column;
  gap: 0.1rem;
}

.confirm-hint {
  font-size: 0.8125rem;
  font-weight: 400;
  opacity: 0.85;
}

.confirm-note {
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--graphite);
}

.day-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* --- Bewegung reduzieren --------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
