/* Design tokens */
:root {
    --accent: #5caeeb;
    --accent-2: #818cf8;
    --primary-color: #5caeeb;
    --primary-hover: #4a9fd4;
    --bg-base: #0c0e14;
    --bg-dark: #141820;
    --bg-darker: #090b10;
    --bg-light: #0c0e14;
    --surface: rgba(255, 255, 255, 0.035);
    --surface-raised: rgba(255, 255, 255, 0.055);
    --surface-border: color-mix(in srgb, var(--text-light) 8%, transparent);
    --text-light: #eceef4;
    --text-secondary: #b4bac9;
    --text-muted: #7a8296;
    --border-color: color-mix(in srgb, var(--text-light) 10%, transparent);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.35);
    --sidebar-width: 260px;
    --transition: 0.18s ease;
    --color-success: #4ade80;
    --color-success-bg: color-mix(in srgb, var(--color-success) 15%, transparent);
    --color-error: #f87171;
    --color-error-bg: color-mix(in srgb, var(--color-error) 15%, transparent);
    --color-warning: #facc15;
    --color-warning-bg: color-mix(in srgb, var(--color-warning) 15%, transparent);
    --color-diff-add-bg: color-mix(in srgb, var(--color-success) 18%, transparent);
    --color-diff-remove-bg: color-mix(in srgb, var(--color-error) 18%, transparent);
    --link: var(--accent);
    --link-visited: color-mix(in srgb, var(--accent-2) 88%, white);
    --link-hover: var(--primary-hover);

    /* Derived tints — follow --accent / --accent-2 / semantic colors when theme changes */
    --tint-accent-faint: color-mix(in srgb, var(--accent) 6%, transparent);
    --tint-accent-subtle: color-mix(in srgb, var(--accent) 8%, transparent);
    --tint-accent-hover: color-mix(in srgb, var(--accent) 10%, transparent);
    --tint-accent: color-mix(in srgb, var(--accent) 12%, transparent);
    --tint-accent-emphasis: color-mix(in srgb, var(--accent) 15%, transparent);
    --tint-accent-medium: color-mix(in srgb, var(--accent) 18%, transparent);
    --tint-accent-strong: color-mix(in srgb, var(--accent) 20%, transparent);
    --border-accent-soft: color-mix(in srgb, var(--accent) 25%, transparent);
    --border-accent-light: color-mix(in srgb, var(--accent) 30%, transparent);
    --border-accent: color-mix(in srgb, var(--accent) 35%, transparent);
    --border-accent-medium: color-mix(in srgb, var(--accent) 45%, transparent);
    --border-accent-strong: color-mix(in srgb, var(--accent) 55%, transparent);
    --border-accent-focus: color-mix(in srgb, var(--accent) 50%, transparent);
    --outline-accent: color-mix(in srgb, var(--accent) 60%, transparent);
    --ring-accent: color-mix(in srgb, var(--accent) 15%, transparent);
    --shadow-accent: color-mix(in srgb, var(--accent) 12%, transparent);
    --shadow-accent-md: color-mix(in srgb, var(--accent) 30%, transparent);
    --shadow-accent-lg: color-mix(in srgb, var(--accent) 40%, transparent);
    --gradient-accent-glow: color-mix(in srgb, var(--accent) 14%, transparent);
    --gradient-accent-2-glow: color-mix(in srgb, var(--accent-2) 8%, transparent);

    --tint-accent-2: color-mix(in srgb, var(--accent-2) 15%, transparent);

    --tint-success: color-mix(in srgb, var(--color-success) 12%, transparent);
    --tint-success-strong: color-mix(in srgb, var(--color-success) 15%, transparent);
    --border-success: color-mix(in srgb, var(--color-success) 35%, transparent);
    --border-success-medium: color-mix(in srgb, var(--color-success) 45%, transparent);
    --border-success-strong: color-mix(in srgb, var(--color-success) 55%, transparent);
    --border-success-focus: color-mix(in srgb, var(--color-success) 70%, transparent);
    --shadow-success: color-mix(in srgb, var(--color-success) 12%, transparent);
    --inset-success: color-mix(in srgb, var(--color-success) 20%, transparent);
    --border-error: color-mix(in srgb, var(--color-error) 45%, transparent);

    --surface-hover: color-mix(in srgb, var(--text-light) 4%, transparent);
    --surface-hover-strong: color-mix(in srgb, var(--text-light) 6%, transparent);
    --surface-code: color-mix(in srgb, var(--text-light) 8%, transparent);
    --surface-pre: color-mix(in srgb, black 25%, transparent);
    --overlay-backdrop: color-mix(in srgb, black 55%, transparent);
    --overlay-scrim: color-mix(in srgb, black 65%, transparent);
    --border-on-surface: color-mix(in srgb, var(--text-light) 10%, transparent);

    --meta-title: #8ab4f8;
    --meta-url: var(--text-muted);
    --meta-desc: var(--text-secondary);

    --text-on-brand: #fff;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-light);
    background: var(--bg-base);
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 100%;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }

/* Layout */
.layout-row {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 100%;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    background: var(--bg-darker);
    border-right: 1px solid var(--surface-border);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-sticky {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem 0.85rem 0.5rem;
    overflow: hidden;
}

.sidebar-brand-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem 1rem;
    margin-bottom: 0.25rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1;
    min-width: 0;
    padding: 0;
    margin: 0;
    text-decoration: none;
    color: var(--text-light);
}

.sidebar-brand-mark {
    display: block;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.sidebar-brand-mark-light {
    display: none;
}

[data-theme="light"] .sidebar-brand-mark-dark {
    display: none;
}

[data-theme="light"] .sidebar-brand-mark-light {
    display: block;
}

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.03em;
}

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.75rem 0.65rem 0.35rem;
    margin: 0;
}

.sidebar-nav-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0 -0.15rem 0.5rem;
    padding: 0 0.15rem;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.nav-group {
    margin-bottom: 0.15rem;
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0;
    padding: 0.55rem 0.65rem 0.3rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.nav-group-toggle i {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .nav-group-toggle:hover {
        color: var(--text-secondary);
        background: rgba(255, 255, 255, 0.03);
    }
}

.nav-group-toggle:active {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.nav-group.is-collapsed .nav-group-toggle i {
    transform: rotate(-90deg);
}

.nav-group.is-collapsed .nav-list {
    display: none;
}

.nav-group .nav-list {
    padding-bottom: 0.15rem;
}

.nav-search {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    font-size: 0.8125rem;
    font-family: inherit;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%237a8296' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.1a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E") 0.65rem center no-repeat;
    color: var(--text-light);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.nav-search-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    text-align: left;
}

.nav-search-label {
    flex: 1;
    color: var(--text-muted);
}

.nav-search-kbd {
    display: none;
    margin-left: auto;
    padding: 0.1rem 0.35rem;
    font-size: 0.6875rem;
    font-family: inherit;
    line-height: 1.3;
    border: 1px solid var(--surface-border);
    border-radius: 0.25rem;
    background: var(--bg-dark);
    color: var(--text-muted);
}

@media (min-width: 769px) {
    .nav-search-kbd {
        display: inline-block;
    }
}

@media (hover: hover) and (pointer: fine) {
    .nav-search-trigger:hover {
        border-color: var(--border-accent-soft);
        background-color: var(--surface-raised);
    }
}

.nav-search-trigger:active {
    border-color: var(--border-accent-soft);
    background-color: var(--surface-raised);
}

.nav-search-trigger:focus-visible {
    border-color: var(--border-accent-focus);
    box-shadow: 0 0 0 3px var(--tint-accent-emphasis);
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    margin-bottom: 2px;
    position: relative;
}

.nav-item[data-tool-id] > .nav-link {
    padding-right: 2rem;
}

.nav-pin-btn {
    position: absolute;
    right: 0.25rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition), color var(--transition), background var(--transition);
}

.nav-item[data-tool-id]:hover .nav-pin-btn,
.nav-pin-btn.is-pinned,
.nav-item-quick .nav-pin-btn {
    opacity: 1;
    pointer-events: auto;
}

.nav-pin-btn:active {
    color: var(--accent);
    background: var(--tint-accent-soft);
}

.nav-pin-btn.is-pinned {
    color: var(--accent);
}

.nav-quick-access {
    margin-bottom: 0.35rem;
}

.nav-quick-access .nav-section-label {
    margin-top: 0.15rem;
}

.nav-item-quick .nav-link {
    padding-right: 2rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.65rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.nav-link span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-link i {
    flex-shrink: 0;
    width: 1.15rem;
    text-align: center;
    font-size: 0.95rem;
    opacity: 0.85;
}

@media (hover: hover) and (pointer: fine) {
    .nav-link:hover {
        background: var(--surface-raised);
        color: var(--text-light);
    }

    .nav-pin-btn:hover {
        color: var(--accent);
        background: var(--tint-accent-soft);
    }
}

.nav-link:active {
    background: var(--surface-raised);
    color: var(--text-light);
}

.nav-link.active,
.nav-link.is-current {
    background: var(--tint-accent);
    color: var(--accent);
    scroll-margin-block: 2rem;
}

.nav-link.active i,
.nav-link.is-current i {
    opacity: 1;
}

.nav-link.is-done-today i {
    color: var(--color-success);
    opacity: 1;
}

/* Main content */
.main-content {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 2rem 2rem 3rem;
    background:
        radial-gradient(ellipse 90% 50% at 50% -10%, var(--gradient-accent-glow), transparent),
        radial-gradient(ellipse 60% 40% at 100% 0%, var(--gradient-accent-2-glow), transparent),
        var(--bg-base);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    min-width: 0;
}

.page-header-text {
    min-width: 0;
}

.page-subtitle {
    margin-top: 0.35rem;
    font-size: 0.9375rem;
    color: var(--text-muted);
    font-weight: 400;
}

.main-content a {
    color: var(--link);
}

.main-content a:visited {
    color: var(--link-visited);
}

.main-content a:hover {
    color: var(--link-hover);
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.page-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.page-share-btn i {
    font-size: 0.95rem;
}

.share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    color: inherit;
}

.share-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

html[data-share-icon="apple"] .share-icon--default {
    display: none;
}

html:not([data-share-icon="apple"]) .share-icon--apple {
    display: none;
}

.page-share-btn:hover {
    background: var(--surface-raised);
    border-color: var(--border-accent-light);
    color: var(--text-light);
}

.page-cmd-hint {
    flex-shrink: 0;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition), border-color var(--transition);
}

.page-cmd-hint:hover {
    background: var(--surface-raised);
    border-color: var(--border-accent-light);
    color: var(--text-light);
}

.page-cmd-hint kbd {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
}

.page-body {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    min-width: 0;
    max-width: 100%;
    overflow-x: clip;
}

.page-body-flush {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

.page-body > p:first-child {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    max-width: 52rem;
}

/* Forms */
.form-control,
.form-select {
    display: block;
    width: 100%;
    min-height: 40px;
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-light);
    background: var(--bg-dark);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--border-accent-strong);
    outline: none;
    box-shadow: 0 0 0 3px var(--tint-accent-emphasis);
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%237a8296' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.25rem;
    appearance: none;
}

