/* The look of liforra.de: a dark purple window with a title bar, Space Mono,
   square corners and thin borders. */

@font-face {
  font-family: 'Space Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/space-mono-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Mono'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/space-mono-bold.woff2') format('woff2');
}

:root {
  --bg: oklch(0.09 0.015 300);
  --panel: oklch(0.13 0.024 300);
  --panel-2: oklch(0.08 0.02 300);
  --frame: oklch(0.62 0.22 300);
  --line: oklch(0.4 0.06 300 / 0.5);
  --line-soft: oklch(0.4 0.06 300 / 0.35);
  --track: oklch(0.4 0.06 300 / 0.3);
  --text: oklch(0.94 0.015 300);
  --body: oklch(0.8 0.015 300);
  --muted: oklch(0.65 0.02 300);
  --faint: oklch(0.5 0.02 300);
  --accent: oklch(0.68 0.19 300);
  --accent-2: oklch(0.76 0.17 300);
  --accent-bright: oklch(0.85 0.15 300);
  --accent-text: oklch(0.09 0.015 300);
  --wash: oklch(0.68 0.19 300 / 0.15);
  --wash-strong: oklch(0.68 0.19 300 / 0.28);
  --hover-line: oklch(0.68 0.19 300 / 0.7);
  --ok: oklch(0.72 0.19 145);
  --warn: oklch(0.78 0.16 90);
  --bad: oklch(0.6 0.2 25);
  --radius: 0;
  --shadow: 0 10px 28px oklch(0 0 0 / 0.45);
  --font: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: var(--font);
  color-scheme: dark;
}
@supports not selector(::-webkit-scrollbar) {
  :root { scrollbar-color: oklch(0.35 0.05 300) transparent; scrollbar-width: thin; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--body); font-size: 13.5px; line-height: 1.55; min-height: 100vh; }
::selection { background: oklch(0.7 0.2 300 / 0.35); }
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: oklch(0.35 0.05 300); border-radius: 0; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
h1, h2, h3, h4 { color: var(--text); }
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent-bright); text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: transparent; border-radius: 0; color: var(--body);
  padding: 7px 12px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
button:hover { background: var(--wash); border-color: var(--hover-line); color: var(--text); }
button:disabled { opacity: .5; cursor: default; background: transparent; border-color: var(--line); color: var(--body); }
button.primary { background: var(--wash); border-color: var(--accent); color: var(--accent-bright); font-weight: 700; }
button.primary:hover { background: var(--wash-strong); }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--accent-2); }
button.link:hover { color: var(--accent-bright); text-decoration: underline; }
button.danger:hover { border-color: var(--bad); color: var(--bad); background: oklch(0.55 0.22 25 / 0.15); }
input[type=text], input[type=password], input[type=number], input[type=url], select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 0; padding: 8px 10px; min-width: 0; color: var(--text);
}
input::placeholder { color: var(--faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); }
button:focus-visible, a:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* the window around everything */
.shell { padding: 40px 20px 64px; }
.window { max-width: 1040px; margin: 0 auto; background: var(--panel); border: 2px solid var(--frame); }

.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 36px; padding: 0 6px 0 14px; background: var(--panel); border-bottom: 2px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px; text-decoration: none;
  background: var(--wash); color: var(--accent); font-weight: 700; font-size: 12.5px;
}
.brand:hover { color: var(--accent-bright); text-decoration: none; }
.brand svg { width: 12px; height: 12px; }
.top-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.icon-btn { width: 26px; height: 26px; padding: 0; display: inline-grid; place-items: center; line-height: 1; color: var(--muted); }
.icon-btn svg { width: 13px; height: 13px; }
.pill { font-size: 11.5px; padding: 3px 9px; display: inline-flex; gap: 7px; align-items: center; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

main { padding: 30px 36px 44px; display: flex; flex-direction: column; gap: 28px; }

.hero { padding-top: 0; }
.search { display: flex; background: var(--panel-2); border: 1px solid var(--line); }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; border: 0; background: transparent; font-size: 14px; padding: 11px 14px; }
.search select { border: 0; border-left: 1px solid var(--line); background: transparent; }
.search button.primary { border: 0; border-left: 1px solid var(--accent); padding: 0 20px; }
.hint { margin: 10px 2px 0; color: var(--faint); font-size: 11.5px; }

.panel { background: transparent; border: 1px solid var(--line); border-radius: 0; }

