/* ============================================================
   Cahill NXT — Statutory Graph Visualization
   Design tokens extracted from cahill.com
   ============================================================ */

:root {
    /* Cahill Brand Colors */
    --navy:          #002857;
    --navy-dark:     #001a3a;
    --navy-light:    #003d7a;
    --orange:        #e04403;
    --orange-hover:  #c73a00;
    --orange-glow:   rgba(224, 68, 3, 0.35);
    --link-blue:     #00538b;
    --body-text:     #4d423d;
    --light-bg:      #faf8f7;
    --white:         #ffffff;
    --border:        rgba(255, 255, 255, 0.08);
    --border-light:  #e0dcd8;
    --shadow:        0 2px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg:     0 8px 32px rgba(0, 0, 0, 0.35);

    /* Typography */
    --font-primary:  'Lato', Arial, Helvetica, sans-serif;
    --font-serif:    'Lido', 'Source Serif 4', Georgia, 'Times New Roman', serif;

    /* Layout */
    --topbar-height: 97px;
    --sidebar-width: 280px;
    --detail-width:  400px;

    /* Animation */
    --ease-out:      cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-primary);
    color: var(--navy);
    background: var(--light-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== TOPBAR ===== */
#topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 12px 24px;
    z-index: 100;
    gap: 20px;
}

.topbar-brand {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.brand-cahill {
    color: var(--navy);
}

.brand-nxt {
    color: var(--orange);
}

.topbar-title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 600;
    color: var(--navy);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-subtitle {
    font-size: 12px;
    font-weight: 400;
    color: rgba(0, 40, 87, 0.55);
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.55;
    margin-top: 4px;
}

.description-bar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    padding: 10px 24px;
    z-index: 99;
    font-family: var(--font-primary);
    font-size: 12.5px;
    font-weight: 400;
    color: rgba(0, 40, 87, 0.6);
    line-height: 1.6;
}
.description-bar strong {
    font-weight: 700;
    color: var(--navy);
}

.global-nav {
    display: flex;
    background: rgba(0, 40, 87, 0.06);
    border-radius: 8px;
    padding: 3px;
    gap: 4px;
    margin-left: auto;
    align-items: center;
}
.nav-tab {
    background: transparent;
    color: rgba(0, 40, 87, 0.6);
    text-decoration: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    white-space: nowrap;
}
.nav-tab:hover {
    color: var(--navy);
    background: rgba(0, 40, 87, 0.04);
}
.nav-tab.active {
    background: rgba(0, 40, 87, 0.12);
    color: var(--navy);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ===== VIEW MODE TOGGLE ===== */
.view-toggle {
    display: flex;
    background: rgba(0, 40, 87, 0.06);
    border-radius: 8px;
    padding: 3px;
    border: 1px solid rgba(0, 40, 87, 0.08);
    flex-shrink: 0;
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(0, 40, 87, 0.5);
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-toggle-btn:hover {
    color: rgba(0, 40, 87, 0.8);
}

.view-toggle-btn.active {
    background: var(--navy);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(0, 40, 87, 0.35);
}

.view-toggle-btn svg {
    flex-shrink: 0;
}

/* ===== APP LAYOUT ===== */
#app {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
}

/* ===== SIDEBAR ===== */
#sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-search {
    padding: 16px;
    position: relative;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: rgba(0, 40, 87, 0.4);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background: #faf8f7;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--navy);
    font-family: var(--font-primary);
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}

#searchInput::placeholder {
    color: rgba(0, 40, 87, 0.4);
}

#searchInput:focus {
    background: #ffffff;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(224, 68, 3, 0.15);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 40, 87, 0.15) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(0, 40, 87, 0.15);
    border-radius: 3px;
}

.nav-group {
    margin-bottom: 4px;
}

