:root {
  --bg: #f6f4f0;
  --card: #ffffff;
  --text: #1d1b19;
  --muted: #6b665f;
  --line: #e2ddd5;
  --accent: #c2410c;
  --chip: #efebe5;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --card: #1f1d1b;
    --text: #ede9e3;
    --muted: #a39d94;
    --line: #34312d;
    --accent: #fb923c;
    --chip: #2b2825;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.5);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; font-weight: 600; text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.top { display: flex; align-items: baseline; row-gap: 4px; gap: 12px; padding: 20px 16px 4px; max-width: 1400px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.count { margin: 0; color: var(--muted); }

.filters {
  position: sticky; top: 0; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 16px; max-width: 1400px; margin: 0 auto;
  background: var(--bg);
}
.filters input, .filters select {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; min-width: 0;
}
.filters input { flex: 1 1 220px; }

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  padding: 8px 16px 40px; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .status-row button { font-size: 10px; padding: 3px 0; }
  .top { flex-wrap: wrap; }
  .filters { position: static; }
  .filters select { flex: 1 1 45%; }
}
.card { display: block; align-self: start; width: 100%; min-width: 0; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; }
.poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden;
  background: var(--chip); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); font-weight: 600; padding: 8px;
}
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card:hover .poster { outline: 2px solid var(--accent); }
.card .name { font-weight: 600; font-size: 14px; margin-top: 6px; line-height: 1.25; }
.card .en { color: var(--muted); font-size: 12px; line-height: 1.25; }
.card .meta { color: var(--muted); font-size: 12px; }
.badge {
  position: absolute; top: 6px; left: 6px; z-index: 1;
  background: rgb(0 0 0 / 0.72); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
}
.status {
  position: absolute; left: 6px; bottom: 6px; z-index: 1;
  font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; color: #fff;
}
.s-watched { background: #15803d; }
.s-maybe { background: #b45309; }
.cell.is-watched .poster img { filter: saturate(0.35); }
.status-row { display: flex; gap: 4px; margin-top: 4px; }
.sheet .status-row { margin: 6px 0 10px; max-width: 320px; }
.status-row button {
  flex: 1; font: inherit; font-size: 11px; padding: 3px 2px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text);
}
.status-row button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.top .edit {
  margin-left: auto; font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; background: var(--card); color: var(--text);
}
.save-info { color: var(--muted); font-size: 13px; }
.flags { position: absolute; top: 6px; left: 6px; z-index: 1; display: flex; gap: 3px; flex-wrap: wrap; }
.flag {
  background: rgb(0 0 0 / 0.72); color: #fff; font-size: 12px; font-weight: 700; line-height: 1.3;
  padding: 1px 5px; border-radius: 4px;
}
.flag.award { background: #ca8a04; }
.sheet details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.badge.check { left: auto; right: 6px; background: #b45309; }

.sheet {
  width: min(900px, 100vw); max-height: 92vh; padding: 0;
  border: 0; border-radius: 12px; background: var(--card); color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / 0.6); }
@media (max-width: 640px) {
  .sheet { max-height: 100vh; height: 100vh; border-radius: 0; margin: 0; max-width: 100vw; }
}
.sheet-head { display: grid; grid-template-columns: 200px 1fr; gap: 20px; padding: 20px; }
@media (max-width: 640px) { .sheet-head { grid-template-columns: 110px 1fr; gap: 12px; padding: 16px; } }
.sheet-head .poster { aspect-ratio: 2 / 3; }
.sheet h2 { margin: 0 0 2px; font-size: 24px; line-height: 1.2; }
.sheet .orig { color: var(--muted); margin: 0 0 6px; }
.sheet section { padding: 0 20px 16px; }
@media (max-width: 640px) { .sheet section { padding: 0 16px 14px; } }
.sheet h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 8px 0 6px; }
.close {
  position: sticky; top: 8px; float: right; margin: 8px 8px 0 0; z-index: 3;
  font: inherit; font-size: 20px; line-height: 1; padding: 6px 10px; cursor: pointer;
  border: 0; border-radius: 8px; background: var(--chip); color: var(--text);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; padding: 0; list-style: none; }
.chips li { background: var(--chip); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0;
  padding: 6px 12px; border-radius: 8px; font-size: 14px;
}
.btn:hover { color: #fff; border-bottom-color: transparent; filter: brightness(1.1); }
.prov { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0; }
.prov img { width: 36px; height: 36px; border-radius: 8px; }
.prov .kind { color: var(--muted); font-size: 13px; min-width: 90px; }
.muted { color: var(--muted); }
.foot { color: var(--muted); font-size: 12px; padding: 16px 16px 80px; max-width: 1400px; margin: 0 auto; }

/* Feedback widget (js/notes-widget.js) */
.notes-widget { position: fixed; right: 16px; bottom: 16px; z-index: 10; }
.notes-widget__toggle, .notes-widget__save, .notes-widget__cancel {
  font: inherit; font-size: 14px; cursor: pointer; border-radius: 8px; padding: 6px 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.notes-widget__toggle { box-shadow: var(--shadow); font-weight: 600; }
.notes-widget__save { background: var(--accent); color: #fff; border-color: var(--accent); }
.notes-widget__panel {
  position: absolute; right: 0; bottom: 44px; width: min(340px, calc(100vw - 32px));
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: var(--shadow);
}
.notes-widget__panel[hidden] { display: none; }
.notes-widget__label { display: block; font-weight: 600; margin-bottom: 6px; }
.notes-widget__text {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}
.notes-widget__row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.notes-widget__status { font-size: 13px; color: var(--muted); }
.notes-widget__status[data-kind="error"] { color: #dc2626; }
.notes-widget__hp { position: absolute; left: -9999px; }
