:root{
  --accent:#b48415;
  --bg:#fafafa;
  --text:#222;
  --boxShadow: rgba(0,0,0,.05);
  --navhover:#fa425a;
  --navbg: #ffe0b27c;
}
*{
  box-sizing:border-box;
  margin:0;
  padding:0;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
}
body{
  background:var(--bg);
  color:var(--text);
  line-height:1.6;
}
.back {
    position: fixed;
    background:var(--bg);
    color:var(--text);
    padding: 5px;
    border: 0.3px solid var(--accent);
    border-radius: 5px;
    right: 20px;
    top: 10px; /* Adjusted position for better visibility */
    z-index: 10;
    transition: transform 0.2s;
}
.back:active {
    transform: scale(0.95);
}

/* === NAVIGATION STYLES ENHANCEMENT START === */
header{
  /* Removed height: 70px; to allow content to dictate height */
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 24px; /* Adjusted padding to match navbar */
  background:#fff;
  box-shadow:0 2px 4px var(--boxShadow);
  min-height: 70px; /* Ensure minimum height */
  position: sticky; /* Keep the header visible when scrolling */
  top: 0;
  z-index: 10; /* Ensure it stays on top */
}

.logo{
  font-size:1.4rem;
  font-weight:700;
  color:var(--accent);
  flex-shrink: 0; /* Prevents logo from shrinking on smaller screens */
}

li {
  list-style-type: none;
}

a {
  color: var(--text); /* Changed link color for better contrast */
  text-decoration: none;
  font-weight: 500;
}

.navbar {
  /* Removed fixed positioning attributes and gap to rely on header flex layout */
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0; /* Padding is now in header */
  width: 100%; /* Make navbar fill header width */
  position: static;
  z-index: 2;
}

.nav-menu {
  display: flex;
  justify-content: flex-end; /* Align menu to the right */
  align-items: center;
  gap: 40px; /* Reduced gap for better fit, 80px was very large */
  margin-left: auto; /* Push menu to the right */
}

.nav-link {
  transition:all 0.3s ease;
  padding: 8px 12px; /* Add padding for better hover/click area */
  border-radius: 5px;
  color: var(--text); /* Base color */
}

.nav-link:hover {
  color: var(--navhover);
  background-color: var(--navbg);
  padding: 8px 12px; /* Keep padding consistent */
}

.hamburger {
  display: none;
  cursor: pointer;
}

.bar {
  display: block;
  width: 25px;
  height: 3px;
  margin: 5px auto;
  -webkit-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  background-color: var(--accent);
}

@media (max-width:768px) {
  .hamburger {
    display: block;
    z-index: 11; /* Higher z-index to be over nav-menu */
  }

  .hamburger.active .bar:nth-child(2) {
    opacity: 0;
  }
  .hamburger.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }
  .hamburger.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }

  .nav-menu {
    position: fixed;
    left: -100%;
    top: 70px; /* Ensure it starts below the fixed header */
    gap: 0;
    flex-direction: column;
    background-color: var(--bg);
    width: 100%;
    text-align: center;
    transition: 0.3s;
    z-index: 9; /* Below the header (z-index 10) */
    padding: 20px 0; /* Add vertical padding for better look */
    box-shadow: 0 4px 6px var(--boxShadow);
  }

  .nav-item {
    margin: 10px 0; /* Reduced margin */
  }

  .nav-menu.active {
    left: 0;
  }
  
  .nav-link {
    color: var(--text);
  }
  
  .auth-buttons {
    display: flex; /* Display buttons side by side on mobile */
    justify-content: center;
    gap: 10px;
  }
}

.auth-buttons button{
  margin-left:.5rem;
  padding:.5rem 1rem;
  border:none;
  background:var(--accent);
  color:#fff;
  border-radius:4px;
  cursor:pointer;
}

.books {
  padding: 5px;
  border:1px solid #ddd;
  border-radius:4px;
  font-size: 18px;
  background-color: var(--bg);
}

.books a {
  text-decoration: none;
  color: var(--accent);
}

@media (max-width: 768px) {
    header {
    flex-direction: row; /* Keep elements in a row on mobile header */
    justify-content: space-between;
    padding:1rem 0.5rem;
    min-height: 70px;
  }

  .auth-buttons button {
        background: none;
        color:var(--accent);
        margin: 0;
    }
}

/* === NAVIGATION STYLES ENHANCEMENT END === */

