/* ── Custom Properties ─────────────────────────────────────────────────────── */
:root {
  --teal-dark:  #003547;
  --teal-mid:   #005E54;
  --yellow:     #C2BB00;
  --red:        #E1523D;
  --orange:     #ED8B16;

  --bg:         #f5f4f0;
  --card-bg:    #ffffff;
  --text:       #1a1a1a;
  --text-muted: #6b6560;
  --border:     #e0ddd8;

  --radius:     8px;
  --radius-sm:  4px;
  --shadow:     0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg:  0 8px 28px rgba(0, 0, 0, 0.16);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font: inherit; }
select, input { font: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ── Base ──────────────────────────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
header {
  background: var(--teal-dark);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo { display: flex; flex-direction: column; gap: 1px; }
.logo-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1;
  color: white;
}
.logo-sub {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.lang-toggle {
  padding: 0.3rem 0.65rem;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.lang-toggle:hover {
  border-color: white;
  color: white;
  background: rgba(255, 255, 255, 0.08);
}
.view-toggle { display: flex; gap: 2px; }
.view-btn {
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.view-btn svg { width: 20px; height: 20px; }
.view-btn:hover { color: white; background: rgba(255, 255, 255, 0.08); }
.view-btn.active { color: white; background: rgba(255, 255, 255, 0.12); }

/* ── Main ──────────────────────────────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
  width: 100%;
}

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  align-items: center;
}
.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}
.chip {
  padding: 0.3rem 0.8rem;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  background: transparent;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--teal-dark); color: var(--teal-dark); }
.chip.active {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  color: white;
}
.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.filter-controls select {
  padding: 0.38rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text);
  background: white;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.75rem;
}
.filter-controls select:focus { outline: none; border-color: var(--teal-mid); }
.search-wrap { position: relative; }
.search-wrap input {
  padding: 0.38rem 0.75rem 0.38rem 2rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  width: 220px;
  transition: border-color 0.15s, width 0.2s;
  background-color: white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.5rem center;
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--teal-mid);
  width: 260px;
}
.search-wrap input::-webkit-search-cancel-button { cursor: pointer; }

/* ── Results bar ───────────────────────────────────────────────────────────── */
.results-bar {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding: 0 0.1rem;
}

/* ── Grid view ─────────────────────────────────────────────────────────────── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 1.25rem;
}
.book-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 2 / 3;
  background: var(--teal-dark);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.book-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}
.book-card:focus { outline: none; }
.book-card:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}
.book-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 3rem 0.75rem 0.85rem;
  background: linear-gradient(transparent, rgba(0, 25, 35, 0.94) 45%);
  color: white;
}
.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.45rem;
}
.card-title {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.2rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-author {
  font-size: 0.74rem;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── List view ─────────────────────────────────────────────────────────────── */
.book-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.book-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.book-row:hover { border-color: var(--teal-mid); box-shadow: var(--shadow); }
.book-row:focus { outline: none; }
.book-row:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.row-cover {
  width: 44px;
  height: 66px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--teal-dark);
}
.row-info { flex: 1; min-width: 0; }
.row-title {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-author {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.row-stars { display: flex; gap: 1px; }
.row-stars .star { font-size: 0.8rem; color: var(--border); }
.row-stars .star.filled { color: var(--orange); }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 100px;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-bought    { background: var(--orange);   color: white; }
.badge-reading   { background: var(--yellow);   color: #2d2800; }
.badge-finished  { background: var(--teal-mid); color: white; }
.badge-abandoned { background: var(--red);      color: white; }
.badge-type {
  background: rgba(255, 255, 255, 0.18);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.28);
}
/* Override badge-type when inside a list row (dark overlay not present) */
.book-row .badge-type {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 5rem 2rem;
  font-size: 0.95rem;
  font-style: italic;
}

/* ── Modal overlay ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  max-width: 780px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  animation: slideUp 0.18s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background 0.15s;
}
.modal-close:hover { background: rgba(0, 0, 0, 0.16); }

.modal-body {
  display: grid;
  grid-template-columns: 200px 1fr;
}
.modal-cover-wrap {
  background: var(--teal-dark);
  border-radius: var(--radius) 0 0 var(--radius);
  overflow: hidden;
  min-height: 300px;
}
.modal-cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.modal-details { padding: 1.75rem 1.5rem; overflow: hidden; }
.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--teal-dark);
  margin-bottom: 1rem;
  padding-right: 2rem;
}
.modal-meta {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  margin-bottom: 0.5rem;
}
.modal-meta th,
.modal-meta td {
  padding: 0.32rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.modal-meta th {
  color: var(--text-muted);
  font-weight: 600;
  width: 38%;
  white-space: nowrap;
  padding-right: 0.75rem;
}
.modal-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.modal-section h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.modal-section p {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
}
.modal-rating { display: flex; gap: 2px; margin-bottom: 0.4rem; }
.modal-rating .star { font-size: 1.15rem; color: var(--border); }
.modal-rating .star.filled { color: var(--orange); }
.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tag {
  padding: 0.2rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* ── Logo Japanese subtitle ───────────────────────────────────────────────── */
.logo-jp {
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  opacity: 0.5;
  margin-left: 0.4rem;
}

/* ── Info / About button ───────────────────────────────────────────────────── */
.info-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.45);
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.info-btn:hover { color: white; background: rgba(255, 255, 255, 0.08); }
.info-btn:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ── About modal ───────────────────────────────────────────────────────────── */
.about-modal { max-width: 520px; }
.about-content { padding: 2rem 2rem 1.75rem; }
.about-content h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--teal-dark);
  margin-bottom: 0.25rem;
}
.about-jp {
  display: block;
  font-size: 2rem;
  color: var(--teal-mid);
  opacity: 0.6;
  letter-spacing: 0.1em;
  margin-bottom: 1.25rem;
}
.about-content p {
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.about-content h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin: 1.5rem 0 0.6rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
footer {
  background: var(--teal-dark);
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.78rem;
  margin-top: auto;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .filter-bar { padding: 0.75rem 1rem; }
  .filter-controls { width: 100%; }
  .filter-controls select { flex: 1; min-width: 0; }
  .search-wrap, .search-wrap input { width: 100%; }
  .search-wrap input:focus { width: 100%; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.875rem; }
  .row-meta { flex-direction: column; align-items: flex-end; gap: 0.25rem; }
  main { padding: 1rem; }
}

@media (max-width: 540px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-cover-wrap {
    border-radius: var(--radius) var(--radius) 0 0;
    min-height: 0;
    max-height: 200px;
  }
  .modal-cover-wrap img { object-position: top; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.625rem; }
}

@media (max-width: 380px) {
  .logo-sub { display: none; }
  .header-inner { padding: 0 1rem; }
  main { padding: 0.75rem; }
}
