.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 12px 38px 12px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 15px;
}

.search-box.inline input {
    padding: 10px 36px 10px 12px;
}

.search-box button {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--muted);
}

.search-results {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
    max-height: 500px;
    overflow: auto;
    position: absolute;
    width: 140%;
    max-width: 650px;
    z-index: 20;
}

.search-header {
    padding: 10px 12px;
    background: #f9fafb;
    border-bottom: 2px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.search-filter-clear {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    margin-left: 8px;
    transition: all 0.2s;
}

.search-filter-clear:hover {
    background: rgba(239, 68, 68, 0.2);
}

.search-category-header {
    padding: 8px 12px;
    background: #f3f4f6;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e5e7eb;
}

.search-result {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
}

.search-result:last-child {
    border-bottom: none;
}

.search-result:hover,
.search-result.selected {
    background: rgba(37, 99, 235, 0.08);
}

.search-result.selected {
    border-left: 3px solid rgba(37, 99, 235, 0.6);
}

.search-result-header {
    display: flex;
    align-items: baseline;
    margin-bottom: 6px;
}

.search-result-law {
    font-weight: 600;
    color: #1f2937;
    font-size: 13px;
}

.search-result-norm {
    font-size: 13px;
    color: #1f2937;
    font-weight: 700;
    background: #e0e7ff;
    padding: 3px 8px;
    border-radius: 5px;
    border: 1px solid #c7d2fe;
}

.search-result-title {
    font-size: 13px;
    color: #374151;
    margin-bottom: 4px;
    font-weight: 500;
}

.search-result-preview {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
}

.search-result-preview mark,
.search-result-title mark {
    background: #fef3c7;
    color: #92400e;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

.law-suggestion {
    padding: 10px 12px;
}

.law-suggestion:hover,
.law-suggestion.selected {
    background: rgba(37, 99, 235, 0.06);
}

.search-no-results {
    padding: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.laws-layout {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem;
    height: calc(100vh - 70px);
    overflow: hidden;
}

.law-main-column {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.law-main-column .header-search {
    flex: 0 0 auto;
    margin-bottom: 8px;
}

.law-main-wrapper {
    background: transparent;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.law-sidebar,
.law-sidebar-right {
    background: #f9f9f9;
    border-radius: 16px;
    padding: 1rem;
    border: 1px solid #f1f1f1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 2rem;
    align-self: flex-start;
}

.law-sidebar {
    width: 280px;
}

.law-sidebar-right {
    width: 280px;
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.quick-jump-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.quick-jump-input {
    width: 55px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    transition: border-color 0.2s;
    text-align: center;
}

.quick-jump-input:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.5);
}

.quick-jump-input::placeholder {
    color: var(--muted);
    font-size: 13px;
}

.quick-jump-info {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.quick-jump-info:hover {
    background: rgba(37, 99, 235, 0.05);
    border-color: rgba(37, 99, 235, 0.3);
}

.quick-jump-info svg {
    width: 14px;
    height: 14px;
    color: var(--muted);
}

.quick-jump-help {
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    font-size: 13px;
    color: #374151;
    line-height: 1.5;
    flex-shrink: 0;
}

.quick-jump-help p {
    margin: 0;
}

.quick-jump-help strong {
    color: #1f2937;
}

.pill.small {
    padding: 6px 10px;
    font-size: 12px;
}

.pill.small.ghost {
    background: #fff;
    border-color: var(--border);
    cursor: pointer;
}

.law-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f1f1;
}

/* Scrollbar styling for law-list */
.law-list::-webkit-scrollbar {
    width: 8px;
}

.law-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.law-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.law-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.law-item {
    padding: 1rem 0.5rem;
    border-bottom: 1px solid #eeeeee;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: relative;
    transition: all 0.2s;
}

.law-item:last-child {
    border-bottom: none;
}

.law-item:hover {
    background: #ffffff;
    border-radius: 8px;
    border-bottom-color: transparent;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transform: translateX(4px);
}

.law-item .title {
    font-weight: 700;
}

/* Custom tooltip */
.law-item[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 5px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 400;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.law-item[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 100%;
    border: 5px solid transparent;
    border-bottom-color: rgba(0, 0, 0, 0.9);
    z-index: 1001;
    pointer-events: none;
}

.law-item .favorite {
    color: rgba(37, 99, 235, 0.8);
}

.law-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.law-actions button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    font-weight: 700;
}

.law-actions button:hover {
    border-color: rgba(37, 99, 235, 0.35);
}

.law-content {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 1fr;
    gap: 12px;
    padding: 0;
    height: 100%;
    min-height: 0;
    overflow: auto;
}

.law-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
    padding: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    transition: all 0.2s;
}

.law-panel.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.law-panel.drag-over {
    border-color: rgba(37, 99, 235, 0.6);
    background: rgba(37, 99, 235, 0.05);
    transform: scale(1.02);
}

.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    cursor: grab;
    color: var(--muted);
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.drag-handle:hover {
    background: rgba(37, 99, 235, 0.05);
    border-color: rgba(37, 99, 235, 0.3);
    color: rgba(37, 99, 235, 0.8);
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle svg {
    pointer-events: none;
}

.law-panel.placeholder {
    box-shadow: none;
    border-style: dashed;
    color: var(--muted);
    justify-content: center;
    align-items: center;
    grid-column: 1 / -1;
}

.placeholder-content {
    max-width: 800px;
    width: 100%;
    padding: 2rem;
}

.placeholder-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.placeholder-header svg {
    color: rgba(37, 99, 235, 0.6);
    margin-bottom: 1rem;
}

.placeholder-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.5rem 0;
}

.placeholder-subtitle {
    font-size: 1rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

.placeholder-features {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.feature-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem;
    background: rgba(249, 250, 251, 0.5);
    border-radius: 10px;
    border: 1px solid #f1f1f1;
    transition: all 0.2s;
}

.feature-item:hover {
    background: #fff;
    border-color: rgba(37, 99, 235, 0.2);
    transform: translateX(4px);
}

.feature-item svg {
    flex-shrink: 0;
    color: rgba(37, 99, 235, 0.7);
    margin-top: 2px;
}

.feature-item strong {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.25rem;
}

.feature-item p {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

.placeholder-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 10px;
    text-align: center;
}

.placeholder-cta svg {
    flex-shrink: 0;
    color: rgba(37, 99, 235, 0.8);
}

.placeholder-cta p {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #374151;
    margin: 0;
}

.law-panel.active {
    border-color: rgba(37, 99, 235, 0.4);
    box-shadow: 0 16px 40px rgba(37, 99, 235, 0.16);
}

/* Soft, pastel color themes per law */
.law-panel.theme-1 { background: rgba(231, 240, 255, 0.9); } /* zartes Blau */
.law-panel.theme-2 { background: rgba(228, 248, 239, 0.9); } /* sanftes Grün */
.law-panel.theme-3 { background: rgba(255, 243, 228, 0.9); } /* warmes Apricot */
.law-panel.theme-4 { background: rgba(245, 236, 255, 0.9); } /* leichtes Flieder */
.law-panel.theme-5 { background: rgba(255, 248, 234, 0.9); } /* helles Creme-Gelb */

.law-panel.theme-1 .law-panel.theme-2 .law-panel.theme-3 .law-panel.theme-4 .law-panel.theme-4 {
    height: 100%;
    overflow-y: auto;
}

.panel-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
}

.panel-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    font-weight: 700;
    flex-wrap: wrap;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
}

.panel-nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    flex-shrink: 0;
}

.panel-close {
    margin-left: auto;
}

.drag-handle {
    flex-shrink: 0;
}

.panel-tab-title {
    color: var(--text);
}

.panel-tab-subtitle {
    color: var(--muted);
    font-weight: 600;
}

.panel-header .muted.tiny {
    font-size: 12px;
    margin: 0;
}

.panel-close {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-weight: 700;
}

.panel-close:hover {
    border-color: rgba(37, 99, 235, 0.35);
}

.panel-nav {
    display: inline-flex;
    gap: 6px;
}

.nav-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-weight: 700;
    color: var(--muted);
}