/* search results */
.results-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.results-head h2 { margin: 0; font-size: 15px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.card { cursor: pointer; display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; background: none; text-align: left; white-space: normal; color: var(--body); }
.card:hover { background: none; color: var(--text); }
.card .cover { aspect-ratio: 2/3; background: var(--panel-2) center/cover no-repeat; border: 1px solid var(--line); display: grid; place-items: center; color: var(--faint); font-size: 28px; font-weight: 700; overflow: hidden; }
.card:hover .cover { border-color: var(--accent); outline: 1px solid var(--accent); }
.card .name { font-weight: 700; font-size: 12.5px; color: var(--text); }
.badge { display: inline-block; font-size: 10.5px; font-weight: 400; padding: 1px 7px; border: 1px solid var(--line); color: var(--muted); background: transparent; }
.badge.lang { color: var(--body); }

/* discover */
#discover .tabs { margin-bottom: 4px; }
.shelf h3 { font-size: 12.5px; margin: 16px 0 8px; color: var(--muted); font-weight: 700; }
.shelf-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 112px; gap: 12px; overflow-x: auto;
  padding-bottom: 10px; scroll-snap-type: x proximity; overscroll-behavior-x: contain;
}
.shelf-row .card { scroll-snap-align: start; }
.shelf-row .card .muted { font-size: 11px; }
.shelf-row .card .name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11.5px; }

