/* =========================================================
   Textwerkstatt – mobiles Theme
   ========================================================= */
:root {
  --brand:   #5b3ea6;
  --brand-d: #472f83;
  --bg:      #f5f2fb;
  --card:    #ffffff;
  --text:    #1c1a2b;
  --muted:   #6c6880;
  --border:  #e3ddf0;
  --danger:  #c0392b;
  --success: #2e9e6b;
  --radius:  14px;
}

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

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

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ─────────────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.login-card {
  background: var(--card); border-radius: 18px; padding: 2.5rem 2rem;
  width: min(360px, 94vw); box-shadow: 0 8px 32px rgba(91,62,166,.14); text-align: center;
}
.login-logo { font-size: 2.6rem; margin-bottom: .4rem; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 1.6rem; font-weight: 650; }
.login-card label { display: block; text-align: left; font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.login-card input[type=password] {
  width: 100%; padding: .8rem 1rem; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 1rem; outline: none; transition: border-color .2s;
}
.login-card input[type=password]:focus { border-color: var(--brand); }
.login-error { margin-top: .75rem; color: var(--danger); font-size: .875rem; }
.login-card button[type=submit] {
  margin-top: 1.2rem; width: 100%; padding: .85rem; background: var(--brand); color: #fff;
  border: none; border-radius: 10px; font-size: 1rem; font-weight: 650; cursor: pointer;
}
.login-card button[type=submit]:active { background: var(--brand-d); }

/* ── Header ────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem 1rem; padding-top: max(.7rem, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 10px rgba(91,62,166,.25);
}
.hdr-title { flex: 1; font-weight: 650; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-back, .hdr-logout {
  background: rgba(255,255,255,.16); color: #fff; border: none; border-radius: 9px;
  width: 38px; height: 38px; font-size: 1.3rem; cursor: pointer; flex: 0 0 auto;
}
.hdr-back[hidden] { display: none; }

/* ── Layout ────────────────────────────────────────────── */
.main { max-width: 720px; margin: 0 auto; padding: 1rem 1rem 4rem; }
.screen { display: none; }
.screen.active { display: block; }

.screen-actions { display: flex; gap: .6rem; margin-bottom: 1rem; }
.screen-actions.wrap { flex-wrap: wrap; }

.section-label {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 1.4rem 0 .5rem; font-weight: 650;
}
.muted { color: var(--muted); font-size: .9rem; }
.empty-hint { color: var(--muted); text-align: center; padding: 2rem 1rem; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .7rem 1rem; border: 1.5px solid var(--border); background: var(--card);
  color: var(--text); border-radius: 11px; font-size: .95rem; font-weight: 550;
  cursor: pointer; transition: transform .05s, background .15s; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:active { background: var(--brand-d); }
.btn-sm { padding: .5rem .8rem; font-size: .875rem; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: #ecc6c2; }
.btn-danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── Listen / Karten ───────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: .7rem; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.03);
}
.project-card { display: flex; align-items: center; gap: .8rem; cursor: pointer; }
.project-card .pc-main { flex: 1; min-width: 0; }
.project-card h3 { font-size: 1.05rem; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card .pc-meta { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.project-card .pc-del { background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: .3rem; }

.project-head { margin-bottom: 1rem; }
.project-head h2 { font-size: 1.35rem; font-weight: 680; }

/* ── Kapitelbaum ───────────────────────────────────────── */
.chapter { margin-bottom: .6rem; }
.chapter-head {
  display: flex; align-items: center; gap: .5rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 11px;
  padding: .6rem .8rem;
}
.chapter-head .ch-title { flex: 1; font-weight: 600; }
.chapter-head .ch-count { font-size: .78rem; color: var(--muted); }
.chapter-menu-btn { background: none; border: none; font-size: 1.2rem; color: var(--muted); cursor: pointer; padding: .2rem .4rem; }
.chapter-children { margin-left: 1rem; padding-left: .6rem; border-left: 2px solid var(--border); margin-top: .5rem; }
.chapter-body { padding: .4rem 0 .2rem .3rem; }

/* ── Gedanken ──────────────────────────────────────────── */
.thought-drop { display: flex; flex-direction: column; gap: .5rem; min-height: 8px; }
.thought {
  display: flex; align-items: flex-start; gap: .6rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 11px;
  padding: .7rem .8rem;
}
.thought.selected { border-color: var(--brand); box-shadow: 0 0 0 1.5px var(--brand); }
.thought .th-check { margin-top: .15rem; width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--brand); }
.thought .th-main { flex: 1; min-width: 0; }
.thought .th-content { white-space: pre-wrap; word-break: break-word; }
.thought .th-type {
  display: inline-block; font-size: .7rem; padding: .1rem .5rem; border-radius: 20px;
  background: #efeaf8; color: var(--brand-d); margin-top: .35rem; font-weight: 600;
}
.thought .th-actions { display: flex; gap: .3rem; flex: 0 0 auto; }
.thought .th-actions button { background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer; padding: .25rem; }
.thought-empty { color: var(--muted); font-size: .85rem; padding: .3rem .2rem; }

/* ── Bulk-Leiste ───────────────────────────────────────── */
/* Mobil: zwei Zeilen (Anzahl oben, Buttons darunter in voller Breite). */
.bulk-bar {
  position: sticky; top: 56px; z-index: 15;
  display: flex; flex-direction: column; gap: .5rem;
  background: var(--brand); color: #fff; border-radius: 11px; padding: .55rem .7rem; margin-bottom: 1rem;
}
#bulk-count { font-size: .85rem; font-weight: 600; }
.bulk-actions { display: flex; gap: .4rem; }
.bulk-actions #bulk-move, .bulk-actions #bulk-delete { flex: 1; }
.bulk-actions #bulk-clear { flex: 0 0 auto; }
.bulk-bar .btn { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.14); color: #fff; padding: .5rem .7rem; }
.bulk-bar .btn-danger { background: rgba(255,255,255,.14); color: #ffd9d3; }

/* Ab Tablet-Breite: alles wieder in einer Zeile. */
@media (min-width: 520px) {
  .bulk-bar { flex-direction: row; align-items: center; justify-content: space-between; }
  .bulk-actions #bulk-move, .bulk-actions #bulk-delete { flex: 0 0 auto; }
}

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,16,40,.5);
  display: none; align-items: flex-end; justify-content: center; z-index: 50; padding: 0;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--card); border-radius: 18px 18px 0 0; padding: 1.4rem 1.2rem;
  padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-box h2 { font-size: 1.15rem; margin-bottom: 1rem; font-weight: 650; }
.modal-box label { display: block; font-size: .82rem; color: var(--muted); margin: .7rem 0 .3rem; }
.modal-box input[type=text], .modal-box textarea, .modal-box select {
  width: 100%; padding: .7rem .8rem; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 1rem; font-family: inherit; outline: none;
}
.modal-box input:focus, .modal-box textarea:focus, .modal-box select:focus { border-color: var(--brand); }
.modal-box textarea { min-height: 110px; resize: vertical; }
.modal-actions { display: flex; gap: .6rem; margin-top: 1.4rem; }
.modal-actions .btn { flex: 1; }
.modal-choice-list { display: flex; flex-direction: column; gap: .4rem; max-height: 46dvh; overflow-y: auto; }
.modal-choice-list .choice {
  padding: .7rem .8rem; border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer; text-align: left;
  background: var(--card);
}
.modal-choice-list .choice:active { background: var(--bg); }
.modal-choice-list .choice.sub { margin-left: 1rem; font-size: .92rem; }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: 18px; }
}

