/* =====================================================================
   Setup wizard
   1. Layout + stepper   2. Shared bits   3. Keys   4. Languages + preview
   5. Collections        6. Layout step   7. Install   8. Bottom nav   9. Small screens
   ===================================================================== */

/* ---------- 1. Layout + stepper ---------- */
main{
  position:relative; z-index:3; max-width:1180px; margin:0 auto;
  padding:calc(clamp(84px, 12vmin, 130px) + env(safe-area-inset-top,0px)) var(--gutter) calc(120px + env(safe-area-inset-bottom,0px));
}
.intro{ text-align:center; margin-bottom:clamp(18px, 3vmin, 32px); }
.page-title{ cursor:default; }

.stepper{ list-style:none; margin:0 auto clamp(16px, 2.6vmin, 28px); padding:0; display:flex; justify-content:center; gap:6px; flex-wrap:wrap; counter-reset:s; }
.stepper li{ counter-increment:s; }
.stepper button{
  display:inline-flex; align-items:center; gap:9px; min-height:40px; padding:0 14px 0 6px; border-radius:999px;
  border:1px solid var(--border); background:var(--surface); color:var(--dim); font-weight:600; font-size:14px; cursor:pointer;
  backdrop-filter:blur(10px); transition:background-color .2s ease, color .2s ease, border-color .2s ease;
}
:root[dir="rtl"] .stepper button{ padding:0 6px 0 14px; }
.stepper button::before{
  content:counter(s); display:grid; place-items:center; width:28px; height:28px; border-radius:999px;
  background:var(--hover); font-size:13px; font-variant-numeric:tabular-nums;
}
.stepper button[aria-current="step"]{ background:var(--btn); color:var(--on-btn); border-color:transparent; }
.stepper button[aria-current="step"]::before{ background:rgba(127,127,127,.25); }
.stepper button.done{ color:var(--text); }
.stepper button.done::before{ content:'✓'; background:var(--accent); color:var(--on-accent); }
.stepper button:disabled{ cursor:not-allowed; opacity:.5; }

.panel{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px); box-shadow:var(--shadow);
}
.step{ padding:clamp(18px, 3vmin, 34px); animation:step-in .35s var(--ease-out); }
@keyframes step-in{ from{ opacity:0; transform:translateY(8px); } }
.step h2{ margin:0; font-size:clamp(22px, 3vmin, 30px); letter-spacing:-.02em; }
:root[lang="ar"] .step h2{ letter-spacing:0; }
.lead{ margin:8px 0 22px; color:var(--dim); font-size:16px; line-height:1.5; max-width:62ch; }

/* ---------- 2. Shared bits ---------- */
.field{ display:grid; gap:8px; }
.field > span{ font-size:14px; font-weight:500; color:var(--dim); }
.field input, .key-field input, .svc-add input, select{
  height:48px; padding:0 14px; border-radius:12px; border:1px solid var(--border); background:var(--well);
  color:var(--text); font:inherit; font-size:16px; outline:0; min-width:0; width:100%;
  transition:border-color .2s ease, box-shadow .2s ease;
}
select{ appearance:none; padding-inline-end:38px; cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-size:18px; background-position:right 12px center; }
:root[dir="rtl"] select{ background-position:left 12px center; }
.field input:focus, .key-field input:focus, .svc-add input:focus, select:focus{ border-color:var(--accent); }
.btn.small{ min-height:40px; padding:0 16px; font-size:14px; }
.link{ border:0; background:none; color:var(--accent); font-weight:600; font-size:14px; cursor:pointer; padding:6px 2px; }
.hint{ color:var(--faint); font-size:14px; line-height:1.5; margin:14px 0 0; }

.toggle{ display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 0; cursor:pointer; }
.toggle + .toggle{ border-top:1px solid var(--border); }
.toggle > span{ display:grid; gap:3px; }
.toggle small{ color:var(--dim); font-size:14px; line-height:1.45; }
.toggle input{ position:absolute; opacity:0; pointer-events:none; }
.toggle i{ position:relative; width:44px; height:26px; border-radius:999px; background:var(--line); flex-shrink:0; transition:background-color .25s ease; }
.toggle i::after{ content:''; position:absolute; top:3px; inset-inline-start:3px; width:20px; height:20px; border-radius:999px; background:var(--raised); box-shadow:0 1px 3px rgba(0,0,0,.3); transition:transform .25s var(--ease-out); }
.toggle input:checked + i{ background:var(--accent); }
.toggle input:checked + i::after{ transform:translateX(18px); }
:root[dir="rtl"] .toggle input:checked + i::after{ transform:translateX(-18px); }
.toggle input:focus-visible + i{ outline:2px solid var(--accent); outline-offset:3px; }