.nav-group-title {
    display: flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(0, 40, 87, 0.5);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.nav-group-title:hover {
    color: rgba(0, 40, 87, 0.8);
}

.chevron {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s var(--ease-out);
}

.nav-group-title.collapsed .chevron {
    transform: rotate(-90deg);
}

.nav-count {
    margin-left: auto;
    font-size: 10px;
    background: rgba(0, 40, 87, 0.08);
    padding: 2px 6px;
    border-radius: 10px;
    color: rgba(0, 40, 87, 0.6);
}

.nav-list {
    list-style: none;
    margin-top: 10px;
}

.nav-list.collapsed {
    display: none !important;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 400;
    color: rgba(0, 40, 87, 0.7);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

summary.nav-item {
    list-style: none; /* remove default triangle in some browsers */
}
summary.nav-item::marker,
summary.nav-item::-webkit-details-marker {
    display: none;
}
summary.nav-item::before {
    content: "▶";
    font-size: 8px;
    margin-right: 6px;
    color: rgba(0, 40, 87, 0.4);
    transition: transform 0.2s;
    display: inline-block;
}
details[open] > summary.nav-item::before {
    transform: rotate(90deg);
}

.nav-item:hover {
    background: rgba(0, 40, 87, 0.06);
    color: var(--navy);
}

.nav-item.active {
    background: rgba(0, 40, 87, 0.08);
    color: var(--navy);
    font-weight: 600;
}

.nav-item .nav-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

.nav-badge.section-badge {
    display: none;
}

.nav-badge.term-badge {
    background: #e8e5e2;
    color: #6b6159;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    margin-left: 6px;
    border-radius: 3px;
}

/* ===== LEGEND ===== */
.sidebar-legend {
    padding: 12px 20px;
    background: #faf8f7;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.sidebar-legend h3.nav-group-title {
    margin-top: 1px; /* Visual tweak to align text baselines */
}

.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 8px;
    margin-top: 0;
    flex: 1;
}

.legend-item, .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: rgba(0, 40, 87, 0.6);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: rgba(0, 40, 87, 0.6);
}

.legend-section { background: var(--link-blue); }
.legend-term { background: var(--orange); }

.legend-line-sample {
    width: 24px;
    height: 2px;
    flex-shrink: 0;
    border-radius: 1px;
}

.legend-ref { background: rgba(109, 184, 255, 0.5); }
.legend-usage {
    border-bottom: 2px dashed rgba(0, 40, 87, 0.4);
}

/* ===== MAIN GRAPH AREA ===== */
#graphContainer {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--navy-dark); /* Keep the map dark */
}

#graphSvg {
    width: 100%;
    height: 100%;
    display: block;
}

/* D3 graph styles */
.node-circle {
    cursor: pointer;
    transition: filter 0.15s, r 0.4s var(--ease-out);
}

.node-circle:hover {
    filter: brightness(1.3);
}

.node-label {
    font-family: var(--font-primary);
    font-weight: 700;
    fill: var(--white);
    pointer-events: none;
    text-anchor: middle;
    transition: opacity 0.3s;
}

.link-line {
    fill: none;
    stroke-linecap: round;
    transition: opacity 0.3s;
}

.link-reference {
    stroke: rgba(109, 184, 255, 0.55);
    stroke-width: 2.5;
}

.link-uses_term {
    stroke: rgba(255, 138, 80, 0.45);
    stroke-width: 1.8;
}

.link-hierarchy {
    stroke: rgba(255, 255, 255, 0.35);
    stroke-width: 2.0;
    stroke-dasharray: 4 4;
}

/* Node dimming on search */
.node-dimmed .node-circle {
    opacity: 0.12;
}

.node-dimmed .node-label {
    opacity: 0.08;
}

.link-dimmed {
    opacity: 0.04;
}

.node-highlighted .node-circle {
    filter: brightness(1.3) drop-shadow(0 0 8px var(--orange-glow));
}

/* ===== BREADCRUMB BAR ===== */
.breadcrumb-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0;
    padding: 8px 20px;
    background: rgba(0, 40, 87, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    font-family: var(--font-primary);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    z-index: 20;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 80%;
    overflow: hidden;
}

.breadcrumb-item {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.breadcrumb-item:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
}

.breadcrumb-item.breadcrumb-active {
    color: var(--orange);
    font-weight: 700;
}

.breadcrumb-separator {
    margin: 0 6px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 11px;
    flex-shrink: 0;
}

/* ===== TOOLTIP (Enhanced) ===== */
.tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(0, 40, 87, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--white);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.15s;
    max-width: 360px;
    z-index: 50;
}

.tooltip.visible {
    opacity: 1;
}

.tooltip-label {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 14px;
}

.tooltip-type {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.45);
}

.tooltip-score {
    margin-top: 4px;
    font-size: 12px;
    color: var(--orange);
}

.tooltip-definition {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.75);
    max-height: 120px;
    overflow: hidden;
}

.tooltip-definition-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 4px;
}

/* ===== DETAIL PANEL ===== */
#detailPanel {
    width: var(--detail-width);
    background: #ffffff;
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transform: translateX(100%);
    transition: transform 0.3s var(--ease-out);
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 150;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
}

#detailPanel.open {
    transform: translateX(0);
}

.detail-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: rgba(0, 40, 87, 0.4);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
    z-index: 2;
}

.detail-close:hover {
    color: var(--orange);
}

#detailContent {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
}

