/* 0.9.21: the account pages (account_pages.py, templates/account-*.html, static/account.js).
   0.9.23 (3): redesigned for trust and polish, and the whole look of these pages (reader.css
   is no longer loaded). A header says where you are (the server's logo, "Project Base" and
   the server's own address), one calm card holds the page, and a footer says what the site
   is. Dark by default, light when the device asks for it, as reader.css does. Every class
   starts with account-, except the few shared names (password-, project-, setup-, qr-,
   recovery-, code-). No inline styles anywhere (the CSP): the project colours of the home
   page are set by account.js through the CSS object model. */

/* --- colours ---------------------------------------------------------------------------- */

body.account-body{
  color-scheme:dark;
  --account-page:#0b0e14;
  --account-page-glow:#13203a;
  --account-header:#0f131c;
  --account-card:#151a24;
  --account-card-line:#273042;
  --account-raised:#1b2230;
  --account-field:#0e1219;
  --account-field-line:#39445b;
  --account-text:#e9edf5;
  --account-muted:#a7b0c1;
  --account-link:#8db4ff;
  --account-focus:#8db4ff;
  --account-primary:#1d5fe0;
  --account-primary-hover:#2a6cf0;
  --account-on-primary:#fff;
  --account-error:#ffa39c;
  --account-error-back:#2a1517;
  --account-error-line:#7a3a37;
  --account-ok:#86dbb5;
  --account-ok-back:#122520;
  --account-ok-line:#2f6b55;
  --account-brand-red:#ff2a3d;
  --account-brand-blue:#2f7bff;
  --account-shadow:0 18px 50px rgba(0,0,0,.35);
  --account-meter-1:#ff6b5f;
  --account-meter-2:#f2a53a;
  --account-meter-3:#9fcf4a;
  --account-meter-4:#3fc98a;
}
@media(prefers-color-scheme:light){
  body.account-body{
    color-scheme:light;
    --account-page:#f3f5fa;
    --account-page-glow:#e3eafb;
    --account-header:#fff;
    --account-card:#fff;
    --account-card-line:#dde2ec;
    --account-raised:#f5f7fb;
    --account-field:#fff;
    --account-field-line:#bfc8d8;
    --account-text:#172033;
    --account-muted:#546074;
    --account-link:#1d4fc4;
    --account-focus:#1d5fe0;
    --account-primary:#1d5fe0;
    --account-primary-hover:#174fc2;
    --account-on-primary:#fff;
    --account-error:#a3261e;
    --account-error-back:#fdf0ef;
    --account-error-line:#eab5b0;
    --account-ok:#17684a;
    --account-ok-back:#ecf8f2;
    --account-ok-line:#a6d9c1;
    --account-brand-red:#e5001a;
    --account-brand-blue:#0060ff;
    --account-shadow:0 14px 40px rgba(23,32,51,.08);
    --account-meter-1:#d93025;
    --account-meter-2:#c77700;
    --account-meter-3:#5f8f00;
    --account-meter-4:#16824f;
  }
}

/* --- the page --------------------------------------------------------------------------- */

[hidden]{display:none!important}
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
body.account-body{
  margin:0;
  min-height:100vh;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  align-items:center;
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  font-size:16px;
  line-height:1.5;
  color:var(--account-text);
  background:radial-gradient(900px 420px at 50% -120px,var(--account-page-glow),transparent 70%) no-repeat,var(--account-page);
  -webkit-font-smoothing:antialiased;
}
.account-visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}

