/* Only the shadow-root navigation and account UI. All measurements use pixels,
   independent of tool pages' root font size and resets. */
:host { font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); }
:host([embedded]) .site-header { display:none; }
* { box-sizing: border-box; }
h1, h2, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; }
[hidden], .hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.site-header :focus-visible { outline-color: white; }
.site-header { visibility: visible; height: 88px; padding: 8px 20px 0; background: var(--site-header-bg); color: white; box-shadow: var(--shadow); }
.header-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { color: white; font-size: 26px; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.theme-toggle { width: 40px; height: 40px; border: 0; border-radius: 50%; background: #ffffff26; color: white; font-size: 22px; }
.theme-toggle:hover { background: #ffffff40; }
.account-control { position: relative; width: 164px; }
#account-toggle { display: flex; align-items: center; gap: 8px; width: 100%; height: 42px; padding: 4px 8px; border: 1px solid #ffffff66; border-radius: 6px; background: #ffffff33; color: white; font-size: 13px; }
#auth-label { flex: 1; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.avatar { position: relative; display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; background: #ffffff26; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 32px; height: 32px; object-fit: cover; }
#account-menu { position: absolute; top: 50px; right: 0; width: 240px; max-height: calc(100dvh - 80px); overflow-y: auto; padding: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); z-index: 2; }
#account-menu > * { display: block; width: 100%; padding: 10px 12px; text-align: left; font-size: 14px; border: 0; border-radius: 4px; background: none; color: inherit; }
#account-menu > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom: 1px solid var(--border); }
#account-menu button:hover, #account-menu a:hover { background: var(--alt); }
.site-header nav { display: flex; gap: 20px; overflow-x: auto; margin-top: 4px; }
.site-header nav a { color: white; white-space: nowrap; font-size: 14px; padding: 4px 0 6px; border-bottom: 3px solid transparent; }
.site-header nav a[aria-current] { border-color: white; }
dialog { width: 400px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); margin: auto; padding: 32px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: auto; }
dialog::backdrop { background: #0009; }
dialog h2 { font-size: 20px; margin: 0 15px 8px 0; }
dialog p { color: var(--muted); font-size: 14px; }
.dialog-close { position: absolute; right: 10px; top: 8px; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); font-size: 25px; }
#login-dialog { text-align: center; }
#login-status { height: 64px; overflow: auto; font-size: 13px; color: var(--muted); padding-top: 12px; }
#login-area { height: 48px; display: flex; align-items: center; justify-content: center; }
#login-area:empty::before { content: ""; width: 220px; height: 40px; border-radius: 8px; background: var(--alt); }
#login-area > button { min-height: 40px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; background: var(--alt); }
#profile-status { height: 48px; overflow: auto; }
dt { color: var(--muted); font-size: 13px; }
dd { height: 24px; margin: 0 0 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#theme-mode { display: block; margin: 8px 0 18px; width: 100%; padding: 10px; background: var(--alt); border: 1px solid var(--border); border-radius: 6px; }
@media(max-width:440px) {
    .site-header { visibility: visible; height: 84px; padding: 6px 12px 0; }
    .brand { font-size: 21px; }
    .header-row { gap: 8px; }
    .header-actions { gap: 8px; }
    .account-control { width: 142px; }
    .theme-toggle { width: 34px; height: 34px; }
    .site-header nav { gap: 18px; margin-top:2px; }
    .site-header nav a { font-size: 12px; }
    dialog { padding: 28px 18px; }
}

.branding { display:flex; align-items:center; gap:12px; min-width:0; }
.brand { flex:none; }
#site-page-title { font-weight:500; font-size:20px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.header-actions { flex:none; }

.branding { flex:1; }
#site-page-title { min-width:0; }
.site-header nav { overflow:visible; }
#navigation-links { display:flex; gap:20px; }
#navigation-toggle { display:none; }
@media(max-width:1040px) {
    .account-control { width:42px; }
    #account-toggle { padding:4px; justify-content:center; }
    #auth-label, #account-toggle > span:last-child { display:none; }
    .header-actions { gap:8px; }
    .theme-toggle { width:34px; height:34px; }
    .branding { gap:8px; }
    #site-page-title { font-size:16px; }
    #navigation-toggle { display:block; height:34px; padding:4px 0 6px; border:0; background:none; color:white; font-size:14px; }
    #navigation-links { display:none; position:absolute; left:12px; right:12px; top:100%; max-height:calc(100dvh - 100px); overflow-y:auto; padding:8px; background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:8px; box-shadow:var(--shadow); }
    #navigation-links.expanded { display:flex; flex-direction:column; gap:0; }
    #navigation-links a { display:block; padding:10px 12px; color:var(--text); text-align:left; }
    #navigation-links a[aria-current] { background:var(--bg-hover); border-color:var(--primary); }
}
@media(max-width:360px) { .brand { font-size:19px; } #site-page-title { font-size:14px; } .header-actions { gap:6px; } }

#account-menu button:is(:hover,:focus-visible), #account-menu a:is(:hover,:focus-visible),
#navigation-links a:is(:hover,:focus-visible) { text-decoration:underline; text-underline-offset:3px; }

@media(max-width:360px) { #login-dialog { max-width:calc(100vw - 12px); padding:28px 8px; } }

#admin-toggle { flex-shrink:0; border:0; border-bottom:3px solid transparent; background:none; color:white; padding:4px 0 6px; font-size:14px; }
#admin-toggle[aria-current] { border-color:white; }
#admin-menu { position:fixed; z-index:3; overflow-y:auto; width:230px; padding:8px; background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:8px; box-shadow:var(--shadow); }
#admin-menu a { display:block; padding:8px 12px; color:inherit; font-size:14px; }
#admin-menu a[aria-current], #admin-menu a:hover { background:var(--bg-hover); }
#admin-menu a:is(:hover,:focus-visible), #admin-toggle:is(:hover,:focus-visible) { text-decoration:underline; text-underline-offset:3px; }
@media(max-width:1040px) { #admin-toggle { display:block; padding:10px 12px; text-align:left; color:var(--text); } #admin-toggle[aria-current] { border-color:var(--primary); background:var(--bg-hover); } }
@media(max-width:440px) { #admin-toggle { font-size:12px; } }


/* One reserved account card, shared by every tool and every auth state. */
.site-header { display:grid; grid-template-columns:minmax(0,1fr) 184px auto; grid-template-rows:42px 38px; column-gap:16px; }
.header-row { display:contents; }
.branding { grid-column:1; grid-row:1; }
.header-actions { grid-column:3; grid-row:1/3; align-self:start; }
.navigation-row { grid-column:1; grid-row:2; min-width:0; }
#membership-cta { grid-column:2; grid-row:1/3; align-self:center; display:flex; align-items:center; justify-content:space-between; gap:8px; height:36px; padding:0 12px; border:1px solid #f5d8a3; border-radius:6px; background:#e5bb77; color:#253021; font-size:13px; font-weight:650; white-space:nowrap; }
#membership-cta:hover { background:#f0ca8d; text-decoration:underline; text-underline-offset:3px; }
#membership-cta svg { flex:none; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
.account-control { display:grid; grid-template-columns:36px minmax(0,1fr); grid-template-rows:36px 28px; width:232px; border:1px solid #ffffff60; border-radius:7px; background:#15251055; box-shadow:inset 0 1px #ffffff18,0 1px 2px #0002; }
.theme-toggle { width:30px; height:30px; margin:3px; border-radius:4px; background:transparent; font-size:21px; }
#account-toggle { height:36px; padding:3px 8px 3px 4px; border:0; border-radius:0 6px 0 0; background:transparent; gap:7px; }
#account-toggle:hover { background:#ffffff18; }
#auth-label, #account-toggle > span:last-child { display:block; }
.avatar, .avatar img { width:26px; height:26px; }
.avatar { flex-basis:26px; }
#account-summary { display:grid; grid-column:1/-1; grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); height:28px; border-top:1px solid #ffffff30; background:#10200e25; border-radius:0 0 6px 6px; }
#account-summary a { display:flex; align-items:center; justify-content:flex-start; gap:4px; min-width:0; padding:0 6px; color:white; font-size:12px; line-height:26px; border-radius:0 0 0 6px; }
#account-summary #tokens-link { display:grid; grid-template-columns:minmax(0,1fr) auto; }
#account-summary a + a { border-left:1px solid #ffffff30; border-radius:0 0 6px 0; }
#account-summary a:hover { background:#ffffff18; }
#account-summary strong { font-size:12px; font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#account-summary span { font-size:11px; }
#account-summary #membership-link { flex-direction:column; align-items:flex-start; justify-content:center; gap:0; line-height:12px; }
#account-summary .membership-label { font-size:9px; line-height:11px; color:#e1e8d9; }
#account-menu { top:72px; }
@media(max-width:1040px) { .account-control { width:190px; } .site-header { column-gap:10px; } }
/* A compact second row keeps the invitation visible beside Menu on phones. */
@media(max-width:820px) {
 .site-header { height:108px; grid-template-columns:minmax(0,1fr) auto; grid-template-rows:66px 34px; }
 .branding { align-self:start; height:36px; }
 .header-actions { grid-column:2; grid-row:1; }
 .navigation-row { grid-column:1/-1; margin-right:176px; }
 #membership-cta { grid-column:1/-1; grid-row:2; justify-self:end; align-self:start; width:164px; height:30px; padding:0 9px; font-size:12px; }
 .site-header nav { margin-top:0; }
}
@media(max-width:440px) { .branding { gap:6px; } }
@media(max-width:360px) {
 .account-control { width:150px; grid-template-columns:30px minmax(0,1fr); }
 .theme-toggle { width:26px; margin-left:2px; margin-right:2px; }
 #account-toggle { gap:4px; padding-right:5px; font-size:12px; }
 .avatar, .avatar img { width:22px; height:22px; } .avatar { flex-basis:22px; }
 #account-summary a { padding:0 3px; gap:3px; } #account-summary strong, #account-summary span { font-size:10px; }
 #account-summary .membership-label { font-size:9px; }
}

/* Anonymous users get two ordinary controls; the reserved lower row is invisible.
   Borders keep the same width in every state, so auth cannot move either button. */
.account-control:not(.signed-in) { border-color:transparent; background:transparent; box-shadow:none; }
#account-toggle { border:1px solid transparent; padding:2px 7px 2px 3px; }
.account-control:not(.signed-in) #account-toggle { border-color:#ffffff66; border-radius:6px; background:#15251055; }
.account-control:not(.signed-in) #account-toggle:hover { background:#15251077; }
.account-control:not(.signed-in) .theme-toggle { background:#ffffff26; box-shadow:inset 0 0 0 1px #ffffff44; }
.account-control:not(.signed-in) .theme-toggle:hover { background:#ffffff40; }
.account-control:not(.signed-in) .avatar { background:transparent; }
.account-control:not(.signed-in) #avatar-initial, .signed-in .signin-icon { display:none; }
.account-control:not(.signed-in) .account-chevron { visibility:hidden; }
.signin-icon { fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
@media(max-width:360px) { #account-toggle { padding:2px 4px 2px 3px; } }
