/* Shared design tokens and application shell for every page. */
:root {
    color-scheme: dark;
    --background: #0b1019;
    --surface: #121b28;
    --surface-secondary: #172234;
    --surface-hover: #1d2c40;
    --border: #29394e;
    --border-secondary: #34465e;
    --border-input: #425672;
    --text: #edf3fc;
    --text-strong: #ffffff;
    --text-secondary: #c4d1e4;
    --text-muted: #9caec6;
    --text-muted-strong: #b0bfd3;
    --input-background: #101927;
    --code-background: #1a293d;
    --accent: #8eb9ff;
    --accent-surface: #213d65;
    --success: #79dda8;
    --success-surface: #16382c;
    --error: #ff9eaa;
    --error-surface: #432632;
    --toggle-background: #425672;
    --toggle-thumb: #edf3fc;
    --panel-background: var(--surface);
    --border-color: var(--border);
    --muted-text: var(--text-muted);
}
html[data-theme="light"] {
    color-scheme: light;
    --background: #eef3fa;
    --surface: #ffffff;
    --surface-secondary: #f1f5fb;
    --surface-hover: #e6eef9;
    --border: #d4deed;
    --border-secondary: #c5d1e3;
    --border-input: #9aacc4;
    --text: #182a42;
    --text-strong: #102037;
    --text-secondary: #354e6e;
    --text-muted: #526984;
    --text-muted-strong: #465e7b;
    --input-background: #ffffff;
    --code-background: #e6eef9;
    --accent: #245db0;
    --accent-surface: #e0ebfc;
    --success: #176a40;
    --success-surface: #e2f5e9;
    --error: #a52d42;
    --error-surface: #fbe7eb;
    --toggle-background: #c5d1e3;
    --toggle-thumb: #245db0;
}
* { box-sizing: border-box; }
html, body {
    margin: 0;
    min-height: 100%;
    background: var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
[hidden] { display: none !important; }
.topbar {
    padding: 18px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-strong);
    text-decoration: none;
    white-space: nowrap;
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -0.5px;
}
.brand-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--accent-surface);
    color: var(--accent);
    font-size: 22px;
}
.topbar .navigation { display: flex; gap: 6px; width: auto; order: initial; }
.topbar .navigation a {
    padding: 9px 13px;
    border-radius: 9px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}
.topbar .navigation a:hover { background: var(--surface-hover); color: var(--text); }
.topbar .navigation a.active { background: var(--accent-surface); color: var(--accent); }
.theme-toggle { display: flex; align-items: center; gap: 9px; margin-left: auto; }
#themeLabel { color: var(--text-muted); font-size: 12px; }
.topbar .theme-switch { margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; }
.theme-switch-track { position: relative; display: block; width: 42px; height: 24px; border-radius: 20px; background: var(--toggle-background); }
.theme-switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--toggle-thumb); }
html[data-theme="light"] .theme-switch-thumb { transform: translateX(18px); }
main { max-width: 1440px; margin: 0 auto; padding: 32px 28px; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 28px; }
h1, h2, h3 { color: var(--text-strong); letter-spacing: -0.025em; }
.page-header h1 { font-size: 28px; margin: 0; font-weight: 750; }
.page-header p { color: var(--text-muted); margin: 6px 0 0; font-size: 14px; }
.panel, .section { border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.card, .stat-card, .latest-card, .scanner-summary-card { border-radius: 12px; }
button, input, select, textarea { font-family: inherit; }
button:not(.theme-switch) { cursor: pointer; font-weight: 600; }
button:disabled { cursor: default; opacity: .45; }
.button.primary, .control-button.primary { background: var(--accent); border-color: var(--accent); color: var(--background); }
.button.primary:hover:not(:disabled), .control-button.primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); filter: brightness(1.1); }
:where(a, button, input, select, textarea):focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.source-link, .source-link:hover { color: var(--accent); }
.status-badge.available, .repository-status.success { background: var(--success-surface); color: var(--success); border-color: var(--success); }
.status-badge.missing, .repository-status.error, .opening-error { background: var(--error-surface); color: var(--error); border-color: var(--error); }
.stats strong { color: var(--accent); font-variant-numeric: tabular-nums; }
main.scanner { max-width: 600px; min-height: auto; margin: 0 auto; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.scanner-header { background: var(--surface); padding: 20px; border-color: var(--border); }
.scanner-header h1 { font-size: 24px; margin: 0; }
.scanner-header .header-row { margin-bottom: 16px; }
.scanner .camera-container { margin-top: 0; margin-bottom: 0; }
.variant-option.selected, .opening-type-option:has(input:checked) { background: var(--accent-surface); border-color: var(--accent); }
/* Camera overlays retain contrast over a live image in either theme. */
.camera-container .last-identifier { color: #d7e3f5; }
.camera-container .last-identifier.has-value { color: #fff; }
@media (max-width: 760px) {
    .topbar { padding: 14px 16px; }
    .topbar-inner { flex-wrap: wrap; gap: 12px; }
    .topbar .navigation { order: 3; width: 100%; overflow-x: auto; }
    .topbar .theme-toggle { align-self: center; }
    main { padding: 24px 16px; }
    .page-header { align-items: flex-start; flex-direction: column; gap: 16px; }
    .page-header h1 { font-size: 25px; }
    main.scanner { width: calc(100% - 24px); margin: 0 auto; }
    .variant-dialog-footer { flex-wrap: wrap; }
    .variant-dialog-footer .control-button { min-width: 100px; }
}

.icon-button {
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 44px; width: 44px; min-height: 44px; margin: 0;
    padding: 10px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-button:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--accent); }
.navigation-toggle { display: none; }
@media (max-width: 760px) {
    .topbar .topbar-inner { gap: 8px; }
    .topbar .brand { font-size: 16px; }
    .topbar .navigation-toggle { display: inline-flex; margin-left: auto; }
    .topbar .navigation, .topbar .theme-toggle { display: none; }
    .topbar.navigation-open .navigation { display: flex; }
    .topbar.navigation-open .theme-toggle { display: flex; order: 4; margin: 0; }
    .topbar { padding: 8px 12px; }
}
