:root {
  --bg: #1c1c1c;
  --fg: #e2e2e2;
  --row-hover: #292929;
  --field: #262626;
  --border: #383838;
  --btn: #2e2e2e;
  --btn-hover: #3a3a3a;
  --err: #d98080;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.4 system-ui, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
[hidden] { display: none !important; }
input, button, select { font: inherit; color: var(--fg); }
input {
  background: var(--field); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
}
input:focus, select:focus { outline: none; border-color: #7a7a7a; }
select {
  background: var(--field); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; width: 100%;
}
button {
  background: var(--btn); border: 1px solid #3a3a3a; border-radius: 6px; padding: 7px 12px; cursor: pointer;
}
button:hover:not(:disabled) { background: var(--btn-hover); }
button:disabled { opacity: .45; cursor: default; }
a { color: inherit; }
.sub { opacity: .6; font-size: .85em; margin: 0; }
.err { color: var(--err); font-size: .85em; }

#app { max-width: 640px; margin: 0 auto; padding: 0 16px 24px; }
header {
  display: flex; gap: 8px; padding: 12px 0; position: sticky; top: 0; background: var(--bg); z-index: 1;
}
#search { flex: 1; min-width: 0; }
button.icon { padding: 0 12px; font-size: 1.1em; }
button.toggle { padding: 0 10px; font-weight: 600; }
button.toggle[aria-pressed="true"] { background: #7a3b3b; border-color: #a65454; }
button.toggle[aria-pressed="true"]:hover { background: #8a4545; }

#list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
#list > li.msg { padding: 8px; }
.row { display: flex; gap: 10px; padding: 6px; border-radius: 8px; align-items: center; }
.row:hover { background: var(--row-hover); }
.cover {
  flex: none; width: 48px; height: 68px; border-radius: 6px; background: var(--field);
  object-fit: cover; align-self: flex-start;
}
.info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.title {
  font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chapter { display: flex; align-items: center; gap: 6px; }
.chapter input { width: 5.5em; padding: 2px 6px; }
.chapter input.missing { color: #8a8a8a; font-style: italic; }
.btns { display: flex; gap: 4px; }
.btns a, .btns button {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0;
  background: var(--btn); border: 1px solid #3a3a3a; border-radius: 6px; text-decoration: none; cursor: pointer;
}
.btns a:hover, .btns button:hover:not(:disabled) { background: var(--btn-hover); }

#lock { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
#lock form { display: grid; gap: 12px; width: min(280px, 100%); text-align: center; }
#lock h1 { margin: 0 0 8px; font-size: 1.2em; font-weight: 600; }
#lock input { text-align: center; font-size: 1.3em; letter-spacing: .2em; }
#lock .err { margin: 0; min-height: 1.4em; }

dialog {
  background: #222; color: var(--fg); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; width: min(420px, calc(100% - 32px));
}
dialog::backdrop { background: rgb(0 0 0 / .6); }
dialog h2 { margin: 0 0 4px; font-size: 1.1em; }
dialog h3 { margin: 18px 0 6px; font-size: .95em; }
dialog form > * + * { margin-top: 8px; }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; }
dialog footer { margin-top: 20px; text-align: right; }
