/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

:root {
    /* Brand Colors */
    --darkblue: #003470;
    --aqua: #0CF3AE;
    --blue: #1FAAFF;
    --red: #fc6655;
    --yellow: #ffc14f;
    --lightgrey: #f7f9fb;
    
    /* Application Colors */
    --primary-color: var(--darkblue);
    --accent-color: var(--aqua);
    --link-color: var(--blue);
    --text-color: #2c3e50;
    --text-light: #6b7280;
    --border-color: #e2e8f0;
    --bg-color: #ffffff;
    --sidebar-bg: var(--lightgrey);
    --hover-bg: #f0f4f8;
    --highlight-color: var(--yellow);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--lightgrey);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Desktop: body should not scroll, content areas do */
@media (min-width: 769px) {
    body {
        height: 100vh;
        overflow: hidden;
    }
}

/* Mobile: allow body scroll unless menu is open */
@media (max-width: 768px) {
    body {
        overflow: auto;
    }
    
    body.mobile-menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

/* Header */
.site-header {
    background: var(--bg-color);
    border-bottom: 3px solid var(--primary-color);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 52, 112, 0.08);
    flex-shrink: 0;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 28px;
}

.site-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.site-title a {
    color: var(--primary-color);
    position: relative;
    padding-left: 2rem;
}


.regulation-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.regulation-switcher label {
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
}

.regulation-switcher select {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    background: var(--bg-color);
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s ease;
}

.regulation-switcher select:hover {
    border-color: var(--link-color);
}

.regulation-switcher select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 52, 112, 0.1);
}

/* Main Content */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    flex: 1;
    width: 100%;
}

/* Desktop: main-content doesn't scroll, inner areas do */
@media (min-width: 769px) {
    .main-content {
        overflow: hidden;
    }
}

/* Mobile: main-content allows normal flow */
@media (max-width: 768px) {
    .main-content {
        overflow: visible;
    }
}

.layout-container {
    display: flex;
    align-items: flex-start;
}

/* Desktop: fixed height layout with scrollable inner areas */
@media (min-width: 769px) {
    .layout-container {
        height: 100%;
    }
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-color);
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    height: 100%;
    overflow-y: auto;
    align-self: flex-start;
}

.sidebar-content {
    padding: 1.5rem;
}

.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--lightgrey);
}

.sidebar h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s;
}

.toc-controls {
    display: flex;
    gap: 0.25rem;
}

.toc-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
    background: var(--lightgrey);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.toc-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.toc-btn:active {
    transform: translateY(1px);
}

/* Search Box */
.search-box {
    margin-bottom: 1.5rem;
}

#search-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--lightgrey);
    color: var(--text-color);
    transition: all 0.2s ease;
}

#search-input::placeholder {
    color: var(--text-light);
}

#search-input:focus {
    outline: none;
    border-color: var(--link-color);
    background: var(--bg-color);
    box-shadow: 0 0 0 3px rgba(31, 170, 255, 0.1);
}

.search-results {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Table of Contents */
.toc {
    font-size: 0.875rem;
}

.toc-chapter {
    margin-bottom: 0.75rem;
}

.toc-chapter-title {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: all 0.2s ease;
    background: var(--lightgrey);
}

.toc-chapter-title:hover {
    background-color: var(--hover-bg);
    border-left: 3px solid var(--link-color);
    padding-left: calc(0.6rem - 3px);
}

.toc-chapter-title-text {
    flex: 1;
}

.toc-title-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-table-icon {
    font-size: 0.9rem;
    color: var(--link-color);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 3px;
    transition: all 0.2s;
    opacity: 0.8;
}

.toc-table-icon:hover {
    opacity: 1;
    background: rgba(31, 170, 255, 0.15);
    transform: scale(1.1);
}

.toc-chapter-icon {
    font-size: 0.75rem;
    transition: transform 0.2s;
    color: var(--link-color);
}

.toc-chapter.collapsed .toc-chapter-icon {
    transform: rotate(-90deg);
}

.toc-chapter.collapsed .toc-chapter-content {
    display: none;
}

.toc-chapter-number {
    font-weight: normal;
    color: var(--text-light);
}

.toc-chapter-subtitle {
    display: block;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.85rem;
}

.toc-section {
    margin-bottom: 0.5rem;
}

.toc-section-title {
    margin-bottom: 0.15rem;
    color: var(--text-light);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    padding-left: 1rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: all 0.2s ease;
}

.toc-section-title:hover {
    background-color: var(--hover-bg);
    border-left: 2px solid var(--aqua);
    padding-left: calc(1rem - 2px);
}

.toc-section-title-text {
    flex: 1;
}

.toc-section-number {
    font-weight: normal;
    color: var(--text-light);
}

.toc-section-name {
    font-weight: 600;
    color: var(--text-color);
}

.toc-section-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
    color: var(--link-color);
}

