Dark/light redesign, theme toggle, nginx examples (subdomain, subpath, LAN-only)

This commit is contained in:
Clarth 2026-12-01 15:39:23 -05:00
parent 2d6d6819e6
commit 5cbd39ae9c
10 changed files with 590 additions and 55 deletions

14
examples/README.md Normal file
View file

@ -0,0 +1,14 @@
# Examples
## nginx
Pick one and adapt the paths, domain, and PHP-FPM socket. Each file is commented.
| File | Use when |
| --- | --- |
| `nginx/subdomain.conf` | You want `https://tinyauth-web.example.com/` on its own name. |
| `nginx/subpath.conf` | You want `https://www.example.com/tinyauth-web/` inside an existing site. |
| `nginx/subdomain-lan-only.conf` | As above, but only reachable from your LAN or VPN. |
All of them serve only `public/`, so `config.php` and `data/` are never reachable over HTTP.
After editing, run `nginx -t` before reloading.

View file

@ -0,0 +1,37 @@
# tinyauth-web on a subdomain, reachable only from your LAN and VPN.
#
# This is the subdomain config plus an IP allowlist. Login through tinyauth is still
# required, so the allowlist is an extra layer, not a replacement.
# Replace the example ranges with your own. Test with `nginx -t`, then reload nginx.
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name tinyauth-web.example.com;
ssl_certificate /etc/letsencrypt/live/tinyauth-web.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/tinyauth-web.example.com/privkey.pem;
allow 192.168.1.0/24; # LAN
allow 100.64.0.0/10; # Tailscale
allow 127.0.0.1;
deny all;
root /var/www/tinyauth-web/public;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.4-fpm.sock; # match your PHP-FPM socket
}
location ~ /\. {
deny all;
}
}

View file

@ -0,0 +1,38 @@
# tinyauth-web on its own subdomain: https://tinyauth-web.example.com/
#
# Only public/ is served, so config.php and data/ are never reachable.
# Test with `nginx -t`, then reload nginx. Adjust the paths and the PHP-FPM socket.
server {
listen 80;
listen [::]:80;
server_name tinyauth-web.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name tinyauth-web.example.com;
ssl_certificate /etc/letsencrypt/live/tinyauth-web.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/tinyauth-web.example.com/privkey.pem;
root /var/www/tinyauth-web/public;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.4-fpm.sock; # match your PHP-FPM socket
}
location ~ /\. {
deny all;
}
}

View file

@ -0,0 +1,26 @@
# tinyauth-web under an existing site: https://www.example.com/tinyauth-web/
#
# Put these blocks inside the existing `server { }` for www.example.com.
# The URL path maps to public/. Set redirect_uri in config.php to
# https://www.example.com/tinyauth-web/callback.php
# and register the same URL as a trusted redirect URI in tinyauth.
# Test with `nginx -t`, then reload nginx. Adjust the paths and the PHP-FPM socket.
location = /tinyauth-web {
return 301 /tinyauth-web/;
}
location ^~ /tinyauth-web/ {
alias /var/www/tinyauth-web/public/;
index index.php;
location ~ ^/tinyauth-web/(.+\.php)$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/tinyauth-web/public/$1;
fastcgi_pass unix:/run/php/php8.4-fpm.sock; # match your PHP-FPM socket
}
location ~ /\. {
deny all;
}
}

14
public/assets/app.js Normal file
View file

@ -0,0 +1,14 @@
(function () {
var root = document.documentElement;
var button = document.getElementById('theme-toggle');
if (!button) {
return;
}
button.addEventListener('click', function () {
var next = root.getAttribute('data-theme') === 'light' ? 'dark' : 'light';
root.setAttribute('data-theme', next);
try {
localStorage.setItem('tinyauth-web-theme', next);
} catch (e) {}
});
})();

372
public/assets/style.css Normal file
View file