.detail-type {
    display: inline-block;
    padding: 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.type-section {
    color: #148acb;
}

.type-term {
    color: var(--orange);
}

.detail-title {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 600;
    color: var(--navy);
    line-height: 1.2;
    margin-bottom: 8px;
}

.detail-ref {
    font-size: 13px;
    color: rgba(0, 40, 87, 0.5);
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.detail-summary {
    font-size: 13px;
    line-height: 1.6;
    color: var(--body-text);
    margin-bottom: 16px;
}

.detail-subheading {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--navy);
    margin: 24px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.detail-ref-list {
    list-style: none;
    padding: 0;
    margin-bottom: 16px;
}

.detail-ref-list li {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--link-blue);
    font-weight: 600;
    border-bottom: 1px solid rgba(0,40,87,0.04);
}

.detail-ref-list li:hover {
    background: rgba(0, 83, 139, 0.06);
}

.detail-text-preview {
    font-size: 12px;
    line-height: 1.7;
    color: rgba(77, 66, 61, 0.8);
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: #faf8f7;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-family: var(--font-primary);
}

/* Delegated Authority callout */
.detail-authority {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    background: rgba(224, 68, 3, 0.06);
    border-left: 3px solid var(--orange);
    border-radius: 0 6px 6px 0;
    font-size: 13px;
}

.authority-label {
    font-weight: 700;
    color: var(--navy);
    white-space: nowrap;
}

.authority-value {
    font-weight: 600;
    color: var(--orange);
}

/* Obligations & Exceptions lists */
.detail-obligations-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.obligation-item,
.exception-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.obligation-item {
    background: rgba(0, 83, 139, 0.04);
    border-left: 3px solid var(--link-blue);
}

.exception-item {
    background: rgba(224, 68, 3, 0.04);
    border-left: 3px solid var(--orange);
}

.obligation-item:hover,
.exception-item:hover {
    background: rgba(0, 40, 87, 0.08);
}

.obligation-rule {
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
    line-height: 1.5;
    margin-bottom: 4px;
}

.obligation-trace {
    font-size: 11px;
    color: rgba(77, 66, 61, 0.6);
    line-height: 1.55;
    font-style: italic;
    padding-left: 8px;
    border-left: 2px solid rgba(0, 83, 139, 0.15);
    margin-top: 4px;
}

/* ===== SCROLLBAR for detail panel ===== */
.detail-panel::-webkit-scrollbar {
    width: 6px;
}

.detail-panel::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

/* ===== HIERARCHY NODE ANIMATION ===== */
@keyframes nodeAppear {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.node-entering .node-circle {
    animation: nodeAppear 0.4s var(--ease-out) forwards;
}

/* ===== INDEX.HTML SPECIFIC PANEL ===== */
#panel {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    width: var(--detail-width);
    background: #ffffff;
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: -4px 0 24px rgba(0,40,87,0.08);
    z-index: 200;
    transform: translateX(0);
    transition: transform 0.3s ease;
}
#panel.hidden {
    transform: translateX(100%);
    pointer-events: none;
}
#panel-header {
    padding: 20px;
    border-left: 4px solid transparent;
    flex-shrink: 0;
}
#panel-tag {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #fff;
    margin-bottom: 8px;
}
#panel-name {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
    color: var(--navy);
}
#panel-ref {
    font-size: 13px;
    opacity: 0.8;
}
#panel-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
}
#panel-close:hover { opacity: 1; }
#panel-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
#panel-summary {
    font-size: 14px;
    line-height: 1.6;
    color: rgba(0, 40, 87, 0.7);
    white-space: pre-wrap;
    margin-bottom: 24px;
}
.conn-head {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    margin: 16px 0 8px 0;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 4px;
}
.conn-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: background 0.2s;
}
.conn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.conn-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
}
.conn-ref {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
}
.conn-dir {
    font-size: 16px;
    opacity: 0.5;
    font-weight: bold;
}

/* ===== FOOTER ===== */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    font-family: var(--font-primary);
    z-index: 100;
    border-top: 2px solid var(--orange);
}

.footer-main {
    display: flex;
    align-items: center;
    padding: 12px 32px;
    gap: 0;
}

.footer-logo {
    display: flex;
    align-items: center;
    padding-right: 28px;
}

.footer-logo img {
    height: 36px;
    display: block;
}

.footer-offices {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 18px;
    border-left: 2px solid var(--orange);
    padding-left: 24px;
    padding-right: 40px;
    align-self: center;
}

.footer-offices a,
.footer-offices span {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--navy);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.6;
}

.footer-offices a:hover {
    color: var(--orange);
}

.footer-subscribe {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: auto;
    max-width: 360px;
    gap: 10px;
}

.footer-subscribe-text {
    font-size: 12px;
    color: var(--navy);
    line-height: 1.5;
}