/* The header: where you are. */
.account-header{width:100%;background:var(--account-header);border-bottom:1px solid var(--account-card-line)}
.account-header-inner{display:flex;align-items:center;gap:14px;max-width:960px;margin:0 auto;padding:12px 16px;min-width:0}
.account-logo{display:block;height:44px;width:auto;max-width:200px;object-fit:contain;flex:0 0 auto}
.account-site{display:flex;flex-direction:column;gap:1px;margin:0;padding-left:14px;border-left:1px solid var(--account-card-line);min-width:0;line-height:1.3}
.account-site-name{font-size:15px;font-weight:650;letter-spacing:.01em}
.account-site-where{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--account-muted);min-width:0}
.account-site-address{overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
.account-globe{width:14px;height:14px;flex:0 0 14px}

/* The card. */
.account-card{
  position:relative;
  width:min(calc(100% - 32px),440px);
  margin:48px auto 20px;
  padding:32px 32px 28px;
  background:var(--account-card);
  border:1px solid var(--account-card-line);
  border-radius:14px;
  box-shadow:var(--account-shadow);
  overflow-wrap:anywhere;
}
.account-card::before{content:"";position:absolute;left:-1px;right:-1px;top:-1px;height:3px;border-radius:14px 14px 0 0;background:linear-gradient(90deg,var(--account-brand-red),var(--account-brand-blue))}
.account-card.account-wide{width:min(calc(100% - 32px),680px)}
.account-heading{margin:0 0 24px}
.account-card h1{margin:0 0 6px;font-size:25px;line-height:1.25;font-weight:650;letter-spacing:-.01em}
.account-card h2{margin:0 0 4px;font-size:17px;line-height:1.35;font-weight:650}
.account-card h2:focus{outline:none}
.account-card p{margin:0}
.account-card a{color:var(--account-link);text-underline-offset:2px}
.account-lead{font-size:15px;color:var(--account-muted)}
.account-text{margin-bottom:14px!important}

/* The footer: what this site is. */
.account-footer{width:min(calc(100% - 32px),680px);margin:0 auto 32px;padding:0 4px;text-align:center;font-size:13px;color:var(--account-muted)}
.account-footer p{margin:0}

@media(max-width:480px){
  .account-header-inner{gap:10px;padding:10px 16px}
  .account-logo{height:34px;max-width:130px}
  .account-site{padding-left:10px}
  .account-site-name{font-size:14px}
  .account-site-where{font-size:12px}
  .account-card,.account-card.account-wide{margin-top:20px;padding:24px 18px 22px}
  .account-card h1{font-size:22px}
}

/* --- focus ------------------------------------------------------------------------------ */

.account-body :is(a,button,summary):focus-visible{outline:2px solid var(--account-focus);outline-offset:2px;border-radius:6px}
.account-body input:focus-visible{outline:none}

/* --- forms ------------------------------------------------------------------------------ */

.account-form{display:grid;gap:16px;margin:0}
.account-field{display:grid;gap:6px;min-width:0}
.account-field label{font-size:14px;font-weight:600;color:var(--account-text)}
.account-field input{
  width:100%;
  min-width:0;
  min-height:48px;
  padding:10px 14px;
  font:inherit;
  font-size:16px;
  color:var(--account-text);
  background:var(--account-field);
  border:1px solid var(--account-field-line);
  border-radius:10px;
  transition:border-color .15s,box-shadow .15s;
}
.account-field input:hover{border-color:color-mix(in srgb,var(--account-field-line) 60%,var(--account-text))}
.account-field input:focus{border-color:var(--account-focus);box-shadow:0 0 0 3px color-mix(in srgb,var(--account-focus) 28%,transparent);outline:none}
.account-field input[readonly]{color:var(--account-muted);background:var(--account-raised);border-style:dashed}
.account-field input[readonly]:focus{box-shadow:none;border-color:var(--account-field-line)}
.code-input{font-family:ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",monospace!important;font-size:20px!important;letter-spacing:.25em;text-align:center}

/* Show sits inside the password field. */
.password-field{position:relative;min-width:0}
.password-field input{padding-right:78px}
.account-card .password-toggle{
  position:absolute;
  top:5px;
  right:5px;
  bottom:5px;
  min-height:0;
  min-width:62px;
  padding:0 12px;
  font-size:14px;
  font-weight:600;
  color:var(--account-link);
  background:transparent;
  border:0;
  border-radius:7px;
}
.account-card .password-toggle:hover{background:var(--account-raised)}

/* The strength meter and the rules under a new password (0.9.23 (5)). */
.password-check{display:grid;gap:8px;margin-top:2px}
.password-meter{display:flex;align-items:center;gap:10px}
.password-meter-bar{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;flex:1}
.password-meter-bar>span{height:6px;border-radius:3px;background:var(--account-field-line);transition:background-color .2s}
.password-meter-label{min-width:74px;font-size:13px;font-weight:600;color:var(--account-muted);text-align:right}
.password-meter[data-score="1"] .password-meter-bar>span:nth-child(-n+1){background:var(--account-meter-1)}
.password-meter[data-score="2"] .password-meter-bar>span:nth-child(-n+2){background:var(--account-meter-2)}
.password-meter[data-score="3"] .password-meter-bar>span:nth-child(-n+3){background:var(--account-meter-3)}
.password-meter[data-score="4"] .password-meter-bar>span{background:var(--account-meter-4)}
.password-meter[data-score="0"] .password-meter-label,.password-meter[data-score="1"] .password-meter-label{color:var(--account-meter-1)}
.password-meter[data-score="2"] .password-meter-label{color:var(--account-meter-2)}
.password-meter[data-score="3"] .password-meter-label{color:var(--account-meter-3)}
.password-meter[data-score="4"] .password-meter-label{color:var(--account-meter-4)}
.password-rules{display:grid;gap:3px;margin:0;padding:0;list-style:none;font-size:13px;color:var(--account-muted)}
.password-rules li{display:flex;gap:7px;align-items:baseline}
.password-rules li::before{content:"○";flex:0 0 1em;text-align:center}
.password-rules li[data-met=true]{color:var(--account-ok)}
.password-rules li[data-met=true]::before{content:"✓";font-weight:700}
.password-rules li[data-met=unknown]::before{content:"•"}

.account-check{display:flex;gap:10px;align-items:center;min-height:44px;font-weight:600;cursor:pointer}
.account-check input{width:20px;height:20px;margin:0;accent-color:var(--account-primary)}

/* --- buttons ---------------------------------------------------------------------------- */

.account-card button,.account-button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-height:44px;
  padding:10px 18px;
  font:inherit;
  font-size:15px;
  font-weight:600;
  line-height:1.3;
  text-align:center;
  text-decoration:none;
  color:var(--account-text);
  background:var(--account-raised);
  border:1px solid var(--account-card-line);
  border-radius:10px;
  cursor:pointer;
  transition:background-color .15s,border-color .15s;
}
.account-card a.account-button{color:var(--account-text)}
.account-card button:hover,.account-card a.account-button:hover{border-color:var(--account-field-line)}
.account-card .account-primary,.account-card a.account-primary{color:var(--account-on-primary);background:var(--account-primary);border-color:var(--account-primary)}
.account-card .account-primary:hover,.account-card a.account-primary:hover{background:var(--account-primary-hover);border-color:var(--account-primary-hover)}
.account-card .account-wide-button{width:100%}
.account-card button:disabled{opacity:.55;cursor:not-allowed}
.account-card [aria-busy=true] button{cursor:progress}
.account-card .account-link-button{min-height:36px;padding:4px 0;font-size:14px;color:var(--account-link);background:none;border:0;border-radius:4px;text-decoration:underline;text-underline-offset:2px;justify-self:start}
.account-card .account-link-button:hover{background:none;text-decoration-thickness:2px}
.account-links{display:flex;flex-wrap:wrap;gap:8px 16px;align-items:center;font-size:14px}
.account-back{margin-top:20px!important}
.account-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:28px;padding-top:20px;border-top:1px solid var(--account-card-line)}

