/* Copyright (c) 2026 Pavel Bardukov. All rights reserved. See LICENSE. */
/* The application around the screens: header, screen switching, the skill-profile dialog. */
/* Every theme is dark: native parts (select drop-downs, number spinners, the search field's ✕,
   default scrollbars) follow that instead of Chromium's white. */
:root{--muted:var(--dim); color-scheme:dark}
html,body{height:100%}

/* ── form fields ──
   Without this every input/select/textarea is the browser's white box on the dark window.
   `:where()` keeps the specificity at zero, so any class rule (`.ships-search`, `.ed-cq-in`,
   `.ed-name`, the SSO dialog's own checkboxes) still wins on sizes and details. */
:where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea){
  background-color:var(--bg-card); color:var(--text); border:1px solid var(--border); border-radius:3px;
  font-family:"Segoe UI",Arial,sans-serif; padding:2px 5px}
:where(input, select, textarea):focus{outline:none; border-color:var(--accent)}
:where(input, textarea)::placeholder{color:var(--dim); opacity:1}
:where(option, optgroup){background-color:var(--bg-panel); color:var(--text)}
:where(optgroup){color:var(--accent)}
:where(select){cursor:pointer}
:where(input:not([type=checkbox]):not([type=radio]), select, textarea):disabled{opacity:.5; cursor:default}
/* Read only (built-in and EVE profiles): still legible, but flatter than an editable field.
   Checkboxes count as `:read-only` too, hence the exclusions. */
:where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), textarea):read-only:not(:disabled){
  background-color:var(--bg-panel); color:var(--dim)}
:where(input:not([type=checkbox]):not([type=radio]), textarea):read-only:focus{border-color:var(--border-lt)}
/* Chromium paints autofilled fields pale yellow/blue; hold the theme colours instead. */
:where(input):-webkit-autofill{-webkit-text-fill-color:var(--text);
  box-shadow:inset 0 0 0 40px var(--bg-card); caret-color:var(--text)}
/* Plain checkboxes and radios outside the SSO dialog take the accent instead of system blue. */
:where(input[type=checkbox], input[type=radio]){accent-color:var(--accent)}
body{margin:0; padding:0; display:flex; flex-direction:column; overflow:hidden}

.app-head{display:flex; align-items:center; gap:10px; padding:8px 14px;
  background-color:var(--bg-panel); border-bottom:1px solid var(--accent2); flex:0 0 auto}
.app-title{font-family:var(--font-display); letter-spacing:var(--display-tracking);
  color:var(--accent); font-size:16px; margin-right:6px}
/* The open fit's controls, moved up from the editor's head row (2026-09-27; that row holds the
   fit tabs now). Shown on the fit screen only. The name field gives way first when the window is
   narrow; the name prompt floats under the bar instead of widening it. */
.app-fitbar{display:inline-flex; align-items:center; gap:8px; min-width:0; flex:0 1 auto; position:relative}
.app-fitbar .ed-name{width:200px; min-width:90px; flex:0 1 200px}
.app-fitbar button{flex:0 0 auto; white-space:nowrap}
.app-fitbar .ed-ask{position:absolute; left:0; top:calc(100% + 9px); z-index:1320;
  padding:6px 8px; border:1px solid var(--border-lt); border-radius:4px;
  background-color:var(--bg-panel); box-shadow:0 6px 20px rgba(0,0,0,.5)}
.head-field{display:inline-flex; align-items:center; gap:6px; color:var(--dim); font-size:12px}
#profile{min-width:160px}
/* Refresh the pilot's skills from EVE. Shown only while an EVE character is picked; it spins
   while the request runs and turns red with the reason in its tooltip when it fails. */
