:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --fg: #1f2328;
  --muted: #5b636e;
  --line: #d6dae0;
  --accent: #b4363d;
  --accent-fg: #ffffff;
  --error: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181d; --card: #1f2229; --fg: #e6e8eb; --muted: #9aa3ad; --line: #353a44; --accent: #e0676d; --accent-fg: #16181d; --error: #ff8a80; }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}
main { max-width: 28rem; margin: 0 auto; padding: 1rem; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
h1 { margin: 0; font-size: 1.6rem; }
h2 { margin: 0 0 .75rem; font-size: 1.2rem; }
.muted { color: var(--muted); margin: .25rem 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
label { font-weight: 600; margin-top: .25rem; }
input { font: inherit; padding: .7rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); width: 100%; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; padding: .75rem 1rem; border-radius: 8px; border: 0; background: var(--accent); color: var(--accent-fg); font-weight: 600; cursor: pointer; margin-top: .5rem; min-height: 44px; }
button:disabled { opacity: .6; cursor: default; }
button.secondary { background: transparent; color: var(--fg); border: 1px solid var(--line); }
button.link { background: none; color: var(--accent); padding: .25rem .5rem; margin: 0; min-height: 0; font-weight: 500; }
.error { color: var(--error); min-height: 1.5em; margin: .25rem 0 0; }

/* Kopf */
.top .actions { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
a { color: var(--accent); }
a.home { color: inherit; text-decoration: none; }
.row { display: flex; gap: .5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row h2 { margin: 0; }
.filters > * { flex: 1 1 12rem; }
select, textarea { font: inherit; padding: .7rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); width: 100%; }
textarea { resize: vertical; }
small.muted { margin-top: -.25rem; }
a.button { display: inline-flex; align-items: center; justify-content: center; padding: .6rem 1rem; border-radius: 8px; background: var(--accent); color: var(--accent-fg); font-weight: 600; text-decoration: none; min-height: 44px; }
a.button.secondary, button.secondary { background: transparent; color: var(--fg); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--error); border: 1px solid var(--error); }
form .row > * { flex: 1; margin-top: .5rem; }
form { display: flex; flex-direction: column; gap: .5rem; }

/* Liste */
ul.pairs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
ul.pairs li { border-top: 1px solid var(--line); }
a.pair { display: flex; gap: .75rem; padding: .75rem .25rem; color: inherit; text-decoration: none; align-items: flex-start; }
.badge { font-size: .75rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: .1rem .35rem; margin-top: .2rem; }
.texts { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.target { font-size: 1.15rem; font-weight: 600; }
.reading { color: var(--muted); font-size: .9rem; }
.de { color: var(--fg); }
.tags { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.tag { font-size: .75rem; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 0 .5rem; color: var(--muted); }
.trashlink { align-self: flex-start; }
li.trashitem { padding: .75rem 0; display: flex; flex-direction: column; gap: .25rem; }
li.trashitem .row { justify-content: flex-start; }
li.trashitem button { margin-top: .25rem; }
.error p { margin: .25rem 0; }
.dup { color: var(--fg); }
.card > p.error:empty { min-height: 0; margin: 0; }

/* Ueben */
.study-banner { margin-bottom: 1rem; }
.study-banner p { margin: 0; }
.card + .card { margin-top: 1rem; }
.study .big { font-size: 1.8rem; font-weight: 600; text-align: center; margin: 1.25rem 0 .5rem; overflow-wrap: anywhere; }
.study .answer { border-top: 1px solid var(--line); padding-top: .5rem; text-align: center; }
.study .answer .reading { font-size: 1.1rem; }
.study .note { white-space: pre-line; color: var(--muted); text-align: left; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.rate button { display: flex; flex-direction: column; align-items: center; padding: .5rem .25rem; font-size: .9rem; }
.rate button small { font-weight: 400; opacity: .85; }
.rate .r1 { background: #b3261e; }
.rate .r2 { background: #8a6d1f; }
.rate .r3 { background: #2e7d32; }
.rate .r4 { background: #1f5fa8; }
@media (prefers-color-scheme: dark) { .rate button { color: #fff; } }
[hidden] { display: none !important; }

/* Update-Hinweis */
.update-bar { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); width: min(28rem, calc(100% - 2rem));
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .75rem;
  background: var(--fg); color: var(--bg); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 10; }
.update-bar span { font-size: .95rem; flex: 1; }
.update-bar button { margin: 0; white-space: nowrap; }

/* Sprechtest */
.modes > button { flex: 1; margin-top: 0; }
.speak #recbtn { font-size: 1.1rem; min-height: 56px; }
.speak .result p { margin: .25rem 0; text-align: center; }
.accuracy { font-size: 1.5rem; font-weight: 700; }
.accuracy.good { color: #2e7d32; }
.accuracy.mid { color: #8a6d1f; }
.accuracy.bad { color: var(--error); }
.rate .suggested { outline: 3px solid var(--fg); outline-offset: 2px; }
p.small { font-size: .8rem; }
.study-banner .row .button { margin-top: .25rem; }
