

:root{
  --bg:#f7f7f9; --surface:#fff; --text:#111214; --muted:#5d6068; --line:#e6e7ea;
  --brand:#6b7cff; --shadow:0 6px 24px rgba(22,25,30,.06), 0 2px 8px rgba(22,25,30,.05);
  --radius:16px; --radius-lg:22px; --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Noto Sans, Arial;
}

html,body{height:100%}
body{margin:0; background:var(--bg); color:var(--text); font:16px/1.4 var(--font)}
*{box-sizing:border-box}

/* ===== HEADER ===== */
header{position:sticky; top:0; z-index:40; display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 18px; background:var(--bg); backdrop-filter:saturate(140%) blur(6px); border-bottom:1px solid var(--line)}
.search{display:flex; align-items:center; gap:8px; border:1px solid var(--line); background:var(--surface); box-shadow:var(--shadow); border-radius:999px; height:38px; overflow:hidden; transition:width .25s ease; width:38px}
.search.expanded{width:min(520px,72vw)}
.search button{all:unset; display:grid; place-items:center; width:38px; height:38px; cursor:pointer}
.search svg{width:18px; height:18px; opacity:.75}
.search input{flex:1; min-width:0; border:0; outline:0; background:transparent; color:var(--text); font-size:14px; padding-right:12px; display:none}
.search.expanded input{display:block}
.menu{display:flex; align-items:center; gap:16px}
.menu a{font-weight:500; text-decoration:none; position:relative}
.menu a::after{content:""; position:absolute; left:0; bottom:-4px; height:2px; width:0; background:var(--text); transition:width .2s ease}
.menu a:hover::after{width:100%}
.btn{appearance:none; border:1px solid var(--line); background:var(--surface); color:var(--text); border-radius:12px; padding:10px 14px; font-weight:700; box-shadow:var(--shadow); cursor:pointer}
.btn.primary{background:var(--brand); color:#fff; border-color:transparent}
.btn.danger{background:#ef5b5b; color:#fff; border-color:transparent}
.btn.danger:hover{filter:brightness(0.95)}

/* ===== LAYOUT ===== */
.container{ width:80vw !important; max-width:none !important; margin:18px auto; padding:0 8px }
@media (max-width:900px){ .container{ width:96vw } }

/* ===== FILTER BAR ===== */
.sectionbar{display:flex; justify-content:space-between; align-items:center; margin-bottom:8px}
.toolbar{display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin:0 0 14px}
.chips{display:flex; gap:8px; flex-wrap:wrap; align-items:center}
.chip{display:inline-flex; align-items:center; gap:8px; padding:8px 12px; border-radius:999px; background:#eef0ff; color:#2d3266; font-weight:600; cursor:pointer; border:1px solid transparent}
.chip.active{outline:2px solid var(--brand); background:transparent; color:var(--text)}
.select{padding:9px 12px; border-radius:12px; border:1px solid var(--line); background:var(--surface); color:var(--text)}
.mchip{
  display: inline-block;
  width: 100%;
}

/* ===== GRID CARDS ===== */
.grid{display:grid; grid-template-columns:repeat(12,1fr); gap:14px}
@media (max-width:1200px){.grid{grid-template-columns:repeat(10,1fr)}}
@media (max-width:980px){.grid{grid-template-columns:repeat(8,1fr)}}
@media (max-width:740px){.grid{grid-template-columns:repeat(6,1fr)}}
@media (max-width:520px){.grid{grid-template-columns:repeat(4,1fr)}}

.card{grid-column:span 2; display:flex; gap:12px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:12px; box-shadow:var(--shadow); cursor:pointer}
@media (max-width:1200px){.card{grid-column:span 3}}
@media (max-width:980px){.card{grid-column:span 4}}
@media (max-width:740px){.card{grid-column:span 6}}
@media (max-width:520px){.card{grid-column:span 4}}
.cover{width:120px; height:180px; border-radius:12px; background:linear-gradient(135deg,#dfe3ff,#f1f2ff); display:grid; place-items:center; font-weight:800; color:#2a2f6b; overflow:hidden}
.meta{flex:1; min-width:0; display:flex; flex-direction:column}
.title{
  font-weight:800;
  margin:2px 0 4px;
  line-height:1.2;
  display:-webkit-box;
  -webkit-line-clamp:2;       /* number of lines */
  line-clamp: 2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  white-space:normal;
}
.sub{font-size:12px; color:var(--muted); margin-bottom:8px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis}
.row{display:flex; align-items:center; justify-content:space-between; gap:8px}
.rating{display:flex; gap:2px}
.star{width:16px; height:16px}
.stat{font-size:12px; color:var(--muted)}
.tag{font-size:11px; padding:5px 8px; border-radius:999px; background:var(--bg); border:1px solid var(--line)}
.tag.vibe-tag{background:#eef0ff; border-color:#dfe3ff; font-weight:700}
.tag.trope{border:1px solid rgba(0,0,0,0.08)}

/* ===== LIST VIEW (one-row table) ===== */
.grid.is-list{display:block}
.grid.is-list > .panel{max-width:100%}
.table{display:block}
.table .th,.table .tr{
  display:grid;
  grid-template-columns:2.2fr 1.2fr 1.2fr 0.9fr 0.8fr 0.9fr 0.9fr 0.7fr 2.8fr; /* + Link */
  align-items:center;
  gap:14px;
  padding:10px 14px;
  border-bottom:1px solid var(--line);
}.table .th{position:sticky;top:0;background:var(--surface);z-index:1;color:var(--muted);font-weight:700}
.table .tr:hover{background:rgba(0,0,0,.02)}
.cell-title{font-weight:800;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cell-tropes{display:flex;flex-wrap:wrap;gap:6px}

/* ===== PANELS / STATS ===== */
.panel{background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow)}
.stats-grid{display:grid; grid-template-columns:repeat(12,1fr); gap:14px}
.stats-card{grid-column:span 6}
.stats-wide{grid-column:span 12}
@media (max-width:900px){.stats-card{grid-column:span 12}}
.kpi{display:flex; align-items:center; justify-content:space-between}
.kpi h3{margin:0; font-size:14px; color:var(--muted)}
.kpi strong{font-size:24px}
.donut{width:220px; height:220px; border-radius:50%; display:grid; place-items:center; margin:auto}
.donut::after{content:""; width:120px; height:120px; background:var(--surface); border-radius:50%; box-shadow:inset 0 0 0 1px var(--line)}

.bars{display:flex; flex-direction:column; gap:10px}
.bar{display:grid; grid-template-columns:120px 1fr auto; align-items:center; gap:10px}
.bar-label{font-weight:700}
.bar-track{height:12px; background:var(--bg); border:1px solid var(--line); border-radius:999px; overflow:hidden}
.bar-fill{height:100%; background:var(--brand)}

/* ===== MODAL ===== */
.overlay{position:fixed; inset:0; background:rgba(0,0,0,.45); display:none; align-items:center; justify-content:center; padding:20px; z-index:2000}
.overlay.show{display:flex}
.modal{width:min(820px,100%); max-height:90vh; overflow:auto; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-lg); box-shadow:var(--shadow); padding:0px 20px 15px 15px}
.modal-head{display:flex; align-items:center; justify-content:space-between;}



.modal header{position:sticky; top:0; background:var(--surface); border:0; padding:10px; margin-bottom:10px;}


.modal .cover{width:120px; height:160px}
.grid-mini{display:grid; grid-template-columns:120px 1fr; gap:16px}
.field{display:flex; flex-direction:column; gap:6px; margin:10px 0}
.modal label{font-weight:700; font-size:13px}
.modal input,.modal textarea,.modal select{background:var(--bg); border:1px solid var(--line); color:var(--text); border-radius:10px; padding:10px}
.modal textarea{min-height:84px}
.btns{display:flex; gap:10px; justify-content:flex-end; margin-top:12px}

.hidden{display:none}
.muted{color:var(--muted)}
.pill{padding:3px 8px; border-radius:999px; border:1px solid var(--line); background:var(--bg); font-size:12px}

/* Import area */
.drop{border:2px dashed var(--line); border-radius:16px; padding:16px; text-align:center; margin:12px 0}
.import-actions{margin-top:10px; display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.two{display:flex; gap:10px}

/* stars above vibe, words beneath vibe, finished at bottom */
.card .rating{ margin-bottom:6px }
.card .vibe-tag{ display:inline-block; margin-bottom:6px }
.stat.words{ margin-bottom:5px }
.stat.finished{ margin-top:1px }  /* pushes to bottom of the card */

.head-row{display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px}

.seg{display:inline-flex; background:var(--bg); border:1px solid var(--line); border-radius:999px; padding:2px}
.seg button{border:0; background:transparent; padding:6px 10px; border-radius:999px; font-weight:700; cursor:pointer}
.seg button.on{background:var(--surface); box-shadow:var(--shadow)}

.bars .bar .bar-fill{transition:width .25s ease}

/* (already added earlier) donut + legend */
.flex-donut{display:flex; align-items:center; justify-content:center; gap:16px; flex-wrap:wrap}
.legend{display:flex; flex-direction:column; gap:6px; min-width:200px}
.legend-item{display:flex; align-items:center; gap:8px; font-size:14px}
.legend-item .swatch{width:12px; height:12px; border-radius:3px; border:1px solid var(--line)}
.legend-item .pct{color:var(--muted); margin-left:auto}


.card .vibe-tag{
  display: inline-block;   /* or inline-flex */
  align-self: flex-start;  /* stop flex from stretching it */
  width: auto;             /* ensure it doesn't fill */
  max-width: 100%;
}

/* Author stays single-line with ellipsis */
.meta .sub.author{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pairing gets its own line and can wrap */
.meta .sub.pairing{
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;    /* safety for very long strings */
  margin-top: 1px;           /* slight separation from author */
  color: var(--muted);
}

/* 1) Make the card only 4px taller than the 180px image
   - We set fixed height to 184px
   - Reduce vertical padding to 2px (2px top + 2px bottom = 4px total)
   - Keep content clipped nicely if it overflows */
.card{
  height: 190px;
  padding: 5px 5px;         /* was 12px  */
}

/* 2) Ensure the text column packs tight and clips overflow cleanly */
.meta{
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;          /* clip if content is too tall */
}

/* 3) Tighter title + keep wrapping as you wanted */
.title{
  font-weight: 800;
  margin: 0 0 2px;           /* tighter */
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;  
  line-clamp: 2;   /* 2 lines max */
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}

/* 4) Author on one line, pairing right below with minimal gap */
.meta .sub.author{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;                 /* remove extra space */
}
.meta .sub.pairing{
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  margin: 1px 0 0;           /* just 1px gap under author */
  color: var(--muted);
}

/* 5) Stars above vibe, with smaller spacing; words under vibe;
      finished pinned to the bottom */
.card .rating{ margin: 4px 0 }       /* was 6px */
.card .vibe-tag{
  display: inline-block;
  align-self: flex-start;            /* pill is only as wide as its content */
  margin: 0 0 4px;                  
}
.stat.words{ margin: 0 0 4px }      
.stat.finished{ margin-top: auto }   /* stays at bottom */


.cell-link a{
  text-decoration:none;
  font-weight:700;
}
.cell-link a:hover{
  text-decoration:underline;
}

/* God-tier stars turn gold */
.rating.god { color: goldenrod; }

/* Small label for the checkbox under the cover */
.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  user-select: none;
  font-weight: 600;
}

/* Make only the top menu links a different color */
header .menu a { color: #292c38; }                 /* pick your color */
header .menu a::after { background: #58607a; }     /* match underline */

/* 3-column row where the third column is wider */
.mini-kpis{
  display:grid;
  grid-template-columns: 1fr 1fr 2fr;  /* first two equal, third is wider */
  gap:10px;
  margin-top:10px;
}

.mini{
  background:var(--bg);
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.mini-long{
  background:var(--bg);
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
}

.mini-long-head{
  color:var(--muted);
  font-size:13px;
  font-weight:600;
  margin-bottom:8px;
}

/* Longest list */
.mini-long-list{
  list-style: decimal inside;
  margin:0;
  padding:0;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.mini-long-list li{
  display:flex;
  gap:10px;
  align-items:baseline;
}
.mini-long-list .title{
  flex:1 1 auto;
  min-width:0;
  white-space:normal;              /* allow wrapping */
  overflow-wrap: break-word;
  word-break: break-word;
  font-weight:700;
}
.mini-long-list .count{
  white-space:nowrap;
  color:var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Responsive fallback: stack on narrow screens */
@media (max-width: 720px){
  .mini-kpis{ grid-template-columns: 1fr; }
}

.stats-grid > .stats-card:first-child{
  display: flex;
  flex-direction: column;
}
.stats-grid > .stats-card:first-child .mini-kpis{
  margin-top: auto;
  padding-top: 10px;
}

/* Vertical 12-month mini bar chart */
.month-chart{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  align-items:stretch;             /* ✅ stretch items to full height */
  gap:8px;
  height:220px;
  padding:18px 6px 0;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:12px;
}

/* Month cell = bar group + month label */
.mbar{
  display:grid;
  grid-template-rows: 1fr auto;   /* bar area + label */
  row-gap:6px;
  height:100%;
  align-items:end;
}

/* Two bars side by side inside each month cell */
.mbar-group{
  display:grid;
  grid-template-columns: 1fr 1fr; /* 2024 | 2025 */
  gap:10px;
  align-items:end;
  height:100%;                    /* gives % heights a reference */
}

/* Individual bars */
.mbar-fill{
  width:100%;
  border-radius:6px 6px 0 0;
  background:var(--brand);        /* overridden by year classes */
  align-self:end;
}

/* Month label under bars */
.mbar-label{
  font-size:12px;
  color:var(--muted);
  text-align:center;
}

/* Year colors (tweak if you want) */
.mbar-fill.y2024{ background:#6b7cff; }  /* blue-ish */
.mbar-fill.y2025{ background:#ff9f40; }  /* orange-ish */

/* allow labels to sit outside the bar area a bit */
.mbar,
.mbar-group{ overflow: visible; }

/* each bar column is a positioned container */
.barcol{
  position: relative;
  height: 100%;
}

/* the bar itself (still colored via y2024/y2025 classes) */
.mbar-fill{
  position: absolute;   /* <- key: absolute inside .barcol */
  bottom: 0;
  left: 0; right: 0;
  width: 100%;
  border-radius: 6px 6px 0 0;
  align-self: end;
}

/* numeric value above the bar */
.mbar-val{
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  color: var(--muted);
  pointer-events: none;  /* don’t block hover/clicks */
}

/* keep your year colors */
.mbar-fill.y2024{ background:#6b7cff; }
.mbar-fill.y2025{ background:#ff9f40; }

/* Title + legend on the left side of the header row */
.head-left{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}

/* Tiny legend squares using the same year colors as the bars */
.year-legend{
  display:inline-flex;
  align-items:center;
  gap:12px;
  font-size:13px;
  color:var(--muted);
}
.year-legend .swatch{
  width:12px; height:12px; border-radius:3px;
  border:1px solid var(--line); display:inline-block;
}
.year-legend .swatch.y2024{ background:#6b7cff; }  /* same as .mbar-fill.y2024 */
.year-legend .swatch.y2025{ background:#ff9f40; }  /* same as .mbar-fill.y2025 */

/* Make months farther apart */
.month-chart{ gap:14px; }  /* was 8px */

/* Make each month’s pair of bars narrower and centered */
.mbar-group{
  width:60%;               /* tweak 50–70% to taste */
  margin:0 auto;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:6px;                 /* space between 2024 and 2025 bars */
  align-items:end;
  height:100%;
}

/* From earlier steps (ensure you still have these): */
.mbar{ display:grid; grid-template-rows:1fr auto; row-gap:6px; height:100%; align-items:end; }
.barcol{ position:relative; height:100%; overflow:visible; }
.mbar-fill{ position:absolute; left:0; right:0; bottom:0; border-radius:6px 6px 0 0; }
.mbar-fill.y2024{ background:#6b7cff; }
.mbar-fill.y2025{ background:#ff9f40; }
.mbar-val{ position:absolute; left:50%; transform:translateX(-50%); font-size:11px; color:var(--muted); pointer-events:none; }
.mbar-label{ font-size:12px; color:var(--muted); text-align:center; }

.panel.stats-wide:has(#monthChart){
  margin-top: 10px;
}

/* Make the first row three columns: KPI | Vibe | Rereads */
.stats-grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:16px;
}

/* Keep the “wide” cards (fandom bars, reading over time) full width */
.stats-wide{ grid-column: 1 / -1; }

/* Slightly smaller donut so the vibe card feels tighter in one column */
.stats-card .donut{
  width: 140px;
  height: 140px;
}

/* Rereads list — small, tidy */
.rereads-list{
  margin:0;
  padding-left:18px;             /* ordered list numbers */
  font-size:13px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.rereads-list li{
  display:flex;
  gap:8px;
  align-items:baseline;
}
.rereads-list .title{
  flex:1 1 auto;
  min-width:0;
  white-space:normal;
  overflow-wrap:break-word;
  font-weight:600;
}
.rereads-list .count{
  color:var(--muted);
  white-space:nowrap;
  font-variant-numeric:tabular-nums;
}

/* Cap Rereads to 15 visible rows with inner scroll */
.rereads-list{
  --row-h: 28px;                 /* row height (tweak if your font size changes) */
  max-height: calc(var(--row-h) * 15);
  overflow: auto;
  padding-right: 4px;            /* room for scrollbar */
  overscroll-behavior: contain;  /* keep body from scrolling while inside */
  scrollbar-width: thin;         /* Firefox */
}
.rereads-list li{
  min-height: var(--row-h);
}

/* Keep each item to a single line so rows are consistent */
.rereads-list .title{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Optional: smaller cap on small screens */
@media (max-width: 600px){
  .rereads-list{ max-height: calc(var(--row-h) * 10); }
}

/* Optional: nicer scrollbar (WebKit) */
.rereads-list::-webkit-scrollbar{ height:8px; width:8px; }
.rereads-list::-webkit-scrollbar-thumb{ background: var(--line); border-radius: 8px; }


/* Small-screen fallback: stack to one column if needed */
@media (max-width: 900px){
  .stats-grid{ grid-template-columns: 1fr; }
}

/* 3-up: KPI | Vibe | Rereads  (middle a bit wider, right a bit narrower) */
.stats-grid{
  display:grid;
  grid-template-columns: 1.65fr 0.95fr 0.75fr;  /* tweak to taste */
  gap:16px;
}
.stats-card{ grid-column:auto; }
.stats-wide{ grid-column: 1 / -1; }

@media (max-width:900px){
  .stats-grid{ grid-template-columns: 1fr; }
}

/* Vibe card donut size */
.stats-card .donut{
  width: 170px;   /* was ~140 */
  height: 170px;
}

/* Rereads styling tweaks */
#rereadsPanel { font-size: 12px; min-width: 260px; }              /* slightly smaller text */
#rereadsPanel .rereads-list { gap: 5px; }       /* tighter rows */
#rereadsPanel .rereads-list li { gap: 6px; }
#rereadsPanel .rereads-list .title{ font-weight: 600; }

/* Soften title weight in LIST view only */
.table .cell-title{
  font-weight: 600;   /* was likely 700; try 500–600 to taste */
}


a {
    color: black;
}

/* === Auth overlay (blocks page until login) === */
.auth-overlay{
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(16,18,27,.55);
  backdrop-filter: blur(2px);
  z-index: 3000;
}
.auth-overlay.show{ display: flex; }
.auth-card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  width: min(420px, 92vw);
  text-align: center;
  box-shadow: var(--shadow);
}
.auth-card h2{ margin: 0 0 8px; }
.auth-card p{ margin: 0 0 16px; }

/* === Account dock (top-right) === */
.account-dock{
  position: fixed; top: 12px; right: 12px; z-index: 80;
  display: flex; align-items: center; gap: 8px;
}
.btn.small{ padding: 6px 10px; border-radius: 10px; font-weight: 700; }
.user-badge{
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; box-shadow: var(--shadow);
}
.user-badge img{ width: 22px; height: 22px; border-radius: 50%; }
.hidden{ display: none !important; }

.auth-overlay[aria-hidden="true"] { display: none !important; }
.account-dock { display: none !important; }

/* wider on big screens */
.card{ grid-column: span 3; }             /* 4 per row on ≥1200px instead of 6 */

#settingsProfile {
  margin-top:20px;
}

.settings-profile{
  display:flex; align-items:center; gap:10px;
  margin:12px 0; padding:10px;
  background:var(--bg); border:1px solid var(--line); border-radius:12px;
}
.settings-profile.hidden{ display:none; }
.settings-profile img{
  width:40px; height:40px; border-radius:50%; object-fit:cover;
  box-shadow:var(--shadow);
}
.settings-profile .name{ font-weight:700; }
.settings-profile .email{ font-size:13px; }

#wipeAllBtn{
  margin-top:5px;
}

/* Mobile: give cards more horizontal space */
@media (max-width: 600px){
  .container{ width:100vw; padding:0 6px; }   /* was 96vw at <900px */
  .grid{ gap:8px; }                            /* tighter than 14px */
  .card{ padding:2px; }                         /* a touch more breathing room */
}

/* Mobile list: only Title | Words | Rating */
@media (max-width: 600px){
  .table .th, .table .tr{
    grid-template-columns: 2fr 1fr 1fr;   /* Title | Words | Rating */
    gap:10px;
    padding:10px 12px;
  }

  /* Show only 1 (Title), 4 (Words), 5 (Rating) — hide everything else */
  .table .th > :not(:nth-child(1)):not(:nth-child(4)):not(:nth-child(5)),
  .table .tr > :not(:nth-child(1)):not(:nth-child(4)):not(:nth-child(5)){
    display:none;
  }

  /* keep rows tidy & consistent height */
  .table .tr > div{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    line-height:1.25;
  }
  .table .tr{ min-height: 44px; }

  /* smaller stars so Rating fits nicely */
  .table .tr .rating .star{ width:14px; height:14px; }
}


/* Desktop: hamburger hidden */
#menuBtn{ display:none; }

@media (max-width: 740px){
  .search input{ font-size:16px; }   /* prevents iOS zoom */
}

/* Container sizing */
@media (max-width:900px){
  .container{ width:100vw !important; padding:0 10px; }  /* was 96vw */
}
@media (max-width:600px){
  .grid{ gap:10px; }
  .card{ padding:10px;  height: 200px; }  /* a touch more comfort */
}

/* Mobile: hide inline links, show hamburger + drawer */
@media (max-width: 740px){
  header .menu > a{ display:none; }  /* hide only inline links */
  #menuBtn{ display:inline-grid; }   /* show hamburger */

  .menu-drawer{
    position: fixed;
    top: calc(56px + 8px);            /* below your sticky header */
    left: 12px; right: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 10px;
    display: none;
    z-index: 1000;
  }
  .menu-drawer a{
    display:block;
    padding:10px 8px;
    text-decoration:none;
    color: var(--text);
    border-radius:10px;
  }
  .menu-drawer a:hover{
    background: var(--bg);
  }

  /* when open */
  body.menu-open #menuDrawer{
    display:block;
  }
}


/* --- Top Tropes box --- */
.top-tropes-list {
  list-style: none;
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.top-tropes-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(108, 99, 255, 0.06);
}
.top-tropes-list .rank {
  font-weight: 700;
  opacity: 0.9;
}
.top-tropes-list .trope {
  flex: 1;
}
.top-tropes-list .count {
  color: var(--muted-text);
}

/* If your .stats-container is fixed at 2 columns, make it responsive so the new box fits nicely */
.stats-container {
  display: grid;
  gap: var(--spacing);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Optionally make the tropes box wider on large screens */
@media (min-width: 1100px) {
  .stat-box--tropes {
    grid-column: span 2;
  }
}

/* --- Monthly trope cards under the reading-over-time chart --- */
.monthly-trope-cards {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  grid-template-columns: repeat(6, 1fr); /* desktop: 6 x 2 */
}
@media (max-width: 1200px) {
  .monthly-trope-cards { grid-template-columns: repeat(4, 1fr); } /* 4 x 3 */
}
@media (max-width: 700px) {
  .monthly-trope-cards { grid-template-columns: repeat(2, 1fr); } /* mobile */
}

.month-card {
  padding: 12px;
  border-radius: 12px;
  background: rgba(26, 31, 59, 0.7);
  border: 1px solid var(--border);
}
.month-card h4 {
  margin-bottom: 8px;
  font-weight: 700;
}
.month-card .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.month-card .chip {
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: rgba(108, 99, 255, 0.08);
}
.month-card .meta {
  font-size: 0.85rem;
  color: var(--muted-text);
}
.muted { color: var(--muted-text); }

/* Make the Top Tropes box span the whole row in the stats grid */
.stat-box--tropes {
  grid-column: 1 / -1;
}

/* Each trope row stretches full width with clean columns */
.top-tropes-list li {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr auto; /* rank | trope | count */
  align-items: center;
}

.top-tropes-list .trope {
  overflow-wrap: anywhere;  /* long trope names wrap nicely */
}


/* Match cards to the rest of the theme */
.month-card {
  background:
    radial-gradient(circle at 30% 10%, rgba(108, 99, 255, 0.12), transparent 30%),
    radial-gradient(circle at 70% 80%, rgba(0, 229, 255, 0.12), transparent 30%),
    rgba(26, 31, 59, 0.7);
  border: 1px solid var(--border);
  box-shadow: 0 10px 20px var(--shadow);
}

/* (Optional) Smooth hover lift for a bit of delight */
.month-card:hover {
  transform: translateY(-2px);
  transition: transform 120ms ease;
}


/* Sticky year switch */
.stats-head {
  width: 50%;
  position: sticky;
  top: 10px;                 /* distance from viewport top */
  z-index: 1000;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* Make the active button visually pop a bit more on the sticky bar */
.year-switch .switch-button.active {
  box-shadow: 0 0 0 2px rgba(108,99,255,0.25) inset;
}


#topTropesList {
  padding: 0px;
}

#month-card h4{
display: inline-block;
margin-top: -10px;

}




.nn{
  float: right
}






/* adjust columns to divide nicely so rows don’t look ragged */
@media (max-width:1200px){ .grid{ grid-template-columns: repeat(9,1fr) } .card{ grid-column: span 3 } } /* 3/row */
@media (max-width:900px) { .grid{ grid-template-columns: repeat(6,1fr) } .card{ grid-column: span 3 } } /* 2/row */
@media (max-width:600px) { .grid{ grid-template-columns: repeat(4,1fr) } .card{ grid-column: span 4 } } /* 1/row */


/* Hide scrollbars (Chrome/Edge/Safari) */
*::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Hide scrollbars (Firefox) */
* {
  scrollbar-width: none;        /* no gutter */
}

/* Hide scrollbars (old IE/Edge) */
* {
  -ms-overflow-style: none;
}
/* Import-from-clipboard button inside the Add modal */
#import-clipboard-btn {
  position: absolute;
  right: 85px;         /* sits to the left of the × close */
  top: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: rgba(108, 99, 255, 0.1);
  color: var(--text-color);
  cursor: pointer;
  font-size: 0.9rem;
  appearance:none; border:1px solid var(--line); background:var(--surface); color:var(--text); border-radius:12px; padding:10px 14px; font-weight:700; box-shadow:var(--shadow); cursor:pointer;

  
}


#import-clipboard-btn:hover { background: var(--accent); }


/* extra */

/* Card titles wrap (no ellipsis) */
.card .title {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word; /* long words won't blow layout */
}

/* List cells: make author wrap, pairing wrap */
.cell-author, .cell-pairing {
  white-space: normal;
}

/* Words right-aligned (nicer column scan) */
/* .cell-words { text-align: right; }*/

/* Link text centered */
.cell-link { text-align: center; }
.cell-link a { display: inline-block; }

.cell-date {text-align: center;}

.thLink{
  text-align: left;
  margin-left:15px;
}

/* Longest fics: remove boldness */
.mini-long-list strong { font-weight: 500; } /* or 400 to fully match body */

/* Top Tropes box: show up to 20 with scroll, but keep current height */
.stat-box--tropes .top-tropes-list {
  max-height: 9.5rem;   /* roughly 5 items height; adjust to taste */
  overflow: auto;
  padding-right: .25rem; /* tiny gutter for scrollbar */
}


/* List view: let title/author wrap onto multiple lines */
.cell-title,
.cell-author {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}

/* (ensure consistent column widths across rows) */
.table .tr, .list .tr {
  grid-template-columns:
    minmax(12rem, 2.2fr)  /* Title */
    minmax(10rem, 1.6fr)  /* Author */
    minmax(9rem,  1.4fr)  /* Pairing */
    minmax(6rem,  .9fr)   /* Words */
    minmax(6rem,  .9fr)   /* Rating */
    minmax(6rem,  .9fr)   /* Start */
    minmax(6rem,  .9fr)   /* End */
    minmax(5rem,  .7fr)   /* Link */
    minmax(12rem, 1.8fr); /* Tropes */
}

/* Two-row cap for trope chips in list view */
.cell-tropes {
  /* ~26–28px per chip row including gaps; 56px is a safe cap for two rows */
  max-height: 56px;
  overflow: hidden;
  /* helps keep rows tight & consistent */
  line-height: 1.2;
}
.cell-tropes .tag {
  vertical-align: top;
}

/* header looks like a header, but uses the same grid */
.tr-head {
  font-weight: 600;
 /* background: transparent; */
}

/* match alignments */
.tr-head > :nth-child(4) { text-align: left; }   /* Words */

.tr-head > :nth-child(8) { text-align: center; }  /* Link */


/* FINAL OVERRIDE */
.container{
  width: 94vw !important;
  max-width: none !important;
}

/* Classic book title (silvery blue) */
.card .title.classic {
  color: #318cc9;
}

.cell-title.classic  { color: #318cc9; }

/* if your header uses .tr.tr-head */





/* Mobile: make the list grid more forgiving *MIGHT NEED TO BE REMOVED */
@media (max-width: 700px){
  /* Tighter, responsive columns */
  .table .tr, .list .tr, .list .thead, .tr-head{
    grid-template-columns:
      minmax(9rem, 2fr)   /* Title */
      minmax(7.5rem,1.5fr)/* Author */
      minmax(7rem, 1.2fr) /* Pairing */
      minmax(5rem, .8fr)  /* Words */
      minmax(5rem, .8fr)  /* Rating */
      minmax(5rem, .8fr)  /* Start */
      minmax(5rem, .8fr)  /* End */
      minmax(4rem, .7fr)  /* Link */
      minmax(9rem, 1.6fr) /* Tropes */
  }

  /* Clamp long text so rows stay uniform */
  .cell-title,
  .cell-author{
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;         /* max two lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
  }

  /* Keep stars inside their cell */
  .cell-rating{
    white-space: nowrap;           /* stars on one line */
    overflow: hidden;              /* never spill out */
    text-overflow: clip;
    font-size: 0.95rem;            /* tiny downsize for narrow screens */
  }

  /* Make the “Link” cell behave on narrow widths */
  .cell-link{
    text-align: center;
    overflow: hidden;
  }

  /* Tropes: ensure two-row cap still holds visually */
  .cell-tropes{ max-height: 56px; overflow: hidden; }
}

/* If your starsHTML wraps stars in a .stars element, this makes them shrink gracefully.
   Safe even if .stars doesn't exist. */
@media (max-width: 700px){
  .cell-rating .stars{ display:inline-block; transform: scale(0.95); transform-origin: left center; }
}