.nav-btn:hover {
    border-color: rgba(37, 99, 235, 0.35);
    color: var(--text);
}

.paragraph {
    padding: 10px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.paragraph h3,
.paragraph h4 {
    margin: 0 0 6px;
    flex-shrink: 0;
}

.paragraph .number {
    color: var(--accent);
    font-weight: 700;
    margin-right: 6px;
}

.paragraph .title {
    color: var(--muted);
}

.paragraph .favorite {
    cursor: pointer;
    color: rgba(37, 99, 235, 0.7);
    margin-left: 8px;
}

.paragraph-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Ensure all content in paragraph-body fits width */
.paragraph-body * {
    max-width: 100%;
    overflow-wrap: break-word;
}

.paragraph-body table {
    width: 100%;
    table-layout: fixed;
}

.paragraph-body img {
    max-width: 100%;
    height: auto;
}

.paragraph-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f1f1;
}

/* Scrollbar styling for paragraph-list */
.paragraph-list::-webkit-scrollbar {
    width: 8px;
}

.paragraph-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.paragraph-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.paragraph-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.paragraph-item {
    padding: 1rem 0.5rem;
    border-bottom: 1px solid #eeeeee;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.paragraph-item:last-child {
    border-bottom: none;
}

.paragraph-item:hover {
    background: #ffffff;
    border-radius: 8px;
    border-bottom-color: transparent;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transform: translateX(4px);
}