/* --- messages --------------------------------------------------------------------------- */

.account-message{position:relative;margin:0;padding:10px 12px 10px 38px;font-size:14px;line-height:1.5;color:var(--account-text);background:var(--account-raised);border:1px solid var(--account-card-line);border-radius:10px}
.account-message:empty{display:none}
.account-message::before{content:"i";position:absolute;left:12px;top:11px;display:grid;place-items:center;width:18px;height:18px;font-size:12px;font-weight:700;line-height:1;border-radius:50%;color:var(--account-card);background:var(--account-muted)}
.account-message[data-kind=error]{color:var(--account-error);background:var(--account-error-back);border-color:var(--account-error-line)}
.account-message[data-kind=error]::before{content:"!";background:var(--account-error)}
.account-message[data-kind=ok]{color:var(--account-ok);background:var(--account-ok-back);border-color:var(--account-ok-line)}
.account-message[data-kind=ok]::before{content:"✓";background:var(--account-ok)}
#page-message{margin-top:16px}
.account-note{padding:11px 14px;font-size:14px;background:color-mix(in srgb,var(--account-primary) 9%,var(--account-card));border:1px solid color-mix(in srgb,var(--account-primary) 30%,var(--account-card-line));border-radius:10px}
.account-card>.account-note{margin-bottom:18px}
.account-hint{font-size:14px;color:var(--account-muted)}
.account-about{padding-top:16px;border-top:1px solid var(--account-card-line)}
.account-muted{color:var(--account-muted);font-size:14px}
.account-who{font-size:15px;color:var(--account-muted)}
.account-who strong{color:var(--account-text)}
.account-who .account-muted::before{content:"· "}
.account-welcome{font-size:15px}
.account-done{display:grid;gap:12px;justify-items:start}
.account-done>.account-message{justify-self:stretch}
.account-empty{padding:22px 18px;text-align:center;color:var(--account-muted);background:var(--account-raised);border:1px dashed var(--account-card-line);border-radius:12px}

