/* My VoiceLink (client/portal/): the built-in web portal.
   Look and structure follow the blind.software account panel: dark brand header, light cards,
   folder-style tabs, strong 3px focus outlines, 4.5:1 contrast or better, light and dark modes and
   a forced-colours friendly high-contrast fallback. Selected tabs are marked by shape (a thick top
   bar and a joined bottom edge) as well as colour. */
:root {
    color-scheme: light dark;
    font-family: system-ui, -apple-system, "Segoe UI", Arial, Helvetica, sans-serif;
    line-height: 1.6;
    background: #f6f7f9;
    color: #1b1f24;
    --brand: #10243f;
    --brand-2: #0f6b63;
    --accent: #f7c948;
    --surface: #ffffff;
    --border: #c8d0d8;
    --muted: #4d5966;
    --link: #075da8;
    --danger: #a4161a;
    --ok: #1e6b35;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }
a:focus, button:focus, input:focus, textarea:focus, select:focus, summary:focus,
[tabindex]:focus-visible, [role="tab"]:focus {
    outline: 3px solid #111;
    outline-offset: 3px;
    box-shadow: 0 0 0 5px #fff;
}
h2[tabindex="-1"]:focus, h3[tabindex="-1"]:focus, h4[tabindex="-1"]:focus, main:focus { outline: none; box-shadow: none; }
h2[tabindex="-1"]:focus-visible, h3[tabindex="-1"]:focus-visible { outline: 3px dashed var(--brand); outline-offset: 4px; box-shadow: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: auto; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; color: #111; padding: .5rem; border: 2px solid #111; z-index: 2; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

.portal-header { background: var(--brand); color: #fff; padding: 1.1rem 0 1.35rem; }
.portal-header a { color: #fff; }
.portal-header .brand { margin: 0; }
.brand-link { font-weight: 800; font-size: 1.15rem; text-decoration: none; }
.brand-link:focus { outline-color: var(--accent); box-shadow: none; }
h1, h2, h3, h4 { line-height: 1.2; }
h1 { margin: .5rem 0 .4rem; font-size: clamp(2rem, 6vw, 3rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 1rem 0 .75rem; }
h3 { font-size: 1.25rem; margin: 0 0 .6rem; }
h4 { font-size: 1.08rem; margin: 1.1rem 0 .5rem; }
.tagline { margin: 0; color: #e6edf5; font-size: 1.05rem; }
nav { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1rem; align-items: center; }
.portal-header nav a, .portal-header nav button {
    display: inline-block; padding: .55rem .85rem; border: 2px solid #fff; border-radius: .35rem;
    background: transparent; color: #fff; text-decoration: none; font: inherit; font-weight: 700; cursor: pointer;
}
.portal-header nav a:focus, .portal-header nav button:focus { outline-color: var(--accent); box-shadow: none; }

/* Buttons */
button, .button, .primary-btn, .secondary-btn, .danger-btn, .admin-action-btn, .admin-btn {
    display: inline-block; padding: .6rem .9rem; border: 2px solid var(--brand); border-radius: .35rem;
    background: #fff; color: var(--brand); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.primary-btn, button[type="submit"] { background: var(--brand); color: #fff; }
.danger-btn, .admin-action-btn.danger, button.danger { border-color: var(--danger); color: var(--danger); background: #fff; }
button:disabled, button[aria-disabled="true"] { opacity: .65; cursor: not-allowed; }

/* Tabs (role=tablist / tab / tabpanel) */
.tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin: 1.25rem 0 0; border-bottom: 2px solid var(--border); }
.tabs [role="tab"] {
    border: 1px solid var(--border); border-bottom: 0; border-top: 4px solid transparent;
    border-radius: .35rem .35rem 0 0; background: #eef2f5; color: var(--brand); padding: .6rem .95rem;
    font: inherit; font-weight: 700; cursor: pointer;
}
.tabs [role="tab"][aria-selected="true"] {
    background: var(--surface); color: #1b1f24; border-color: var(--brand); border-top-color: var(--brand-2);
    border-bottom: 2px solid var(--surface); margin-bottom: -2px;
}
.tabs.sub-tabs { margin-top: .5rem; }
.tabs.sub-tabs [role="tab"] { padding: .45rem .75rem; font-size: .95rem; }
[role="tabpanel"] { margin-top: .75rem; }
[role="tabpanel"][hidden] { display: none; }

.portal-status { min-height: 1.6em; margin: .75rem 0 0; font-weight: 700; color: var(--ok); }
.portal-status[data-type="error"] { color: var(--danger); }
.portal-status[data-type="error"]::before { content: "Problem: "; }
.portal-status:empty { margin: 0; min-height: 0; }

/* Cards, forms, tables */
.card, .admin-card, .settings-section {
    background: var(--surface); color: #1b1f24; border: 1px solid var(--border);
    border-radius: .45rem; padding: 1rem; margin: 1rem 0;
}
.grid, .admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.actions, .button-group, .admin-toolbar { display: flex; gap: .6rem; flex-wrap: wrap; margin: .85rem 0; align-items: center; }
label { display: block; font-weight: 700; margin: .85rem 0 .3rem; }
label.inline, label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { font-weight: 600; }
input, textarea, select {
    display: block; width: 100%; max-width: 40rem; padding: .55rem; font: inherit;
    border: 1px solid #6d7680; border-radius: .3rem; background: #fff; color: #111;
}
input[type="checkbox"], input[type="radio"] { display: inline-block; width: auto; margin-right: .45rem; vertical-align: middle; }
input[type="range"] { padding: 0; }
fieldset { border: 1px solid var(--border); border-radius: .4rem; padding: .5rem 1rem 1rem; margin: 1rem 0; max-width: 44rem; }
legend { font-weight: 800; padding: 0 .35rem; }
.muted, small, .setting-desc, .hint { display: block; color: var(--muted); max-width: 48rem; }
table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
caption { text-align: left; font-weight: 800; margin-bottom: .35rem; }
th, td { border: 1px solid #8b949e; padding: .5rem; text-align: left; vertical-align: top; }
dl.facts { display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr; gap: .35rem 1rem; max-width: 50rem; }
dl.facts dt { font-weight: 800; color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
ul.plain { list-style: none; padding: 0; }
ul.room-list > li, .signin-methods-list > li, .admin-list-item { border: 1px solid var(--border); border-radius: .4rem; padding: .75rem; margin: .6rem 0; background: var(--surface); }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Shared app screens mounted in the portal */
.stat-item { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--border); padding: .3rem 0; }
.stat-label { font-weight: 700; }
.setting-item { margin: .6rem 0; }
.admin-list { list-style: none; padding: 0; }
.admin-list-item .item-actions, .admin-list-item .admin-item-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.app-tokens-table td button { margin: .1rem 0; }
dialog, .portal-dialog, .vl-dialog {
    border: 2px solid var(--brand); border-radius: .5rem; padding: 1.25rem; max-width: min(40rem, 94vw);
    background: var(--surface); color: #1b1f24;
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }

.portal-footer { border-top: 1px solid var(--border); margin-top: 2.5rem; padding: 1.25rem 0; background: #eef2f5; color: #1b1f24; }
.portal-footer nav a { color: var(--brand); }

@media (prefers-color-scheme: dark) {
    :root { background: #11151a; color: #eef2f5; --surface: #1a2028; --border: #526170; --muted: #c6d0da; --link: #9ec3ff; --danger: #ffb4ab; --ok: #9be7a6; }
    .card, .admin-card, .settings-section, ul.room-list > li, .signin-methods-list > li, .admin-list-item, dialog, .portal-dialog, .vl-dialog { background: var(--surface); color: #eef2f5; }
    button, .button, .secondary-btn, .admin-action-btn, .admin-btn { background: #1a2028; color: #fff; border-color: #8fa1b3; }
    .primary-btn, button[type="submit"] { background: #cfe0ff; color: #10243f; border-color: #cfe0ff; }
    .danger-btn, .admin-action-btn.danger, button.danger { background: #1a2028; color: var(--danger); border-color: var(--danger); }
    .tabs { border-color: #526170; }
    .tabs [role="tab"] { background: #151b22; color: #eef2f5; border-color: #526170; }
    .tabs [role="tab"][aria-selected="true"] { background: #1a2028; color: #fff; border-color: #8fa1b3; border-top-color: #40d6c7; border-bottom-color: #1a2028; }
    input, textarea, select { background: #11151a; color: #fff; border-color: #8fa1b3; }
    a:focus, button:focus, input:focus, textarea:focus, select:focus, summary:focus, [role="tab"]:focus { outline-color: #fff; box-shadow: 0 0 0 5px #000; }
    th, td { border-color: #6b7785; }
    .portal-footer { background: #151b22; color: #eef2f5; }
    .portal-footer nav a { color: #c7dcff; }
}
@media (forced-colors: active) {
    .tabs [role="tab"][aria-selected="true"] { border-top: 4px solid Highlight; }
    a:focus, button:focus, input:focus, [role="tab"]:focus { outline: 3px solid Highlight; }
}
@media (max-width: 560px) {
    dl.facts { grid-template-columns: 1fr; }
    dl.facts dt { margin-top: .5rem; }
    .tabs [role="tab"] { flex: 1 1 auto; }
}

/* Pop-up dialogs from the shared app code (invites.js openAccessibleDialog: .modal > [role=dialog]) */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; background: rgba(0, 0, 0, .55); overflow: auto; }
.modal > [role="dialog"], .modal > .modal-content {
    position: relative; width: min(42rem, 100%); background: var(--surface); color: #1b1f24;
    border: 2px solid var(--brand); border-radius: .5rem; padding: 1.25rem 1.25rem 1rem;
}
.modal .close-modal-btn { position: absolute; top: .6rem; right: .6rem; padding: .3rem .6rem; }
.modal h2 { margin-top: 0; padding-right: 3rem; font-size: 1.5rem; }
@media (prefers-color-scheme: dark) { .modal > [role="dialog"], .modal > .modal-content { color: #eef2f5; } }