#btn-profile-sync{padding:0 8px; line-height:1}
.sync-ico{display:inline-block; font-size:14px}
#btn-profile-sync.busy .sync-ico,.sync-ico.spin{animation:sso-spin .9s linear infinite}
#btn-profile-sync:disabled{opacity:.6; cursor:default; transform:none}
#btn-profile-sync:disabled:hover{color:var(--dim); border-color:var(--border)}
#btn-profile-sync.err{color:var(--red); border-color:var(--red)}
#btn-profile-sync.err:hover{color:var(--red); border-color:var(--red)}
#btn-contacts{flex:0 0 auto; white-space:nowrap}
#btn-contacts[aria-expanded="true"]{color:var(--accent); border-color:var(--accent)}

/* ── Contacts: a drop-down under the header's button (ported from Fleet Manager's contact strip) ──
   `.popup` pins itself with right/bottom for the editor's menus; this one is fixed and placed by
   `placeContacts` (shell.js) from the button's rectangle, so both are reset to auto here.
   The four entries look alike but are two elements - a <button> for Discord (it copies the handle)
   and <a>s for the rest - so the face/bevel the bare `button` rule gives is restated for the
   anchors. background-COLOR only: the `background:` shorthand would drop the bevel's image. */
.popup.contacts-pop{position:fixed; right:auto; bottom:auto; top:0; left:0; z-index:1330;
  width:min(300px, calc(100vw - 16px)); box-sizing:border-box; padding:10px 12px 8px;
  background-color:var(--bg-panel); border-color:var(--border-lt); cursor:default}
.contacts-title{color:var(--dim); font-size:12px; letter-spacing:.4px; margin:0 0 8px}
.contacts-list{display:flex; flex-direction:column; gap:6px}
a.contact{background-image:var(--btn-face); box-shadow:var(--btn-edge);
  font-family:var(--font-display); letter-spacing:var(--display-tracking);
  transition:background-color .12s, box-shadow .1s, border-color .12s, color .12s}
a.contact:hover{background-image:var(--btn-face-hover)}
a.contact:active{transform:translateY(1px); background-image:var(--btn-face-down); box-shadow:var(--btn-edge-down)}
button.contact,a.contact{display:flex; align-items:center; gap:10px; width:100%; box-sizing:border-box;
  text-align:left; text-decoration:none; background-color:var(--bg-card); color:var(--text);
  border:1px solid var(--border); border-radius:4px; padding:6px 10px; cursor:pointer; font-size:12px}