.filter-btn {
  border: 0.5px solid rgb(208, 208, 208);
  background: none;
  padding: 8px;
  border-radius: 5px;
  cursor: pointer;
}

.filter-btn:active {
  border: 0.5px solid rgb(218, 251, 224);
}

.card-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(260px,1fr));
  gap:1.5rem;
  padding:2rem;
}
.card{
  background:#fff;
  border-radius:8px;
  padding:1.2rem;
  box-shadow:0 2px 6px rgba(0,0,0,.06);
  cursor:pointer;
  position:relative;
}
.card h3{
  font-size:1.1rem;
  margin-bottom:.5rem;
}
.card p{
  font-size:.9rem;
  color:#555;
}
.star{
  position:absolute;
  top:.8rem;
  right:.8rem;
  font-size:1.4rem;
  color:#ccc;
  cursor:pointer;
  user-select:none;
}
.star.on{
  color:var(--accent);
}

/* modal */
.modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 1000;
}
/* --- Modal Background (Full Screen Overlay) --- */
.modal {
    /* Anchors the modal to the viewport, regardless of scrolling */
    position: fixed; 
    z-index: 1000; /* Ensure it is above all other content */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scrolling if content is too large (unlikely here) */
    background-color: rgba(0,0,0,0.4); /* Dark semi-transparent background */
    display: flex; /* Use flexbox to easily center the content */
    justify-content: center;
    align-items: center;
}

/* Hide the modal when the 'hidden' class is present */
.modal.hidden {
    display: none; 
}

/* --- Modal Content (The box with the form) --- */
.modal-content {
    background-color: #fefefe;
    padding: 20px;
    border: 1px solid #888;
    /* Set a maximum width so it doesn't span the whole screen */
    max-width: 90%;
    width: 400px; 
    border-radius: 8px;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
    animation: fadeIn 0.5s; /* Optional: adds a nice fading animation */
}

@keyframes fadeIn {
    from {opacity: 0;}
    to {opacity: 1;}
}

.modal-content h2{
  margin-bottom:1rem;
}
.modal-content input{
  width:100%;
  padding:.6rem;
  margin-bottom:.8rem;
  border:1px solid #ddd;
  border-radius:4px;
}
.modal-content button[type="submit"]{
  width:100%;
  padding:.7rem;
  border:none;
  background:var(--accent);
  color:#fff;
  border-radius:4px;
  cursor:pointer;
}
.switch{
  text-align:center;
  margin-top:1rem;
  cursor:pointer;
  color:#555;
}
.close{
  position:absolute;
  top:.8rem;
  right:1rem;
  font-size:1.4rem;
  cursor:pointer;
}
.hidden{
  display:none;
}

footer {
    height: 150px;
    background-color: #b48415;
    color: #fafafa;
    text-align: center;
    font-size: 24px;
}
.social-links {
  margin-top: 10px;
  padding: 10px 0 0 0;
}

.social-links a {
  color: #fcfcfc;
  font-size: 1.5rem;
  margin: 0 8px;
  transition: color 0.3s, transform 0.3s;
}

.social-links a:hover {
  color: #afb0ff; /* soft pink glow */
  transform: scale(1.2);
}
.footertext {
    font-size: 18px;
    padding-top: 20px;
}






/* --- Detail Page Specific Styles (Enhanced Responsiveness) --- */

.player-section {
    padding: 20px;
    max-width: 800px;
    margin: 60px auto 40px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    min-height: calc(100vh - 100px); /* Ensure it takes up enough space on desktop */
}

@media (max-width: 768px) {
  .player-section{
    margin: 0;
    padding: 15px; /* Slight increase in padding for mobile */
    border-radius: 0;
    box-shadow: none; /* Less formal look on mobile */
    min-height: auto;
  }

  /* Improve font size on mobile */
  .player-section h1 {
    font-size: 1.5rem;
  }
  .player-section p {
    font-size: 1rem;
  }

  /* Make audio player controls more compact if needed, though default is usually fine */
  #audioPlayer {
    margin-bottom: 1rem;
  }
}

.player-section h1 {
    font-size: 2rem;
    color: var(--text);
    margin-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 5px;
}

.player-section p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 1.5rem;
}

#audioPlayer {
    width: 100%;
    margin-bottom: 1.5rem;
}

/* Responsive Controls Section - buttons grow to fill space */
.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 10px; /* Space between buttons */
}

