/* ===== Inter (self-hosted, DSGVO) ===== */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-700.woff2') format('woff2');
}

/* ===== Design-Tokens (Spec §13) ===== */
:root {
  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --text:          #1f2733;
  --text-muted:    #6b7280;
  --accent:        #4f7cff;
  --accent-hover:  #3d68e6;
  --success:       #2bb673;
  --warning:       #f5a524;
  --danger:        #ef4444;

  --radius:        16px;
  --radius-pill:   999px;

  --shadow-sm: 0 1px 2px rgba(20,30,55,.06), 0 2px 6px rgba(20,30,55,.06);
  --shadow-md: 0 4px 12px rgba(20,30,55,.10), 0 2px 4px rgba(20,30,55,.06);
  --shadow-lg: 0 10px 30px rgba(20,30,55,.14);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --text-shadow-soft: 0 1px 2px rgba(20,30,55,.12);

  --ease: cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #11151c;
    --surface:    #1b212b;
    --text:       #e7ebf3;
    --text-muted: #9aa3b2;
    --accent:     #5e88ff;
    --accent-hover:#7599ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.45), 0 2px 4px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }

/* hidden muss IMMER gewinnen — sonst überschreiben display:flex-Regeln
   (z.B. .login-view / .app-view) das [hidden]-Attribut. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { text-shadow: var(--text-shadow-soft); }

button { font-family: inherit; }

/* ===== Buttons ===== */
.btn {
  border: none;
  border-radius: var(--radius-pill);
  padding: 0 20px;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all .15s var(--ease);
}
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.97); box-shadow: var(--shadow-sm); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
}
.btn-ghost:hover { background: rgba(127,127,127,.12); color: var(--text); }
.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  box-shadow: none;
}
.btn-danger-ghost:hover { background: rgba(239,68,68,.12); }

/* ===== Login ===== */
.login-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
}
.brand {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent);
}
.brand-sub {
  margin: 4px 0 24px;
  text-align: center;
  color: var(--text-muted);
}
.login-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .85rem; font-weight: 500; color: var(--text-muted); }
.field input, .field select, .field textarea, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.field input:focus, .field select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,124,255,.18);
}
.form-error {
  margin: 0;
  color: var(--danger);
  font-size: .9rem;
  text-align: center;
}

/* ===== App-Layout ===== */
.app-view { min-height: 100dvh; display: flex; flex-direction: column; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding-top: env(safe-area-inset-top);
}
.app-header-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}
.app-title { font-weight: 700; font-size: 1.2rem; color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 10px; }
.current-user { color: var(--text-muted); font-size: .9rem; }

.app-main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
}
.panel-title { margin: 4px 0 16px; font-size: 1.4rem; font-weight: 700; }

.card-list { display: flex; flex-direction: column; gap: 12px; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  transition: box-shadow .2s var(--ease), transform .2s var(--ease), opacity .25s var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-completing { opacity: 0; transform: translateY(8px); }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-weight: 600; font-size: 1.05rem; }
.card-area { color: var(--text-muted); font-weight: 400; font-size: .9rem; }
.card-meta { margin-top: 6px; color: var(--text-muted); font-size: .85rem; }

.card-row { display: flex; align-items: center; gap: 10px; }
.card-feed { display: flex; align-items: flex-start; gap: 12px; }
.feed-icon {
  font-size: 1.2rem;
  width: 36px; height: 36px;
  flex: 0 0 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-radius: var(--radius-pill);
}
.feed-body { flex: 1; }
.feed-text { font-weight: 500; }

/* ===== Badges (Pills) ===== */
.badge {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-overdue { background: rgba(239,68,68,.14);  color: var(--danger); }
.badge-due     { background: rgba(245,165,36,.16); color: #b9770f; }
.badge-upcoming{ background: rgba(43,182,115,.15); color: var(--success); }

.task-card.is-overdue  { border-left: 4px solid var(--danger); }
.task-card.is-due      { border-left: 4px solid var(--warning); }
.task-card.is-upcoming { border-left: 4px solid var(--success); }

.check-btn {
  margin-top: 12px;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  min-height: 48px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all .15s var(--ease);
}
.check-btn:active { transform: scale(.97); box-shadow: var(--shadow-sm); }

.link-btn {
  background: none; border: none; color: var(--accent);
  font-weight: 600; cursor: pointer; padding: 6px 0; font-size: .9rem;
}
.task-inactive { opacity: .55; }

/* ===== Forms in Tabs ===== */
.log-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.log-form textarea { width: 100%; resize: vertical; }

/* ===== Filter-Chips ===== */
.filter-row { display: flex; gap: 8px; margin-bottom: 16px; }
.chip {
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all .15s var(--ease);
}
.chip-active { background: var(--accent); color: #fff; }

/* ===== Empty / Loading ===== */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 16px;
  font-size: 1rem;
}
.skeleton {
  height: 84px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(127,127,127,.08), rgba(127,127,127,.16), rgba(127,127,127,.08));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ===== Tabbar ===== */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  background: var(--surface);
  box-shadow: 0 -2px 12px rgba(20,30,55,.08);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-btn {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-muted);
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: color .15s var(--ease);
}
.tabbar-icon { font-size: 1.3rem; }
.tabbar-label { font-size: .72rem; font-weight: 600; }
.tabbar-active { color: var(--accent); }

/* ===== Dialog ===== */
.dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0;
  width: min(420px, 92vw);
  background: var(--surface);
  color: var(--text);
}
.dialog::backdrop { background: rgba(15,20,35,.45); }
.dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.dialog-form h3 { margin: 0; }
/* Buttons untereinander (mobil), Speichern oben, voll breit — verhindert das
   Abschneiden auf schmalen Screens. column-reverse + display:contents ergibt
   visuelle Reihenfolge: Speichern, Abbrechen, Deaktivieren. */
.dialog-actions {
  display: flex;
  flex-direction: column-reverse;
  align-items: stretch;
  gap: 10px;
  margin-top: 6px;
}
.dialog-actions-right { display: contents; }
.dialog-actions .btn { width: 100%; }

/* ===== Dauer-Chips ===== */
.duration-pick { display: flex; flex-direction: column; gap: 6px; }
.duration-label { font-size: .85rem; color: var(--text-muted); font-weight: 500; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip {
  border: none;
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-pill);
  min-height: 38px;
  padding: 0 14px;
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.tchip-active { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.log-min-custom {
  margin-top: 8px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  width: 100%;
}
.log-min-custom:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,124,255,.18); }

/* ===== Zeit-Editor (nach dem Erledigen) ===== */
.time-editor {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  z-index: 45;
  max-width: 92vw;
}
.time-editor-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.time-editor-label { font-weight: 600; font-size: .9rem; }

/* ===== Statistik ===== */
.stat-big { font-size: 2rem; font-weight: 700; color: var(--accent); margin-top: 4px; }
.stat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid rgba(127,127,127,.12);
}
.stat-row:first-of-type { border-top: none; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--surface);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  opacity: 0;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  z-index: 40;
}
.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
