/* ================= ACCOUNT + LIBRARY (Gate 3 staging) =================
   Previously account system: header avatar menu, sign-in, account settings,
   tabbed library. Follows the site's Midnight Noir / Emerald / pearl tokens.
   Buttons are never red; destructive actions are plain text links. */

/* The `hidden` attribute must always win over component display rules
   (e.g. .ghost-btn sets display:inline-flex, which otherwise overrides
   the UA [hidden] rule and leaves phantom clickable elements). */
[hidden]{display:none!important;}

/* ---------- production CSP hardening ----------
   The live site ships a hash-based style-src (no 'unsafe-inline'), so no
   inline style= attributes may be used. These rules replace the handful of
   inline styles the Gate-3 staging markup carried — same visuals, CSP-clean. */
#avatarPreviewBox{display:contents}
a.ghost-btn{text-decoration:none}
.acct-mt13{margin-top:13px}
.acct-mt16{margin-top:16px}
.acct-mt18{margin-top:18px}
.acct-mt20{margin-top:20px}
.ghost-btn{
  display:inline-flex;align-items:center;justify-content:center;
  min-height:44px;padding:0 18px;border-radius:999px;cursor:pointer;
  border:1px solid var(--line-strong);background:transparent;color:var(--ink);
  font:inherit;font-size:13px;font-weight:700;letter-spacing:.02em;
  transition:border-color .18s,background .18s,transform .12s;white-space:nowrap;
}
.ghost-btn:hover{border-color:var(--emerald-hi);background:rgba(14,95,69,.1);}
.ghost-btn:active{transform:scale(.96);}
.avatar-btn{
  position:relative;display:grid;place-items:center;width:44px;height:44px;
  border-radius:50%;border:1px solid var(--line-strong);background:var(--surface-2);
  color:var(--ink);cursor:pointer;padding:0;
  transition:border-color .18s,transform .12s,box-shadow .18s;
}
.avatar-btn:hover{border-color:var(--emerald-hi);}
.avatar-btn:active{transform:scale(.94);}
.avatar-btn[aria-expanded="true"]{border-color:var(--emerald-hi);box-shadow:0 0 0 4px rgba(14,95,69,.18);}
.avatar-circle{
  display:grid;place-items:center;width:100%;height:100%;border-radius:50%;
  overflow:hidden;font-family:"Cinzel",serif;font-size:17px;font-weight:700;
  color:var(--ink);
}
.avatar-circle.signed-in{background:var(--emerald);color:#fff;}
.avatar-circle img{width:100%;height:100%;object-fit:cover;display:block;}
.avatar-circle svg{width:22px;height:22px;opacity:.85;}

/* ---------- account dropdown menu ---------- */
.acct-menu{
  position:fixed;z-index:120;min-width:264px;max-width:calc(100vw - 24px);
  border:1px solid var(--line-strong);border-radius:16px;background:var(--surface);
  box-shadow:0 18px 50px rgba(0,0,0,.5);padding:8px;
}
.acct-menu[hidden]{display:none;}
.acct-menu-head{padding:12px 14px 10px;border-bottom:1px solid var(--line);margin-bottom:6px;}
.acct-menu-head b{display:block;font-size:14px;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.acct-menu-head span{display:block;font-size:12px;color:var(--muted);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.acct-item{
  display:flex;align-items:center;gap:12px;width:100%;min-height:48px;
  padding:10px 14px;border:0;border-radius:10px;background:transparent;color:var(--ink);
  font:inherit;font-size:14px;font-weight:600;text-align:left;cursor:pointer;
}
.acct-item:hover{background:rgba(14,95,69,.12);}
.acct-item:focus-visible{outline:2px solid var(--emerald-hi);outline-offset:-2px;}
.acct-item .acct-ic{flex:none;width:20px;height:20px;opacity:.8;}
.acct-item.danger{color:var(--ink);}
.acct-sep{height:1px;background:var(--line);margin:6px 4px;}

/* ---------- sign-in modal ---------- */
.signin-card{width:min(480px,100%);}
.signin-card .modal-body{padding:38px 34px;}
.signin-card h2{font-family:"Cinzel",serif;font-size:clamp(28px,4vw,38px);margin:8px 0 10px;}
.signin-sub{color:var(--muted);line-height:1.6;font-size:14px;margin:0 0 6px;}
.signin-mailto{font-size:12px;color:var(--muted);margin-top:14px;line-height:1.5;}

/* ---------- account settings view ---------- */
.acct-wrap{max-width:860px;margin:0 auto;}
.acct-head{margin-bottom:8px;}
.acct-head h1{font-family:"Cinzel",serif;font-size:clamp(38px,7vw,64px);line-height:1;margin:10px 0 12px;}
.acct-head p{color:var(--muted);line-height:1.6;max-width:60ch;}
.acct-sec{
  border:1px solid var(--line);border-radius:20px;background:var(--surface);
  padding:26px;margin-top:22px;
}
.acct-sec>h2{font-family:"Cinzel",serif;font-size:22px;margin:0 0 4px;}
.acct-sec>.acct-sec-sub{color:var(--muted);font-size:13px;line-height:1.6;margin:0 0 18px;}
.acct-row{display:flex;align-items:center;gap:16px;padding:14px 0;border-top:1px solid var(--line);min-height:64px;}
.acct-row:first-of-type{border-top:0;}
.acct-row .grow{flex:1;min-width:0;}
.acct-row .grow b{display:block;font-size:14px;color:var(--ink);}
.acct-row .grow p{margin:3px 0 0;font-size:12.5px;color:var(--muted);line-height:1.55;}
.acct-row .grow p .svc-note{display:block;}
.profile-grid{display:grid;grid-template-columns:96px 1fr;gap:20px;align-items:start;}
.avatar-edit{position:relative;width:96px;height:96px;border-radius:50%;overflow:hidden;border:1px solid var(--line-strong);background:var(--surface-2);cursor:pointer;padding:0;}
.avatar-edit img{width:100%;height:100%;object-fit:cover;display:block;}
.avatar-edit .avatar-fallback{display:grid;place-items:center;width:100%;height:100%;font-family:"Cinzel",serif;font-size:34px;background:var(--emerald);color:#fff;}
.avatar-edit .avatar-cam{
  position:absolute;inset:auto 0 0 0;padding:6px 0 7px;background:rgba(5,5,4,.72);
  color:#fff;font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;
}
.explicit-note{font-size:12px;color:var(--muted);line-height:1.6;margin-top:12px;max-width:60ch;}
.field input[readonly]{opacity:.75;}
.avatar-actions{display:flex;gap:10px;margin-top:10px;flex-wrap:wrap;}

/* switch */
.switch{position:relative;flex:none;width:56px;height:34px;cursor:pointer;}
.switch input{position:absolute;opacity:0;width:100%;height:100%;margin:0;cursor:pointer;}
.switch .track{
  position:absolute;inset:0;border-radius:999px;background:var(--surface-2);
  border:1px solid var(--line-strong);transition:background .2s,border-color .2s;pointer-events:none;
}
.switch .track::after{
  content:"";position:absolute;top:3px;left:4px;width:26px;height:26px;border-radius:50%;
  background:var(--muted);transition:transform .2s,background .2s;
}
.switch input:checked+.track{background:var(--emerald);border-color:var(--emerald-hi);}
.switch input:checked+.track::after{transform:translateX(20px);background:#fff;}
.switch input:focus-visible+.track{outline:2px solid var(--emerald-hi);outline-offset:2px;}

/* segmented */
.segmented{display:inline-flex;border:1px solid var(--line-strong);border-radius:999px;padding:4px;gap:2px;background:var(--surface-2);}
.segmented button{
  border:0;background:transparent;color:var(--muted);font:inherit;font-size:13px;font-weight:700;
  min-height:44px;padding:0 18px;border-radius:999px;cursor:pointer;white-space:nowrap;
}
.segmented button[aria-pressed="true"]{background:var(--emerald);color:#fff;}
.segmented button:focus-visible{outline:2px solid var(--emerald-hi);outline-offset:2px;}

/* danger zone: text link only, never a button */
.danger-zone{border-color:var(--line);}
.text-danger{
  background:none;border:0;padding:0;color:var(--muted);font:inherit;font-size:13px;
  text-decoration:underline;text-underline-offset:3px;cursor:pointer;min-height:44px;
}
.text-danger:hover{color:var(--ink);}
.delete-confirm{border:1px solid var(--line-strong);border-radius:14px;padding:18px;margin-top:14px;background:var(--surface-2);}
.delete-confirm p{font-size:13px;line-height:1.65;color:var(--copy);margin:0 0 14px;}
.delete-confirm .del-actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center;}

/* ---------- library tabs ---------- */
.lib-tabs{
  display:flex;gap:6px;margin:30px 0 8px;padding:4px;flex-wrap:wrap;
  border:1px solid var(--line);border-radius:18px;background:var(--surface);width:fit-content;max-width:100%;
}
.lib-tab{
  border:0;background:transparent;color:var(--muted);font:inherit;font-size:13.5px;font-weight:700;
  min-height:48px;padding:0 18px;border-radius:13px;cursor:pointer;white-space:nowrap;
  display:inline-flex;align-items:center;gap:9px;
}
.lib-tab:hover{color:var(--ink);}
.lib-tab[aria-selected="true"]{background:var(--emerald);color:#fff;}
.lib-tab:focus-visible{outline:2px solid var(--emerald-hi);outline-offset:2px;}
.lib-count{
  font-size:11.5px;font-weight:800;min-width:26px;height:26px;padding:0 7px;border-radius:999px;
  display:inline-grid;place-items:center;background:rgba(127,127,127,.18);color:inherit;
}
.lib-tab[aria-selected="true"] .lib-count{background:rgba(255,255,255,.22);}
.lib-pane{padding:18px 0 8px;}
.lib-pane[hidden]{display:none;}

/* continue watching cards */
.cw-card{
  display:grid;grid-template-columns:132px 1fr;gap:18px;align-items:center;
  border:1px solid var(--line);border-radius:18px;background:var(--surface);
  padding:16px;margin-bottom:14px;
}
.cw-art{width:132px;aspect-ratio:2/3;border-radius:12px;object-fit:cover;background:var(--surface-2);display:block;}
.cw-body{min-width:0;}
.cw-body h3{margin:0 0 6px;font-size:17px;color:var(--ink);}
.cw-meta{font-size:13px;color:var(--muted);margin:0 0 12px;line-height:1.5;}
.cw-meta b{color:var(--copy);font-weight:700;}
.cw-bar{height:8px;border-radius:999px;background:var(--surface-2);border:1px solid var(--line);overflow:hidden;margin-bottom:14px;}
.cw-bar i{display:block;height:100%;background:var(--emerald);border-radius:999px;transition:width .4s;}
.cw-actions{display:flex;gap:10px;flex-wrap:wrap;}

/* continue-watching nudge: gentle, honest, emerald — never gold */
.cw-nudge{
  display:flex;align-items:center;gap:14px;flex-wrap:wrap;
  border:1px solid var(--emerald);border-left-width:4px;border-radius:14px;
  background:color-mix(in srgb, var(--emerald) 8%, var(--surface));
  padding:12px 16px;margin-bottom:12px;
}
.cw-nudge p{margin:0;font-size:14px;color:var(--copy);flex:1;min-width:200px;line-height:1.5;}
.cw-nudge b{color:var(--ink);}

/* watchlist + history rows */
.lib-row{
  display:grid;grid-template-columns:64px 1fr auto;gap:16px;align-items:center;
  border:1px solid var(--line);border-radius:16px;background:var(--surface);
  padding:12px 16px 12px 12px;margin-bottom:12px;
}
.lib-row>img{width:64px;aspect-ratio:2/3;border-radius:9px;object-fit:cover;background:var(--surface-2);display:block;}
.lib-row .grow{min-width:0;}
.lib-row .grow h3{margin:0 0 4px;font-size:15px;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.lib-row .grow p{margin:0;font-size:12.5px;color:var(--muted);line-height:1.5;}
.lib-row .row-actions{display:flex;gap:8px;align-items:center;}
.status-pill{
  display:inline-block;font-size:10.5px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;
  border:1px solid var(--line-strong);border-radius:999px;padding:5px 11px;color:var(--muted);margin-top:7px;
}
.status-pill.watching{color:var(--emerald-hi);border-color:var(--emerald-hi);}
.icon-act{
  display:grid;place-items:center;width:44px;height:44px;border-radius:50%;cursor:pointer;
  border:1px solid var(--line-strong);background:transparent;color:var(--muted);padding:0;
  transition:color .15s,border-color .15s,background .15s,transform .12s;
}
.icon-act:hover{color:var(--ink);border-color:var(--emerald-hi);}
.icon-act:active{transform:scale(.92);}
.icon-act.on{color:#f5c518;border-color:#f5c518;}
.icon-act svg{width:19px;height:19px;}
.icon-act.rm:hover{color:var(--ink);border-color:var(--muted);}

/* favorites grid reuses .catalog poster cards */

/* designed empty states */
.lib-empty{
  border:1px dashed var(--line-strong);border-radius:20px;padding:52px 28px;text-align:center;
  background:var(--surface);margin:8px 0 20px;
}
.lib-empty .empty-art{margin-bottom:14px;color:var(--emerald);}
.lib-empty .empty-art svg{width:44px;height:44px;}
.lib-empty h3{font-family:"Cinzel",serif;font-size:21px;margin:0 0 8px;color:var(--ink);}
.lib-empty p{color:var(--muted);font-size:13.5px;line-height:1.65;margin:0 auto 20px;max-width:44ch;}

/* where-to-watch: signed-in service filter note */
.wtw-filtered-note{
  display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;
  border:1px solid var(--line-strong);border-radius:12px;padding:12px 14px;margin-top:12px;
  background:rgba(14,95,69,.08);font-size:12.5px;color:var(--copy);line-height:1.5;
}

/* sign-in required banners inside library */
.lib-signin-strip{
  display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;
  border:1px solid var(--line-strong);border-radius:14px;padding:14px 18px;margin-bottom:18px;
  background:rgba(14,95,69,.07);
}
.lib-signin-strip p{margin:0;font-size:13px;color:var(--copy);line-height:1.55;}
.lib-signin-strip p b{color:var(--ink);}

@media(max-width:600px){
  .acct-sec{padding:20px 18px;}
  .profile-grid{grid-template-columns:72px 1fr;gap:14px;}
  .avatar-edit{width:72px;height:72px;}
  .cw-card{grid-template-columns:96px 1fr;gap:14px;padding:12px;}
  .cw-art{width:96px;}
  .lib-tabs{width:100%;}
  .lib-tab{flex:1 1 auto;justify-content:center;padding:0 10px;}
  .signin-card .modal-body{padding:30px 22px;}
}

/* ---------- Trakt Phase 1a: Watch history hub ---------- */
.trakt-card{
  border:1px solid var(--line);border-radius:16px;background:var(--surface-2);
  padding:18px;margin-top:12px;
}
.trakt-card h3{margin:0 0 6px;font-size:16px;color:var(--ink);}
.trakt-row{display:flex;gap:14px;align-items:flex-start;}
.trakt-row .grow{flex:1;min-width:0;}
.trakt-badge{
  flex:0 0 auto;width:44px;height:44px;border-radius:12px;display:grid;place-items:center;
  font-weight:800;font-size:20px;color:var(--muted);
  background:var(--surface);border:1px solid var(--line-strong);
}
.trakt-badge.on{color:#fff;background:#0E5F45;border-color:#0E5F45;}
.trakt-muted{color:var(--muted);font-size:13px;line-height:1.5;margin:0;}
.trakt-muted .text-link, #traktReconnect{color:var(--emerald-hi);}
.trakt-report{margin:12px 0 0;font-size:14px;color:var(--ink);}
.trakt-actions{display:flex;gap:10px;margin-top:14px;flex-wrap:wrap;}
.trakt-actions .cta[disabled]{opacity:.55;cursor:wait;}
.trakt-progress{margin-top:14px;}
.trakt-bar{height:8px;border-radius:999px;background:var(--surface);border:1px solid var(--line);overflow:hidden;}
.trakt-bar > span{display:block;height:100%;width:0;border-radius:999px;background:var(--emerald);transition:width .3s;}
.trakt-unmatched{margin-top:14px;border-top:1px solid var(--line);padding-top:12px;}
.trakt-unmatched summary{cursor:pointer;font-weight:700;font-size:14px;color:var(--ink);min-height:44px;display:flex;align-items:center;}
.trakt-unrow{display:flex;justify-content:space-between;gap:12px;padding:8px 0;border-bottom:1px solid var(--line);font-size:13px;color:var(--ink);}
.trakt-list{margin:10px 0 0;padding-left:20px;color:var(--ink);font-size:14px;line-height:1.55;}
.trakt-list li{margin-bottom:8px;}
.trakt-check{display:flex;gap:10px;align-items:flex-start;margin:14px 0 4px;font-size:14px;color:var(--ink);cursor:pointer;}
.trakt-check input{width:20px;height:20px;margin-top:2px;accent-color:#0E5F45;}
.trakt-upsell{margin-top:14px;}
.trakt-notice{
  position:fixed;z-index:400;left:50%;bottom:calc(104px + env(safe-area-inset-bottom));
  transform:translateX(-50%) translateY(16px);background:#1d221f;color:#f2e9d8;
  border:1px solid rgba(242,233,216,.14);border-radius:999px;padding:12px 20px;font-size:14px;
  opacity:0;transition:opacity .25s,transform .25s;pointer-events:none;max-width:92vw;text-align:center;
}
.trakt-notice.show{opacity:1;transform:translateX(-50%) translateY(0);}
@media (max-width:640px){
  .trakt-actions .cta, .trakt-actions .ghost-btn{flex:1 1 auto;}
}
/* Anchor scroll offset under the sticky header. */
#acctWatchHist{scroll-margin-top:96px;}
