/* =========================================================
THEME VARIABLES
========================================================= */

:root[data-theme="dark"] {
  --bg: #1e1e1e;
  --panel: #242424;
  --text: #e4e4e4;
  --muted: #9a9a9a;
  --accent: #7aa2f7;
  --border: #2f2f2f;
  --warning: #f7b267;
}

:root[data-theme="light"] {
  --bg: #f4f0e6;
  --panel: #fbf7ee;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --accent: #3d66b3;
  --border: #e1dbc8;
  --warning: #f7b267;
}

/* =========================================================
BASE
========================================================= */

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto;
  line-height: 1.7;
}

main {
  flex: 1;
  max-width: 760px;
  margin: auto;
  padding: 30px 20px;
  width: 100%;
}

h1,
h2 {
  margin-top: 0;
}

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

a:hover {
  text-decoration: underline;
}

/* =========================================================
TOPBAR
========================================================= */


.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding: 20px 20px;
}

/* left group: title + breadcrumbs */

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

/* right group: search + theme */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* =========================================================
SITE TITLE
========================================================= */

.site-title {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.site-title.active {
  color: var(--text);
}

/* =========================================================
BREADCRUMBS
========================================================= */

.breadcrumb {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  font-size: .9rem;
}

/* separator element */

.breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  margin-right: 8px;
  opacity: .6;
}

.breadcrumb-sep-root {
  opacity: .6;
  margin: 0 6px;
  flex: 0 0 auto;
}

/* default behaviour */

.breadcrumb-item {
  display: block;
  white-space: nowrap;
}

/* links */

.breadcrumb a {
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--text);
}

.breadcrumb-current {
  color: var(--text);
}

.breadcrumb-item.series-breadcrumb {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-item.chapter-breadcrumb {
  flex: 0 0 auto;
}

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

@media (max-width: 1000px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  /* first row: title */

  .topbar-left {
    order: 1;
  }

  /* second row: search + theme */

  .topbar-right {
    order: 2;
    justify-content: space-between;
  }

  /* third row: breadcrumbs */

  .breadcrumb {
    order: 3;
    max-width: 100%;
  }

  .breadcrumb a,
  .breadcrumb-current {
    max-width: 100%;
  }

}

/* =========================================================
SEARCH
========================================================= */

.search-container {
  position: relative;
}

.series-search {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;

  width: 100%;
}

@media (max-width: 1000px) {
  .search-container {
    flex: 1;
    min-width: 0;
  }

  .series-search {
    width: 100%;
  }
}

.series-search::placeholder {
  color: var(--muted);
}

.series-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.search-dropdown {
  position: absolute;
  top: 38px;
  right: 0;
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: none;
  overflow: hidden;
  z-index: 50;
}

.search-result {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover {
  background: var(--bg);
}

.result-title {
  color: var(--text);
  font-size: .9rem;
}

.result-author {
  color: var(--muted);
  font-size: .8rem;
  margin-top: 2px;
}

/* =========================================================
THEME SWITCH
========================================================= */

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle svg {
  display: none;
}

[data-theme="light"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: block;
}

.icon-sun circle { fill: #facc15; }
.icon-sun { stroke: #f59e0b; }

.icon-moon { fill: #e5e7eb; stroke: #cbd5f5; }

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text);
}

/* =========================================================
SERIES LIST
========================================================= */

.series-grid {
  display: grid;
  gap: 18px;
}

.series-card {
  background: var(--panel);
  padding: 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
  color: var(--text);
}

.series-card h2 {
  margin-bottom: 6px;
}

.series-card p {
  color: var(--text);
}

.series-card .author {
  color: var(--muted);
}

.series-card:hover {
  border-color: var(--text);
  text-decoration: none;
}

.series-updated {
  margin-top: 6px;
  font-size: .8rem;
  color: var(--muted);
}

.series-jp {
  font-size: .85rem;
  color: var(--muted);
  margin-top: 2px;
}

.series-description.clamp {
  margin-top: 6px;
  font-size: .95rem;
  color: var(--text);

  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;

  overflow: hidden;
  text-overflow: ellipsis;
}

.series-description p {
  margin: 0;
}

/* =========================================================
SERIES PAGE
========================================================= */

.author {
  color: var(--muted);
  font-size: .9rem;
}

.back-home {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: .95rem;
}

.back-home:hover {
  color: var(--text);
}

/* =========================================================
CHAPTER PAGE
========================================================= */

.chapter {
  margin-top: 30px;
}

.chapter p {
  margin: 1.3em 0;
}

.chapter-nav {
  display: flex;
  margin-top: 40px;
  padding-top: 20px;
  gap: 20px;
}

.chapter-nav a {
  flex: 1 1 50%;
  min-width: 0;
}

.chapter-nav a:first-child {
  text-align: left;
}

.chapter-nav a:last-child {
  text-align: right;
}

.back {
  display: inline-block;
  margin-bottom: 20px;
  color: var(--muted);
}

.translation-warning {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: .9rem;
  color: var(--muted);
}

/* =========================================================
CHAPTER SELECTOR
========================================================= */

.chapter-dropdown {
  margin-top: 20px;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chapter-dropdown label {
  font-size: .85rem;
  color: var(--muted);
}

.chapter-dropdown select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: .9rem;
}

.chapter-dropdown select:invalid {
  color: var(--muted);
}

/* =========================================================
CONTENT ELEMENTS
========================================================= */

.illustration {
  display: block;
  margin: 30px auto;
  max-width: 100%;
  border-radius: 6px;
}

/* =========================================================
TRANSLATION NOTES
========================================================= */

.tn {
  color: var(--muted);
  font-size: .9em;
  font-style: italic;
  border-bottom: 1px dotted var(--muted);
  cursor: help;
}

.tn::before {
  content: "[T/N: ";
  opacity: .7;
}

.tn::after {
  content: "]";
  opacity: .7;
}

/* =========================================================
FOOTER
========================================================= */

.footer {
  margin-top: auto;
  padding: 30px 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}

.footer a {
  color: var(--muted);
}

.footer a:hover {
  color: var(--text);
}

.footer-sep {
  margin: 0 8px;
  color: var(--muted);
}

/* =========================================================
DMCA PAGE
========================================================= */

.dmca-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 30px;
  align-items: start;
}

.dmca-separator {
  width: 1px;
  background: var(--border);
}

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

  .dmca-separator {
    display: none;
  }
}