/* --- the sign-in steps (0.9.23 (3)) -------------------------------------------------------- */

.account-progress{display:flex;align-items:center;gap:10px;margin:0 0 4px;padding:0;list-style:none;counter-reset:account-step;font-size:13px;font-weight:600;color:var(--account-muted)}
.account-progress li{display:flex;align-items:center;gap:8px;counter-increment:account-step}
.account-progress li+li::before{order:-2;content:"";width:28px;height:1px;margin-right:2px;background:var(--account-field-line)}
.account-progress li::after{order:-1;content:counter(account-step);display:grid;place-items:center;width:22px;height:22px;font-size:12px;border-radius:50%;border:1px solid var(--account-field-line)}
.account-progress li[data-done=true]::after{content:"✓";color:var(--account-on-primary);background:var(--account-ok);border-color:var(--account-ok)}
.account-progress li[aria-current=step]{color:var(--account-text)}
.account-progress li[aria-current=step]::after{color:var(--account-on-primary);background:var(--account-primary);border-color:var(--account-primary)}

/* --- the account page's sections ---------------------------------------------------------- */

.account-section{display:grid;gap:12px}
.account-section+.account-section{margin-top:24px;padding-top:24px;border-top:1px solid var(--account-card-line)}
.account-section>.account-button{justify-self:start}
.account-section>.account-form{margin-top:4px}
.account-section .account-form>button[type=submit]{justify-self:start}
.account-section-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px}
.account-section-head h2{margin:0}
.account-details{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:8px 20px;margin:0;font-size:15px}
.account-details dt{color:var(--account-muted)}
.account-details dd{margin:0;font-weight:600}
.account-state{display:inline-flex;align-items:center;gap:6px;padding:3px 10px;font-size:13px;color:var(--account-muted);background:var(--account-raised);border:1px solid var(--account-card-line);border-radius:999px}
.account-state[data-state=on]{color:var(--account-ok);background:var(--account-ok-back);border-color:var(--account-ok-line)}
.account-state[data-state=on] strong{color:var(--account-ok)}

/* The steps of the two-step setup: one shown at a time. */
.account-stage{display:grid;gap:16px}
.account-stage>p:not([class]),.account-done>p:not([class]){font-size:15px}

/* --- lists: the signed-in devices --------------------------------------------------------- */

.account-list{display:grid;gap:0;margin:0;padding:0;list-style:none}
.account-item{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;justify-content:space-between;padding:12px 0;border-top:1px solid var(--account-card-line)}
.account-item:first-child{border-top:0}
.account-item-text{display:grid;gap:2px;min-width:0;flex:1 1 180px}
.account-item-text small{color:var(--account-muted);font-size:13px}
.account-badge{display:inline-block;margin-left:8px;padding:1px 8px;font-size:12px;font-weight:600;color:var(--account-on-primary);background:var(--account-primary);border-radius:999px;vertical-align:1px}

/* --- the projects on the home page (0.9.23 (7)): as Obsidian's file explorer shows them ---- */

/* 0.9.23 review (Q2): rows as Obsidian 1.14.4's file explorer draws them (.tree-item-self:
   4px 8px, 13 px text, a bare 16 px icon, a hover background, no borders) and as the reader's
   sidebar does (.nav-folder-row, 29 px): the whole row is the link, with a small "Open" hint
   at its end (on hover and focus; always on touch screens). Before: 64 px cards with a
   bordered 36 px icon tile and a blue Open button on every row. On a phone a row is at least
   44 px high, a finger's size. The list reaches 8 px into the card's padding, so the icons
   line up with the heading above. */
