/* Shared base styles for both surfaces — layout, typography, responsive
   shell. Surface-specific colour comes from tokens.css. */

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
}

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

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

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.app-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 0;
}

.app-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
}

.app-sidebar nav a .icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.app-sidebar nav a[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
    background: var(--bg);
}

.nav-section-label {
    display: block;
    padding: 8px 16px;
    color: var(--text-muted);
    font-size: 12px;
}

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 16px;
}

.app-main {
    flex: 1;
    min-width: 0;
    padding: 24px;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    width: 32px;
    height: 32px;
    cursor: pointer;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.tooltip {
    position: relative;
    border-bottom: 1px dotted var(--text-muted);
    cursor: help;
}

.tooltip[data-tooltip]:focus-visible::after,
.tooltip[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--structural, var(--text));
    color: var(--bg);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    white-space: normal;
    max-width: 260px;
    z-index: 10;
}

/* Responsive shell — required breakpoints (§14.1–14.6) */

/* Phone portrait/landscape: sidebar becomes a drawer */
@media (max-width: 767px) {
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .app-sidebar {
        position: fixed;
        inset: 56px 0 0 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 20;
        width: 80%;
        max-width: 320px;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .app-main {
        padding: 16px;
    }
}

/* iPad portrait: narrow rail instead of full sidebar text */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
    .app-sidebar {
        width: 72px;
    }

    .app-sidebar nav a {
        justify-content: center;
    }

    .app-sidebar nav a span.label,
    .nav-section-label {
        display: none;
    }
}
