/* ==========================================================================
   Tehilim -- Stylesheet
   Farben als Variablen; Themen: hell (Standard), sepia, dunkel.
   ========================================================================== */

:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #efe8da;
  --text: #2a2620;
  --muted: #6d655a;
  --accent: #7a4b1f;
  --accent-2: #a8742f;
  --line: #ddd3c2;
  --ok: #3d7a4a;
  --shadow: 0 1px 3px rgba(60, 40, 10, .08), 0 6px 18px rgba(60, 40, 10, .06);

  --scale: 1;
  --he-font: 'Frank Ruhl Libre', 'Noto Serif Hebrew', 'SBL Hebrew', 'Times New Roman', serif;
  --la-font: 'Literata', Georgia, 'Times New Roman', serif;
  --rashi-font: 'Noto Rashi Hebrew', var(--he-font);
  --ui-font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="sepia"]) {
    --bg: #17150f; --surface: #201d16; --surface-2: #2b271e; --text: #ece4d4;
    --muted: #a99f8d; --accent: #e0b070; --accent-2: #c8924a; --line: #3a3428; --ok: #7fbf8c;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17150f; --surface: #201d16; --surface-2: #2b271e; --text: #ece4d4;
  --muted: #a99f8d; --accent: #e0b070; --accent-2: #c8924a; --line: #3a3428; --ok: #7fbf8c;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  color-scheme: dark;
}
:root[data-theme="sepia"] {
  --bg: #efe2c6; --surface: #f7ecd4; --surface-2: #e6d5b2; --text: #3b2f1d;
  --muted: #74634a; --accent: #6e3d12; --line: #d4bf98;
}
:root[data-theme="light"] {
  --bg: #fbfaf7; --surface: #ffffff; --surface-2: #f1eee8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--ui-font); line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

/* --- Kopfzeile --------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--text); }
.brand-he { font-family: var(--he-font); font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.brand-de { font-family: var(--la-font); font-size: 1rem; color: var(--muted); }
.topnav { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.topnav a {
  text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: .95rem;
}
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a.active { color: var(--accent); background: var(--surface-2); font-weight: 600; }

main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 16px 16px 48px; outline: none; }
.foot { text-align: center; font-size: .8rem; color: var(--muted); padding: 16px; border-top: 1px solid var(--line); }
.loading, .muted { color: var(--muted); }

h1, h2, h3 { font-family: var(--la-font); font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.6rem; margin: 8px 0 16px; }
h2 { font-size: 1.25rem; margin: 28px 0 12px; }
h3 { font-size: 1.05rem; margin: 16px 0 8px; }

/* --- Bausteine --------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cards .card { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; text-decoration: none;
  font-size: .95rem; line-height: 1.2; min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: .85rem; }
.btn.danger { color: #b3261e; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .45; cursor: default; }

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
input[type="text"], input[type="number"], select {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--surface); min-height: 40px;
}
input[type="number"] { width: 6em; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; padding: 4px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* --- Psalm-Raster ------------------------------------------------------ */
.book-title { display: flex; justify-content: space-between; align-items: baseline; }
.grid {
  display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
}
.grid a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: 1; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: .95rem;
}
.grid a small { font-family: var(--he-font); color: var(--muted); font-size: .85rem; line-height: 1; }
.grid a:hover { border-color: var(--accent); color: var(--accent); }
.grid a.done { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }

/* --- Lesebereich ------------------------------------------------------- */
.reader-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.reader-head h1 { margin: 0; flex: 1; }
.reader-head .head-actions { display: flex; gap: 8px; }
.reader-head h1 .he { font-family: var(--he-font); color: var(--accent); margin-inline-start: 10px; }

