:root {
    font-family: system-ui, sans-serif;

    --bg-color: #f8fafc;
    --text-color: #1e1b4b;
    --bg-card: #ffffff;
    --bg-section: #f1f5f9;
    --border-color: #e2e8f0;
    --hover-bg: #e2e8f0;
    --link-color: #4f46e5;
    --input-bg: #ffffff;
    --muted-text: #64748b;
    --secondary-bg: #e2e8f0;
    --secondary-text: #312e81;

    /* Slider-Aliase */
    --slider-track-color: var(--border-color);
    --slider-point-color: var(--muted-text);
    --slider-text-color: var(--text-color);
    --slider-highlight-color: var(--link-color);
    --slider-focus-color: var(--link-color);
    --slider-surface-color: var(--bg-card);
    --slider-label-gap: 10px;
    --slider-track-size: 4px;
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --bg-card: #1e293b;
    --bg-section: #172554;
    --border-color: #334155;
    --hover-bg: #334155;
    --link-color: #818cf8;
    --input-bg: #0f172a;
    --muted-text: #94a3b8;
    --secondary-bg: #334155;
    --secondary-text: #f8fafc;

    /* Slider-Aliase */
    --slider-track-color: var(--border-color);
    --slider-point-color: var(--muted-text);
    --slider-text-color: var(--text-color);
    --slider-highlight-color: var(--link-color);
    --slider-focus-color: var(--link-color);
    --slider-surface-color: var(--bg-card);
}

*{box-sizing:border-box}

