/*
 * The shell stylesheet: design tokens for light and dark, and the dense frame every page renders
 * in: app bar, side navigation, content area. The side navigation collapses without script, through
 * the checkbox the layout places before the app bar. System fonts only; nothing here is fetched.
 */

:root {
    color-scheme: light dark;
    --surface: #ffffff;
    --surface-raised: #f3f4f6;
    --text: #1c2230;
    --text-muted: #5a6373;
    --accent: #1f5fbf;
    --accent-text: #ffffff;
    --border: #d4d8df;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --radius: 3px;
    --bar-height: 2.5rem;
    --nav-width: 14rem;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size: 0.875rem;
    --line-height: 1.35;
}

@media (prefers-color-scheme: dark) {
    :root {
        --surface: #15181e;
        --surface-raised: #1d2129;
        --text: #e3e6eb;
        --text-muted: #9aa3b2;
        --accent: #6ea2ff;
        --accent-text: #0b1220;
        --border: #323845;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
}

body {
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--font-size);
    line-height: var(--line-height);
}

a {
    color: var(--accent);
}

h1 {
    margin: 0 0 var(--space-3);
    font-size: 1.25rem;
}

table {
    border-collapse: collapse;
}

th,
td {
    padding: var(--space-1) var(--space-2);
    border-bottom: 1px solid var(--border);
    text-align: left;
}

input,
select,
textarea,
button {
    font: inherit;
    color: inherit;
}

input,
select,
textarea {
    padding: var(--space-1) var(--space-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

button {
    padding: var(--space-1) var(--space-3);
    background: var(--accent);
    color: var(--accent-text);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
}

/* The frame. */

.shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.shell-nav-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.shell-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--bar-height);
    padding: 0 var(--space-3);
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border);
}

.shell-nav-button {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    user-select: none;
}

.shell-nav-button:hover {
    border-color: var(--accent);
}

.shell-nav-toggle:focus-visible + .shell-bar .shell-nav-button {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.shell-brand {
    font-weight: 600;
}

.shell-frame {
    position: relative;
    display: flex;
    flex: 1;
    min-height: 0;
}

.shell-nav {
    display: flex;
    flex: 0 0 var(--nav-width);
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3);
    background: var(--surface-raised);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.shell-nav a {
    display: block;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius);
    text-decoration: none;
}

.shell-nav a:hover,
.shell-nav a:focus-visible {
    background: var(--surface);
}

.shell-content {
    flex: 1;
    min-width: 0;
    padding: var(--space-3) var(--space-4);
    overflow-x: auto;
}

/* The command palette: the app bar's search form, and the dialog Ctrl+K opens. */

.shell-palette-form {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}

.shell-palette {
    width: min(32rem, calc(100vw - 2 * var(--space-4)));
    margin-top: 15vh;
    padding: var(--space-3);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.shell-palette::backdrop {
    background: rgb(0 0 0 / 40%);
}

.shell-palette input[type="search"] {
    width: 100%;
}

.shell-palette form {
    margin-top: var(--space-2);
    text-align: right;
}

.shell-palette-list {
    margin: var(--space-2) 0 0;
    padding: 0;
    list-style: none;
}

.shell-palette-list li {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-1) var(--space-2);
}

.shell-palette-group {
    color: var(--text-muted);
}

/* Wide screens: the navigation shows until the toggle collapses it. */
.shell-nav-toggle:checked ~ .shell-frame .shell-nav {
    display: none;
}

/* Tablet width and below: the navigation is collapsed until the toggle opens it over the content. */
@media (max-width: 64rem) {
    .shell-nav {
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 5;
        width: var(--nav-width);
    }

    .shell-nav-toggle:checked ~ .shell-frame .shell-nav {
        display: flex;
    }
}

/* Kit: the toast region, the filter form, the column chooser, the grid, the drawer and the conflict prompt. */
.kit-toasts {
    margin: 0 0 var(--space-3);
}

.kit-toast {
    margin: 0;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
}

.kit-filter,
.kit-chooser fieldset {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-3);
}

.kit-chooser fieldset {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.kit-grid {
    width: 100%;
    border-collapse: collapse;
}

.kit-grid th,
.kit-grid td {
    padding: var(--space-1) var(--space-2);
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.kit-grid thead th {
    background: var(--surface-raised);
}

.kit-drawer:not(:empty) {
    margin: var(--space-3) 0 0;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-raised);
}

.kit-prompt {
    margin: 0 0 var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.kit-editor dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-1) var(--space-3);
}