.toc-section.collapsed .toc-section-icon {
    transform: rotate(-90deg);
}

.toc-section.collapsed .toc-section-content {
    display: none;
}

.toc-articles {
    list-style: none;
}

.toc-section .toc-articles {
    padding-left: 1rem;
}

.toc-articles li {
    margin-bottom: 0.15rem;
}

.toc-articles a {
    display: block;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    color: var(--text-color);
    transition: all 0.2s ease;
}

.toc-articles a:hover {
    background-color: var(--hover-bg);
    text-decoration: none;
    transform: translateX(2px);
}

.toc-articles li.active a {
    background: var(--lightgrey);
    color: var(--text-color);
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 52, 112, 0.1);
    border: 2px solid var(--link-color);
}

.toc-articles .article-number {
    font-weight: normal;
    color: var(--text-light);
}

.toc-articles .article-title {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
}

.toc-articles li.active .article-number {
    color: var(--link-color);
    font-weight: 700;
}

.toc-articles li.active .article-title {
    color: var(--text-color);
    font-weight: 600;
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem 3rem;
    max-width: 1000px;
    background: var(--bg-color);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    height: 100%;
}

/* Recent Articles Panel */
.recent-panel {
    width: 280px;
    background: var(--bg-color);
    border-left: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    height: 100%;
    overflow-y: auto;
    align-self: flex-start;
    flex-shrink: 0;
}

.recent-panel-content {
    padding: 1.5rem;
}

.recent-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--lightgrey);
}

.recent-panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.recent-clear-all {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.25rem;
    line-height: 1;
    transition: all 0.2s ease;
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 300;
}

.recent-clear-all:hover {
    color: var(--red);
    opacity: 1;
    transform: scale(1.15);
}

.recent-articles-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recent-empty {
    color: var(--text-light);
    font-size: 0.85rem;
    text-align: center;
    padding: 1rem 0;
    font-style: italic;
}

.recent-article-item {
    display: block;
    padding: 0.75rem;
    padding-right: 0.75rem;
    background: var(--lightgrey);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    text-decoration: none;
    position: relative;
}

.recent-article-item.pinned {
    background: #fff9e6;
    border-color: var(--yellow);
    box-shadow: 0 1px 3px rgba(255, 193, 79, 0.2);
}

.recent-article-item.pinned:hover {
    background: #fff5d6;
    border-color: var(--yellow);
    box-shadow: 0 2px 8px rgba(255, 193, 79, 0.3);
}

.recent-article-item:hover {
    background: var(--hover-bg);
    border-color: var(--link-color);
    transform: translateX(-2px);
    box-shadow: 0 2px 8px rgba(31, 170, 255, 0.1);
}

.recent-article-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
    z-index: 10;
}

.recent-article-pin,
.recent-article-delete {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.15rem 0.35rem;
    line-height: 1;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    font-weight: normal;
}

.recent-article-delete {
    font-size: 1.1rem;
    font-weight: 300;
}

.recent-article-item:hover .recent-article-pin,
.recent-article-item:hover .recent-article-delete {
    opacity: 1;
}

.recent-article-pin.pinned {
    opacity: 1;
    background: var(--yellow);
    border-color: var(--yellow);
    color: var(--primary-color);
}

.recent-article-pin:hover {
    background: var(--yellow);
    border-color: var(--yellow);
    color: var(--primary-color);
    transform: scale(1.1);
}

.recent-article-delete:hover {
    background: var(--red);
    border-color: var(--red);
    color: white;
    transform: scale(1.1);
}

.recent-article-number {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 0.25rem;
    padding-right: 3rem;
}