body {
  margin: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem max(5vw, 1rem);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.brand {
  font-weight: 800;
  color: var(--link-color);
  text-decoration: none;
}

nav{
    display:flex;
    gap:.8rem;
    flex:1;
    flex-wrap:wrap
}

nav a {
  color: var(--text-color);
  text-decoration: none;
}

main{
    max-width:1100px;
    margin:2rem auto;
    padding:0 1rem
}

h1{
    font-size:2rem
}

.narrow{
    max-width:500px;
    margin:4rem auto
}
    
.stack{
    display:grid;
    gap:1rem
}

label{
    display:grid;
    gap:.35rem;
    font-weight:600
}

input, select, textarea {
  font: inherit;
  padding: .65rem;
  border: 1px solid var(--border-color);
  background-color: var(--input-bg);
  color: var(--text-color);
  border-radius: .5rem;
}

textarea{
    min-height:5rem
}

button, .button {
  border: 0;
  border-radius: .5rem;
  padding: .65rem 1rem;
  background: var(--link-color);
  color: white;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.secondary, .quiet {
  background: var(--secondary-bg);
  color: var(--secondary-text);
}

.quiet{
    margin-left:auto
}

.split{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:2rem
}

.metrics{
    display:grid;
    grid-template-columns:repeat(3,1fr);
    gap:1rem;
    margin:1.5rem 0
}

.metrics article, .card, section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: .75rem;
  padding: 1rem;
}

.metrics strong{
    display:block;
    font-size:2rem
}

.metrics span, .muted {
  color: var(--muted-text);
}

.card{
    margin:.6rem 0
}

.inline{
    display:inline;
    margin-left:.5rem
}

.badge{
    font-size:.7rem;
    padding:.2rem .4rem;
    background:#ede9fe;
    color:#5b21b6;
    border-radius:.3rem
}

.study{
    max-width:700px;
    margin:2rem auto;
    text-align:center
}

.question{
    font-size:2.4rem;
    padding:3rem 1rem
}

.answer{
    font-size:1.5rem
}

.notice{
    padding:1rem;
    border-radius:.6rem;
    margin-bottom:1rem
}

.notice.error{
    background:#fef2f2;
    color:#991b1b;
    border:1px solid #fecaca
}

.qr{
    display:block;
    width:220px;
    max-width:100%;
    margin:1rem auto
}

.recovery {
  padding: 1rem;
  background: var(--bg-section);
  border-radius: .5rem;
  font-size: 1.1rem;
  line-height: 1.8;
}

.study details{
    text-align:left;
    margin:.6rem
}

.ratings{
    display:flex;
    gap:.5rem;
    justify-content:center;
    margin-top:2rem;
    flex-wrap:wrap
}

.again{
    background:#dc2626
}

.ratings button[value=hard]{
    background:#d97706
}

.ratings button[value=good]{
    background:#16a34a
}

.ratings button[value=easy]{
    background:#0284c7
}

.impersonation{
    background:#7f1d1d;
    color:#fff;
    padding:.5rem 1rem;
    display:flex;
    justify-content:center;
    gap:1rem;
    align-items:center
}

.impersonation button{
    background:#fff;
    color:#7f1d1d;
    padding:.25rem .5rem
}

.empty{
    text-align:center
}

.modes a, .login .back {
  color: var(--link-color);
}

.login-step{
    display:grid;
    gap:1rem
}

.login-step[hidden]{
    display:none
}

.login .back{
    justify-self:start;
    background:transparent;
    color:#4338ca;
    padding:0
}

.login input,.login select{
    font-size:1.05rem
}

@media(max-width:700px){
    header{align-items:flex-start;
        flex-wrap:wrap
    }
    
    .split,.metrics{
        grid-template-columns:1fr
    }
    
    .question{
        font-size:1.8rem
    }
}




/* =========================================================
   RESPONSIVE: FÄCHER & SETS
   ========================================================= */

@media (max-width: 768px) {

  /* Zwei Spalten -> eine Spalte */
  .view-decks .split,
  .view-cards .split {
    grid-template-columns: 1fr !important;
    display: grid;
    gap: 1rem;
  }

  /* Sektionen kompakter */
  .view-decks .split > section,
  .view-cards .split > section {
    min-width: 0;
    box-sizing: border-box;
  }


  /* -------------------------------------------------------
     FÄCHER
     ------------------------------------------------------- */

  .view-decks .deck-subject-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  .view-decks .deck-subject-info {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .view-decks .deck-subject-info strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .view-decks .subject-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem !important;
    width: 100%;
  }

  .view-decks .subject-actions button,
  .view-decks .subject-actions form,
  .view-decks .subject-actions form button {
    width: 100%;
    box-sizing: border-box;
  }


  /* -------------------------------------------------------
     SETS
     ------------------------------------------------------- */

  .view-decks .deck-row {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem;
  }

  .view-decks .deck-row > div:first-child {
    min-width: 0;
  }

  .view-decks .deck-row > div:first-child p {
    margin-bottom: 0;
  }

  .view-decks .deck-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem !important;
    width: 100%;
    align-items: stretch !important;
  }

  .view-decks .deck-actions form {
    margin-top: 0 !important;
    width: 100%;
  }

  .view-decks .deck-actions button {
    width: 100%;
    box-sizing: border-box;
  }


  /* -------------------------------------------------------
     FORMULARE
     ------------------------------------------------------- */

  .view-decks .stack input,
  .view-decks .stack textarea,
  .view-decks .stack select,
  .view-decks .stack .subject-dropdown {
    width: 100%;
    box-sizing: border-box;
  }

  .view-decks .subject-dropdown-menu {
    max-width: 100%;
    box-sizing: border-box;
  }


  /* -------------------------------------------------------
     KARTEN: FILTER
     ------------------------------------------------------- */

  .view-cards #card-filter-form {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 0.75rem !important;
    align-items: stretch !important;
  }

  .view-cards #card-filter-form > label {
    width: 100%;
    min-width: 0 !important;
    min-height: auto !important;
    box-sizing: border-box;
  }

  .view-cards #card-filter-form input,
  .view-cards #card-filter-form select,
  .view-cards #card-filter-form details {
    width: 100%;
    box-sizing: border-box;
  }

  .view-cards #card-filter-form > a {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
  }

  .view-cards #cardFilter-deck-dropdown {
    width: 100% !important;
  }

  .view-cards #cardFilter-deck-dropdown .subject-dropdown-menu {
    position: static;
    width: 100% !important;
    max-height: 300px;
    overflow-y: auto;
  }


  /* -------------------------------------------------------
     KARTEN: TOOLBAR
     ------------------------------------------------------- */

  .view-cards .cards-toolbar {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 0.5rem !important;
    align-items: stretch !important;
  }

  .view-cards .cards-toolbar label {
    width: 100%;
  }

  .view-cards .cards-toolbar button {
    width: 100%;
  }


  /* -------------------------------------------------------
     KARTEN: SET-DROPDOWNS
     ------------------------------------------------------- */

  .view-cards .subject-dropdown {
    width: 100% !important;
    box-sizing: border-box;
  }

  .view-cards .subject-dropdown summary {
    width: 100% !important;
    box-sizing: border-box;
    min-height: 42px;
  }

  .view-cards .subject-dropdown-menu {
    position: static;
    width: 100% !important;
    max-width: 100%;
    max-height: 300px;
    overflow-y: auto;
    box-sizing: border-box;
  }


  /* -------------------------------------------------------
     DIALOGE / MODALS
     ------------------------------------------------------- */

  .view-decks dialog,
  .view-cards dialog {
    width: calc(100vw - 1rem) !important;
    max-width: calc(100vw - 1rem) !important;
    max-height: calc(100vh - 1rem);
    margin: 0.5rem;
    box-sizing: border-box;
    overflow-y: auto;
  }

  .view-decks dialog form,
  .view-cards dialog form {
    min-width: 0;
  }

  .view-decks dialog input,
  .view-decks dialog select,
  .view-decks dialog textarea,
  .view-cards dialog input,
  .view-cards dialog select,
  .view-cards dialog textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Buttons am Dialog-Boden untereinander */
  .view-decks dialog .modal-actions,
  .view-cards dialog .modal-actions {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 0.5rem !important;
  }

  .view-decks dialog .modal-actions button,
  .view-cards dialog .modal-actions button {
    width: 100%;
  }

}