.paragraph-item.active {
    background: rgba(37, 99, 235, 0.06);
    border-radius: 8px;
    border-bottom-color: transparent;
}

.paragraph-item .number {
    font-weight: 700;
    margin-right: 6px;
}

.paragraph-item .title {
    color: var(--muted);
}

.paragraph-pin {
    position: absolute;
    top: 8px;
    right: 8px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 4px 6px;
    cursor: pointer;
    display: none;
}

.paragraph-item:hover .paragraph-pin {
    display: inline-flex;
}

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 80px;
    left: 1rem;
    z-index: 1000;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-top: -5px;
}

.mobile-menu-toggle:hover {
    background: rgba(37, 99, 235, 0.05);
    border-color: rgba(37, 99, 235, 0.3);
}

.mobile-menu-toggle svg {
    color: #374151;
}

/* Spezialfall: Linke Sidebar unter 1200px ausblenden */
@media (min-width: 969px) and (max-width: 1200px) {
    .laws-layout {
        grid-template-columns: 1fr 280px;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .law-sidebar {
        position: fixed;
        top: 70px;
        left: 0;
        height: calc(100vh - 70px);
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
        width: 280px;
    }

    .law-sidebar.open {
        transform: translateX(0);
        margin-top: -5px;
    }
}

@media (max-width: 968px) {
    .laws-layout {
        display: block;
        height: calc(100vh - 70px);
        max-height: calc(100vh - 70px);
        width: 100vw;
        max-width: 100vw;
        position: fixed;
        top: 70px;
        left: 0;
        padding: 0.5rem;
        overflow: hidden;
        margin: 0;
        margin-top: -5px;
    }

    .drag-handle {
        display: none;
    }

    .sidebar-header {
        justify-content: right;
    }

    .law-main-column {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .law-main-column .header-search {
        flex-shrink: 0;
        margin-bottom: 0.5rem;
        width: 70%;
        order: 1;
        left: 3rem;
        margin-left: 10px;
    }

    .law-main-wrapper {
        order: 2;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .law-sidebar {
        position: fixed;
        top: 70px;
        left: 0;
        height: calc(100vh - 70px);
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    }

    .law-sidebar.open {
        transform: translateX(0);
        margin-top: -5px;
    }

    .law-sidebar-right {
        position: fixed !important;
        top: 70px;
        right: 0;
        width: 56px !important;
        height: calc(100vh - 70px);
        z-index: 998;
        padding: 0.5rem 0.25rem;
        border-radius: 16px 0 0 16px;
        border-right: none;
    }

    .law-sidebar-right .sidebar-header {
        display: none;
    }

    .law-sidebar-right .quick-jump-help {
        display: none !important;
    }

    .law-sidebar-right .paragraph-list {
        padding-right: 0;
        gap: 0.25rem;
    }

    .law-sidebar-right .paragraph-item {
        padding: 0.5rem 0.1rem;
        font-size: 0.7rem;
        text-align: center;
        border-bottom: none;
        border-radius: 6px;
        font-weight: 600;
    }

    .law-sidebar-right .paragraph-item:hover {
        transform: none;
        background: rgba(37, 99, 235, 0.1);
    }

    .law-sidebar-right .paragraph-item.active {
        background: rgba(37, 99, 235, 0.15);
        border-radius: 6px;
    }

    .law-sidebar-right .paragraph-item .title {
        display: none;
    }

    .law-sidebar-right .paragraph-item .number {
        display: block;
        margin: 0;
        writing-mode: horizontal-tb;
        font-size: 0.7rem;
    }

    .law-sidebar-right .paragraph-pin {
        display: none !important;
    }

    .law-main-wrapper {
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .law-content {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0;
        width: 100%;
        max-width: 100%;
        flex: 1;
        min-height: 0;
    }

    .has-right-sidebar .law-content {
        width: calc(100% - 60px);
        max-width: calc(100% - 60px);
    }

    .law-panel {
        height: auto;
        min-height: 400px;
    }

    .law-panel.placeholder {
        padding-right: 0;
        margin-right: 0;
        overflow-y: scroll;
    }

    .placeholder-content {
        padding: 1rem;
    }

    .placeholder-header h2 {
        font-size: 1.5rem;
    }

    .feature-item {
        padding: 0.75rem;
    }
}

@media (max-height: 800px) {
    .law-panel.placeholder {
        padding-top: 14rem;
    }
}