.footer-subscribe-btn {
    display: inline-block;
    align-self: flex-start;
    padding: 6px 20px;
    border: 1px solid var(--orange);
    color: var(--orange);
    background: transparent;
    font-family: var(--font-primary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.footer-subscribe-btn:hover {
    background: var(--orange);
    color: #fff;
}

.footer-bottom {
    padding: 10px 32px;
    border-top: 1px solid var(--border-light);
    font-size: 11px;
    color: rgba(0, 40, 87, 0.55);
    line-height: 1.5;
}

/* ===== MOBILE RESPONSIVENESS ===== */
.mobile-menu-btn {
    display: none;
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --detail-width: 100%;
    }
    
    /* Topbar adjustments */
    #topbar, #header {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 8px;
    }
    .topbar-title, #header-title {
        font-size: 16px !important;
        white-space: normal;
    }
    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        font-size: 24px;
        color: var(--navy);
        cursor: pointer;
        padding: 0 10px 0 0;
    }
    .view-toggle {
        width: 100%;
        margin-right: 0;
    }
    .view-toggle-btn {
        flex: 1;
        justify-content: center;
    }
    .global-nav {
        width: 100%;
        margin-top: 0;
        margin-left: 0;
    }
    .nav-tab {
        flex: 1;
        padding: 6px 8px;
        font-size: 12px;
        justify-content: center;
        text-align: center;
    }

    /* Description Bar Tag */
    .description-bar {
        max-height: 38px;
        overflow: hidden;
        cursor: pointer;
        padding: 9px 16px;
        position: relative;
        transition: background 0.2s; /* Removed max-height transition to fix syncLayout white space */
    }
    .description-bar::before {
        content: 'ⓘ How To: ';
        font-weight: 700;
        color: var(--orange);
    }
    .description-bar strong {
        display: none;
    }
    .description-bar.expanded {
        max-height: 800px;
        background: #fdfaf8;
    }

    /* Sidebar Off-Canvas */
    #sidebar {
        position: fixed;
        top: var(--app-top, 97px);
        left: -100%;
        bottom: 0;
        z-index: 140;
        transition: left 0.3s ease;
        border-right: none;
        box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    }
    #sidebar.mobile-open {
        left: 0;
    }

    /* Detail Panel Full Width */
    #detailPanel, #panel {
        width: 100% !important;
    }

    /* Disclaimer Card (index.html) */
    .disclaimer-card {
        padding: 1.5rem !important;
    }
    
    /* Footer Scaling */
    .site-footer .footer-main {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
        padding: 12px 20px;
    }
    .footer-logo img {
        height: 24px;
    }
    .footer-offices {
        border-left: none;
        padding-left: 0;
        padding-right: 0;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .footer-offices a, .footer-offices span {
        font-size: 9px;
    }
    .footer-subscribe {
        margin-left: 0;
        align-items: center;
    }
    .footer-subscribe-btn {
        font-size: 9px;
        padding: 4px 10px;
    }
    .footer-bottom {
        padding: 6px 12px;
        font-size: 9px;
        text-align: center;
    }
}

/* ===== EXTRA SMALL MOBILE SCALING (<= 550px) ===== */
@media (max-width: 550px) {
    /* Header Scaling */
    #topbar, #header {
        padding: calc(1000vw / 550) calc(1400vw / 550);
        gap: calc(600vw / 550);
    }
    #topbar img, #header img, .disclaimer-card img {
        height: calc(2200vw / 550) !important;
        width: auto !important;
    }
    #topbar span[style*="24px"], #header span[style*="24px"] {
        font-size: calc(1800vw / 550) !important;
        white-space: nowrap !important;
    }
    .topbar-title, #header-title {
        font-size: calc(1600vw / 550) !important;
        white-space: nowrap !important;
    }
    .mobile-menu-btn {
        font-size: calc(2000vw / 550);
        padding: 0 calc(800vw / 550) 0 0;
    }
    .nav-tab {
        padding: calc(500vw / 550) calc(600vw / 550);
        font-size: calc(1100vw / 550);
        white-space: nowrap;
    }
    .description-bar {
        padding: calc(800vw / 550) calc(1400vw / 550);
        font-size: calc(1200vw / 550);
    }
    
    /* Footer Scaling */
    .site-footer .footer-main {
        gap: calc(800vw / 550);
        padding: calc(800vw / 550) calc(1400vw / 550);
    }
    .footer-logo img {
        height: calc(1800vw / 550);
        width: auto !important;
    }
    .footer-offices {
        gap: calc(700vw / 550);
    }
    .footer-offices a, .footer-offices span {
        font-size: calc(700vw / 550);
        white-space: nowrap;
    }
    .footer-subscribe-btn {
        font-size: calc(700vw / 550);
        padding: calc(300vw / 550) calc(800vw / 550);
        white-space: nowrap;
    }
    .footer-bottom {
        padding: calc(400vw / 550) calc(800vw / 550);
        font-size: calc(700vw / 550);
        white-space: nowrap;
    }
}