/* =========================================================
   SEHR KLEINE GERÄTE
   ========================================================= */

@media (max-width: 480px) {

  .view-decks .subject-actions,
  .view-decks .deck-actions {
    grid-template-columns: 1fr;
  }

  .view-decks h1,
  .view-cards h1 {
    font-size: 1.5rem;
  }

  .view-decks h2,
  .view-cards h2 {
    font-size: 1.2rem;
  }

  .view-decks section,
  .view-cards section {
    padding: 0.7rem;
  }

}

/* =========================================================
   SMTP KONFIGURATION
   ========================================================= */

.smtp-section {
  min-width: 0;
}

.smtp-preset {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.smtp-preset label {
  flex-shrink: 0;
}

.smtp-preset select {
  min-width: 220px;
}

.smtp-form {
  min-width: 0;
}

.smtp-form input,
.smtp-form select {
  max-width: 100%;
  box-sizing: border-box;
}

.smtp-port-row {
  display: flex;
  gap: 1rem;
}

.smtp-port-row > label {
  flex: 1;
  min-width: 0;
}

.smtp-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 768px) {

  .smtp-section {
    padding: 0.75rem;
  }

  .smtp-section h2 {
    font-size: 1.25rem;
    line-height: 1.3;
  }

  .smtp-section p {
    line-height: 1.5;
  }

  /* Anbieter-Auswahl untereinander */
  .smtp-preset {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .smtp-preset select {
    width: 100%;
    min-width: 0;
  }

  /* Port + Verschlüsselung untereinander */
  .smtp-port-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .smtp-port-row > label {
    width: 100%;
  }

  /* Alle Felder volle Breite */
  .smtp-form input,
  .smtp-form select {
    width: 100%;
    min-width: 0;
  }

  /* Buttons untereinander */
  .smtp-actions {
    flex-direction: column;
    gap: 0.6rem;
  }

  .smtp-actions button {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
  }
}


@media (max-width: 480px) {

  .smtp-section {
    padding: 0.65rem;
  }

  .smtp-section h2 {
    font-size: 1.15rem;
  }

  .smtp-actions {
    margin-top: 0.75rem;
  }

}

/* Globale Scrollbar für den Darkmode */
[data-theme="dark"] * {
    scrollbar-width: thin;
    scrollbar-color: #4b5563 #1f2937;
}

[data-theme="dark"] *::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

[data-theme="dark"] *::-webkit-scrollbar-track {
    background: #1f2937;
    border-radius: 4px;
}

[data-theme="dark"] *::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 4px;
}

[data-theme="dark"] *::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}