.title {
  transition: color 0.3s ease;
}

/* Light mode (default) */
@media (prefers-color-scheme: light) {
  :root {
    --study_mode: #f4f4f4;
    --study_card: white;
    --tab-active: #17a2b8;
    --question-list-font: black;
    --tab-content: black;
  }

  .title {
    color: black;
  }
  #main {
    background-color: #f4f6f9;
  }
  .tabs {
    background-color: #dce1e2;
  }
  .tab {
    background-color: #cccece;
    color: black;
  }
  .tab-content {
    color: white;
  }
  #study-mode {
    background-color: var(--study_mode);
  }

  #study-card {
    background-color: var(--study_card);
  }

}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #ffffff;
    --accent: #8b5cf6;
    --border: #333;
    --card-bg: #1e1e1e;
    --transition: 0.3s ease;
    --tabs: #121212;
    --tabs-font-color: gray;
    --tab: white;
    --deck_title: white;
    --deck_background: #2e3030;
    --study_mode: black;
    --study_card: #888989;
    --question-list: #888989;
    --question-list-font: white;
    --tab-content: white;
  }
  .title {
    color: white;

  }

}

/* Responsive tweaks */
@media (max-width: 1600px) {
  nav {
    width: 100%;
    display: flex;
    flex-direction: column;
    margin-top: 1rem;
  }

  nav a {
    margin: 0.5rem 0;
  }
}



* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: background-color var(--transition), color var(--transition), border var(--transition);
}

  body, html {
    background-color: var(--bg);
    color: var(--fg);
    line-height: 1.6;
    /*min-height: 500vh;
    max-height: 500vh;*/
    height: auto;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  }

/  /* Header & Navigation */
header {
  padding: 1rem;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.5rem;
  color: var(--accent);
}

nav a {
  margin-left: 1rem;
  text-decoration: none;
  color: var(--fg);
  font-weight: 500;
  transition: color var(--transition);
}

nav a:hover {
  color: var(--accent);
}

/* Main content */
main {
  flex: 1;
  padding: 1rem;
  background: var(--bg);
}

.page-content {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  max-width: 800px;
  max-height: 500px;
  margin: auto;
}

/* Footer */
footer {
  text-align: center;
  padding: 1rem;
  background-color: var(--card-bg);
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}



  #container {
    display: flex;
    height: 100vh;
    background-color: var(--bg);
  }

  #decks {
    width: 250px;
    background: var(--bg);
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 15px;
  }

  #decks h3 {
    margin-top: 0;
    font-size: 2rem;
    margin-bottom: 10px;
  }

  #add-deck-btn {
    width: 100%;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #0b47b7;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
  }

  #add-deck-btn:hover {
    background-color: #cbd5e0;
  }

  #decks ul {
    list-style: none;
    padding: 0;
    margin: 0;
    color: var(--deck_title);
    background-color: var(--bg);
  }
  
/* Decks lists */

/* Prevent text selection during deck drag */
#decks-list li {
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none;    /* Firefox */
  -ms-user-select: none;     /* IE10+ */
  user-select: none;         /* Standard */
  cursor: grab;
}

.sortable-chosen {
  cursor: grabbing; /* while dragging */
}


/* Visual cue */
#decks-list li,
#decks-list .deck-info {
  cursor: grab;
}
#decks-list li:active,
#decks-list .deck-info:active {
  cursor: grabbing;
}

  #decks li {
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Keeps buttons aligned to top */
    transition: background-color 0.2s;
    background-color: #cacdce;
    color: black;
    display: flex;
    flex-wrap: nowrap;
  }

  #decks li span.deck-name {
    flex: 1;
  }

  #decks li:hover,
  #decks li.active {
    background-color: #007bff;
    color: white;
  }

  .deck-item {
  margin-bottom: 10px;
  padding: 10px;
  background-color: #f7f7f7;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.deck-item:hover {
  background-color: #eaeaea;
}

.deck-name {
  font-weight: bold;
  font-size: 16px;
  line-height: 1.2em;
  word-wrap: break-word;
  white-space: normal;
}

.deck-count {
  font-size: 14px;
  color: #666;
  margin-top: 4px;
}

.deck-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-left: 10px;
  margin: auto;
  flex-shrink: 0; /* Prevents shrinking and keeps spacing */
}

#decks-list li {
  cursor: pointer;
  padding: 10px;
  border-bottom: 1px solid #ddd;
  transition: background-color 0.2s;
  user-select: none;
}

#decks-list li:hover {
  background-color: #17a2b8;
}

#decks-list li.active .deck-count {
  color: lightgray;
}