.recent-article-title {
    display: block;
    font-size: 0.85rem;
    color: var(--text-color);
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    padding-right: 3rem;
}

.recent-article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-light);
}

.recent-article-reg {
    font-weight: 600;
    text-transform: uppercase;
}

.recent-article-time {
    font-style: italic;
}

/* Article Navigation */
.article-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--lightgrey);
}

.nav-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-light);
    font-style: italic;
    flex-shrink: 0;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--lightgrey);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.875rem;
    white-space: nowrap;
    font-weight: 500;
}

.nav-btn:hover {
    border-color: var(--link-color);
    background: var(--bg-color);
    color: var(--primary-color);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(31, 170, 255, 0.2);
}

.nav-spacer {
    flex: 0 0 auto;
}

.nav-arrow {
    font-size: 1rem;
    color: var(--link-color);
}

.nav-btn:hover .nav-arrow {
    color: var(--primary-color);
}

.nav-label {
    color: var(--text-color);
}

.article-content {
    margin-bottom: 3rem;
}

.article-heading {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
    border-left: 4px solid var(--aqua);
    padding-left: 1rem;
}

.article-title-heading {
    display: block;
    font-size: 1.15rem;
    font-weight: normal;
    color: var(--text-light);
    margin-top: 0.5rem;
    border-left: none;
    padding-left: 0;
}

.article-body {
    line-height: 1.8;
}

.article-body p {
    margin-bottom: 1rem;
}

.article-body strong {
    font-weight: 600;
}

.article-body em {
    font-style: italic;
}

/* Defined Terms */
.defined-term {
    border-bottom: 2px dotted var(--link-color);
    cursor: help;
    position: relative;
    color: var(--link-color);
}

.defined-term:hover {
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
}

/* Definition Tooltip */
.definition-tooltip {
    position: absolute;
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 52, 112, 0.4);
    z-index: 1000;
    max-width: 400px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    border: 2px solid var(--aqua);
}

.definition-tooltip.visible {
    opacity: 1;
}

.definition-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--aqua);
}

.tooltip-term {
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
    color: var(--aqua);
}

.tooltip-definition {
    font-size: 0.8rem;
    line-height: 1.5;
    color: white;
}

/* Lists */
.fmx-list {
    margin: 1rem 0 1rem 1.5rem;
}

.fmx-list-decimal {
    list-style-type: decimal;
}

.fmx-list-lower-alpha {
    list-style-type: lower-alpha;
}

.fmx-list-disc {
    list-style-type: disc;
}

.fmx-list-item {
    margin-bottom: 0.5rem;
}

/* Hide browser's default list markers when custom markers are present */
.fmx-list-item[data-marker] {
    list-style-type: none;
    display: flex;
    margin-left: -1.5rem;
}

.fmx-list-item-num {
    min-width: 3rem;
    font-weight: 600;
    flex-shrink: 0;
}

.fmx-list-item-body {
    flex: 1;
}

/* Numbered blocks */
.fmx-numbered-block {
    display: flex;
    margin-bottom: 1rem;
}

.fmx-numbered-block-num {
    min-width: 3rem;
    font-weight: 600;
}

.fmx-numbered-block-body {
    flex: 1;
}

/* Search highlighting */
.search-highlight,
mark.search-highlight {
    background-color: var(--highlight-color);
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
}

/* Error and Select Pages */
.error-page,
.select-page {
    padding: 3rem;
    text-align: center;
    background: var(--bg-color);
    min-height: calc(100vh - 200px);
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.error-page h2,
.select-page h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.select-page h2::before {
    font-size: 2.5rem;
}

.select-hero {
    margin-bottom: 3rem;
}

.select-subtitle {
    color: var(--text-light);
    font-size: 1.15rem;
    margin-top: 0.75rem;
    font-weight: 400;
    line-height: 1.6;
}

.regulation-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    padding: 0 1rem;
}

.regulation-card {
    border: 1px solid rgba(0, 52, 112, 0.08);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    text-align: center;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 52, 112, 0.06), 0 1px 3px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-height: 240px;
    position: relative;
    overflow: hidden;
}

.regulation-card:hover {
    border-color: rgba(31, 170, 255, 0.3);
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 52, 112, 0.12), 0 8px 16px rgba(31, 170, 255, 0.1);
}