button.contact:hover,a.contact:hover{border-color:var(--accent); color:var(--accent); background-color:var(--primary-bg)}
a.contact:focus-visible,button.contact:focus-visible{outline:1px solid var(--accent); outline-offset:1px}
.contact-icon{width:22px; height:22px; flex:0 0 22px; display:block}
.contact-portrait{border-radius:50%; border:1px solid var(--border-lt); box-sizing:border-box; object-fit:cover}
.contact-txt{display:flex; flex-direction:column; align-items:flex-start; min-width:0; line-height:1.25}
.contact-net{font-size:12px; font-weight:bold; color:var(--accent)}
.contact-id{font-size:11px; color:var(--dim); font-family:"Segoe UI",Arial,sans-serif; letter-spacing:0;
  max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.contact:hover .contact-id{color:var(--text)}
/* The press that shows the ✓ leaves the pointer ON the entry, so the hover rule (0,3,0) is restated. */
.contact-id.done,.contact:hover .contact-id.done{color:var(--green)}
/* The legal lines: present and readable, never competing with the entries above. */
.contacts-pop .legal{margin-top:10px; padding-top:8px; border-top:1px solid var(--border);
  color:var(--muted); font-size:10.5px; line-height:1.45; font-family:"Segoe UI",Arial,sans-serif}
.contacts-pop .legal p{margin:3px 0}

/* One screen at a time under the header: the ship list or the fit. Each fills what is left of
   the window and scrolls INSIDE itself - `min-height:0` is what lets a flex child shrink below
   its content instead of pushing the page taller than the window. */
.screen{flex:1 1 auto; min-height:0; min-width:0; display:flex; flex-direction:column;
  overflow:hidden}

.vf-dialog{background:var(--bg-card); border:1px solid var(--border-lt); border-radius:6px;
  padding:14px 16px; width:min(760px, 94vw); max-height:92vh; display:flex; flex-direction:column;
  gap:8px; box-shadow:0 10px 40px rgba(0,0,0,.6); box-sizing:border-box}
.vf-profile{width:min(1100px, 96vw); height:90vh}
.vf-profile .stat-head{gap:10px}
#prof-pick{min-width:180px}
.vf-field{display:flex; flex-direction:column; gap:4px; color:var(--dim); font-size:12px}
.vf-row{display:flex; align-items:flex-end; gap:12px; flex-wrap:wrap}
.vf-row #prof-search{flex:1; min-width:200px}
.vf-actions{display:flex; justify-content:flex-end; gap:8px}
button.seg.del:hover{color:var(--red); border-color:var(--red)}

.prof-skills{flex:1 1 auto; overflow-y:auto; columns:2 420px; column-gap:24px; min-height:0}
.prof-group{break-inside:avoid; margin-bottom:10px}
/* A group is a fold: the header toggles it (its 0/V buttons do not), closed by default. */
.prof-group h5{display:flex; align-items:center; gap:6px; margin:6px 0 3px; color:var(--accent);
  cursor:pointer; user-select:none}
.prof-group h5 .spacer{flex:1}
.prof-caret{display:inline-block; width:10px; font-size:10px; color:var(--dim); transition:transform .12s}
.prof-group.open .prof-caret{transform:rotate(90deg)}
.prof-group h5:hover .prof-caret{color:var(--accent)}
.prof-gcount{color:var(--dim); font-weight:normal; font-size:11px}
.prof-row{display:flex; align-items:center; gap:6px; padding:1px 0}
.prof-name{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px}
.prof-lvls{display:inline-flex; gap:2px}
button.prof-lv{padding:0 5px; min-width:22px; font-size:10px; color:var(--dim)}
button.prof-lv.on{color:var(--accent); border-color:var(--accent); background-color:var(--primary-bg)}
/* Built-in profiles are read only. No global dimming for :disabled exists, and `button:hover`
   would still light a dead button up - so both are undone here. The trained level stays legible. */
button.prof-lv:disabled{opacity:.45; cursor:default; transform:none}
button.prof-lv.on:disabled{opacity:.85}
button.prof-lv:disabled:hover{color:var(--dim); border-color:var(--border)}
button.prof-lv.on:disabled:hover{color:var(--accent); border-color:var(--accent)}

/* Implants: the preset row (a game set or the pilot's own), then the rack and the picker. */
.prof-imp > label{cursor:default}
.prof-imp-head{display:flex; align-items:center; gap:6px; flex-wrap:wrap}
#prof-imp-count{font-variant-numeric:tabular-nums}
/* Why the field is closed - built-in profiles only. An EVE character's implants ARE editable. */
.prof-imp-ro{color:var(--amber); font-size:11px}
.prof-sets{display:flex; align-items:center; gap:6px; flex-wrap:wrap}
#prof-set{flex:0 1 320px; min-width:200px; max-width:100%}
.prof-set-ask{display:inline-flex; align-items:center; gap:6px}
#prof-set-name{width:200px; max-width:60vw}

/* The rack on the left, the catalog on the right - the way the game's clone window reads. */
.prof-imp-body{display:flex; align-items:flex-start; gap:12px; flex-wrap:wrap}
.prof-imp-rack{flex:1 1 300px; min-width:0; min-height:44px; display:flex; align-items:center;
  padding:4px 6px; border:1px solid var(--border); border-radius:4px; background-color:var(--bg-panel)}
/* Only the profile's own cells are clickable; a built-in profile just shows them. */
.prof-imp-rack .slot{cursor:pointer}
.prof-imp-rack.ro .slot{cursor:default; opacity:.6}
.prof-imp-browser{flex:1 1 320px; min-width:0; display:flex; flex-direction:column; gap:4px}
#prof-imp-search{width:100%; box-sizing:border-box}
.prof-imp-list{max-height:210px; overflow-y:auto; border:1px solid var(--border); border-radius:4px;
  background-color:var(--bg-panel); padding:4px 6px}
.prof-imp-list .status{margin:2px 0}
.pi-folder{margin-bottom:2px}
.pi-folder h6{display:flex; align-items:center; gap:6px; margin:4px 0 2px; color:var(--accent);
  font-size:12px; cursor:pointer; user-select:none}
.pi-folder h6 .spacer{flex:1}
.pi-folder.open .prof-caret{transform:rotate(90deg)}
.pi-in{color:var(--text); font-weight:normal; font-size:11px; overflow:hidden;
  text-overflow:ellipsis; white-space:nowrap; max-width:60%}
.pi-count{color:var(--dim); font-weight:normal; font-size:11px}
.pi-row{display:flex; align-items:center; gap:6px; padding:1px 4px; border-radius:3px;
  cursor:pointer; font-size:12px}
.pi-row:hover{background-color:var(--primary-bg); color:var(--accent)}
.pi-row.on{color:var(--accent)}
.pi-row.ro{cursor:default}
.pi-row.ro:hover{background-color:transparent; color:inherit}
.pi-ico{width:24px; height:24px; flex:0 0 auto}
.pi-name{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
/* Dead buttons (read-only profile, nothing picked) must not light up on hover. */
.prof-sets button:disabled{opacity:.45; cursor:default}
.prof-sets button:disabled:hover{color:var(--dim); border-color:var(--border)}

/* ── EVE Login (SSO) dialog: permission cards, then a waiting state while the browser logs in ── */
.vf-sso{width:min(520px, 94vw); padding:0; gap:0; overflow:hidden}
.sso-head{display:flex; align-items:flex-start; gap:12px; padding:16px 18px 12px;
  border-bottom:1px solid var(--border)}
.sso-shield{flex:0 0 auto; width:38px; height:38px; display:inline-flex; align-items:center;
  justify-content:center; border-radius:50%; border:1px solid var(--accent);
  background-color:var(--primary-bg); color:var(--accent)}
.sso-shield svg{width:20px; height:20px}
.sso-titles{display:flex; flex-direction:column; gap:3px; min-width:0}
.sso-titles b{font-family:var(--font-display); letter-spacing:var(--display-tracking);
  color:var(--accent); font-size:16px}
.sso-titles span{font-size:12px}
/* The body scrolls on its own when the window is short; head and footer stay put. */
.sso-body{flex:1 1 auto; min-height:0; overflow-y:auto; padding:10px 18px 12px;
  display:flex; flex-direction:column; gap:8px}
.sso-sect{display:flex; align-items:center; gap:6px; margin:8px 0 0; color:var(--dim);
  font-size:11px; font-weight:bold; letter-spacing:.08em; text-transform:uppercase}
.sso-dot{width:7px; height:7px; border-radius:50%; background-color:var(--blue)}
.sso-perm{display:flex; align-items:flex-start; gap:10px; padding:10px 12px; cursor:pointer;
  border:1px solid var(--border); border-radius:4px; background-color:var(--bg-panel);
  transition:border-color .12s, background-color .12s}
.sso-perm:hover{border-color:var(--accent)}
.sso-perm:has(input:checked:not(:disabled)){border-color:var(--accent); background-color:var(--primary-bg)}
/* Required permissions: always on, cannot be changed - greyed and not hoverable. */
.sso-perm.req{cursor:default; opacity:.7}
.sso-perm.req:hover{border-color:var(--border)}
.sso-perm input[type=checkbox]{appearance:none; -webkit-appearance:none; flex:0 0 auto;
  width:16px; height:16px; margin:2px 0 0; display:inline-grid; place-content:center; cursor:pointer;
  border:1px solid var(--border-lt); border-radius:3px; background-color:var(--bg-deep)}
.sso-perm input[type=checkbox]::before{content:""; width:9px; height:5px; opacity:0;
  border-left:2px solid var(--accent); border-bottom:2px solid var(--accent);
  transform:translateY(-1px) rotate(-45deg)}
.sso-perm input[type=checkbox]:checked{border-color:var(--accent)}
.sso-perm input[type=checkbox]:checked::before{opacity:1}
.sso-perm input[type=checkbox]:disabled{cursor:default; border-color:var(--border); background-color:var(--bg-card)}
.sso-perm input[type=checkbox]:disabled::before{border-color:var(--dim)}
.sso-perm input[type=checkbox]:focus-visible{outline:1px solid var(--accent); outline-offset:2px}
.sso-perm-text{display:flex; flex-direction:column; gap:2px; min-width:0}
.sso-perm-text b{color:var(--text); font-size:13px}
.sso-perm.req .sso-perm-text b{color:var(--dim)}
.sso-perm-text span{color:var(--dim); font-size:12px}
.sso-wait{display:flex; flex-direction:column; align-items:center; gap:12px; padding:28px 18px 8px;
  text-align:center; font-size:12px}
.sso-spinner{width:26px; height:26px; border:2px solid var(--border-lt); border-top-color:var(--accent);
  border-radius:50%; animation:sso-spin .9s linear infinite}
@keyframes sso-spin{to{transform:rotate(360deg)}}
#sso-status{margin:0; padding:4px 18px; text-align:center}
#sso-status:empty{display:none}
.sso-foot{display:flex; align-items:center; gap:8px; padding:12px 18px;
  border-top:1px solid var(--border); background-color:var(--bg-panel)}
/* A text-like button: no bevel, no border, just the words. */
button.sso-text,button.sso-text:active{background-color:transparent; background-image:none;
  box-shadow:none; border-color:transparent; color:var(--dim); transform:none}
button.sso-text:hover{color:var(--accent); border-color:transparent; text-decoration:underline}
button.sso-primary{background-color:var(--primary-bg); color:var(--accent); border-color:var(--accent);
  padding:6px 16px}
button.sso-primary:hover{background-color:var(--primary-bg-hover)}
button.sso-text:disabled,button.sso-primary:disabled{opacity:.45; cursor:not-allowed}

/* ── the header, 2026-09-28: every button, select and field on the bar is ONE height ──
   Listed by where they sit (the bar itself, the Character field, the fit bar, the split button,
   the floating name prompt) so the controls INSIDE the Contacts / Settings drop-downs keep their
   own sizes. Text is centred with flex, since the vertical padding is gone. */
header.app-head > :is(button, select, input),
header.app-head > .head-field > select,
header.app-head .app-fitbar > :is(button, input),
header.app-head .split-btn > button,
header.app-head .ed-ask > :is(button, input){
  height:28px; box-sizing:border-box; padding-top:0; padding-bottom:0; vertical-align:middle}
header.app-head > button, header.app-head .app-fitbar > button,
header.app-head .split-btn > button, header.app-head .ed-ask > button{
  display:inline-flex; align-items:center; justify-content:center}
/* Save fit + the fit menu: one control, the two halves sharing a border. */
.split-btn{display:inline-flex; flex:0 0 auto}
.split-btn > button:first-child{border-top-right-radius:0; border-bottom-right-radius:0}
.split-btn > button + button{border-top-left-radius:0; border-bottom-left-radius:0; margin-left:-1px}
/* Icon-only header buttons (the gear) are square. */
header.app-head > button.head-ico{width:28px; padding:0}
#btn-graphs{flex:0 0 auto; white-space:nowrap}
#btn-settings[aria-expanded="true"]{color:var(--accent); border-color:var(--accent)}
/* The Settings drop-down (placed by shell.js placeSettings; `.contacts-pop` gives it the frame). */
.popup.contacts-pop.settings-pop{width:min(250px, calc(100vw - 16px))}
.settings-row{display:flex; align-items:center; justify-content:space-between; gap:10px;
  margin:7px 0 3px; font-size:12px; color:var(--dim)}
.settings-row select{width:140px}