.toolbar {
  position: sticky; top: 57px; z-index: 10;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 8px 0; background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 4px 12px; font-size: .85rem; cursor: pointer; min-height: 34px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.chip.icon { min-width: 36px; font-weight: 600; }

.passage { margin-bottom: 28px; }
.passage-title {
  font-family: var(--la-font); font-size: 1.15rem; color: var(--muted);
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 18px 0 8px;
}
.passage-title .he { font-family: var(--he-font); font-size: 1.4rem; color: var(--accent); }
.letter-head {
  text-align: center; font-family: var(--he-font); color: var(--accent);
  font-size: calc(2.2rem * var(--scale)); margin: 22px 0 4px; line-height: 1;
}
.letter-head small { display: block; font-family: var(--la-font); font-size: .9rem; color: var(--muted); margin-top: 4px; }

.verse { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.verse:last-child { border-bottom: 0; }
.verse.parallel { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.verse.parallel .v-he, .verse.parallel .v-tl { grid-column: 2; }
.verse.parallel .v-tr { grid-column: 1; grid-row: 1 / span 2; }
.verse.parallel .v-com { grid-column: 1 / -1; }

.v-he {
  font-family: var(--he-font); direction: rtl; text-align: right;
  font-size: calc(1.75rem * var(--scale)); line-height: 1.75;
}
.v-num { color: var(--accent-2); font-size: .6em; margin-inline-end: .35em; vertical-align: .15em; font-weight: 600; }
.v-tl { font-family: var(--la-font); font-style: italic; color: var(--muted); font-size: calc(1.02rem * var(--scale)); line-height: 1.6; }
.v-tr { font-family: var(--la-font); font-size: calc(1.08rem * var(--scale)); line-height: 1.65; }
.v-tr .v-num { font-size: .75em; }
.v-com { margin-top: 6px; }
.com {
  background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin-top: 6px;
  font-size: calc(1rem * var(--scale)); line-height: 1.6;
}
.com .com-label { font-family: var(--ui-font); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: block; margin-bottom: 2px; }
.com.he { direction: rtl; text-align: right; font-family: var(--he-font); font-size: calc(1.15rem * var(--scale)); }
.com.he.rashi-script { font-family: var(--rashi-font); }
.com.he .com-label { direction: ltr; text-align: right; }
.com p { margin: 0 0 4px; }
.com b { color: var(--accent); }

.prose-he { font-family: var(--he-font); direction: rtl; text-align: right; font-size: calc(1.6rem * var(--scale)); line-height: 1.8; }
.prose-tr { font-family: var(--la-font); font-size: calc(1.05rem * var(--scale)); line-height: 1.65; }
.prose-block { padding: 8px 0; border-bottom: 1px dashed var(--line); }

.pager { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; margin: 24px 0; }
.done-bar {
  position: sticky; bottom: 0; z-index: 10; padding: 12px; margin: 24px -16px 0;
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}

/* --- Namen ------------------------------------------------------------- */
.he-input { font-family: var(--he-font); direction: rtl; font-size: 1.6rem !important; text-align: right; width: 100%; }
.kbd { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; direction: rtl; margin: 8px 0; }
.kbd button {
  font-family: var(--he-font); font-size: 1.35rem; padding: 4px 0; min-height: 44px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer;
}
.kbd button:hover { border-color: var(--accent); }
.letters { display: flex; flex-wrap: wrap; gap: 6px; direction: rtl; margin: 8px 0; }
.letters a {
  font-family: var(--he-font); font-size: 1.4rem; text-decoration: none; color: var(--accent);
  border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface);
}

/* --- Listen ------------------------------------------------------------ */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .sub { font-size: .85rem; color: var(--muted); }
.suggest { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-top: 4px; max-height: 260px; overflow: auto; }
.suggest button { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 8px 12px; cursor: pointer; }
.suggest button:hover { background: var(--surface-2); }
.badge { display: inline-block; font-size: .75rem; border-radius: 99px; padding: 1px 8px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  transition: transform .25s ease; z-index: 50; max-width: calc(100% - 32px);
}
#toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  .verse.parallel { display: block; }
  .topbar { padding: 6px 12px; }
  .brand-de { display: none; }
  .topnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .topnav a { padding: 6px 7px; font-size: .88rem; white-space: nowrap; }
  .toolbar { position: static; }
  main { padding: 12px 16px 40px; }
}

@media print {
  .topbar, .toolbar, .foot, .done-bar, .pager { display: none !important; }
  body { background: #fff; color: #000; }
}