.regulation-card-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.8;
}

.regulation-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.regulation-card p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.regulation-card .button {
    margin-top: auto;
}

.button {
    display: inline-block;
    padding: 0.75rem 1.75rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #004a94 100%);
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 52, 112, 0.2);
    position: relative;
    overflow: hidden;
}

.button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.button:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 52, 112, 0.3);
    background: linear-gradient(135deg, #004a94 0%, var(--primary-color) 100%);
    color: white;
}

.button:hover::before {
    left: 100%;
}

.button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 52, 112, 0.2);
}

/* Footer */
.site-footer {
    background: var(--bg-color);
    border-top: 3px solid var(--primary-color);
    padding: 1.5rem 2rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-light);
    box-shadow: 0 -2px 8px rgba(0, 52, 112, 0.08);
}

.site-footer a {
    color: var(--link-color);
    font-weight: 600;
    transition: color 0.2s ease;
}

.site-footer a:hover {
    color: var(--primary-color);
}

/* Hamburger Menu Button */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    transition: transform 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.hamburger-menu:hover {
    transform: scale(1.1);
}

.hamburger-menu:active {
    transform: scale(0.95);
}

.hamburger-line {
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    pointer-events: none;
}

.mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap target sizes on touch devices */
    .toc-articles a,
    .toc-chapter-title,
    .toc-section-title,
    .nav-btn,
    .toc-btn {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Remove hover states on touch devices */
    .toc-articles a:hover,
    .toc-chapter-title:hover,
    .toc-section-title:hover {
        transform: none;
    }
    
    /* Add active states for touch feedback */
    .toc-articles a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
    
    .hamburger-menu:active {
        opacity: 0.7;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Show hamburger menu */
    .hamburger-menu {
        display: flex;
    }
    
    /* Mobile header adjustments */
    .site-header {
        padding: 1rem 1.5rem;
    }
    
    .header-content {
        height: auto;
        gap: 0;
    }
    
    .header-left {
        display: flex;
        align-items: center;
        gap: 1rem;
        width: 100%;
    }
    
    .hamburger-menu {
        width: 32px;
        height: 28px;
    }
    
    .hamburger-line {
        height: 3px;
        border-radius: 2px;
    }
    
    .site-title {
        font-size: 1.1rem;
        flex: 1;
    }
    
    .site-title a {
        padding-left: 0;
    }
    
    /* Hide desktop regulation switcher on mobile */
    .header-right {
        display: none;
    }
    
    /* Mobile close button */
    .mobile-close-btn {
        display: none;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
        min-width: 48px;
        background: transparent;
        border: none;
        color: white;
        font-size: 3rem;
        line-height: 1;
        cursor: pointer;
        padding: 0;
        transition: all 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        z-index: 1002;
        flex-shrink: 0;
    }
    
    /* Show close button only when menu is active */
    .sidebar.mobile-active .mobile-close-btn {
        display: flex !important;
    }
    
    .mobile-close-btn:hover {
        color: var(--aqua);
        transform: scale(1.1);
    }
    
    .mobile-close-btn:active {
        transform: scale(0.9);
        color: var(--red);
    }
    
    .close-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 200;
        line-height: 1;
    }
    
    /* Mobile regulation switcher (inside sidebar) */
    .mobile-regulation-switcher {
        display: none;
        background: var(--primary-color);
        border-bottom: 3px solid var(--aqua);
        position: sticky;
        top: 0;
        z-index: 10;
        margin: -1.5rem -1.5rem 2rem -1.5rem;
    }
    
    /* Show regulation switcher only when menu is active */
    .sidebar.mobile-active .mobile-regulation-switcher {
        display: block !important;
    }
    
    .mobile-switcher-content {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1.25rem;
        padding-right: 4rem;
    }
    
    .mobile-switcher-dropdown {
        flex: 1;
        min-width: 0;
    }
    
    .mobile-switcher-dropdown label {
        display: block;
        color: var(--aqua);
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.8px;
        margin-bottom: 0.6rem;
    }
    
    .mobile-switcher-dropdown select {
        width: 100%;
        padding: 0.85rem 1rem;
        border: 2px solid var(--aqua);
        border-radius: 8px;
        font-size: 1rem;
        background: white;
        color: var(--primary-color);
        font-weight: 600;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    /* Layout adjustments */
    .layout-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    
    /* Mobile sidebar (slide-out menu) */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        background: var(--bg-color);
        border-right: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: none;
    }
    
    .sidebar.mobile-active {
        left: 0;
    }
    
    .sidebar-content {
        padding: 1.5rem;
        padding-top: 0;
    }
    
    /* Mobile overlay not needed since sidebar is full-screen, but keep for escape/close functionality */
    
    /* Content area adjustments */
    .content-area {
        padding: 1rem;
        width: 100%;
        max-width: 100%;
        overflow-y: visible;
        height: auto;
        min-height: auto;
    }
    
    /* Hide recent panel on mobile */
    .recent-panel {
        display: none;
    }
    
    /* Article navigation for mobile */
    .article-navigation {
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }
    
    .nav-btn {
        width: 100%;
        justify-content: center;
        padding: 0.75rem;
    }
    
    .nav-hint {
        display: none;
    }
    
    .nav-spacer {
        display: none;
    }
    
    /* Article heading for mobile */
    .article-heading {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }
    
    .article-title-heading {
        font-size: 1rem;
    }
    
    /* TOC adjustments for mobile */
    .toc-header {
        padding-bottom: 0.85rem;
        margin-bottom: 1rem;
        border-bottom: 2px solid var(--border-color);
    }
    
    .sidebar h2 {
        font-size: 0.9rem;
        letter-spacing: 0.3px;
    }
    
    /* Hide table icon on mobile */
    .toc-table-icon {
        display: none;
    }
    
    .toc-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.65rem;
        letter-spacing: 0.2px;
    }
    
    .search-box {
        margin-bottom: 1.25rem;
    }
    
    #search-input {
        font-size: 0.95rem;
        padding: 0.75rem 1rem;
        border-radius: 8px;
    }
    
    /* TOC items for mobile */
    .toc-chapter-title,
    .toc-section-title {
        font-size: 0.85rem;
        padding: 0.7rem 0.75rem;
        margin-bottom: 0.25rem;
    }
    
    .toc-chapter-title {
        background: var(--lightgrey);
        border-radius: 8px;
        margin-bottom: 0.5rem;
    }
    
    .toc-section-title {
        padding-left: 1.25rem;
    }
    
    .toc-chapter-icon,
    .toc-section-icon {
        font-size: 0.85rem;
        opacity: 0.8;
    }
    
    .toc-articles a {
        padding: 0.75rem 0.85rem;
        font-size: 0.9rem;
        border-radius: 8px;
        margin-bottom: 0.25rem;
    }
    
    .toc-articles li {
        margin-bottom: 0.25rem;
    }
    
    .toc-articles .article-number {
        font-size: 0.8rem;
        font-weight: 600;
        display: block;
        margin-bottom: 0.25rem;
    }
    
    .toc-articles .article-title {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    .toc-section .toc-articles {
        padding-left: 0.75rem;
    }
    
    /* Active article styling for mobile */
    .toc-articles li.active a {
        background: linear-gradient(135deg, var(--link-color), var(--primary-color));
        color: white;
        border: none;
        box-shadow: 0 3px 10px rgba(31, 170, 255, 0.3);
    }
    
    .toc-articles li.active .article-number {
        color: var(--aqua);
    }
    
    .toc-articles li.active .article-title {
        color: white;
    }
    
    /* Select page for mobile */
    .select-page {
        padding: 1.5rem;
    }
    
    .select-page h2 {
        font-size: 1.5rem;
    }
    
    .select-subtitle {
        font-size: 1rem;
    }
    
    .regulation-list {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0;
    }
    
    .regulation-card {
        padding: 2rem 1.5rem;
        min-height: auto;
    }
}