.form-check {
    display: flex;
    align-items: center;
    min-height: 1.5rem;
}

.form-switch {
    padding-left: 3.5em;
}

.form-switch .form-check-input {
    width: 2.75em;
    height: 1.4em;
    margin-left: -3.5em;
    background-color: var(--surface-raised);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-position: left center;
    background-repeat: no-repeat;
    background-size: contain;
    border: 1px solid var(--surface-border);
    border-radius: 2em;
    transition: background-position var(--transition), background-color var(--transition);
    appearance: none;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-position: right center;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-switch .form-check-label {
    padding-left: 0.75rem;
    cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    opacity: 0.8;
    cursor: pointer;
}

/* Tables */
.table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    margin-bottom: 1rem;
    border-collapse: collapse;
    color: var(--text-light);
    font-size: 0.875rem;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--surface-border);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.table .tool-mono,
.table .hash-value {
    word-break: break-all;
}

.table td:last-child:has(.btn) {
    width: 5.5rem;
    white-space: nowrap;
}

.table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--surface-border);
}

.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.table-hover tbody tr:hover {
    background: var(--surface-hover);
}

.current-timezone {
    background: var(--tint-accent-hover) !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 40px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #4a9fd4);
    border-color: transparent;
    color: var(--text-on-brand);
    min-width: 100px;
    box-shadow: 0 2px 12px var(--border-accent-light);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px var(--shadow-accent-lg);
}