@ -0,0 +1,372 @@
:root {
--bg: #0c0e13;
--bg-glow: #151a28;
--surface: #161a23;
--surface-2: #1d2230;
--border: #2a3142;
--text: #e7e9f0;
--muted: #8d96ab;
--accent: #7c9cff;
--accent-ink: #0c0e13;
--ok: #3fb950;
--bad: #f85149;
--warn: #e3b341;
--radius: 12px;
--shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
color-scheme: dark;
}
[data-theme="light"] {
--bg: #f4f6fb;
--bg-glow: #e5eaf7;
--surface: #ffffff;
--surface-2: #f0f3fa;
--border: #d9dfeb;
--text: #1a1f2e;
--muted: #5e6880;
--accent: #3557d6;
--accent-ink: #ffffff;
--ok: #1a7f37;
--bad: #b42318;
--warn: #9a6700;
--shadow: 0 10px 30px rgba(20, 30, 60, 0.08);
color-scheme: light;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
margin: 0;
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
font-size: 15px;
line-height: 1.5;
color: var(--text);
background: radial-gradient(1200px 600px at 10% -10%, var(--bg-glow), transparent 60%), var(--bg);
background-attachment: fixed;
}
code, pre, input[type="text"], input[type="password"] {
font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}
h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; letter-spacing: 0.02em; }
a { color: var(--accent); }
/* Top bar */
.topbar {
position: sticky;
top: 0;
z-index: 10;
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 0.75rem 1.5rem;
background: color-mix(in srgb, var(--surface) 85%, transparent);
backdrop-filter: blur(10px);
border-bottom: 1px solid var(--border);
}
.brand {
display: flex;
align-items: center;
gap: 0.5rem;
font-weight: 700;
letter-spacing: 0.01em;
}
.logo {
display: inline-grid;
place-items: center;
width: 1.9rem;
height: 1.9rem;
border-radius: 8px;
background: linear-gradient(135deg, var(--accent), #b07cff);
color: var(--accent-ink);
font-size: 0.85rem;
}
.topbar-right {
display: flex;
align-items: center;
gap: 0.6rem;
}
.who {
color: var(--muted);
font-size: 0.9rem;
}
main {
max-width: 1040px;
margin: 0 auto;
padding: 1.5rem;
display: grid;
gap: 1.25rem;
}
.footer {
text-align: center;
color: var(--muted);
font-size: 0.8rem;
padding: 1.5rem;
}
/* Cards */
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 1.25rem 1.4rem;
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
flex-wrap: wrap;
}
.card-center {
max-width: 420px;
margin: 6vh auto 0;
text-align: center;
display: grid;
gap: 1rem;
justify-items: center;
}
.muted { color: var(--muted); }
.grid-2 {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 1.25rem;
}
/* Service state */
.state {
display: inline-flex;
align-items: center;
gap: 0.45rem;
padding: 0.25rem 0.7rem;
border-radius: 999px;
font-size: 0.85rem;
font-weight: 600;
background: var(--surface-2);
color: var(--muted);
border: 1px solid var(--border);
}
.state::before {
content: "";
width: 0.55rem;
height: 0.55rem;
border-radius: 50%;
background: currentColor;
}
.state-active { color: var(--ok); }
.state-failed { color: var(--bad); }
.state-inactive { color: var(--muted); }
.state-unknown { color: var(--warn); }
/* Buttons */
.btn-row {
display: flex;
flex-wrap: wrap;
gap: 0.6rem;
}
.btn {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.5rem 1rem;
border-radius: 9px;
border: 1px solid var(--border);
background: var(--surface-2);
color: var(--text);
font: inherit;
font-weight: 600;
cursor: pointer;
text-decoration: none;
transition: transform 0.08s ease, filter 0.15s ease, border-color 0.15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); border-color: var(--muted); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.btn-primary {
background: linear-gradient(135deg, var(--accent), #b07cff);
border-color: transparent;
color: var(--accent-ink);
}
.btn-start { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.btn-stop { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.btn-restart { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.btn-status { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.btn-ghost { background: transparent; }
/* Flash messages */
.flash {
padding: 0.7rem 1rem;
border-radius: 10px;
border: 1px solid var(--border);
background: var(--surface-2);
}
.flash-ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); color: var(--ok); }
.flash-error { border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--bad); }
.flash-info { border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent); }
/* Output */
pre {
margin: 1rem 0 0;
padding: 0.9rem 1rem;
border-radius: 10px;
background: var(--bg);
border: 1px solid var(--border);
color: var(--text);
font-size: 0.85rem;
overflow: auto;
white-space: pre-wrap;
max-height: 22rem;
}
/* Permission checks */
.checks {
list-style: none;
margin: 0;
padding: 0;
display: grid;
gap: 0.45rem;
}
.checks li {
display: flex;
justify-content: space-between;
gap: 1rem;
padding: 0.5rem 0.75rem;
border-radius: 9px;
background: var(--surface-2);
border: 1px solid var(--border);
font-size: 0.9rem;
}
.check-ok .mark { color: var(--ok); }
.check-missing .mark { color: var(--bad); }
.mark { font-weight: 700; white-space: nowrap; }
.notice {
margin-top: 1rem;
padding: 0.7rem 0.9rem;
border-radius: 10px;
border: 1px dashed var(--warn);
color: var(--warn);
font-size: 0.9rem;
}
/* Forms and tables */
.table-wrap { overflow-x: auto; }
table.table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
}
.table th, .table td {
text-align: left;
padding: 0.55rem 0.7rem;
border-bottom: 1px solid var(--border);
vertical-align: middle;
}
.table th {
color: var(--muted);
font-size: 0.78rem;
text-transform: uppercase;
letter-spacing: 0.06em;
font-weight: 600;
}
.table tr:last-child td { border-bottom: none; }
.table td.delete { text-align: center; width: 4rem; }
.table td.delete input { accent-color: var(--bad); width: 1rem; height: 1rem; }
input[type="text"], input[type="password"] {
width: 100%;
padding: 0.5rem 0.65rem;
border-radius: 8px;
border: 1px solid var(--border);
background: var(--bg);
color: var(--text);
font-size: 0.9rem;
transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus, input[type="password"]:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
input[type="text"]::placeholder, input[type="password"]::placeholder {
color: var(--muted);
}
.table tr.add-row td { background: var(--surface-2); }
.form-actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
margin-top: 1rem;
flex-wrap: wrap;
}
/* Setup form */
.radio-list {
display: grid;
gap: 0.5rem;
margin: 1rem 0;
}
.radio-row {
display: flex;
align-items: center;
gap: 0.6rem;
padding: 0.6rem 0.8rem;
border-radius: 9px;
border: 1px solid var(--border);
background: var(--surface-2);
cursor: pointer;
}
.radio-row:hover { border-color: var(--muted); }
.radio-row input { accent-color: var(--accent); }
code {
padding: 0.1rem 0.35rem;
border-radius: 6px;
background: var(--surface-2);
border: 1px solid var(--border);
font-size: 0.88em;
}
@media (max-width: 640px) {
.topbar { padding: 0.7rem 1rem; }
main { padding: 1rem; }
.who { display: none; }
}