/* Extra small devices (phones in portrait mode) */
@media (max-width: 480px) {
    .site-header {
        padding: 0.75rem 1rem;
    }
    
    .site-title {
        font-size: 0.95rem;
    }
    
    .hamburger-menu {
        width: 26px;
        height: 20px;
    }
    
    .hamburger-line {
        height: 2.5px;
    }
    
    .sidebar {
        width: 100%;
        max-width: 100%;
    }
    
    .mobile-close-btn {
        top: 0.75rem;
        right: 0.75rem;
        width: 44px;
        height: 44px;
        min-width: 44px;
        font-size: 2.5rem;
    }
    
    .mobile-switcher-content {
        padding: 1rem;
        padding-right: 3.5rem;
        gap: 0.75rem;
    }
    
    .mobile-regulation-switcher {
        margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    }
    
    .toc-articles a {
        padding: 0.65rem 0.75rem;
    }
    
    .content-area {
        padding: 0.75rem;
    }
    
    .article-heading {
        font-size: 1.2rem;
        padding-left: 0.75rem;
    }
    
    .article-title-heading {
        font-size: 0.9rem;
    }
    
    .article-body {
        font-size: 0.95rem;
    }
    
    .nav-btn {
        font-size: 0.8rem;
        padding: 0.6rem;
    }
    
    .nav-label {
        display: none;
    }
    
    .nav-btn .nav-arrow {
        font-size: 1.2rem;
    }
    
    .select-page {
        padding: 1rem;
    }
    
    .select-page h2 {
        font-size: 1.3rem;
    }
    
    .select-subtitle {
        font-size: 0.9rem;
    }
    
    .regulation-card {
        padding: 1.5rem 1rem;
    }
    
    .regulation-card h3 {
        font-size: 1.1rem;
    }
    
    .button {
        padding: 0.65rem 1.5rem;
        font-size: 0.85rem;
    }
}