/* ---------- 3. Keys ---------- */
.keys{ display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:16px; }
.key{ display:grid; gap:10px; padding:18px; border-radius:16px; border:1px solid var(--border); background:var(--well); }
.key-head{ display:grid; gap:2px; }
.key-head b{ font-size:18px; }
.key-head span{ color:var(--dim); font-size:14px; }
.key-field{ position:relative; display:block; }
.key-field input{ background:var(--surface-solid); padding-inline-end:46px; font-family:ui-monospace, monospace; font-size:15px; }
.key .state{ position:absolute; top:50%; inset-inline-end:14px; translate:0 -50%; width:22px; height:22px; border-radius:999px; }
.key[data-state="ok"] .key-field input{ border-color:#3ddc84; box-shadow:0 0 0 3px rgba(61,220,132,.14); }
.key[data-state="bad"] .key-field input{ border-color:#ff5d6c; box-shadow:0 0 0 3px rgba(255,93,108,.14); }
.key[data-state="ok"] .state{ background:#3ddc84 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23062' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l4 4L19 6'/%3E%3C/svg%3E") center/14px no-repeat; }
.key[data-state="bad"] .state{ background:#ff5d6c url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23400' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7 7 17'/%3E%3C/svg%3E") center/12px no-repeat; }
.key[data-state="checking"] .state{ border:2.5px solid var(--line); border-top-color:var(--accent); animation:spin .8s linear infinite; }
@keyframes spin{ to{ rotate:360deg; } }
.key-note{ font-size:14px; color:var(--dim); min-height:1.2em; }
.key[data-state="bad"] .key-note{ color:#ff7d89; }
.key[data-state="ok"] .key-note{ color:#3ddc84; }
.key-help{ font-size:14px; font-weight:600; color:var(--accent); text-decoration:none; justify-self:start; }
.key-help:hover{ text-decoration:underline; }

/* ---------- 4. Languages + preview ---------- */
.quick{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:20px; }
.quick button{
  min-height:38px; padding:0 14px; border-radius:999px; border:1px solid var(--line); background:transparent; color:var(--text);
  font-weight:600; font-size:14px; cursor:pointer; transition:background-color .2s ease, border-color .2s ease;
}
.quick button:hover{ background:var(--hover); }
.quick button[aria-pressed="true"]{ border-color:var(--accent); background:var(--accent-soft); color:var(--accent); }
.lang-grid{ display:grid; grid-template-columns:minmax(0, 1.1fr) minmax(0, 1fr); gap:24px; align-items:start; }
.lang-fields{ display:grid; }
.row{ display:grid; grid-template-columns:minmax(0,1fr) minmax(0, 270px); align-items:center; gap:14px; padding:12px 0; border-bottom:1px solid var(--border); }
.row:last-child{ border-bottom:0; }
.row > span{ display:grid; gap:2px; }
.row small{ color:var(--dim); font-size:13px; }
.row select{ height:44px; }

.preview-card{ margin:0; position:sticky; top:110px; border-radius:18px; overflow:hidden; border:1px solid var(--border); background:#0d0f11; color:#ece7dc; min-height:380px; display:flex; flex-direction:column; }
.pv-bg{ position:absolute; inset:0; background-size:cover; background-position:center; opacity:.55; transition:opacity .4s ease; }
.pv-bg::after{ content:''; position:absolute; inset:0; background:linear-gradient(90deg, rgba(13,15,17,.95) 0%, rgba(13,15,17,.7) 55%, rgba(13,15,17,.35) 100%), linear-gradient(0deg, rgba(13,15,17,.9), transparent 60%); }
:root[dir="rtl"] .pv-bg::after{ background:linear-gradient(270deg, rgba(13,15,17,.95) 0%, rgba(13,15,17,.7) 55%, rgba(13,15,17,.35) 100%), linear-gradient(0deg, rgba(13,15,17,.9), transparent 60%); }
.pv-body{ position:relative; flex:1; display:flex; gap:20px; padding:24px; align-items:flex-end; }
.pv-poster{ width:clamp(96px, 30%, 150px); aspect-ratio:2/3; object-fit:cover; border-radius:12px; box-shadow:0 14px 34px rgba(0,0,0,.55); background:#1d2125; flex-shrink:0; }
.pv-text{ min-width:0; display:grid; gap:8px; }
.pv-logo{ max-width:min(260px, 100%); max-height:90px; object-fit:contain; object-position:left center; filter:drop-shadow(0 4px 14px rgba(0,0,0,.6)); }
:root[dir="rtl"] .pv-logo{ object-position:right center; }
.pv-logo[src=""], .pv-poster[src=""]{ visibility:hidden; }
.pv-text h3{ margin:0; font-size:22px; }
.pv-meta{ margin:0; font-size:13px; color:rgba(236,231,220,.7); }
.pv-story{ margin:0; font-size:14px; line-height:1.55; color:rgba(236,231,220,.88); display:-webkit-box; -webkit-line-clamp:4; -webkit-box-orient:vertical; overflow:hidden; }
.pv-samples{ position:relative; display:flex; gap:6px; flex-wrap:wrap; padding:0 24px 20px; }
.pv-samples button{ min-height:32px; padding:0 12px; border-radius:999px; border:1px solid rgba(236,231,220,.25); background:rgba(0,0,0,.3); color:#ece7dc; font-size:13px; font-weight:600; cursor:pointer; }
.pv-samples button[aria-pressed="true"]{ background:#ece7dc; color:#141618; }
.preview-card.loading .pv-body{ opacity:.6; }

/* ---------- 5. Collections ---------- */
.col-head{ display:flex; justify-content:space-between; align-items:flex-start; gap:18px; flex-wrap:wrap; }
.col-head .lead{ margin-bottom:16px; }
.search{ display:flex; align-items:center; gap:10px; height:46px; padding:0 14px; width:min(100%, 280px); border:1px solid var(--border); border-radius:12px; background:var(--well); }
.search:focus-within{ border-color:var(--accent); }
.search svg{ width:18px; height:18px; fill:none; stroke:var(--faint); stroke-width:2; stroke-linecap:round; flex-shrink:0; }
.search input{ flex:1; min-width:0; border:0; outline:0; background:transparent; color:var(--text); font:inherit; font-size:16px; }

.groups{ display:flex; gap:6px; overflow-x:auto; padding-bottom:6px; scrollbar-width:thin; margin:0 -4px; padding-inline:4px; }
.groups button{
  flex-shrink:0; display:inline-flex; align-items:center; gap:8px; min-height:40px; padding:0 14px; border-radius:999px;
  border:1px solid var(--border); background:var(--well); color:var(--dim); font-weight:600; font-size:14px; cursor:pointer; white-space:nowrap;
}
.groups button span{ min-width:22px; padding:1px 7px; border-radius:999px; background:var(--hover); font-size:12px; text-align:center; }
.groups button span.on{ background:var(--accent); color:var(--on-accent); }
.groups button[aria-selected="true"]{ background:var(--btn); color:var(--on-btn); border-color:transparent; }
.group-tools{ display:flex; justify-content:space-between; align-items:center; margin:10px 0 12px; color:var(--dim); font-size:14px; }

.cards{ display:grid; grid-template-columns:repeat(auto-fill, minmax(210px, 1fr)); gap:14px; align-items:start; }
.card{
  position:relative; display:flex; flex-direction:column; border-radius:16px; overflow:hidden; cursor:pointer;
  border:1px solid var(--border); background:var(--well); text-align:start; padding:0; color:var(--text);
  transition:transform .25s var(--ease-out), border-color .2s ease, box-shadow .25s ease;
}
@media (hover:hover){ .card:hover{ transform:translateY(-3px); box-shadow:var(--card-shadow); } }
.card .art{ position:relative; aspect-ratio:16/9; background:#121417; overflow:hidden; }
.card .art img, .card .art canvas{ display:block; width:100%; height:100%; object-fit:cover; }
.card .check{
  position:absolute; top:10px; inset-inline-end:10px; width:28px; height:28px; border-radius:999px; display:grid; place-items:center;
  background:rgba(0,0,0,.45); border:2px solid rgba(255,255,255,.7); transition:background-color .2s ease, transform .25s var(--ease-out);
}
.card .check svg{ width:16px; height:16px; fill:none; stroke:#1b0e04; stroke-width:3; stroke-linecap:round; stroke-linejoin:round; opacity:0; }
.card[aria-pressed="true"]{ border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.card[aria-pressed="true"] .check{ background:var(--accent); border-color:var(--accent); transform:scale(1.05); }
.card[aria-pressed="true"] .check svg{ opacity:1; }
.card[aria-pressed="mixed"] .check{ background:var(--accent); border-color:var(--accent); }
.card[aria-pressed="mixed"] .check::after{ content:''; width:12px; height:3px; border-radius:2px; background:#1b0e04; }
.card .meta{ display:flex; align-items:center; justify-content:space-between; gap:8px; padding:10px 12px; }
.card .meta b{ font-size:15px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chips{ display:flex; gap:4px; flex-shrink:0; }
.chip{
  min-height:28px; padding:0 10px; border-radius:999px; border:1px solid var(--line); background:transparent; color:var(--dim);
  font-size:12px; font-weight:600; cursor:pointer;
}
.chip[aria-pressed="true"]{ background:var(--accent-soft); border-color:var(--accent); color:var(--accent); }
.card .src{ position:absolute; bottom:8px; inset-inline-start:8px; font-size:11px; font-weight:700; letter-spacing:.06em; padding:3px 8px; border-radius:999px; background:rgba(0,0,0,.55); color:#ece7dc; }
.empty{ grid-column:1/-1; text-align:center; color:var(--dim); padding:30px 0; }

.custom{ display:grid; gap:14px; margin-top:16px; }
.custom-msg{ margin:0; min-height:1.3em; color:var(--dim); font-size:14px; }
.custom-msg.bad{ color:#ff7d89; }

/* ---------- 6. Layout step ---------- */
.options{ border:1px solid var(--border); border-radius:16px; padding:4px 18px; background:var(--well); margin-bottom:20px; }
.order{ list-style:none; margin:0; padding:0; display:grid; gap:8px; }
.order li{
  display:grid; grid-template-columns:auto auto 128px minmax(0,1fr) auto auto; align-items:center; gap:10px;
  padding:8px 12px 8px 8px; border-radius:14px; border:1px solid var(--border); background:var(--well);
  transition:transform .2s var(--ease-out), box-shadow .2s ease, opacity .2s ease;
}
:root[dir="rtl"] .order li{ padding:8px 8px 8px 12px; }
.order li.past-limit{ opacity:.55; }
.lay-limit{ margin:0 0 10px; }
.order .grip{ width:28px; height:40px; display:grid; place-items:center; color:var(--faint); cursor:grab; border:0; background:none; }
.order .grip svg{ width:18px; height:18px; fill:currentColor; }
.order .thumb{ width:96px; aspect-ratio:16/9; border-radius:8px; overflow:hidden; background:#121417; }
.order .thumb img, .order .thumb canvas{ width:100%; height:100%; object-fit:cover; display:block; }
.order .name{ display:grid; gap:2px; min-width:0; }
.order .name input{ height:38px; border-radius:9px; border:1px solid transparent; background:transparent; color:var(--text); font:inherit; font-weight:600; font-size:15px; padding:0 8px; margin-inline-start:-8px; min-width:0; }
.order .name input:hover{ border-color:var(--border); }
.order .name input:focus{ border-color:var(--accent); outline:0; background:var(--surface-solid); }
.order .name small{ color:var(--faint); font-size:12px; }
.order .home, .order .unmerge{
  min-height:34px; padding:0 12px; border-radius:999px; border:1px solid var(--line); background:transparent; color:var(--dim);
  font-size:13px; font-weight:600; cursor:pointer; white-space:nowrap;
}
.order .unmerge[hidden], .order .home[hidden]{ display:none; }
.order .home[aria-pressed="true"]{ background:var(--accent-soft); border-color:var(--accent); color:var(--accent); }
.order .moves{ display:flex; gap:2px; }
.order .moves button{ width:34px; height:34px; border-radius:999px; border:0; background:transparent; color:var(--dim); cursor:pointer; display:grid; place-items:center; }
.order .moves button:hover{ background:var(--hover); color:var(--text); }
.order .moves svg{ width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; }

/* ---------- 7. Install ---------- */
.install-box{ display:grid; justify-items:start; gap:10px; }
.btn.big{ min-height:56px; padding:0 30px; font-size:17px; }
.err{ margin:0; color:#ff7d89; font-size:14px; min-height:1.2em; }
.done{ display:grid; gap:18px; }
.done-actions{ display:flex; flex-wrap:wrap; gap:10px; }
.copy-row{ display:flex; gap:8px; }
.copy-row input{ flex:1; font-family:ui-monospace, monospace; font-size:14px; direction:ltr; }

/* ---------- 8. Bottom nav ---------- */
.wizard-nav{
  position:fixed; left:50%; bottom:calc(16px + env(safe-area-inset-bottom,0px)); z-index:15; translate:-50% 0;
  display:flex; align-items:center; gap:12px; width:min(calc(100% - 2 * var(--gutter)), 1180px);
  padding:10px; border-radius:999px; border:1px solid var(--border);
  background:var(--header-frost); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px); box-shadow:var(--shadow);
}
.wizard-nav .btn{ min-height:46px; }
.wizard-nav svg{ width:18px; height:18px; }
:root[dir="rtl"] .wizard-nav svg{ transform:scaleX(-1); }
.nav-status{ flex:1; text-align:center; color:var(--dim); font-size:14px; }
#back[hidden]{ display:inline-flex !important; visibility:hidden; }

/* ---------- 9. Small screens ---------- */
@media (max-width:900px){
  .lang-grid{ grid-template-columns:1fr; }
  .preview-card{ position:relative; top:auto; order:-1; min-height:300px; }
}
@media (max-width:640px){
  .keys{ grid-template-columns:1fr; }
  .row{ grid-template-columns:1fr; gap:8px; }
  .cards{ grid-template-columns:repeat(2, minmax(0,1fr)); gap:10px; }
  .card .meta{ flex-direction:column; align-items:flex-start; }
  .order li{ grid-template-columns:auto auto minmax(0,1fr) auto; }
  .order .flags{ flex-direction:column; }
  .order .thumb{ display:none; }
  .order .moves{ grid-column:1 / -1; justify-content:flex-end; display:none; }
  .nav-status{ font-size:13px; }
  .wizard-nav{ border-radius:20px; }
  .wizard-nav .btn{ padding:0 16px; }
  .pv-body{ padding:16px; gap:14px; }
}

/* ---------- v1.1: TVDB card, sources, poster services, apps, Jellyfin ---------- */
.keys{ grid-template-columns:repeat(3, minmax(0,1fr)); }
.key-head{ display:flex; align-items:center; gap:12px; }
.key-head img{ width:36px; height:36px; border-radius:9px; object-fit:contain; flex-shrink:0; background:#fff1; }
.key-head > span{ display:grid; gap:2px; min-width:0; }
.key-head em{ font-style:normal; font-size:12px; font-weight:600; color:var(--faint); margin-inline-start:6px; }
.key.optional:not([data-state="ok"]):not([data-state="bad"]) .key-note{ color:var(--faint); }
.key-links{ display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; }

/* where details come from: logo tiles, the picked one ringed in accent with a tick */
.src-block{ display:grid; gap:4px; padding:14px 0; border-bottom:1px solid var(--border); }
.src-block h3{ margin:0; font-size:16px; }
.src-block > .hint{ margin:0 0 6px; }
.src-row{ display:grid; grid-template-columns:minmax(0,1fr) minmax(0, 270px); align-items:center; gap:14px; padding:8px 0; }
.src-row > span:first-child{ display:grid; gap:2px; }
.src-row small{ color:var(--dim); font-size:13px; }
.src-pick{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.src-opt{
  position:relative; display:flex; align-items:center; gap:10px; min-height:52px; padding:8px 12px; border-radius:12px;
  border:1px solid var(--line); background:var(--well); color:var(--text); cursor:pointer; font-size:15px;
  transition:border-color .2s ease, box-shadow .2s ease, background-color .2s ease, transform 160ms var(--ease-out);
}
.src-opt img{ width:28px; height:28px; border-radius:7px; object-fit:contain; flex-shrink:0; }
.src-opt .tick{ position:absolute; top:-7px; inset-inline-end:-7px; width:22px; height:22px; border-radius:999px; display:grid; place-items:center;
  background:var(--accent); color:var(--on-accent); opacity:0; transform:scale(.5); transition:opacity .2s ease, transform .25s var(--ease-out); }
.src-opt .tick svg{ width:13px; height:13px; fill:none; stroke:currentColor; stroke-width:3.2; stroke-linecap:round; stroke-linejoin:round; }
.src-opt[aria-checked="true"]{ border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); background:var(--accent-soft); }
.src-opt[aria-checked="true"] .tick{ opacity:1; transform:none; }
.src-opt:disabled{ opacity:.4; cursor:not-allowed; filter:grayscale(1); }
.src-opt:active:not(:disabled){ transform:scale(.97); }
@media (hover:hover){ .src-opt:hover:not(:disabled):not([aria-checked="true"]){ border-color:var(--dim); } }
.src-need{ margin:2px 0 0; }

/* key fields: masked text with a show/hide eye beside the tick */
.key-field input{ padding-inline-end:84px; }
.key-field input.masked{ -webkit-text-security:disc; }
.key .eye{ position:absolute; top:50%; inset-inline-end:42px; translate:0 -50%; width:36px; height:36px; padding:0; border:0; border-radius:999px;
  display:grid; place-items:center; background:transparent; color:var(--dim); cursor:pointer; }
.key .eye svg{ width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
@media (hover:hover){ .key .eye:hover{ color:var(--text); background:var(--hover); } }
.lang-fields .toggle + .toggle{ border-top:0; }

.providers{ display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:10px; margin-bottom:20px; }
.provider{
  display:grid; gap:4px; align-content:start; text-align:start; padding:14px 16px; min-height:84px; border-radius:14px;
  border:1px solid var(--border); background:var(--well); color:var(--text); cursor:pointer;
  transition:border-color .2s ease, box-shadow .2s ease, transform .2s var(--ease-out);
}
.provider b{ font-size:16px; }
.provider small{ color:var(--dim); font-size:13px; line-height:1.4; }
.provider[aria-checked="true"]{ border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); background:var(--accent-soft); }
@media (hover:hover){ .provider:hover{ transform:translateY(-2px); } }
.pos-grid{ display:grid; grid-template-columns:minmax(0, 1fr) minmax(0, 1.1fr); gap:24px; align-items:start; }
.pos-panel{ display:grid; }
.pos-panel .key-help{ margin-top:12px; }
textarea{ width:100%; min-height:130px; padding:12px 14px; border-radius:12px; border:1px solid var(--border); background:var(--well); color:var(--text);
  font:13px/1.5 ui-monospace, monospace; resize:vertical; outline:0; direction:ltr; }
textarea:focus{ border-color:var(--accent); }
.pos-preview{ display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:12px; position:sticky; top:110px; transition:opacity .2s ease; }
.pos-preview.loading{ opacity:.55; }
.pos-card{ margin:0; display:grid; gap:8px; }
.pos-card img{ width:100%; aspect-ratio:2/3; object-fit:cover; border-radius:12px; background:var(--well); box-shadow:var(--card-shadow); display:block; }
.pos-card.broken img{ visibility:hidden; }
.pos-card.broken::before{ content:'—'; display:grid; place-items:center; aspect-ratio:2/3; border-radius:12px; background:var(--well); color:var(--faint); grid-row:1; }
.pos-card figcaption{ font-size:13px; color:var(--dim); text-align:center; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* install: one icon per app, tap it and the app opens */
.apps-label{ margin:0; font-size:14px; font-weight:600; color:var(--dim); }
.done-actions{ gap:14px; }
.app-icon{
  display:grid; justify-items:center; gap:8px; width:112px; padding:16px 8px 12px; border-radius:20px; text-decoration:none;
  border:1px solid var(--line); background:var(--well); color:var(--text); transition:transform .2s var(--ease-out), border-color .2s ease, box-shadow .2s ease;
}
.app-icon img{ width:64px; height:64px; border-radius:16px; object-fit:contain; display:block; }
.app-icon b{ font-size:14px; font-weight:600; }
@media (hover:hover){ .app-icon:hover{ transform:translateY(-3px); border-color:var(--accent); box-shadow:var(--card-shadow); } }
.app-icon:active{ transform:scale(.96); }

.jf{ border:1px solid var(--border); border-radius:16px; padding:4px 18px 14px; background:var(--well); margin-bottom:20px; }
.jf-head{ display:flex !important; align-items:center; gap:12px; }
.jf-head img{ width:34px; height:34px; flex-shrink:0; }
.jf-head > span{ display:grid; gap:3px; }
.jf-body{ display:grid; gap:12px; padding-top:6px; }
.jf-body .toggle{ padding:10px 0; }
.jf-fields{ display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:12px; }
.jf-body .field input{ background:var(--surface-solid); }
.jf-done{ display:grid; gap:8px; }
.copy-sq{ flex:0 0 48px; width:48px; height:48px; display:grid; place-items:center; padding:0; border:0; border-radius:12px;
  background:var(--accent); color:var(--on-accent, #fff); cursor:pointer; transition:transform .15s ease, filter .15s ease; }
.copy-sq svg{ width:21px; height:21px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.copy-sq:active{ transform:scale(.94); }
.copy-sq:disabled{ opacity:.45; cursor:default; }
@media (hover:hover){ .copy-sq:not(:disabled):hover{ filter:brightness(1.08); } }
#jf .scrobble{ display:grid; gap:6px; padding-top:12px; margin-top:8px; border-top:1px solid var(--border); }
.cine{ display:grid; gap:12px; padding-top:14px; }
.cine .field input{ background:var(--surface-solid); }
.cine-acts{ display:flex; flex-wrap:wrap; gap:8px; }

@media (max-width:900px){
  .keys{ grid-template-columns:1fr; }
  .providers{ grid-template-columns:repeat(2, minmax(0,1fr)); }
  .pos-grid{ grid-template-columns:1fr; }
  .pos-preview{ position:relative; top:auto; order:-1; }
}
@media (max-width:640px){
  .jf-fields{ grid-template-columns:1fr; }
  .src-row{ grid-template-columns:1fr; gap:8px; }
  .app-icon{ flex:1 1 0; width:auto; }
}
.key:not([data-state="ok"]):not([data-state="bad"]):not([data-state="checking"]) .eye{ inset-inline-end:6px; }
.key:not([data-state="ok"]):not([data-state="bad"]):not([data-state="checking"]) .key-field input{ padding-inline-end:48px; }

/* ---------- v1.3: PostersPlus language, poster keys, catalogs ---------- */
.lang-pick{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.lang-pick button{
  min-height:46px; padding:0 12px; border-radius:12px; border:1px solid var(--line); background:var(--well); color:var(--text);
  font-size:15px; font-weight:600; cursor:pointer; transition:border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.lang-pick button[data-value="ar"]{ font-family:var(--font-ar); }
.lang-pick button[aria-checked="true"]{ border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); background:var(--accent-soft); }
.pos-panel .row{ border-bottom:0; padding-top:0; }
.pos-panel .key{ margin-bottom:2px; }
.svc-links{ list-style:none; margin:4px 0 0; padding:0; display:flex; flex-wrap:wrap; gap:8px; }
.svc-links a{ display:inline-flex; align-items:center; min-height:38px; padding:0 14px; border-radius:999px; border:1px solid var(--line);
  color:var(--text); text-decoration:none; font-size:14px; font-weight:600; }
@media (hover:hover){ .svc-links a:hover{ border-color:var(--accent); color:var(--accent); } }

.track{ display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:12px; margin-bottom:18px; }
.svc{ display:flex; align-items:center; gap:12px; padding:14px 16px; border-radius:16px; border:1px solid var(--border); background:var(--well); min-width:0; }
.svc img{ width:40px; height:40px; border-radius:10px; object-fit:contain; flex-shrink:0; }
.svc-text{ display:grid; gap:2px; min-width:0; flex:1; }
.svc-text b{ font-size:16px; }
.svc-text small{ color:var(--dim); font-size:13px; }
.svc[data-on="true"]{ border-color:#3ddc84; }
.svc[data-on="true"] .svc-state{ color:#3ddc84; }
.svc-add{ display:flex; gap:8px; flex:1 1 320px; }
.svc-add input{ flex:1; min-width:0; }
.code-box{ grid-column:1 / -1; display:grid; gap:10px; padding:16px; border-radius:16px; border:1px dashed var(--accent); background:var(--accent-soft); }
.code-box p{ margin:0; }
.code-row{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.code{ font:700 26px/1 ui-monospace, monospace; letter-spacing:.12em; padding:10px 14px; border-radius:12px; background:var(--surface-solid); direction:ltr; user-select:all; }
.track .custom-msg{ grid-column:1 / -1; margin:0; }
.track .custom-msg:empty{ display:none; }
@media (max-width:640px){
  .track{ grid-template-columns:1fr; }
  .svc-add{ flex-basis:100%; }
}
/* sample titles: an even grid so the rows line up */
.pv-samples{ display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); }
.pv-samples button{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding:0 8px; }
@media (max-width:640px){ .pv-samples{ grid-template-columns:repeat(2, minmax(0,1fr)); } }
#catTabs{ margin-bottom:14px; }
.svc img[src*="simkl"]{ background:#fff; padding:5px; }

/* ---------- v1.4 ---------- */
.keys{ grid-template-columns:repeat(2, minmax(0,1fr)); }
.key-head .mini-seg{ display:inline-flex; margin-inline-start:auto; }
.mini-seg{ display:inline-flex; padding:3px; gap:2px; border-radius:999px; border:1px solid var(--line); background:var(--surface-solid); }
.mini-seg button{ min-height:30px; padding:0 12px; border:0; border-radius:999px; background:transparent; color:var(--dim); font-size:13px; font-weight:600; cursor:pointer; }
.mini-seg button[aria-checked="true"]{ background:var(--btn); color:var(--on-btn); }
.svc-pills{ display:flex; flex-wrap:wrap; gap:8px; }
.svc-pills button{ min-height:38px; padding:0 14px; border-radius:999px; border:1px solid var(--line); background:var(--well); color:var(--text); font-size:14px; font-weight:600; cursor:pointer; }
.svc-pills button[aria-checked="true"]{ border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); background:var(--accent-soft); }
.pos-panel[data-for="byok"]{ gap:14px; }
.byok-svc{ display:grid; gap:10px; }
.cat-tools{ display:grid; gap:10px; margin-bottom:16px; }
.cat-tools:empty{ display:none; }
.cat-tools .hint{ margin:0; }
.mdb-tools{ display:grid; gap:10px; }
.tool-row{ max-width:560px; }
.key-inline{ padding:0; border:0; background:none; flex:1 1 320px; gap:4px; }
.key-inline .key-note{ min-height:0; font-size:13px; }
@media (max-width:900px){ .keys{ grid-template-columns:1fr; } }
.more-btn{ grid-column:1 / -1; justify-self:center; }

/* ---------- v1.6: poster fan on catalog cards, import + scrobble ---------- */
.card .art .fan3{ position:absolute; inset:0; display:grid; place-items:center; perspective:600px;
  background:radial-gradient(120% 90% at 50% 100%, rgba(255,138,61,.16), transparent 60%), #0d0f11; }
.card .art .fan3 img{ position:absolute; width:auto; height:78%; aspect-ratio:2/3; object-fit:cover; border-radius:6px;
  box-shadow:0 10px 24px rgba(0,0,0,.6); transition:transform .35s var(--ease-out); }
.card .art .fan3 .c{ z-index:2; transform:translateY(4%); }
.card .art .fan3 .l{ z-index:1; transform:translateX(-46%) translateY(2%) rotateY(28deg) scale(.86); filter:brightness(.6); }
.card .art .fan3 .r{ z-index:1; transform:translateX(46%) translateY(2%) rotateY(-28deg) scale(.86); filter:brightness(.6); }
@media (hover:hover){
  .card:hover .art .fan3 .l{ transform:translateX(-58%) translateY(2%) rotateY(32deg) scale(.86); }
  .card:hover .art .fan3 .r{ transform:translateX(58%) translateY(2%) rotateY(-32deg) scale(.86); }
}
.svc-extra{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.svc .svc-extra{ flex-basis:100%; justify-content:flex-end; }
.svc{ flex-wrap:wrap; }

/* layout rows: catalogs show their poster fan, like their cards */
.order .thumb{ position:relative; width:128px; }
@media (min-width:641px) and (max-width:900px){ .order li{ grid-template-columns:auto auto 96px minmax(0,1fr) auto auto; } .order .thumb{ width:96px; } }
.order .thumb.art{ background:linear-gradient(135deg, #1c2026, #121417); }
.order .thumb .fan3{ position:absolute; inset:0; display:grid; place-items:center; perspective:400px; }
.order .thumb .fan3 img{ position:absolute; width:auto; height:84%; aspect-ratio:2/3; object-fit:cover; border-radius:3px; box-shadow:0 3px 8px rgba(0,0,0,.5); }
.order .thumb .fan3 .c{ z-index:2; }
.order .thumb .fan3 .l{ z-index:1; transform:translateX(-46%) rotateY(28deg) scale(.86); filter:brightness(.6); }
.order .thumb .fan3 .r{ z-index:1; transform:translateX(46%) rotateY(-28deg) scale(.86); filter:brightness(.6); }

/* layout: tick rows, then act on all of them */
.order .flags{ display:flex; gap:6px; align-items:center; }
.order li.picked{ border-color:var(--accent); background:linear-gradient(var(--accent-soft), var(--accent-soft)), var(--well); }
.pick{ position:relative; display:inline-flex; align-items:center; gap:10px; cursor:pointer; }
.pick input{ position:absolute; opacity:0; width:1px; height:1px; }
.pick i{ width:20px; height:20px; border-radius:6px; border:2px solid var(--line); display:grid; place-items:center; flex-shrink:0; transition:background-color .15s ease, border-color .15s ease; }
.pick input:checked + i{ background:var(--accent); border-color:var(--accent); }
.pick input:checked + i::after{ content:''; width:9px; height:5px; border:2px solid var(--on-accent); border-top:0; border-right:0; transform:rotate(-45deg) translate(1px,-1px); }
.pick input:indeterminate + i{ border-color:var(--accent); }
.pick input:indeterminate + i::after{ content:''; width:9px; height:2px; background:var(--accent); }
.pick input:focus-visible + i{ outline:2px solid var(--accent); outline-offset:2px; }
.bulk{ display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; padding:8px 12px; margin-bottom:8px;
  border:1px solid var(--border); border-radius:14px; background:var(--well); position:sticky; top:72px; z-index:4; }
.bulk-count{ font-size:14px; font-weight:600; color:var(--dim); }
.bulk-acts{ display:flex; gap:6px; flex-wrap:wrap; }
.bulk-acts .btn.small{ min-height:32px; font-size:13px; padding:0 12px; }
.bulk-acts .btn[disabled]{ opacity:.4; }
.bulk-acts .danger{ color:#ff7d89; border-color:rgba(255,125,137,.4); }
:root[data-theme="light"] .bulk-acts .danger{ color:#c43a4e; }

/* AI tab settings */
.ai-box{ display:grid; gap:4px; padding:4px 16px 12px; border:1px solid var(--border); border-radius:16px; background:var(--well); margin-bottom:6px; }
.ai-box .row select{ max-width:100%; }
.ai-box .tool-row{ margin-top:8px; }
.svc-pills button[disabled]{ opacity:.4; cursor:not-allowed; }
.ai-box .row .svc-pills{ display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
.ai-box .row .svc-pills button{ width:auto; flex:0 0 auto; }
@media (max-width:640px){ .ai-box .row .svc-pills{ justify-content:flex-start; } }

/* Simple / Advanced */
body.simple [data-adv]{ display:none !important; }
.mode-row{ display:flex; flex-direction:column; align-items:center; margin:0 0 18px; }
.mode-pick{ display:inline-grid; grid-template-columns:1fr 1fr; gap:4px; padding:4px; border-radius:16px; border:1px solid var(--border); background:var(--well); }
.mode-pick button{ display:grid; gap:1px; padding:8px 18px; border:0; border-radius:12px; background:transparent; color:var(--dim); text-align:center; cursor:pointer; font:inherit; }
.mode-pick b{ font-size:15px; font-weight:600; }
.mode-pick small{ font-size:12px; color:var(--faint); }
.mode-need{ margin:8px 0 0; font-size:13px; color:var(--dim); }
.mode-pick button[aria-checked="true"]{ background:var(--btn); color:var(--on-btn); }
.mode-pick button[aria-checked="true"] small{ color:var(--on-btn); opacity:.7; }
@media (max-width:520px){ .mode-pick button{ padding:8px 10px; } .mode-pick small{ font-size:11px; } }

/* ---------- v1.14: scrobble on Install, your lists, own cover ---------- */
.scrobble{ padding-top:14px; }
.scrobble > .jf-head{ margin-bottom:4px; }
/* the trackers as tiles, two to a row: logo and switch on top, the name and its state under them */
.scrobble-list{ display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:10px; margin-top:10px; }
.scrobble-row{ display:grid; grid-template-columns:auto 1fr auto; grid-template-areas:"logo . switch" "name name wl" "note note note";
  align-content:start; align-items:center; gap:10px 8px; padding:14px; border:1px solid var(--border); border-radius:14px; background:var(--well); }
.scrobble-row img{ grid-area:logo; width:32px; height:32px; border-radius:8px; }
.scrobble-row .toggle.sw{ grid-area:switch; padding:0; border:0; justify-self:end; }
/* the watchlist switch (Jellyfin's ♥), right under the scrobble one */
.scrobble-row .toggle.sw.wl{ grid-area:wl; gap:8px; }
.scrobble-row .toggle.sw.wl span{ font-size:12px; font-weight:600; color:var(--dim); white-space:nowrap; }
.scrobble-row .toggle.sw.wl input:checked ~ span, .scrobble-row .toggle.sw.wl:has(input:checked) span{ color:var(--text); }
.scrobble-row b{ grid-area:name; font-size:15px; }
.scrobble-row small{ grid-area:note; font-size:12.5px; line-height:1.4; color:var(--dim); }
.scrobble-row.off .toggle{ cursor:default; }
.scrobble-row.off img, .scrobble-row.off b, .scrobble-row.off small, .scrobble-row.off .wl span{ opacity:.55; }
/* Jellyfin only: a tile across both columns, under the trackers */
#scrobbleJf.scrobble-row{ display:grid; margin-top:10px; padding:14px; border-top:1px solid var(--border); cursor:pointer; }
#scrobbleJf.scrobble-row[hidden]{ display:none; }
#scrobbleJf > i{ grid-area:switch; justify-self:end; }
#scrobbleJf small{ color:var(--dim); }
@media (max-width:340px){ .scrobble-list{ grid-template-columns:1fr; } }
/* the source: just its logo, under the tick (services without a logo keep their name); Own cover sits in the name area */
.card .src{ top:44px; bottom:auto; inset-inline-start:auto; inset-inline-end:10px; white-space:nowrap; }
.card > .own-cover{ position:absolute; bottom:10px; inset-inline-end:10px; z-index:3; font:inherit; font-size:12px; font-weight:600; color:var(--text);
  background:transparent; border:1px solid var(--border); border-radius:999px; padding:4px 10px; cursor:pointer; }
@media (hover:hover){ .card > .own-cover:hover{ border-color:var(--dim); } }

/* ---------- v1.15: trackers on the Keys step ---------- */
.keys-sub{ margin:28px 0 4px; font-size:18px; }
.keys-sub em{ font-style:normal; font-size:13px; font-weight:500; color:var(--dim); margin-inline-start:6px; }
[data-step="keys"] .track{ margin-top:12px; margin-bottom:0; }
.tab-logo{ height:18px; width:auto; vertical-align:-4px; border-radius:3px; }
.card .src img{ display:block; height:15px; width:auto; border-radius:2px; }
.card .src:has(img){ padding:3px; background:transparent; }
.src-opt img.wide-logo{ width:auto; height:20px; object-fit:contain; border-radius:3px; }

/* ---------- v1.20: service logos on source badges + tabs ---------- */
.card .src.logo{ display:inline-flex; align-items:center; padding:4px; border-radius:8px; background:rgba(0,0,0,.6); backdrop-filter:blur(6px); }
.card .src.logo span{ display:none; }
.card .src.logo img{ width:20px; height:20px; border-radius:4px; object-fit:contain; }
.card .src.logo img[alt="IMDb"]{ width:auto; height:16px; border-radius:2px; }
.tab-logo.sq{ height:18px; width:18px; border-radius:4px; }

/* ---------- v1.22: AIOMetadata mode, Select all on catalogs, Jellyfin window ---------- */
.mode-pick{ grid-template-columns:repeat(3, 1fr); }
@media (max-width:640px){ .mode-pick{ grid-template-columns:1fr; } }
body.aiom [data-not-aiom]{ display:none !important; }
body:not(.aiom) [data-only-aiom]{ display:none !important; }
body:not(.aiom) #aiomHint{ display:none; }
button.app-icon{ font:inherit; color:inherit; cursor:pointer; }
dialog.jf-dialog{
  width:min(720px, calc(100vw - 32px)); max-height:calc(100dvh - 32px); padding:22px; border:1px solid var(--border); border-radius:22px;
  background:var(--surface-solid); color:var(--text); box-shadow:var(--shadow); overflow:auto;
}
dialog.jf-dialog[open]{ display:grid; gap:14px; animation:pop-in 220ms var(--ease-out); }
dialog.jf-dialog::backdrop{ background:rgba(8,8,10,.6); backdrop-filter:blur(3px); }
.jf-dialog .ld-head{ display:flex; justify-content:space-between; gap:12px; align-items:center; }
.jf-dialog .ld-head h2{ margin:0; font-size:22px; }
.jf-dialog .ld-close{ width:40px; height:40px; border-radius:999px; border:0; background:transparent; color:var(--text); cursor:pointer; display:grid; place-items:center; }
.jf-dialog .ld-close svg{ width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; }
@media (hover:hover){ .jf-dialog .ld-close:hover{ background:var(--hover); } }
.jf-dialog .jf{ margin-bottom:0; }
.jf-actions{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.jf-actions .err{ margin:0; }

.cine-opts{ display:grid; }
.cine-opts .toggle{ padding:10px 0; }

/* ---------- v1.24: rows AIOMetadata doesn't have ---------- */
.card.na{ cursor:default; }
.card.na .art > *:not(.na-tag){ opacity:.45; }
.card.na .meta{ opacity:.55; }
.na-tag{ position:absolute; top:10px; inset-inline-start:10px; font-size:11px; font-weight:700; padding:4px 9px; border-radius:999px; background:var(--btn); color:var(--on-btn); }

/* ---------- v1.25: Letterboxd tile ---------- */
.lb-add{ display:flex; gap:8px; flex-basis:100%; }
.lb-add input{ flex:1; min-width:0; height:40px; padding:0 12px; border-radius:12px; border:1px solid var(--line); background:var(--surface-solid); color:var(--text); font:inherit; }
.svc[data-svc="lb"][data-on="true"] .lb-add{ flex-basis:auto; margin-inline-start:auto; }
.svc[data-svc="pmdb"] .key-inline{ flex-basis:100%; }
.svc[data-svc="pmdb"] .svc-text, .svc[data-svc="lb"] .svc-text{ flex:1; }
.svc[data-svc="lb"][data-on="true"] .lb-add{ flex:0 0 auto; margin-inline-start:auto; }

/* setup password + delete */
.owner-pass{ max-width:420px; width:100%; display:grid; gap:12px; }
.owner-pass em{ font-style:normal; opacity:.6; font-weight:400; }
.account-row{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:-4px 0 16px; font-size:14px; opacity:.85; }
.account-row span{ margin-inline-end:auto; }
.danger-zone{ margin-top:28px; padding-top:20px; border-top:1px solid var(--line, rgba(127,127,127,.25)); display:grid; gap:8px; }
.danger-zone h3{ margin:0; font-size:16px; }
.del-btn{ background:#c73545; color:#fff; border-color:#c73545; }
.cine-who{ margin:0; display:flex; gap:8px; align-items:center; flex-wrap:wrap; }

/* cards look the same on every screen: name on top, Movies / Shows chips side by side under it (room kept for Own cover);
   every card in a row as tall as the tallest, so a card with both chips is no bigger than its neighbours */
.cards{ align-items:stretch; }
.card .meta{ flex-direction:column; align-items:flex-start; flex:1; }
.card .meta b{ max-width:100%; }
.card .meta .chips{ flex-direction:row; flex-wrap:wrap; align-items:flex-start; gap:6px; padding-inline-end:96px; }

/* Install: the Cinemeta row opens its own dialog */
.link-row{ display:flex; align-items:center; gap:12px; width:100%; margin:4px 0 16px; padding:12px 14px; border-radius:16px;
  border:1px solid var(--border); background:var(--well); color:var(--text); font:inherit; text-align:start; cursor:pointer; }
.link-row img{ width:34px; height:34px; flex-shrink:0; }
.link-row > span{ display:grid; gap:3px; flex:1; min-width:0; }
.link-row small{ color:var(--dim); font-size:13px; }
.link-row svg{ width:20px; height:20px; flex-shrink:0; fill:none; stroke:var(--dim); stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; }
:root[dir="rtl"] .link-row svg{ transform:scaleX(-1); }
@media (hover:hover){ .link-row:hover{ background:var(--hover); } }
#cineDialog .cine{ padding-top:4px; }
#cineDialog .jf-head small{ color:var(--dim); font-size:14px; line-height:1.45; }

/* phone Layout rows keep a picture: cover or poster fan on the left, name over the Home / Collection buttons */
@media (max-width:640px){
  .order li{ grid-template-columns:auto 14px 92px minmax(0,1fr); grid-template-areas:"pick grip thumb name" "pick grip thumb flags"; gap:4px 8px; }
  .order .pick{ grid-area:pick; } .order .grip{ grid-area:grip; width:14px; } .order .name{ grid-area:name; } .order .flags{ grid-area:flags; flex-direction:row; flex-wrap:wrap; }
  .order .thumb{ display:block; grid-area:thumb; width:92px; aspect-ratio:3/2; align-self:center; }
  .order .home, .order .unmerge{ min-height:30px; padding:0 10px; font-size:12px; }
}

/* the cover editor ("Own cover"): the builder, full screen over the wizard */
dialog.editor-dialog{ position:fixed; inset:0; width:100vw; height:100dvh; max-width:none; max-height:none; margin:0; padding:0; border:0; background:var(--bg); color:inherit; }
dialog.editor-dialog[open]{ animation:fade-in 200ms var(--ease-out); }
dialog.editor-dialog::backdrop{ background:var(--bg); }
dialog.editor-dialog iframe{ display:block; width:100%; height:100%; border:0; }

/* a collection with more than one cover: small see-through arrows on the picture */
.card .art .cv-nav{ position:absolute; top:50%; transform:translateY(-50%); z-index:3; width:28px; height:28px; border-radius:999px; display:grid; place-items:center;
  background:rgba(0,0,0,.32); border:0; color:#fff; cursor:pointer; opacity:.75; transition:opacity .15s ease, background-color .15s ease; padding:0; }
.card .art .cv-nav svg{ width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2.4; stroke-linecap:round; stroke-linejoin:round; }
.card .art .cv-prev{ inset-inline-start:6px; }
.card .art .cv-next{ inset-inline-end:6px; }
:root[dir="rtl"] .card .art .cv-nav svg{ transform:scaleX(-1); }
@media (hover:hover){ .card .art .cv-nav:hover{ opacity:1; background:rgba(0,0,0,.55); } }
.card .art .cv-count{ position:absolute; bottom:8px; inset-inline-start:50%; transform:translateX(-50%); z-index:3; font-size:11px; font-weight:600; color:#fff;
  background:rgba(0,0,0,.4); border-radius:999px; padding:1px 7px; pointer-events:none; }
:root[dir="rtl"] .card .art .cv-count{ transform:translateX(50%); }

/* ---------- v1.43: every card 16:9, more than one source, collections waiting on an MDBList key ---------- */
.card .art .fit{ position:absolute; inset:0; background:#000; }
.card .art .fit .fit-bg{ position:absolute; inset:0; object-fit:cover; filter:blur(18px) brightness(.45); transform:scale(1.15); }
.card .art .fit .fit-fg{ position:relative; object-fit:contain; box-shadow:0 0 24px rgba(0,0,0,.6); }
.card .src.srcs{ flex-direction:column; gap:4px; padding:3px; }
.card .src-pick{ display:block; padding:2px; border:0; border-radius:6px; background:transparent; cursor:pointer; opacity:.4; transition:opacity .15s ease; }
.card .src-pick[aria-pressed="true"]{ opacity:1; box-shadow:0 0 0 1.5px #ece7dc; }
@media (hover:hover){ .card .src-pick:hover{ opacity:1; } }
.card .src-pick span{ display:none; }
.card .src-pick img{ display:block; width:20px; height:20px; border-radius:4px; object-fit:contain; }
.card.dim .art > :not(.src):not(.cv-bar){ opacity:.35; }
.card.dim .meta{ opacity:.55; }
.key[data-state="builtin"] .key-note{ color:#e8b04a; }
/* back, count and next together at the bottom middle, clear of the stacked source logos on the right */
.card .art .cv-bar{ position:absolute; bottom:6px; inset-inline-start:50%; transform:translateX(-50%); z-index:3; display:flex; align-items:center; gap:6px; }
:root[dir="rtl"] .card .art .cv-bar{ transform:translateX(50%); }
.card .art .cv-bar .cv-nav, .card .art .cv-bar .cv-count{ position:static; transform:none; }
.card .art .cv-bar .cv-nav{ width:26px; height:26px; }

/* header save button (shown once the setup has a link): green = saved, red = last save failed */
.qsave{ position:relative; display:inline-flex; }
.qsave[hidden]{ display:none; }
.qsave{ --qs-ok:#4ade80; --qs-bad:#ff7d89; }
:root[data-theme="light"] .qsave{ --qs-ok:#15803d; --qs-bad:#c62839; }
.qsave #qsaveBtn{ transition:background-color .2s ease, color .2s ease, transform 160ms var(--ease-out); }
.qsave[data-flash="saved"] #qsaveBtn{ color:var(--qs-ok); }
.qsave[data-flash="failed"] #qsaveBtn{ color:var(--qs-bad); }
.qsave[data-state="saving"] #qsaveBtn svg{ animation:qs-pulse 900ms ease-in-out infinite; }
@keyframes qs-pulse{ 50%{ opacity:.35; } }
.qsave-note{
  position:absolute; top:calc(100% + 6px); inset-inline-end:0; z-index:60;
  display:grid; gap:2px; width:max-content; max-width:min(280px, 80vw);
  padding:8px 12px; border-radius:12px; background:var(--surface-solid); border:1px solid var(--line);
  box-shadow:var(--shadow); font-size:14px; line-height:1.35; cursor:pointer;
  opacity:0; transform:translateY(-4px); pointer-events:none; transition:opacity .2s ease, transform .25s var(--ease-out);
}
.qsave-note.show{ opacity:1; transform:none; pointer-events:auto; }
.qsave-note small{ color:var(--dim); font-size:13px; }
.qsave[data-flash="saved"] .qsave-note b{ color:var(--qs-ok); }
.qsave[data-flash="failed"] .qsave-note b{ color:var(--qs-bad); }
.pp-look button{ white-space:nowrap; padding-inline:14px; }
.row:has(> .pp-look){ display:grid; grid-template-columns:1fr; gap:10px; }

/* tab logos on the Catalogs and Collections steps */
.tab-ic{ flex:none; width:18px; height:18px; border-radius:4px; object-fit:contain; vertical-align:-4px; margin-inline-end:2px; }
.tab-ic.wide{ width:auto; max-width:32px; }
.tab-ic.round{ border-radius:999px; object-fit:cover; }
.tab-ic.face{ object-position:50% 20%; }
.tab-ic.left{ object-position:22% 30%; }
svg.tab-ic{ fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; border-radius:0; }
svg.tab-ic .gold{ stroke:#e0b04a; }
:root[data-theme="dark"] [aria-selected="true"] .tab-ic.wide.mono, :root[data-theme="light"] [aria-selected="false"] .tab-ic.wide.mono{ filter:invert(1); }

/* Layout: one tool bar (export / import, keys tick, rename sections) */
.lay-tools{ display:flex; align-items:center; justify-content:space-between; gap:8px 12px; flex-wrap:wrap; margin:0 0 10px; }
.lay-io{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.lay-tools .btn svg{ width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.lay-tools .btn[aria-expanded="true"]{ border-color:var(--accent); color:var(--accent); }
.lay-tools .btn[hidden]{ display:none; }
.lay-warn{ margin:-2px 0 10px; font-size:13px; color:#e0a040; }
:root[data-theme="light"] .lay-warn{ color:#9a6200; }
svg.tab-ic .fire{ stroke:#ff6a2b; }

/* ---------- v1.70: login page (/login/) ---------- */
.login-main{ display:grid; place-items:start center; }
.login{ width:min(480px, 100%); display:grid; gap:16px; margin-top:clamp(8px, 4vh, 48px); padding:clamp(22px, 4vmin, 36px); }
.login .page-title{ font-size:clamp(28px, 6vw, 40px); margin:0; }
.login .lead{ margin:0; }
.login .btn{ width:100%; }
.login-alt{ margin:0; text-align:center; font-size:14px; }
.login-alt a, .intro-login a{ color:var(--accent); }
.intro-login{ margin:6px 0 0; color:var(--dim); font-size:14px; }
.lay-io .io-creds{ display:inline-flex; align-items:center; gap:8px; font-size:13px; color:var(--dim); cursor:pointer; padding-inline:6px; }
.lay-io .io-creds input{ width:16px; height:16px; accent-color:var(--accent); }
/* Simple mode shows only the Letterboxd tile in Services: give it the whole row */
body.simple .svc[data-svc="lb"]{ grid-column:1 / -1; }

/* Import your setup (opened from the home page): its window */
.imp-head{ display:flex; align-items:center; gap:12px; }
.imp-head img{ width:40px; height:40px; border-radius:10px; }
.imp-file{ display:flex; align-items:center; gap:10px; min-width:0; }
.imp-file small{ color:var(--dim); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.section-names{ margin:0 0 12px; padding:12px 14px 14px; border:1px solid var(--border); border-radius:14px; background:var(--well); }
.section-names[hidden]{ display:none; }
.section-names .hint{ margin:0 0 10px; font-size:13px; color:var(--dim); }
.section-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(140px, 1fr)); gap:10px; }
.section-names .field{ display:grid; gap:4px; margin:0; }
.section-names .field span{ font-size:12px; font-weight:600; color:var(--faint); }
.section-names .field input{ height:38px; font-size:14px; }

/* Layout covers in their own shape: 2:3 and 1:1 ones sit centred in the 16:9 slot */
.order .thumb[data-shape="poster"], .order .thumb[data-shape="square"]{ justify-self:center; width:auto; height:72px; }
.order .thumb[data-shape="poster"]{ aspect-ratio:2/3; }
.order .thumb[data-shape="square"]{ aspect-ratio:1; }
@media (min-width:641px) and (max-width:900px){ .order .thumb[data-shape="poster"], .order .thumb[data-shape="square"]{ height:54px; } }
@media (max-width:640px){ .order .thumb[data-shape="poster"], .order .thumb[data-shape="square"]{ height:61px; } }

#accountText { min-width: 0; overflow-wrap: anywhere; user-select: text; }

/* ---------- v1.94: Jellyfin window full screen, Save top right, addon list (like AIOStreams) ---------- */
dialog.jf-dialog.jf-full{ width:100vw; max-width:100vw; height:100dvh; max-height:100dvh; margin:0; border:0; border-radius:0; padding:0 0 32px; align-content:start; gap:10px; }
.jf-full > :not(.jf-top){ width:min(980px, calc(100% - 32px)); margin-inline:auto; }
.jf-full .jf{ border:0; background:transparent; padding:0; }
.jf-top{ position:sticky; top:0; z-index:3; display:flex; align-items:center; gap:8px; padding:10px 16px; background:var(--surface-solid); border-bottom:1px solid var(--border); }
.jf-dialog .jf-top h2{ flex:1; font-size:19px; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.jf-full > #jfErr{ margin:0; }
.jf-full > #jfErr:empty{ display:none; }
.jf-full .jf-body{ gap:8px; }
.jf-full .jf-body > .hint{ margin:-2px 0 4px; font-size:13px; }
.jf-full .toggle small{ font-size:12.5px; }
.jf-pass input{ padding-inline-end:46px; font-family:inherit; }
.jf-pass .eye{ position:absolute; top:50%; inset-inline-end:6px; translate:0 -50%; width:36px; height:36px; padding:0; border:0; border-radius:999px; background:transparent; color:var(--dim); cursor:pointer; display:grid; place-items:center; }
.jf-pass .eye svg{ width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.jf-full .jf-done{ gap:4px; }
.jf-full .jf-done .hint{ margin:0; font-size:13px; }
.jf-title{ padding:14px 0 6px; }
/* Jellyfin user name and password: smaller boxes, each with a copy button like the server address */
.jf-fields .copy-row{ gap:6px; }
.jf-fields .copy-row > .key-field{ flex:1; min-width:0; }
.jf-fields .field input{ height:40px; font-size:14px; border-radius:10px; padding:0 12px; }
.jf-fields .jf-pass input{ padding-inline-end:40px; }
.jf-fields .jf-pass .eye{ width:30px; height:30px; inset-inline-end:5px; }
.jf-fields .copy-sq{ flex:0 0 40px; width:40px; height:40px; border-radius:10px; }
.jf-fields .copy-sq svg{ width:18px; height:18px; }
.jfa{ display:grid; gap:8px; padding:14px 0 6px; border-top:1px solid var(--border); margin-top:6px; }
.jfa-head{ display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
.jfa-head b{ font-size:16px; }
.jfa-head small{ color:var(--dim); font-variant-numeric:tabular-nums; }
.jfa > .hint{ margin:0; font-size:13px; color:var(--dim); }
.jfa-add{ display:flex; gap:8px; }
.jfa-add input{ flex:1; min-width:0; min-height:40px; padding:0 12px; border:1px solid var(--border); border-radius:12px; background:var(--surface-solid); color:var(--text); font:inherit; font-size:14px; direction:ltr; }
.jfa-add input:focus{ outline:none; border-color:var(--accent); }
.jfa > .err{ margin:0; }
.jfa > .err:empty{ display:none; }
.jfa-list{ list-style:none; margin:0; padding:0; display:grid; gap:8px; }
.jfa-item{ display:grid; grid-template-columns:auto 40px minmax(0,1fr) auto; grid-template-areas:"move logo name switch" "move logo res del"; align-items:center; column-gap:10px; row-gap:6px;
  padding:10px 12px; border:1px solid var(--border); border-radius:14px; background:var(--well); }
.jfa-item.off .jfa-logo, .jfa-item.off .jfa-name, .jfa-item.off .jfa-res{ opacity:.5; }
.jfa-move{ grid-area:move; display:grid; gap:2px; justify-items:center; }
.jfa-move button, .jfa-del{ width:28px; height:24px; padding:0; border:0; border-radius:8px; background:transparent; color:var(--dim); cursor:pointer; display:grid; place-items:center; }
.jfa-move button:disabled{ opacity:.25; cursor:default; }
.jfa-move svg, .jfa-del svg{ width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
@media (hover:hover){ .jfa-move button:not(:disabled):hover, .jfa-del:hover{ background:var(--hover); color:var(--text); } }
.jfa-move em{ font-style:normal; font-size:11px; font-weight:700; color:var(--dim); font-variant-numeric:tabular-nums; }
.jfa-logo{ grid-area:logo; width:40px; height:40px; border-radius:10px; object-fit:contain; background:var(--surface-solid); }
.jfa-name{ grid-area:name; min-width:0; display:grid; }
.jfa-name b{ font-size:15px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.jfa-name small{ font-size:12px; color:var(--dim); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; direction:ltr; text-align:start; }
.jfa-item > .toggle{ grid-area:switch; padding:0; justify-self:end; }
.jfa-res{ grid-area:res; display:flex; flex-wrap:wrap; gap:6px; }
.jfa-res label{ position:relative; display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border:1px solid var(--border); border-radius:999px; font-size:12.5px; font-weight:600; cursor:pointer; user-select:none; }
.jfa-res input{ position:absolute; opacity:0; pointer-events:none; }
.jfa-res label:has(input:checked){ background:var(--accent); border-color:var(--accent); color:var(--on-accent, #fff); }
.jfa-res label.forced{ border-style:dashed; }
.jfa-res label:has(input:focus-visible){ outline:2px solid var(--accent); outline-offset:2px; }
.jfa-del{ grid-area:del; justify-self:end; }
.jfa-empty{ padding:14px; border:1px dashed var(--border); border-radius:14px; color:var(--dim); font-size:13.5px; text-align:center; }
@media (max-width:520px){ .jfa-item{ grid-template-columns:auto 34px minmax(0,1fr) auto; } .jfa-logo{ width:34px; height:34px; } }

/* live drag on the Layout list: the held row floats above the others, which slide out of its way */
.order{ position:relative; }
.order li{ position:relative; }
@media (pointer:fine){ .order li{ cursor:grab; } .order li input, .order li button, .order li label{ cursor:pointer; } .order .name input{ cursor:text; } .order .grip{ cursor:grab; } }
.order .grip{ touch-action:none; }
.order li.lifted{ z-index:5; cursor:grabbing; border-color:var(--accent); box-shadow:0 14px 34px rgba(0,0,0,.35); background:var(--raised); }
body.sorting, body.sorting *{ user-select:none; -webkit-user-select:none; cursor:grabbing !important; }
