/* ═══════════════════════════════════════════════════════════
   COMPONENTS — Shared UI Elements
   GeniusHub v21 — Redesign

   Ruhig, solide, keine Gradients, kein Glassmorphism.
   Klassen bleiben identisch zu v20, nur Styling neu.
   ═══════════════════════════════════════════════════════════ */

/* ── Input ── */
.inp {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 13px;
  font-family: var(--f-sans);
  outline: none;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.inp:hover { border-color: var(--line-2); }
.inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: var(--bg-1);
}
.inp::placeholder { color: var(--fg-dim); }

.ta {
  resize: vertical;
  min-height: 72px;
  line-height: 1.55;
  font-family: var(--f-sans);
}


/* ── Button: Primary ── */
.bp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: #0b0c0e;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--f-sans);
  letter-spacing: -.005em;
  cursor: pointer;
  transition: filter var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
  white-space: nowrap;
  min-height: 36px;
  box-shadow: none;
}
.bp:hover { filter: brightness(1.08); }
.bp:active { filter: brightness(.95); }


/* ── Button: Ghost / Secondary ── */
.bg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--f-sans);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  white-space: nowrap;
  min-height: 32px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.bg:hover {
  background: var(--bg-2);
  border-color: var(--line-2);
  color: var(--fg);
}


/* ── Button: Small ── */
.bs {
  padding: 5px 9px;
  font-size: 11px;
  border-radius: var(--r-sm);
  min-height: 26px;
}


/* ── Button: Danger ── */
.bd {
  border-color: var(--line);
  color: var(--err);
}
.bd:hover {
  background: color-mix(in oklab, var(--err) 10%, transparent);
  border-color: color-mix(in oklab, var(--err) 30%, var(--line));
  color: var(--err);
}


/* ── Button: Active (auf .task-btn, .nt etc.) ── */
.task-btn.on,
.bg.on {
  border-color: var(--accent-ring);
  color: var(--accent);
  background: var(--accent-weak);
}


/* ── Card ── */
.crd {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
  cursor: pointer;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}
.crd:hover {
  border-color: var(--line-2);
  background: var(--bg-1);
  box-shadow: none;
}
.crd:active { transform: none; }


/* ── Progress Bar ── */
.progress {
  height: 4px;
  background: var(--bg-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-f {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .4s var(--ease);
}


/* ── KI-Assistent Form ── */
.ki-label {
  display: block;
  font-size: 10px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
}
.ki-inp {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-top: 4px;
  font-size: 13px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: var(--r-md);
  outline: none;
  font-family: var(--f-sans);
  transition: border-color var(--dur-1) var(--ease);
}
.ki-inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.ki-inp::placeholder { color: var(--fg-dim); }


/* ── Character Counter ── */
.cc {
  font-size: 10px;
  color: var(--fg-dim);
  text-align: right;
  margin-top: 2px;
  font-family: var(--f-mono);
}


/* ── Streak Widget ── */
.streak-widget {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 80px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.streak-num {
  font-family: var(--f-sans);
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 700;
  line-height: 1;
  color: var(--fg);
  letter-spacing: -.02em;
}
.streak-label {
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-top: 6px;
  font-weight: 500;
}


/* ── Beta Badge ── */
.beta-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent-weak);
  border: 1px solid var(--accent-ring);
  border-radius: var(--r-lg);
}
.beta-badge-icon {
  font-size: 18px;
  flex-shrink: 0;
  color: var(--accent);
}
.beta-badge-text { flex: 1; }
.beta-badge-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -.005em;
}
.beta-badge-sub {
  font-size: 10px;
  color: var(--fg-muted);
  margin-top: 2px;
}


/* ═══════════════════════════════════════════════════════════
   DEMO-MODUS — unverändert
   ═══════════════════════════════════════════════════════════ */

.demo-banner {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9998;
  background: #991b1b;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .2px;
  text-align: center;
  padding: 12px 20px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  pointer-events: none;
  gap: 8px;
  box-shadow: 0 -2px 16px rgba(0,0,0,.3);
  border-top: 1px solid rgba(255,255,255,.1);
}
html.demo-mode .demo-banner { display: flex; align-items: center; justify-content: center; }
html.demo-mode body { padding-bottom: 48px; }
html.demo-mode .demo-hide { display: none !important; }
html.demo-mode .demo-show { display: grid !important; }