/* ── Aufnahme ──────────────────────────────────────────── */
.record-box { text-align: center; }
.record-stage { display: flex; flex-direction: column; align-items: center; gap: .8rem; padding: 1.4rem 0 .6rem; }
.record-btn {
  width: 96px; height: 96px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 2.4rem;
  box-shadow: 0 6px 20px rgba(91,62,166,.35); transition: transform .08s, background .15s;
}
.record-btn:active { transform: scale(.95); }
.record-btn.recording { background: var(--danger); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(192,57,43,.5); } 50% { box-shadow: 0 0 0 16px rgba(192,57,43,0); } }
.record-timer { font-size: 1.6rem; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.record-timer.active { color: var(--danger); }
.record-status { display: flex; align-items: center; justify-content: center; gap: .6rem; margin: .8rem 0; color: var(--muted); }
.record-status[hidden] { display: none; }
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite; flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thought.is-new { animation: flashnew 1.6s ease; }
@keyframes flashnew { 0% { background: #efe7ff; border-color: var(--brand); } 100% { background: var(--card); } }

/* ── Toasts ────────────────────────────────────────────── */
.toast-container {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: .5rem; z-index: 100; width: max-content; max-width: 92vw;
}
.toast {
  background: #2a2340; color: #fff; padding: .7rem 1.1rem; border-radius: 11px;
  font-size: .9rem; box-shadow: 0 4px 16px rgba(0,0,0,.25); animation: toastin .2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