.btn-secondary {
    background: var(--surface-raised);
    border-color: var(--surface-border);
    color: var(--text-light);
}

.btn-secondary:hover {
    background: var(--border-on-surface);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-sm {
    min-height: 32px;
    padding: 0.3rem 0.65rem;
    font-size: 0.8125rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25em 0.55em;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
}

.bg-primary {
    background: var(--tint-accent-strong);
    color: var(--accent);
}

/* Utilities */
.d-none { display: none !important; }
.d-flex { display: flex !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-center { align-items: center !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.ms-2 { margin-left: 0.5rem !important; }

/* Grid */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.col-md-3,
.col-md-4,
.col-md-6,
.col-md-8,
.col-md-9 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    width: 100%;
    min-width: 0;
}

@media (min-width: 768px) {
    .col-md-3 { width: 25%; }
    .col-md-4 { width: 33.333333%; }
    .col-md-6 { width: 50%; }
    .col-md-8 { width: 66.666667%; }
    .col-md-9 { width: 75%; }
}

.sidebar-toggle {
    display: none;
}

/* Mobile app chrome — SwiftUI-style top bar */
.mobile-top-bar {
    display: none;
}

.mobile-bar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 0.625rem;
    background: transparent;
    color: var(--accent);
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease;
}

.mobile-bar-btn:active {
    background: rgb(255 255 255 / 0.08);
}

.mobile-bar-leading {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 2.25rem;
}

.mobile-bar-back {
    display: none;
    align-items: center;
    gap: 0.1rem;
    width: auto;
    max-width: 38vw;
    height: 2.25rem;
    padding: 0 0.25rem 0 0;
    color: var(--accent);
    font-size: 1.0625rem;
    font-weight: 500;
    font-family: inherit;
    letter-spacing: -0.01em;
}

.mobile-bar-back i {
    flex-shrink: 0;
    font-size: 1.45rem;
    line-height: 1;
    margin-left: -0.35rem;
}

.mobile-bar-back-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-bar-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-light);
    pointer-events: none;
}

.mobile-bar-trailing {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.125rem;
    flex-shrink: 0;
    min-width: 2.25rem;
    position: relative;
    z-index: 1;
}

.mobile-share-icon {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--accent);
}

.theme-toggle-mobile {
    display: none;
}

.sidebar-action-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.sidebar-action-btn i {
    font-size: 1rem;
    color: var(--accent);
}

.sidebar-action-btn:hover {
    background: var(--surface-raised);
    color: var(--text-light);
    border-color: var(--border-accent-soft);
}

.sidebar-action-btn span {
    flex: 1;
    text-align: left;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 0.65rem 0.85rem 0.85rem;
    border-top: 1px solid var(--surface-border);
    background: var(--bg-darker);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.support-links {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.support-links + .support-contact {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--surface-border);
}

.support-intro {
    margin: 0 0 0.25rem;
    padding: 0 0.65rem;
    font-size: 0.6875rem;
    line-height: 1.4;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .support-intro {
        font-size: 0.75rem;
    }
}

.support-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease;
}

.support-link:hover {
    color: var(--text-secondary);
    background: rgb(255 255 255 / 0.04);
}