html.demo-mode input,
html.demo-mode textarea {
  pointer-events: none;
  user-select: none;
  opacity: .5;
}
/* Login-Inputs IMMER interaktiv — auch im Demo-Modus */
html.demo-mode #login input,
html.demo-mode #login textarea,
html.demo-mode #login .l-inp,
html.demo-mode #login .l-btn {
  pointer-events: auto !important;
  user-select: auto !important;
  opacity: 1 !important;
}
html.demo-mode #login .l-inp { cursor: text; }
html.demo-mode #emB input,
html.demo-mode #emB textarea {
  pointer-events: auto;
  user-select: auto;
  opacity: 1;
}
html.demo-mode .bp {
  pointer-events: none;
  opacity: .4;
  cursor: not-allowed;
}
html.demo-mode #emB .bp {
  pointer-events: auto;
  opacity: 1;
  cursor: pointer;
}
html.demo-mode .ki-inp,
html.demo-mode .ki-inp:focus {
  pointer-events: none;
  user-select: none;
  opacity: .5;
}
html.demo-mode #kiImportText {
  pointer-events: none;
  opacity: .5;
}
html.demo-mode #kiPromptText {
  user-select: none;
}


/* ═══════════════════════════════════════════════════════════
   MOBILE / TOUCH IMPROVEMENTS
   ═══════════════════════════════════════════════════════════ */

button, .bg, .bs, .bp, .nt, .vorb-tab, .notesk-tab, .learn-mode, .tbtn, .dbtn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (max-width: 480px) {
  #lk-cards .crd {
    grid-template-columns: 1fr !important;
  }
  #learnView [onclick*="flipLearnCard"],
  #learnView [onclick*="flipLearn"] {
    min-height: 160px !important;
    padding: 20px !important;
  }
  #vorbContent > div {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
  }
  #learnView [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  #kiFormArea [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  #lkitList [style*="minmax(220px"] {
    grid-template-columns: 1fr !important;
  }
  .math-topic-btn { padding: 14px 8px; }
  .math-topic-icon { font-size: 24px !important; }
  .math-topic-name { font-size: 11px !important; }
  .math-tab { font-size: 10px; padding: 6px 8px; }
  .vorb-tabs {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .vorb-tabs::-webkit-scrollbar { display: none; }
  .math-sub-btn { padding: 10px !important; gap: 10px !important; }
  .math-sub-num { width: 28px !important; height: 28px !important; font-size: 12px !important; }
}

@media (min-width: 481px) and (max-width: 768px) {
  #vorbContent > div {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important;
  }
}


/* ── Fullscreen Mode ── */
#app.fs-mode .top,
#app.fs-mode .nav,
#app.fs-mode .side { display: none !important; }
#app.fs-mode .pages { padding-top: 0 !important; }
#app.fs-mode .pg { min-height: 100vh; padding-top: 16px; }
#app.fs-mode .pg-inner,
#app.fs-mode .org-canvas-wrap { height: calc(100vh - 32px); }

.fs-toggle {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 9990;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--fg-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  opacity: .7;
  box-shadow: var(--shadow-1);
}
.fs-toggle:hover {
  opacity: 1;
  background: var(--bg-2);
  color: var(--fg);
}
#app.fs-mode .fs-toggle {
  opacity: .9;
  background: color-mix(in oklab, var(--err) 15%, var(--bg-1));
  border-color: color-mix(in oklab, var(--err) 30%, var(--line));
  color: var(--err);
}
#app.fs-mode .fs-toggle:hover {
  background: color-mix(in oklab, var(--err) 25%, var(--bg-1));
}

html.demo-mode .fs-toggle { bottom: 60px; }


/* Nav auf kleinen Screens */
@media (max-width: 768px) {
  .nav {
    padding-left: calc(8px + var(--safe-l)) !important;
    padding-right: calc(8px + var(--safe-r)) !important;
  }
  .nt { padding: 8px 10px !important; font-size: 11px !important; }
  .pg { padding: 14px calc(14px + var(--safe-r)) 14px calc(14px + var(--safe-l)) !important; }
  .math-back-btn { min-height: 44px; }
  .learn-mode { min-height: 38px; }
  #kiPromptText { max-height: 200px; }
}


/* ═══════════════════════════════════════════════════════════
   WHITE MODE — Component Overrides
   ═══════════════════════════════════════════════════════════ */

html.white-mode .crd {
  background: var(--bg-1);
  border-color: var(--line);
}
html.white-mode .crd:hover {
  border-color: var(--line-2);
}
html.white-mode .inp,
html.white-mode .inp.ta,
html.white-mode .ki-inp {
  background: var(--bg-1);
  border-color: var(--line);
}
html.white-mode .bp { color: #fff; }
html.white-mode .bg {
  background: var(--bg-1);
  border-color: var(--line);
  color: var(--fg);
}
html.white-mode .bg:hover {
  background: var(--bg-2);
  color: var(--fg);
}
html.white-mode .streak-widget {
  background: var(--bg-1);
}
html.white-mode .l-lbl { color: var(--fg-muted); }