.deck-info {
  font-size: 14px;
  flex: 1;
  min-width: 0; /* Allows text to wrap instead of overflowing */
}




  #main {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
  }

  .tabs {
    display: flex;
    border-bottom: 1px solid #ccc;
    margin-bottom: 20px;
    background-color: var(--tabs);
    color: var(--tabs-font-color);
  }

  .tab {
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
    border-radius: 6px 6px 0 0;
    margin-right: 8px;
    transition: background-color 0.3s ease;
    background-color: #cccece;
  }

  .tab:hover {
  background-color: #e0e0e0;
  }

  .tab.active {
    background: #17a2b8;
    color: white;
    border: 1px solid #ccc;
    border-bottom: none;
    font-weight: bold;
  }

  .tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: var(--card-bg);
    border: 1px solid #ccc;
    border-radius: 0 0 8px 8px;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--tab-content);
  }

  .study-tab-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%; /* adjust as needed */
  text-align: center;
  gap: 20px;
}

.study-image {
  width: 300px; /* or whatever size looks best */
  height: auto;
  opacity: 1;
}


  #questions-list {
    list-style: none;
    padding: 0;
  }

  #questions-list li {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.card-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.card-line span {
  flex: 1;
  margin-right: 10px;
}

.edit-btn, .delete-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  color: white;
  font-weight: bold;
  cursor: pointer;
}

.edit-btn {
  background-color: #facc15; /* yellow-400 */
  color: black;
}

.delete-btn {
  background-color: #e11d48; /* red-600 */
}


.card-line:last-child {
  margin-bottom: 0;
}

.card-question,
.card-answer {
  flex: 1;
  margin-right: 10px;
  word-break: break-word;
}


  #questions-list li strong {
    display: block;
    margin-bottom: 4px;
  }

  #questions-list button {
    margin-right: 8px;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }



  .edit-btn:hover {
    background-color: #e0a800;
  }

  .delete-btn:hover {
    background-color: #c82333;
  }

/*  .question {
  font-family: 'Segoe UI', sans-serif;
  font-weight: bold;
  font-size: 4rem;
  color: blue;  Customize as needed

  align-items: center;
  text-align: center;
}
.answer {
  font-family: 'Segoe UI', sans-serif;
  margin-top: 10px;
  font-size: 3rem;
  font-weight: lighter;
  color: green; /* Customize as needed
  align-items: center;
  text-align: center;
}
.card-line {
  width: 70%;
  height: 5px;
  background-color: black;
  margin: 20px auto;
  border: none;
}

 .card-content {
  align-items: center;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
} */


 #add-question-form {
  margin-bottom: 20px; /* space below form */
  margin-top: 0; /* remove top margin */
}


  #add-question-form input,
  #add-question-form textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    background-color: var(--question-form);
    color: black;
  }

  #add-question-form button {
    padding: 10px 16px;
    background-color: #17a2b8;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
  }

  #add-question-form button:hover {
    background-color: var(--card-bg);
  }

  #study-now-btn {
    padding: 10px 16px;
    background-color: #17a2b8;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
  }

  #study-now-btn:disabled {
    background-color: #cbd5e0;
    cursor: not-allowed;
  }

  #study-now-btn:hover:not(:disabled) {
    background-color: #138496;
  }

  #study-mode {
    position: fixed;
    width: 100vw;
    height: 100vh;
    background-color: var(--study_mode);
    z-index: 1000;
    display: none;
    flex-direction: column;
  align-items: center;
  justify-content: center;
    overflow: auto;
  }

  #study-card {
    position: sticky;
    display: flex;
    border-radius: 20px;
    background: var(--study_card);
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
    font-size: 1.2rem;
    box-sizing: border-box;
    z-index: 1000;
    flex-direction: column;
    width: 90%;
    height: 80%;
    margin-top: 10px;
}

.study-circles-wrapper {
  /*align-items: center;     center horizontally
  justify-content: center;  center vertically

  display: flex;
  border-radius: 20px;
  background: var(--study_card);
  /*background: none;
  padding: 5px;
  /* margin: 0 auto; Centers horizontally
  text-align: center;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
  font-size: 1.2rem;
  box-sizing: border-box;
  z-index: 1000;
  flex-direction: column;
  width: 90%;
  height: auto;

  overflow-x: auto;
  width: 100%;*/
}

.study-question {
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 500px;
  height: 80%;
  width: 90%;
  margin: 0 auto; /* Centers horizontally */
}

  #study-mode .study-controls {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    width: 80%;
    max-width: 1600px;
    max-height: 800px;
    gap: 15px;
  }

  #study-mode .study-controls button {
    padding: 12px 20px;
    font-size: 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background-color: #007bff;
    color: white;
  }

  #study-mode .study-controls button:hover {
    background-color: var(--card-bg);
  }

  /* Modal background */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
}

