:root { --ink: #e9e9ec; --muted: #9a9ea8; --line: #2c2f36; --panel: #17191e; --bg: #0f1013; --green: #2f9e5b; --green-hi: #37b56a; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
* { box-sizing: border-box; }
a { color: inherit; text-decoration: none; }

header.top { position: sticky; top: 0; z-index: 5; background: #0b0c0e; border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
header.top h1 { font-size: 15px; margin: 0; letter-spacing: .1em; font-weight: 700; }
.brand { letter-spacing: .18em; font-weight: 800; }
header.top nav { margin-left: auto; display: flex; gap: 20px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
header.top nav a[aria-current="page"] { color: var(--green-hi); }
/* App pages: logo left, title centred on the page, nav right. Height stays 49px (.review-header sticks below it). */
header.top.app-top { display: grid; grid-template-columns: 1fr auto 1fr; height: 49px; }
.top-logo { justify-self: start; display: flex; }
.top-logo img { height: 20px; width: auto; display: block; }
.top-title { font-size: 13px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }
header.top.app-top nav { justify-self: end; margin-left: 0; }
@media (max-width: 520px) { .top-title { display: none; } header.top.app-top { grid-template-columns: auto 1fr; } }
.hero-logo { display: block; width: min(420px, 80%); height: auto; margin: 40px auto 36px; }

main { max-width: 900px; margin: 0 auto; padding: 20px 16px 80px; }

h1, h2 { margin: 0 0 12px; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; margin-top: 32px; }

textarea, input, select { width: 100%; background: #0f1013; color: var(--ink); border: 1px solid #353944; border-radius: 6px; padding: 8px; font: inherit; resize: vertical; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.row label { font-weight: 500; }
.row select, .row input { margin-bottom: 0; }

button { font: inherit; font-size: 13px; color: var(--ink); background: #22252c; border: 1px solid #353944; border-radius: 6px; padding: 5px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: #5a606d; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.go { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; padding: 8px 16px; font-size: 14px; }
button.go:hover:not(:disabled) { background: var(--green-hi); }
button.stop { background: #b53a2e; border-color: #b53a2e; color: #fff; font-weight: 600; }

.hint { color: var(--muted); font-size: 13px; }
.error { color: #e07a5f; margin-top: 8px; font-size: 13px; }

.job { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; position: relative; }
.job h3 { margin: 0 0 12px; font-size: 14px; }
.job .close { position: absolute; top: 12px; right: 12px; background: none; border: none; font-size: 18px; padding: 0; color: var(--muted); line-height: 1; }
.item-row { display: flex; align-items: center; gap: 12px; font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.item-row:last-child { border-bottom: none; padding-bottom: 0; }
.item-url { flex: 1 1 200px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.pill { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #22252c; white-space: nowrap; }
.msg { color: var(--muted); font-size: 12px; }

.manual-form { background: rgba(255,255,255,0.03); padding: 12px; border-radius: 6px; margin-top: 8px; width: 100%; }

.review-block { margin-bottom: 32px; border: 1px solid var(--line); border-radius: 8px; overflow: clip; }
.review-header { background: var(--panel); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); flex-wrap: wrap; gap: 8px; position: sticky; top: 49px; z-index: 3; }
.review-header a { font-weight: 600; color: #4ea1ff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.bin-card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; text-decoration: none; transition: border-color .15s; }
.bin-card:hover { border-color: #5a606d; }
.bin-cover { width: 100%; aspect-ratio: 16/9; background: #000; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.bin-cover img { width: 100%; height: 100%; object-fit: contain; }
.bin-info { padding: 12px; }
.bin-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bin-meta { color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 2px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--green); color: #fff; padding: 10px 20px; border-radius: 8px; font-weight: 600; display: none; z-index: 10; box-shadow: 0 4px 12px rgba(0,0,0,0.5); }
#toast a { text-decoration: underline; margin-left: 8px; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; }
@media (max-width: 640px) { .choices { grid-template-columns: 1fr; } }
.choice { display: flex; flex-direction: column; justify-content: space-between; min-height: 220px; padding: 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; transition: border-color .15s, transform .15s; }
.choice:hover { border-color: #5a606d; transform: translateY(-2px); }
.choice .t { font-size: 28px; font-weight: 700; line-height: 1.15; }
.choice .s { color: var(--muted); margin-top: 8px; }
.choice .arrow { align-self: flex-end; font-size: 28px; color: var(--muted); }
.choice.primary { border-color: var(--green); background: rgba(47,158,91,.10); }
.choice.primary:hover { border-color: var(--green-hi); }
.choice.primary .arrow { color: var(--green-hi); }
.choice .icon { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 20px; background: #22252c; color: var(--ink); transition: background .15s; }
.choice .icon svg { width: 30px; height: 30px; }
.choice:hover .icon { background: #2b2f38; }
.choice.primary .icon { background: rgba(47,158,91,.18); color: var(--green-hi); }
.choice.primary:hover .icon { background: rgba(47,158,91,.28); }
#waiting { margin-top: 20px; color: var(--muted); }
#waiting a { color: var(--green-hi); font-weight: 600; margin-left: 6px; }
.review-header .save-all { margin-right: 12px; }
@media (prefers-reduced-motion: reduce) { .choice { transition: none; } .choice:hover { transform: none; } .choice .icon { transition: none; } }

.lib-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.lib-tools .sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.lib-tools .sort select { width: auto; margin: 0; padding: 6px 8px; }
.seg { display: inline-flex; border: 1px solid #353944; border-radius: 8px; overflow: hidden; }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 6px 12px; }
.seg button + button { border-left: 1px solid #353944; }
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-pressed="true"] { background: #e9e9ec; color: #111; }
.grid.list { grid-template-columns: 1fr; gap: 8px; }
.grid.list .bin-card { display: grid; grid-template-columns: 160px minmax(0, 1fr); align-items: center; }
.grid.list .bin-cover { width: 160px; }
.grid.list .bin-info { padding: 10px 16px; }
.grid.list .bin-meta { flex-direction: row; flex-wrap: wrap; gap: 4px 16px; }
@media (max-width: 480px) {
  .grid.list .bin-card { grid-template-columns: 96px minmax(0, 1fr); }
  .grid.list .bin-cover { width: 96px; }
}

dialog.modal { width: min(420px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
dialog.modal::backdrop { background: rgba(0,0,0,.6); }
.modal > form { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-x { width: 32px; height: 32px; padding: 0; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.modal-x:hover { border-color: #353944; color: var(--ink); }
.modal label { font-size: 13px; color: var(--muted); }
.modal input { margin: 0; }
.modal .error:empty { display: none; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

dialog.modal-wide { width: min(640px, calc(100vw - 32px)); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 64px); overflow: auto; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 7px; line-height: 0; }
.icon-btn svg { width: 18px; height: 18px; }
.manage-add { display: flex; gap: 8px; }
.manage-add input { margin: 0; flex: 1; }
.manage-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; }
.manage-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.manage-row:first-child { border-top: 0; }
.manage-row .name { flex: 1 1 160px; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manage-row .meta { color: var(--muted); font-size: 12px; }
.manage-row .acts { display: flex; gap: 6px; margin-left: auto; }
.manage-row input { margin: 0; flex: 1 1 180px; }
.manage-row.confirm { background: rgba(181, 58, 46, .12); }
.manage-row.confirm .name { white-space: normal; font-weight: 500; }
.archive-box summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.archive-box .manage-list { margin-top: 8px; }