/* Landscape tablets and small laptops */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .recent-panel {
        width: 240px;
    }
    
    .content-area {
        padding: 1.5rem 2rem;
    }
}

/* Utility Classes */
.uppercase {
    text-transform: uppercase;
}

.no-content {
    padding: 3rem;
    text-align: center;
    color: var(--text-light);
}

.no-content::before {
    content: "📄";
    display: block;
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Articles Table View */
.articles-table-view {
    margin-top: 2rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.table-view-heading {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
    padding-bottom: 1rem;
    border-bottom: 3px solid var(--aqua);
}

.articles-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--bg-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    overflow: hidden;
}

.articles-table thead {
    background: var(--primary-color);
    color: white;
    border-bottom: 3px solid var(--aqua);
}

.articles-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.articles-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.articles-table tbody tr:last-child {
    border-bottom: none;
}

.articles-table tbody tr:hover {
    background: var(--lightgrey);
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(31, 170, 255, 0.1);
}

.articles-table td {
    padding: 1rem;
    vertical-align: top;
}

.article-col-number {
    width: 150px;
    font-weight: 700;
    color: var(--link-color);
}

.article-col-title {
    color: var(--text-color);
    line-height: 1.6;
}

.article-row:hover .article-col-number {
    color: var(--primary-color);
}

/* Responsive table */
@media (max-width: 768px) {
    .articles-table {
        font-size: 0.8rem;
    }
    
    .articles-table th,
    .articles-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .article-col-number {
        width: 100px;
        font-size: 0.75rem;
    }
}

.toc-chapter-title:hover::after,
.toc-section-title:hover::after {
    opacity: 0.7;
}

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--lightgrey);
    border-top: 3px solid var(--link-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Focus States for Accessibility */
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 3px solid var(--aqua);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .site-header,
    .sidebar,
    .article-navigation,
    .site-footer {
        display: none;
    }
    
    .content-area {
        max-width: 100%;
        padding: 0;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .article-heading {
        color: black;
        border-left-color: black;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
}

/* Smooth Scrollbar */
.sidebar::-webkit-scrollbar,
.recent-panel::-webkit-scrollbar,
.content-area::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track,
.recent-panel::-webkit-scrollbar-track,
.content-area::-webkit-scrollbar-track {
    background: var(--lightgrey);
}

.sidebar::-webkit-scrollbar-thumb,
.recent-panel::-webkit-scrollbar-thumb,
.content-area::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.recent-panel::-webkit-scrollbar-thumb:hover,
.content-area::-webkit-scrollbar-thumb:hover {
    background: var(--link-color);
}

/* Selection Color */
::selection {
    background: var(--aqua);
    color: var(--primary-color);
}

::-moz-selection {
    background: var(--aqua);
    color: var(--primary-color);
}