/* Modal content */
.modal-content {
  background-color: #fefefe;
  margin: 5px auto 10% auto;
  padding: 30px;
  border: 1px solid #888;
  width: 90%;
  max-width: 400px;
  border-radius: 10px;
  text-align: center;
}

/* Close button */
.close {
  color: #aaa;
  float: right;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover {
  color: #000;
}

.review-buttons {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.review-buttons button {
  flex: 1;
  padding: 10px 15px;
  border: none;
  color: white;
  font-weight: bold;
  border-radius: 6px;
  min-width: 80px;
  cursor: pointer;
  opacity: 1;
  transform: translateY(0);
}

.btn-again {
  background-color: #f44336; /* red */
}

.btn-hard {
  background-color: #ff9800; /* orange */
}

.btn-good {
  background-color: #4caf50; /* green */
}

.btn-easy {
  background-color: #2196f3; /* blue */
}

#reviewChart {
  max-width: 600px;
  max-height: 400px;
}

div.studyContainer {
  width:100%;
  overflow:auto;
}
div.studyContainer div {
  width:30%;
  float:left;
}

.study-complete {
  text-align: center;
  padding: 20px;
  background-color: #f0f8ff;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.study-complete h2 {
  color: #0077cc;
  margin-bottom: 10px;
}

.study-complete button {
  margin: 10px;
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
}

.study-circles {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  margin: 0 auto;

    /* align-items: center;    center horizontally */
    /* justify-content: center;  center vertically */
  /*flex-grow: 1;
  flex-wrap: nowrap;  /* <- Important! Keep them in a row, no wrap */
}

.study-circles .circle {
  width: 100px;
  height: 10px;
  background: #ccc;
  border-radius: 10px;
  transition: all 0.3s ease;
}

/* Default (desktop) */
.circles-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 50px;
  padding: 5px;
  transition: gap 0.3s ease;
}

.circles-container .circle {
  width: 100px;
  height: 10px;
  background: #ccc;
  border-radius: 10px;
  transition: width 0.3s ease, height 0.3s ease, border-radius 0.3s ease;
  align-items: center;
  justify-content: center;
}

/* Responsive: transform to circles smoothly */
@media (max-width: 600px) {
  .circles-container {
    gap: 20px;
    justify-content: center; /* no transition, but usually not a big jump */
  }

  .circles-container .circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
  }


}

/* Close button styles */
#closeBtn {
  background: lightgray;
  border: none;
  font-size: 30px;
  color: white;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-left: 10px;
  flex-shrink: 0;
  transition: color 0.3s ease; /* Smooth hover */
}

#closeBtn:hover {
  color: #111827;
}

#questions-list li.dragging {
  opacity: 0.5;
  background-color: #f0f0f0;
  border: 2px dashed #aaa;
  transition: background-color 0.2s, border 0.2s;
}

#questions-list li:hover {
  background-color: #f9f9f9;
  cursor: move;
}

.dragging {
  opacity: 0.6;
  background-color: rgba(0, 0, 0, 0.05);
}

.drag-over {
  border: 2px dashed #007bff;
  background-color: rgba(0, 123, 255, 0.1);
}

li.selected {
  background-color: #cce5ff;
  border: 1px solid #3399ff;
}

li.dragging {
  opacity: 0.5;
}

#questions-list li.selected {
  background-color: #cce5ff;
}

#questions-list {
  list-style: none;
  padding: 0;
  margin: 0;
  user-select: none; /* prevent text selection */
}

#questions-list li {
  cursor: grab;       /* show drag hand */
  margin-bottom: 6px;
  padding: 8px;
  background: #f9f9f9;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#questions-list li.sortable-ghost {
  opacity: 0.4;
}


/* Disable text selection while dragging */
#decks-list li {
  user-select: none;
  cursor: grab;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  margin-bottom: 6px;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #f9f9f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#decks-list li:active {
  cursor: grabbing;
}

/* Drag handle styling */
.deck-info {
  flex-grow: 1;
  user-select: none;
  -webkit-user-drag: none;
  cursor: grab;
}

/* Optional ghost class for visual feedback */
.sortable-ghost {
  opacity: 0.5;
}

.modal { display: none; position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; }
.modal-content { background: #fff; padding: 20px; border-radius: 8px; max-width: 400px; margin: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-content .close { position: absolute; top: 10px; right: 15px; cursor: pointer; font-size: 20px; }