.controls button {
    padding: 10px 15px;
    border: none;
    background: var(--accent);
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-weight: bold;
    flex-grow: 1; /* Makes buttons share space equally */
    min-width: 45%; 
}

.controls button:hover {
    background: #e04b4b;
}

.controls button:active {
    transform: scale(0.98);
}


/* Transcript and Grammar Section (details/summary) */
details {
    margin-top: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0;
    background: #f9f9f9;
}

details[open] {
    border-color: var(--accent);
    box-shadow: 0 0 5px rgba(255, 95, 95, 0.2);
}

summary {
    font-weight: bold;
    font-size: 1.2rem;
    padding: 15px; /* Increased padding for better tap target */
    background: #eee;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    color: var(--text);
    transition: background 0.2s;
}

summary:hover {
    background: #e5e5e5;
}

summary::marker {
    color: var(--accent);
}

/* Preformatted Text (Transcript/Grammar content) */
pre {
    white-space: pre-wrap;
    font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
    font-size: 1.05rem;
    line-height: 1.8;
    padding: 15px;
    margin: 0;
    color: #333;
}

/* Mobile-specific adjustments for text content */
@media (max-width: 768px) {
    pre {
        font-size: 18px; /* Slightly smaller font on very small screens */
        line-height: 1.7;
        padding: 0;
    }
    summary {
        font-size: 1.1rem;
    }
}


/* --- LIVE TRANSCRIPT HIGHLIGHT (NEW) --- */
.transcript-line-container {
    padding: 8px 5px; /* Base padding for tap target and separation */
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 5px;
}
.transcript-line-container:hover {
    background-color: #f0f0f0;
}

.ko-line {
    font-weight: bold;
    color: var(--text);
    display: block;
    margin-bottom: 2px;
}

.my-line {
    font-style: italic;
    color: #555;
    display: block;
    font-size: 0.95em;
}

.current-line {
    background-color: #ffe8e8; /* Light pink/red background for highlight */
    border-left: 5px solid var(--accent);
    padding-left: 10px;
}

/* --- Custom Alert Modal Styles --- */
.modal-content-alert {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    text-align: center;
}

#alertMessage {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--text);
}

#alertCloseBtn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

#alertCloseBtn:hover {
    background: #e04b4b;
}


 /* ---- flash-cards ONLY styles ---- */
    .fc-grid {
      display: grid;
      gap: 1.2rem;
      grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      padding: 2rem;
      max-width: 1200px;
      margin: auto;
    }
    .fc-card {
      aspect-ratio: 3/2;
      perspective: 1000px;
      cursor: pointer;
    }
    .fc-inner {
      position: relative;
      width: 100%;
      height: 100%;
      transition: transform .6s;
      transform-style: preserve-3d;
    }
    .fc-card.flip .fc-inner {
      transform: rotateY(180deg);
    }
    .fc-face {
      position: absolute;
      inset: 0;
      backface-visibility: hidden;
      border-radius: 12px;
      box-shadow: 0 4px 12px rgba(0,0,0,.15);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1.2rem;
      text-align: center;
      font-size: 1.1rem;
      line-height: 1.45;
    }
    .fc-front {
      background: #ffffff;
      color: #111;
    }
    .fc-back {
      background: #ffe4e1;
      color: #222;
      transform: rotateY(180deg);
      /* === FLASHCARD OVERFLOW FIX START === */
      overflow: hidden; /* Hide scrollbar for a cleaner look */
      display: block; /* Change from flex to block for standard text flow */
      text-align: center; /* Align text to the left */
      padding: 20px; /* Adjust padding for block content */
      white-space: pre-wrap; /* Ensure text wraps correctly */
      /* Add overflow-y: auto; for accessibility, but hide scrollbar */
      max-height: 100%;
    }
    
    .fc-back:hover {
        overflow-y: auto; /* Show scrollbar on hover if content is clipped */
    }
    
    /* Custom scrollbar styles to hide it (Webkit) */
    .fc-back::-webkit-scrollbar {
        width: 0;
        height: 0;
    }
    /* === FLASHCARD OVERFLOW FIX END === */

    /* small tweak for your navbar */
    .navbar { z-index: 10; }


    .modal-footer-links {
  text-align: center;
  margin-top: 12px;
  font-size: 0.9rem;
}

.modal-footer-links p {
  margin: 4px 0;
}

.modal-footer-links b {
  color: #b48415;
  cursor: pointer;
}