.account-projects{display:grid;gap:1px;margin:0 -8px}
.project-item{
  --project-icon-color:var(--account-muted);
  --project-text-color:var(--account-text);
  display:block;
  min-width:0;
}
.project-row{
  display:flex;
  align-items:center;
  gap:8px;
  min-height:32px;
  padding:5px 8px;
  border-radius:6px;
  font-size:15px;
  line-height:1.3;
  color:var(--project-text-color);
  text-decoration:none;
  -webkit-tap-highlight-color:transparent;
}
.account-card a.project-row{color:var(--project-text-color);text-decoration:none}
.account-card a.project-row:hover{background:color-mix(in srgb,var(--account-text) 8%,transparent)}
.account-card a.project-row:focus-visible{outline:2px solid var(--account-focus);outline-offset:-2px;background:color-mix(in srgb,var(--account-text) 8%,transparent)}
.account-card a.project-row:active{background:color-mix(in srgb,var(--account-text) 13%,transparent)}
.project-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 16px;width:16px;height:16px;color:var(--project-icon-color)}
.project-icon svg{display:block;width:16px;height:16px}
.project-emoji{font-size:15px;line-height:1}
.project-text{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:8px;flex:1 1 auto;min-width:0}
.project-name{min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500;color:var(--project-text-color)}
.project-item[data-background] .project-name{padding:0 4px;margin-left:-4px;border-radius:4px;background:color-mix(in srgb,var(--project-background,transparent) 22%,transparent)}
.project-as{min-width:0;font-size:13px;color:var(--account-muted)}
.project-hint{flex:0 0 auto;font-size:13px;color:var(--account-muted);opacity:0;transition:opacity .1s}
.account-card a.project-row:hover .project-hint,.account-card a.project-row:focus-visible .project-hint{opacity:1}
@media(hover:none){.project-hint{opacity:1}}
.project-row[data-unavailable] .project-name{color:var(--account-muted)}
.project-row[data-unavailable] .project-icon{opacity:.7}
.project-unavailable{flex:1 0 100%;font-size:13px;color:var(--account-muted)}
@media(max-width:480px){
  .project-row{min-height:44px;padding:8px;font-size:16px}
}

/* --- the two-step setup: steps, the QR code (dark modules on white, whatever the theme),
   the key ------------------------------------------------------------------------------ */

.account-steps{display:grid;gap:8px;margin:0;padding:0;list-style:none;counter-reset:setup-step;font-size:14px}
.account-steps li{display:flex;gap:10px;align-items:baseline;counter-increment:setup-step}
.account-steps li::before{content:counter(setup-step);display:grid;place-items:center;flex:0 0 22px;width:22px;height:22px;font-size:12px;font-weight:700;color:var(--account-on-primary);background:var(--account-primary);border-radius:50%;transform:translateY(-1px)}
.setup-qr{display:flex;justify-content:center}
.qr-code{display:block;padding:12px;background:#fff;border-radius:12px;line-height:0;box-shadow:0 0 0 1px var(--account-card-line)}
.qr-code svg{display:block;width:200px;height:200px;max-width:100%}
.setup-links{justify-content:center}
.setup-key{display:flex;flex-wrap:wrap;gap:8px 10px;align-items:center}
.setup-key-label{font-size:14px;font-weight:600}
.setup-secret{flex:1 1 200px;padding:9px 12px;font:600 15px/1.5 ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",monospace;letter-spacing:.04em;word-spacing:.2em;color:var(--account-text);background:var(--account-raised);border:1px solid var(--account-card-line);border-radius:10px;user-select:all}
.setup-secret:empty{display:none}
/* 0.9.23 review (Q8): the numbers in a column of their own, 3 characters wide and right
   aligned, so "10." keeps its code in line with the others (the list's own markers were
   as wide as each number). account.js puts each code in its own span. */
.recovery-codes{display:grid;grid-template-columns:repeat(2,minmax(0,max-content));justify-content:space-between;gap:6px 14px;margin:0;padding:14px 16px;list-style:none;counter-reset:recovery-code;font:600 15px/1.5 ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",monospace;background:var(--account-raised);border:1px solid var(--account-card-line);border-radius:10px;user-select:all}
.recovery-codes li{display:flex;align-items:baseline;gap:.6ch;counter-increment:recovery-code;white-space:nowrap}
.recovery-codes li::before{content:counter(recovery-code) ".";flex:0 0 3ch;text-align:right;font-weight:400;color:var(--account-muted);user-select:none}
@media(max-width:480px){.recovery-codes{padding:12px;font-size:14px}}
@media(max-width:340px){.recovery-codes{grid-template-columns:minmax(0,1fr)}}
.account-stage>.account-button{justify-self:start}