View file

@ -47,6 +47,7 @@ try {
redirect('index.php');
} catch (RuntimeException $e) {
page_start('Login error');
echo '<h1>Login failed</h1><p>' . h($e->getMessage()) . '</p><p><a href="login.php">Try again</a></p>';
echo '<section class="card card-center"><h1>Login failed</h1><div class="flash flash-error">' . h($e->getMessage())
. '</div><a class="btn btn-primary" href="login.php">Try again</a></section>';
page_end();
}

View file

@ -7,8 +7,12 @@ require dirname(__DIR__) . '/src/actions.php';
start_session();
if (empty($_SESSION['user'])) {
page_start('tinyauth-web');
echo '<h1>tinyauth-web</h1><p><a class="button" href="login.php">Log in with tinyauth</a></p>';
page_start('Log in');
echo '<section class="card card-center">'
. '<h1>Welcome back</h1>'
. '<p class="muted">Manage the tinyauth service and its settings. Log in with your tinyauth account.</p>'
. '<a class="btn btn-primary" href="login.php">Log in with tinyauth</a>'
. '</section>';
page_end();
exit;
}
@ -42,24 +46,32 @@ $lastOutput = $_SESSION['last_output'] ?? '';
unset($_SESSION['last_output']);
$token = csrf_token();
page_start('tinyauth-web');
echo '<header><h1>tinyauth-web</h1><span>' . h($_SESSION['user']) . ' · <a href="logout.php">log out</a></span></header>';
$userHtml = '<span class="who">' . h($_SESSION['user']) . '</span>'
. '<a class="btn btn-ghost btn-sm" href="logout.php">Log out</a>';
page_start('Dashboard', $userHtml);
foreach ($flashes as $flash) {
echo '<p class="flash ' . h($flash['type']) . '">' . h($flash['message']) . '</p>';
echo '<div class="flash flash-' . h($flash['type']) . '">' . h($flash['message']) . '</div>';
}
if ($allowedGroup === '') {
echo '<section><h2>First-time setup</h2>';
echo '<p>Choose the tinyauth group whose members may use this tool.</p>';
echo '<section class="card card-center">';
echo '<h2>First-time setup</h2>';
echo '<p class="muted">Choose the tinyauth group whose members may use this tool.</p>';
if ($groups === []) {
echo '<p class="flash error">Your account has no groups in tinyauth. Add yourself to a group first, then reload.</p>';
echo '<div class="flash flash-error">Your account has no groups in tinyauth. Add yourself to a group, then reload.</div>';
} else {
echo '<form method="post"><input type="hidden" name="csrf" value="' . h($token) . '">';
echo '<form method="post" class="setup-form">';
echo '<input type="hidden" name="csrf" value="' . h($token) . '">';
echo '<input type="hidden" name="action" value="setup">';
echo '<div class="radio-list">';
foreach ($groups as $group) {
echo '<label><input type="radio" name="group" value="' . h($group) . '" required> ' . h($group) . '</label><br>';
echo '<label class="radio-row"><input type="radio" name="group" value="' . h($group) . '" required> '
. h($group) . '</label>';
}
echo '<p><button type="submit">Save access group</button></p></form>';
echo '</div>';
echo '<button type="submit" class="btn btn-primary">Save access group</button>';
echo '</form>';
}
echo '</section>';
page_end();
@ -67,7 +79,10 @@ if ($allowedGroup === '') {
}
if (!$authorized) {
echo '<p class="flash error">You are not in the required tinyauth group <b>' . h($allowedGroup) . '</b>.</p>';
echo '<section class="card card-center">';
echo '<h2>Access denied</h2>';
echo '<p class="muted">You are not in the required tinyauth group <b>' . h($allowedGroup) . '</b>.</p>';
echo '</section>';
page_end();
exit;
}
@ -81,15 +96,23 @@ $state = 'unknown';
if ($status !== null && preg_match('/Active:\s+(\S+)/', $status['output'], $m)) {
$state = $m[1];
}
$stateClass = match ($state) {
'active' => 'state-active',
'failed' => 'state-failed',
'inactive' => 'state-inactive',
default => 'state-unknown',
};
$service = $cfg['service'];
echo '<section><h2>Service: <code>' . h($service) . '</code></h2>';
echo '<p>State: <span class="badge">' . h($state) . '</span></p>';
echo '<form method="post" style="display:inline-flex;gap:.5rem">';
echo '<section class="card">';
echo '<div class="card-head"><h2>Service <code>' . h($service) . '</code></h2>';
echo '<span class="state ' . $stateClass . '">' . h($state) . '</span></div>';
echo '<form method="post" class="btn-row">';
echo '<input type="hidden" name="csrf" value="' . h($token) . '">';
foreach (SERVICE_ACTIONS as $action) {
$disabled = $perms[$action] ? '' : ' disabled';
echo '<button type="submit" name="action" value="' . h($action) . '"' . $disabled . '>' . h(ucfirst($action)) . '</button>';
echo '<button type="submit" name="action" value="' . h($action) . '" class="btn btn-' . h($action) . '"'
. $disabled . '>' . h(ucfirst($action)) . '</button>';
}
echo '</form>';
if ($status !== null) {
@ -105,29 +128,42 @@ $envReadable = is_file($envPath) && is_readable($envPath);
$envWritable = $envReadable && is_writable($envPath);
$dataWritable = is_writable(data_dir());
echo '<section><h2>Permission checks</h2><table>';
echo '<div class="grid-2">';
echo '<section class="card"><div class="card-head"><h2>Permission checks</h2></div><ul class="checks">';
foreach (SERVICE_ACTIONS as $action) {
echo '<tr><td>sudo: systemctl ' . h($action) . ' ' . h($service) . '</td><td>' . permission_mark($perms[$action]) . '</td></tr>';
echo permission_row('sudo: systemctl ' . $action . ' ' . $service, $perms[$action]);
}
echo '<tr><td>Env file readable (' . h($envPath) . ')</td><td>' . permission_mark($envReadable) . '</td></tr>';
echo '<tr><td>Env file writable</td><td>' . permission_mark($envWritable) . '</td></tr>';
echo '<tr><td>Data directory writable</td><td>' . permission_mark($dataWritable) . '</td></tr>';
echo '</table>';
echo permission_row('Env file readable', $envReadable, $envPath);
echo permission_row('Env file writable', $envWritable);
echo permission_row('Data directory writable', $dataWritable);
echo '</ul>';
if (in_array(false, $perms, true)) {
echo '<p>Missing sudo rules: install <code>sudoers/tinyauth-web.sudoers</code> from this repo (check with <code>visudo -cf</code>).</p>';
echo '<p class="notice">Missing sudo rules. Install <code>sudoers/tinyauth-web.sudoers</code> '
. 'from this repo and check it with <code>visudo -cf</code>.</p>';
}
echo '<form method="post" style="margin-top:.8rem"><input type="hidden" name="csrf" value="' . h($token) . '">';
echo '<button type="submit" name="action" value="reset_group">Change access group</button></form>';
echo '<form method="post" class="form-actions"><input type="hidden" name="csrf" value="' . h($token) . '">';
echo '<span class="muted">Current group: <code>' . h($allowedGroup) . '</code></span>';
echo '<button type="submit" name="action" value="reset_group" class="btn btn-ghost btn-sm">Change access group</button>';
echo '</form>';
echo '</section>';
echo '<section><h2>Config: <code>' . h($envPath) . '</code></h2>';
echo '<section class="card"><div class="card-head"><h2>Quick notes</h2></div>';
echo '<ul class="muted" style="margin:0;padding-left:1.1rem;display:grid;gap:.4rem">';
echo '<li>Saving the config writes a backup first.</li>';
echo '<li>Changes take effect after you restart the service.</li>';
echo '<li>Secret values are never shown. Leave a secret blank to keep it.</li>';
echo '</ul></section>';
echo '</div>';
echo '<section class="card"><div class="card-head"><h2>Config <code>' . h($envPath) . '</code></h2></div>';
if (!$envReadable) {
echo '<p class="flash error">The env file cannot be read by this user.</p>';
echo '<div class="flash flash-error">The env file cannot be read by this user.</div>';
} else {
$vars = env_parse((string) file_get_contents($envPath));
echo '<form method="post"><input type="hidden" name="csrf" value="' . h($token) . '">';
echo '<input type="hidden" name="action" value="save_config">';
echo '<table><tr><th>Variable</th><th>Value</th><th>Delete</th></tr>';
echo '<div class="table-wrap"><table class="table">';
echo '<thead><tr><th>Variable</th><th>Value</th><th class="delete">Delete</th></tr></thead><tbody>';
foreach ($vars as $key => $value) {
$name = h($key);
echo '<tr><td><code>' . $name . '</code></td><td>';
@ -137,19 +173,22 @@ if (!$envReadable) {
} else {
echo '<input type="text" name="value[' . $name . ']" value="' . h($value) . '">';
}
echo '</td><td><input type="checkbox" name="delete[]" value="' . $name . '"></td></tr>';
echo '</td><td class="delete"><input type="checkbox" name="delete[]" value="' . $name . '"></td></tr>';
}
echo '<tr><td><input type="text" name="new_key" placeholder="NEW_VARIABLE"></td>';
echo '<td><input type="text" name="new_value" placeholder="value"></td><td>add</td></tr>';
echo '</table>';
echo '<p><button type="submit"' . ($envWritable ? '' : ' disabled') . '>Save config</button> ';
echo 'Saving writes a backup first. Restart tinyauth to apply changes.</p>';
echo '<tr class="add-row"><td><input type="text" name="new_key" placeholder="NEW_VARIABLE"></td>';
echo '<td><input type="text" name="new_value" placeholder="value"></td><td class="delete muted">add</td></tr>';
echo '</tbody></table></div>';
echo '<div class="form-actions"><span class="muted">Saving writes a backup first. Restart the service to apply.</span>';
echo '<button type="submit" class="btn btn-primary"' . ($envWritable ? '' : ' disabled') . '>Save config</button></div>';
echo '</form>';
}
echo '</section>';
page_end();
function permission_mark(bool $ok): string
function permission_row(string $label, bool $ok, ?string $detail = null): string
{
return $ok ? '<span class="yes">✔ ok</span>' : '<span class="no">✘ missing</span>';
$class = $ok ? 'check-ok' : 'check-missing';
$mark = $ok ? '✔ ok' : '✘ missing';
$extra = $detail !== null ? '<br><small class="muted">' . h($detail) . '</small>' : '';
return '<li class="' . $class . '"><span>' . h($label) . $extra . '</span><span class="mark">' . $mark . '</span></li>';
}

View file

@ -20,6 +20,7 @@ try {
]));
} catch (RuntimeException $e) {
page_start('Login error');
echo '<h1>Cannot reach tinyauth</h1><p>' . h($e->getMessage()) . '</p>';
echo '<section class="card card-center"><h1>Cannot reach tinyauth</h1><div class="flash flash-error">'
. h($e->getMessage()) . '</div></section>';
page_end();
}