.support-link i {
    font-size: 0.9rem;
    color: var(--accent);
    opacity: 0.85;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.theme-toggle i {
    font-size: 1rem;
    color: var(--accent);
}

.theme-toggle:hover {
    background: var(--surface-raised);
    color: var(--text-light);
    border-color: var(--border-accent-soft);
}

.theme-toggle span {
    flex: 1;
    text-align: left;
}

.theme-toggle.theme-toggle-brand {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    margin-left: auto;
    flex-shrink: 0;
    justify-content: center;
    gap: 0;
}

.theme-toggle.theme-toggle-brand i {
    font-size: 1.05rem;
}

.theme-toggle.theme-toggle-brand span {
    display: none;
}

.pwa-install-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--bg-darker) 92%, transparent);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 0.5px solid var(--surface-border);
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
    animation: pwaSlideUp 0.35s ease;
}

.pwa-install-banner::before {
    content: '';
    align-self: center;
    width: 2.25rem;
    height: 0.25rem;
    margin-bottom: 0.15rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 45%, transparent);
}

.pwa-install-text {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.pwa-install-text strong {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-light);
}

.pwa-install-text span {
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.pwa-install-steps {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.pwa-install-steps li {
    margin-bottom: 0.25rem;
}

.pwa-install-steps li:last-child {
    margin-bottom: 0;
}

.pwa-install-actions {
    display: flex;
    flex-shrink: 0;
    gap: 0.5rem;
}

@keyframes pwaSlideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 992px) {
    .main-content {
        margin-left: 240px;
    }

    :root {
        --sidebar-width: 240px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
        --mobile-bar-height: 2.75rem;
    }

    .mobile-top-bar {
        display: flex;
        align-items: center;
        gap: 0.375rem;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1030;
        min-height: var(--mobile-bar-height);
        padding: 0.375rem 0.625rem;
        padding-top: calc(0.375rem + env(safe-area-inset-top, 0px));
        padding-left: calc(0.625rem + env(safe-area-inset-left, 0px));
        padding-right: calc(0.625rem + env(safe-area-inset-right, 0px));
        background: color-mix(in srgb, var(--bg-darker) 78%, transparent);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 0.5px solid color-mix(in srgb, var(--surface-border) 80%, transparent);
    }

    body.has-mobile-back .mobile-bar-back {
        display: inline-flex;
    }

    body.has-mobile-back .mobile-bar-trailing .sidebar-toggle {
        display: flex;
    }

    .desktop-header-actions,
    .page-cmd-hint {
        display: none !important;
    }

    .sidebar {
        left: 0;
        transform: translate3d(-100%, 0, 0);
        -webkit-transform: translate3d(-100%, 0, 0);
        transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
        box-shadow: var(--shadow-md);
        border-right: none;
    }

    .main-content {
        margin-left: 0;
        padding: 0.875rem;
        padding-top: calc(var(--mobile-bar-height) + 0.875rem + env(safe-area-inset-top, 0px));
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    .page-header h1 {
        display: none;
    }

    .page-header:not(:has(.page-subtitle)) {
        display: none;
    }

    .page-header:has(.page-subtitle) {
        margin-bottom: 0.75rem;
    }

    .page-body {
        padding: 1.125rem;
        border-radius: 0.75rem;
        border: none;
        box-shadow: none;
        background: var(--surface);
    }

    body.tool-page .page-body {
        padding: 0.5rem 0 0.75rem;
        background: transparent;
    }

    .page-body-flush {
        background: transparent;
    }

    body.sidebar-collapsed .sidebar,
    body.sidebar-open #sidebar {
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
        z-index: 1040;
        visibility: visible;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1035;
        background: var(--overlay-backdrop);
        backdrop-filter: blur(2px);
    }

    html.is-pwa body.sidebar-open .sidebar-backdrop:not([hidden]) {
        z-index: 9999;
    }

    .sidebar-collapsed .sidebar-toggle {
        visibility: hidden;
    }

    .sidebar-backdrop[hidden] {
        display: none;
    }

    .sidebar-toggle {
        display: flex;
    }

    .mobile-bar-share {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.25rem;
        height: 2.25rem;
        padding: 0;
        border: none;
        background: transparent;
        box-shadow: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .mobile-bar-share[hidden] {
        display: none !important;
    }

    .mobile-bar-share .mobile-share-icon {
        pointer-events: none;
    }

    .mobile-bar-share .mobile-share-icon {
        width: 1.3rem;
        height: 1.3rem;
    }

    .pwa-install-banner {
        flex-direction: column;
        align-items: stretch;
        border-radius: 1rem 1rem 0 0;
    }

    .pwa-install-actions .btn {
        flex: 1;
    }

    .sidebar-footer {
        border-top: 1px solid var(--surface-border);
        padding: 0.65rem 0.85rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
        background: var(--bg-darker);
        display: flex;
        flex-direction: column;
        gap: 0.45rem;
    }

    .nav-link {
        touch-action: manipulation;
    }

    .nav-pin-btn {
        display: none;
    }

    .nav-item[data-tool-id] > .nav-link,
    .nav-item-quick .nav-link {
        padding-right: 0.65rem;
    }
}

/* Installed PWA — edge-to-edge, safe areas, no browser chrome feel */
html.is-pwa {
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html.is-pwa body {
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

html.is-pwa body.is-grid-dragging {
    touch-action: none;
    overscroll-behavior: none;
}

html.is-pwa .game-drag-grid {
    touch-action: none;
    -webkit-touch-callout: none;
}

/* iOS auto-zooms focused inputs below 16px — bump on touch / in PWA */
@media (max-width: 768px) {
    .form-control,
    .form-select,
    .tool-textarea,
    .palette-input,
    .share-url-input,
    input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]),
    select,
    textarea {
        font-size: 16px;
    }
}

html.is-pwa .form-control,
html.is-pwa .form-select,
html.is-pwa .tool-textarea,
html.is-pwa .palette-input,
html.is-pwa .share-url-input,
html.is-pwa input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]),
html.is-pwa select,
html.is-pwa textarea {
    font-size: 16px;
}