/* title view */
.title-view { padding: 20px; display: grid; grid-template-columns: 160px 1fr; gap: 22px; }
.title-view .poster { width: 160px; aspect-ratio: 2/3; background: var(--panel-2) center/cover no-repeat; border: 1px solid var(--line); }
.title-view h1 { margin: 0 0 6px; font-size: 24px; line-height: 1.2; letter-spacing: -0.5px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 12px; }
.desc { color: var(--body); font-size: 12.5px; line-height: 1.7; margin: 12px 0 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.desc.open { -webkit-line-clamp: unset; }
.title-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.sub-btn { font-size: 12.5px; padding: 6px 12px; }
.sub-btn.on { color: var(--ok); border-color: color-mix(in oklch, var(--ok) 50%, transparent); }
.groups { grid-column: 1 / -1; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 10px; }
.tab { border: 0; padding: 4px 9px; font-size: 12.5px; color: oklch(0.58 0.02 300); }
.tab:hover { background: none; color: var(--text); }
.tab.active { background: var(--wash); color: var(--accent); font-weight: 700; }
.list-tools { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; font-size: 12.5px; color: var(--muted); }
.episodes { border: 1px solid var(--line); overflow: hidden; }
.ep { display: grid; grid-template-columns: 28px 70px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line-soft); cursor: pointer; }
.ep:first-child { border-top: 0; }
.ep:hover { background: oklch(0.68 0.19 300 / 0.07); }
.ep.focus { background: var(--wash); }
.ep input { width: 15px; height: 15px; }
.ep .num { color: var(--muted); font-size: 12px; font-weight: 700; }
.ep .t { min-width: 0; }
.ep .t b { font-weight: 400; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep .t small { color: var(--muted); font-size: 11px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep .langs { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.loading { padding: 24px; text-align: center; color: var(--muted); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--track); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.actionbar {
  position: sticky; bottom: 14px; z-index: 5; margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--accent); box-shadow: var(--shadow);
}
.actionbar .grow { flex: 1; }
.actionbar label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* downloads and subscriptions */
#sub-list { display: flex; flex-direction: column; gap: 10px; }
.sub .job-title { padding: 0; border: 0; text-align: left; white-space: normal; color: var(--text); }
.sub .job-title:hover { background: none; color: var(--accent-2); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 15px; }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.toggle input { width: 15px; height: 15px; }
.empty { color: var(--faint); font-size: 12.5px; text-align: center; padding: 28px; border: 1px dashed var(--line); margin: 0; }
#jobs { display: flex; flex-direction: column; gap: 10px; }
.job { padding: 14px 16px; display: grid; grid-template-columns: 44px 1fr; gap: 14px; }
.job .thumb { width: 44px; height: 64px; background: var(--panel-2) center/cover no-repeat; border: 1px solid var(--line); }
.job-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.job-title { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.job-sub { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.job-actions { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.job-actions button, .item button, .item a.btn { font-size: 11.5px; padding: 5px 10px; }
.status { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border: 1px solid var(--line); color: var(--muted); }
.status.running, .status.resolving { color: var(--accent); }
.status.done { color: var(--ok); }
.status.failed { color: var(--bad); }
.status.partial, .status.cancelled { color: var(--warn); }
.bar { height: 4px; background: var(--track); overflow: hidden; margin: 12px 0 2px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.bar.indeterminate > i { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.items { margin-top: 10px; border-top: 1px solid var(--line-soft); }
.item { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.item:last-child { border-bottom: 0; }
.item .lbl { color: var(--muted); font-weight: 700; font-size: 12px; }
.item .info { min-width: 0; }
.item .info .err { color: var(--bad); font-size: 11px; overflow-wrap: anywhere; }
.item .info small { color: var(--muted); font-size: 11px; }
.item .bar { margin: 4px 0 0; height: 2px; }
a.btn { display: inline-block; text-decoration: none; border: 1px solid var(--line); color: var(--body); background: transparent; font-size: 12.5px; }
a.btn:hover { background: var(--wash); border-color: var(--hover-line); color: var(--text); text-decoration: none; }
.captcha-flag { color: var(--warn); font-weight: 700; }

/* dialogs: a smaller window with its own title bar */
dialog { border: 0; padding: 0; background: transparent; color: var(--body); max-width: min(680px, 94vw); width: 100%; }
dialog::backdrop { background: oklch(0.05 0.01 300 / 0.75); }
.sheet { background: var(--panel); border: 2px solid var(--frame); padding: 0 20px 20px; box-shadow: var(--shadow); max-height: 88vh; overflow: auto; }
.sheet.wide { max-width: none; }
dialog#captcha { max-width: min(1320px, 96vw); }
.sheet header {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: 36px; margin: 0 -20px 12px; padding: 0 6px 0 14px; background: var(--panel); border-bottom: 2px solid var(--line);
}
.sheet h2 { margin: 0; padding: 4px 8px; font-size: 12.5px; background: var(--wash); color: var(--accent); }
.sheet header .icon-btn { width: 24px; height: 24px; font-size: 12px; background: oklch(0.55 0.22 25 / 0.22); color: oklch(0.85 0.02 300); }
.sheet header .icon-btn:hover { background: oklch(0.55 0.22 25 / 0.4); border-color: oklch(0.6 0.2 25 / 0.7); color: oklch(0.95 0.02 300); }
.sheet h3 {
  font-size: 11px; font-weight: 700; margin: 24px 0 8px;
  text-transform: uppercase; letter-spacing: 1px; color: var(--accent);
}
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.field span { color: var(--muted); }
.field small { color: var(--faint); font-size: 11px; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 14px; }
.row-end .muted { margin-right: auto; font-size: 12px; }
.code { background: var(--panel-2); border: 1px solid var(--line-soft); padding: 10px 12px; font: 11px/1.6 var(--font); color: var(--accent); overflow: auto; white-space: pre; }
.bookmarklet { display: inline-block; padding: 6px 12px; border: 1px dashed var(--accent); color: var(--accent-bright); text-decoration: none; font-weight: 700; }
.captcha-view { position: relative; margin-top: 8px; background: var(--panel-2); border: 1px solid var(--line-soft); min-height: 240px; display: grid; place-items: center; overflow: hidden; }
.captcha-view img { max-width: 100%; display: block; cursor: crosshair; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; }
#toast div {
  background: var(--panel); color: var(--text); padding: 9px 14px; font-size: 12.5px; max-width: 90vw; animation: pop .2s ease;
  border: 1px solid var(--line); border-top: 2px solid var(--accent); box-shadow: var(--shadow);
}
#toast div.bad { border-color: var(--bad); background: color-mix(in oklch, var(--bad) 22%, var(--panel)); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 640px) {
  .title-view { grid-template-columns: 1fr; }
  .title-view .poster { width: 120px; }
  .ep { grid-template-columns: 24px 54px 1fr; }
  .ep .langs { grid-column: 3; justify-content: flex-start; }
  .grid2 { grid-template-columns: 1fr; }
  .search { flex-wrap: wrap; }
  .search input { flex-basis: 100%; border-bottom: 1px solid var(--line); }
  .search select { flex: 1; border-left: 0; }
  .search button.primary { padding: 9px 20px; }
  .job-head { flex-direction: column; }
  .item { grid-template-columns: 56px 1fr; }
  .item > :last-child { grid-column: 2; }
}

/* login, user, requests */
#gate { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.gate-card { max-width: 380px; width: 100%; text-align: center; background: var(--panel); border: 2px solid var(--frame); padding: 32px 24px; }
.gate-card h1 { margin: 14px 0 4px; font-size: 22px; letter-spacing: -0.5px; }
.gate-card .btn { margin-top: 14px; }
a.btn.primary { background: var(--wash); border: 1px solid var(--accent); color: var(--accent-bright); font-weight: 700; padding: 9px 20px; }
a.btn.primary:hover { background: var(--wash-strong); }
a.btn.small, a.btn.sub-btn { padding: 4px 10px; font-size: 12px; }
#who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.user-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; padding: 2px 8px 2px 2px; border: 1px solid var(--line); max-width: 240px; min-width: 0; }
.user-chip .avatar { width: 20px; height: 20px; display: grid; place-items: center; font-weight: 700; font-size: 11px; color: var(--accent-text); background: var(--accent); flex: none; }
.user-chip .user-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge.admin { color: var(--accent); }
.badge.owner { color: var(--text); }
.pill.warn { color: var(--warn); border-color: color-mix(in oklch, var(--warn) 45%, transparent); }
#requests .section-head h2 { font-size: 15px; }
#req-list { display: flex; flex-direction: column; gap: 10px; }
.req.open { border-color: color-mix(in oklch, var(--warn) 30%, transparent); }
.status.rq-pending { color: var(--warn); }
.status.rq-approved { color: var(--ok); }
.status.rq-rejected, .status.rq-failed { color: var(--bad); }
.note-text { margin: 8px 0 0; padding: 6px 10px; border-left: 2px solid var(--accent); background: var(--panel-2); color: var(--body); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.actionbar .note, .sheet .note { flex: 1 1 100%; }
.actionbar .allowance { flex-basis: 100%; font-size: 11px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; margin-top: 10px; }
#server-fields > * + * { margin-top: 10px; }
.field.check .toggle { color: var(--body); font-size: 12.5px; }
.site-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; }
.site-checks .toggle { font-size: 12.5px; color: var(--body); }
@media (max-width: 640px) {
  .grid3 { grid-template-columns: 1fr; }
  .user-chip .user-name { display: none; }
  .user-chip { padding-right: 2px; }
}
main > section { scroll-margin-top: 52px; }
.site-checks .toggle:has(input:disabled) { opacity: .45; }

/* destination and drives */
.seg { display: inline-flex; border: 1px solid var(--line); overflow: hidden; }
.seg button { border: 0; padding: 5px 11px; font-size: 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--wash); color: var(--accent); font-weight: 700; }
.dest, .sub-dest { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sub-dest { margin: 6px 0 4px; }
.drive-picks { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.drive-picks .toggle { font-size: 12px; color: var(--body); }
.badge.lib { color: var(--accent); }
.badge.ok { color: var(--ok); }
.status.uploading { color: var(--accent); }
.item .lbl .badge { margin-top: 2px; }
.upload + .upload { margin-top: 4px; }
.upload.failed small { color: var(--bad); }
.drive-list { display: flex; flex-direction: column; gap: 10px; }
.drive { border: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.drive.editing { border-color: var(--hover-line); }
.drive-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.drive-head .job-actions button { font-size: 11.5px; padding: 5px 10px; }
.conn { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12.5px; min-width: 0; }
.conn-label { overflow-wrap: anywhere; }
.conn.bad small { color: var(--bad); overflow-wrap: anywhere; }
.conn-edit { border-top: 1px solid var(--line-soft); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.conn-edit-head { display: flex; gap: 8px; align-items: center; }
.conn-edit-head .grow { flex: 1; }
.conn-edit .field.wide { grid-column: 1 / -1; }
.conn-edit textarea { font: 11.5px/1.5 var(--font); background: var(--panel-2); border: 1px solid var(--line); padding: 8px 10px; resize: vertical; color: var(--text); min-width: 0; }
.conn-result.bad { color: var(--bad); overflow-wrap: anywhere; }
.drive-rules h4, #drive-fields > h4 { margin: 16px 0 2px; font-size: 12.5px; }
.drive-rules .site-checks { margin: 4px 0; }
.rule { border: 1px solid var(--line); padding: 8px 10px; margin-top: 8px; }
.rule-head { display: flex; justify-content: space-between; align-items: center; }
.secret-once { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; margin-top: 8px; }
.secret-once input { font-size: 12px; min-width: 0; color: var(--accent-bright); }
.secret-once small { grid-column: 1 / -1; }
.drive-rules > select { margin-top: 8px; }
#drive-fields .grid3 { margin-top: 6px; }
#jf-fields .toggle + .grid2 { margin-top: 12px; }
#jf-fields .rule select { margin-top: 6px; }
#jf-fields .rule small { display: block; margin-top: 4px; }

/* phones: the window fills the screen */
@media (max-width: 640px) {
  .shell { padding: 0; }
  .window { border: 0; min-height: 100vh; }
  main { padding: 20px 16px 100px; }
  .top { padding-left: 10px; }
}
