
:root{--bg:#f6f7fb;--card:#fff;--accent:#0066ff;--muted:#6b7280}
.container{max-width:1000px;margin:2rem auto;padding:0 1rem}
.full-height {
  min-height: 100vh; /* ensure sections stretch to full viewport height on phones */
  display: flex;
  flex-direction: column;
}
.header{display:flex;justify-content:space-between;align-items:center;margin-bottom:1.25rem}
.brand{font-weight:700;font-size:1.25rem;color:var(--accent)}
.topnav{display:flex;gap:0.5rem;align-items:center;flex-wrap:wrap}
.topnav{flex-wrap:wrap}
.brand{display:block}

.header .topnav{display:flex!important;position:relative!important;z-index:50!important;flex-wrap:wrap;align-items:center}
.header .topnav a{display:inline-block!important;color:#0066ff!important;background:transparent!important;font-weight:600!important;padding:0.35rem 0.6rem;border-radius:6px}
.header .topnav a:hover{background:rgba(0,102,255,0.08)!important}
.topnav a{color:var(--accent);text-decoration:none;padding:0.4rem 0.6rem;border-radius:6px}
.topnav a:hover{background:rgba(0,102,255,0.08)}

/* Ensure topnav is always visible and links render as inline blocks */
.topnav{display:flex!important}
.topnav a{display:inline-block!important;color:var(--accent)!important}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:1rem}
.card{background:var(--card);border-radius:10px;box-shadow:0 4px 16px rgba(16,24,40,0.06);overflow:hidden}
.card img{width:100%;height:150px;object-fit:cover;display:block}
.card-body{padding:0.75rem}
.card-body h3{margin:0 0 0.5rem 0;font-size:1rem}
.card-body p{margin:0;color:var(--muted);font-size:0.9rem}
.card-body .meta{margin-top:0.5rem;color:var(--muted);font-size:0.85rem}
.button{display:inline-block;background:var(--accent);color:#fff;padding:0.45rem 0.65rem;border-radius:8px;text-decoration:none}
.reader img{display:block;margin:0 auto 1rem auto;max-width:720px;width:100%}
.form-row{margin-bottom:0.5rem}
.input,textarea{width:100%;padding:0.6rem;border:1px solid #e6e9ef;border-radius:8px}
.footer{margin-top:3rem;color:var(--muted);text-align:center;font-size:0.9rem}

/* Homepage spacing tweaks */
.container h2 { margin-top: 2.25rem; margin-bottom: 0.9rem; font-size: 1.35rem; }
.grid { margin-bottom: 2rem; }
.table{width:100%;border-collapse:collapse;background:var(--card);border-radius:10px;overflow:hidden}
.table th,.table td{padding:0.6rem;border-bottom:1px solid #eee;text-align:left}
.small{font-size:0.85rem;color:var(--muted)}

.form-card {
  max-width: 600px;
  margin: 2rem auto;
  padding: 2rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.form-card label {
  font-weight: bold;
}
.form-card input[type="text"],
.form-card textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 6px;
}
.form-card button {
  background: #1e90ff;
  color: white;
  padding: 0.75rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.form-card button:hover {
  background: #0074d9;
}
.alert.success {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

/* Auth action alignment: left link, right button */
.auth-actions {
  width: 100%;
  max-width: 1000px; /* match page container max width */
  margin: 0.75rem auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between; /* push items to left/right */
  padding: 0 0.5rem; /* small horizontal padding so button isn't flush to viewport */
}
.auth-actions .auth-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
}
.auth-actions .auth-link:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .auth-actions { padding: 0 0.25rem; }
  /* On very small screens, stack vertically to avoid cramped layout */
  .auth-actions { gap: 0.5rem; }
  .auth-actions .button { width: auto; }
}

/* ========== Global Reset & Base Styles ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}
body {
  font-family: "Poppins", sans-serif;
  background-color: #f5f6fa;
  color: #222;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* prevent horizontal scrolling caused by off-canvas elements */
html, body { overflow-x: hidden; }

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* ========== Navbar ========== */
.navbar {
  background: #1e90ff;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  flex-wrap: wrap;
}

.navbar a {
  color: white;
  text-decoration: none;
  margin: 0.5rem;
  font-weight: 500;
}

.navbar a:hover {
  text-decoration: underline;
}

/* ========== Card Layout ========== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
}

.card:hover {
  transform: translateY(-5px);
}

.card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.card-content {
  padding: 1rem;
}

/* ========== Forms ========== */
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
}

button {
  background: #1e90ff;
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover {
  background: #0074d9;
}

/* ========== Alerts ========== */
.alert.success {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

/* ========== Footer ========== */
footer {
  text-align: center;
  background: #1e90ff;
  color: white;
  padding: 1rem;
  margin-top: auto;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px){
  .navbar {
    flex-direction: column;
    align-items: flex-start;
  }

  /* On small screens stack the header so brand sits above the nav */
  .header { flex-direction: column; align-items: flex-start; gap:0.4rem }
  /* Mobile: ensure nav is static and visible under the brand */
  .topnav {
    display:flex;
    position:static;
    top:auto; right:auto; left:auto;
    transform:none;
    transition:none;
    width:100%;
    max-width:none;
    background:transparent;
    border-radius:0;
    padding:0.25rem 0;
    box-shadow:none;
    flex-direction:row; /* side-by-side on mobile */
    gap:0.5rem;
    z-index:auto;
    margin-top:0;
    overflow-x:auto; /* allow horizontal scroll if needed */
    -webkit-overflow-scrolling:touch;
    white-space:nowrap;
  }
  .topnav a{ padding:0.45rem 0.75rem; display:inline-block }

  .topnav.open{ transform: translateX(0); }

  .navbar a {
    margin: 0.25rem 0;
  }

  .form-card {
    padding: 1rem;
  }

  .card img {
    height: 150px;
  }

  body {
    font-size: 0.95rem;
  }

  /* On small screens make the main container fill and reduce horizontal padding */
  .container { margin: 0; padding: 0.75rem 0.5rem; width:100%; }
  /* make header use the full width and remove extra left gap */
  .header { padding: 0 0.25rem; }
  .container > .header { margin-bottom: 0.5rem; }
}

/* Desktop: brand left, menu items extreme right */
@media (min-width: 769px){
  .header{justify-content:space-between;align-items:center}
  /* brand left, menu items on the right */
  .brand{order:0;margin-left:0;margin-right:auto}
  .topnav{order:1;margin-left:auto}
  /* ensure nav is pinned to the right edge on desktop */
  .topnav{position:absolute;right:1rem;top:50%;transform:translateY(-50%);margin-left:0}

  /* center the title a little more while keeping nav at extreme right */
  .header{position:relative}
  /* keep brand static on the left and push nav to the right using flex/margin */
  .brand{position:static;left:auto;top:auto;transform:none;margin:0}
  .topnav{position:static;right:auto;top:auto;transform:none;margin-left:auto}
  .topnav a{margin-left:0.25rem}

  /* Make header span the full viewport so nav can sit at the extreme right edge */
  /* Keep header inside the centered container so nav isn't flush to the browser edges */
  .header{
    position:static;
    left:auto; right:auto;
    margin-left:0; margin-right:0;
    width:100%;
    padding:0; /* use container padding instead */
    box-sizing:border-box;
    background:transparent;
  }
}

@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .navbar {
    padding: 0.5rem;
  }

  button, .topnav a, .navbar a {
    padding: 0.9rem 0.75rem; /* larger tap targets */
    font-size: 1.05rem;
  }

  /* Larger brand title on phones */
  .brand { font-size: 1.5rem; }

  /* Larger webtoon images to feel immersive */
  .card img { height: 260px; }
  .card img[style] { height: auto; max-height: 260px; }
}

/* Hamburger removed: responsive `.topnav` is handled above; no off-canvas drawer or toggle needed. */

/* Reader specific styles */
.reader-shell { background: #000; color: #fff; min-height:100vh; display:flex; flex-direction:column; }
.reader-header { display:flex; justify-content:space-between; align-items:center; padding:0.75rem 1rem; background:rgba(0,0,0,0.6); position:sticky; top:0; z-index:20 }
.reader-header .brand { color:#fff; font-size:1.1rem }
.reader-nav a { color:#fff; text-decoration:none }
.reader-toolbar { display:flex; justify-content:space-between; align-items:center; padding:0.5rem 1rem; background:rgba(0,0,0,0.45); z-index:19 }
.reader-title { font-weight:600 }
.reader-btn { color:#fff; padding:0.4rem 0.6rem; text-decoration:none; border-radius:6px; background:rgba(255,255,255,0.06) }
.reader-btn.disabled { opacity:0.35 }
.reader { flex:1; overflow:auto; display:flex; flex-direction:column; align-items:center; justify-content:flex-start; padding:1rem 0 }
.reader-img { width:100%; max-width:900px; height:auto; margin:0 0 1rem 0; display:block }
.reader-placeholder { color:#bbb; padding:1rem }

/* Hidden header/toolbar */
.reader-header.hidden, .reader-toolbar.hidden { transform:translateY(-110%); transition:transform 200ms ease-in-out; }

/* Admin modal styles */
.admin-modal{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.5);align-items:center;justify-content:center;z-index:9999}
.admin-modal-dialog{background:#fff;border-radius:10px;max-width:1000px;width:95%;max-height:90vh;overflow:auto;box-shadow:0 8px 32px rgba(0,0,0,0.3)}
.admin-modal-header{padding:0.75rem;border-bottom:1px solid #eee;text-align:right}
.admin-modal-body{padding:1rem}

@media (max-width:480px){
  .admin-modal-dialog{width:98%;max-height:95vh}
}

@media (max-width: 480px) {
  .reader-header .brand { font-size:1.2rem }
  .reader-toolbar { padding:0.4rem; }
  .reader-img { margin-bottom:0.5rem }
}