html.is-pwa .sidebar {
    top: env(safe-area-inset-top, 0px);
    bottom: env(safe-area-inset-bottom, 0px);
    height: auto;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 769px) {
    html.is-pwa .sidebar {
        left: env(safe-area-inset-left, 0px);
    }
}

html.is-pwa .sidebar-sticky {
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
}

html.is-pwa .main-content {
    padding-top: calc(2rem + env(safe-area-inset-top, 0px));
    padding-right: calc(2rem + env(safe-area-inset-right, 0px));
    padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(2rem + env(safe-area-inset-left, 0px));
}

@media (max-width: 768px) {
    html.is-pwa .main-content {
        padding-top: calc(var(--mobile-bar-height) + 0.875rem + env(safe-area-inset-top, 0px));
        padding-right: calc(0.875rem + env(safe-area-inset-right, 0px));
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        padding-left: calc(0.875rem + env(safe-area-inset-left, 0px));
    }

    html.is-pwa .mobile-top-bar {
        padding-top: calc(0.375rem + env(safe-area-inset-top, 0px));
    }

    html.is-pwa .sidebar {
        top: 0;
        bottom: 0;
        height: auto;
        padding-left: env(safe-area-inset-left, 0px);
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    html.is-pwa .sidebar-sticky {
        padding-top: 1rem;
    }

    html.is-pwa body.sidebar-collapsed .sidebar,
    html.is-pwa body.sidebar-open #sidebar {
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
        z-index: 10000;
        visibility: visible;
    }
}

/* Page navigation loading */
.nav-loading {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--overlay-scrim);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.nav-loading[hidden] {
    display: none !important;
}

.nav-loading-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    min-width: 10rem;
    padding: 1.15rem 1.35rem;
    background: var(--bg-darker);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.nav-loading-spinner {
    width: 1.75rem;
    height: 1.75rem;
    border: 2px solid var(--surface-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: nav-loading-spin 0.75s linear infinite;
}

.nav-loading-text {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

body.nav-loading-active {
    overflow: hidden;
}

html.is-pwa body.nav-loading-active {
    overflow: hidden;
}

@keyframes nav-loading-spin {
    to {
        transform: rotate(360deg);
    }
}