View file

@ -208,28 +208,21 @@ function env_apply(string $content, array $changes, array $deletes): string
return rtrim(implode("\n", $out), "\n") . "\n";
}
function page_start(string $title): void
function page_start(string $title, string $userHtml = ''): void
{
echo '<!doctype html><html lang="en"><head><meta charset="utf-8">'
. '<meta name="viewport" content="width=device-width,initial-scale=1">'
. '<title>' . h($title) . '</title><style>'
. 'body{font-family:system-ui,sans-serif;background:#f4f5f7;color:#222;margin:0}'
. 'main{max-width:960px;margin:0 auto;padding:1rem}'
. 'header{display:flex;justify-content:space-between;align-items:baseline;flex-wrap:wrap}'
. 'section{background:#fff;border:1px solid #ddd;border-radius:6px;padding:1rem;margin:1rem 0}'
. 'table{width:100%;border-collapse:collapse}'
. 'th,td{text-align:left;padding:.3rem;border-bottom:1px solid #eee;vertical-align:top}'
. 'input[type=text],input[type=password]{width:100%;box-sizing:border-box;padding:.3rem;font-family:monospace}'
. 'button,.button{padding:.4rem .9rem;border:1px solid #888;border-radius:4px;background:#eee;cursor:pointer;text-decoration:none;color:#222;display:inline-block}'
. 'button:disabled{opacity:.4;cursor:not-allowed}'
. '.flash{padding:.5rem;border-radius:4px}.flash.ok{background:#e3f6e5}.flash.error{background:#fbe3e3}.flash.info{background:#e6eefb}'
. '.badge{padding:.1rem .5rem;border-radius:4px;background:#eee}'
. '.yes{color:#1a7f37;font-weight:bold}.no{color:#b42318;font-weight:bold}'
. 'pre{background:#111;color:#ddd;padding:.6rem;overflow:auto;border-radius:4px;white-space:pre-wrap}'
. '</style></head><body><main>';
. '<title>' . h($title) . ' · tinyauth-web</title>'
. '<script>try{var t=localStorage.getItem("tinyauth-web-theme");if(t){document.documentElement.setAttribute("data-theme",t)}}catch(e){}</script>'
. '<link rel="stylesheet" href="assets/style.css">'
. '</head><body>'
. '<header class="topbar"><div class="brand"><span class="logo">◆</span>tinyauth-web</div>'
. '<div class="topbar-right">' . $userHtml
. '<button type="button" class="btn btn-ghost btn-sm" id="theme-toggle" title="Toggle light/dark">◐ Theme</button>'
. '</div></header><main>';
}
function page_end(): void
{
echo '</main></body></html>';
echo '</main><footer class="footer">tinyauth-web</footer><script src="assets/app.js"></script></body></html>';
}