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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    height: 100vh;
}

.chapter-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    background-color: #e3f2fd;
    border-bottom: 2px solid #2196f3;
    max-height: 140px;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease, border-bottom-color 0.25s ease;
}

body.controls-hidden .chapter-selector {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-color: transparent;
}

.selector-grid {
    display: grid;
    grid-template-columns: auto auto auto auto auto;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 8px;
    align-items: center;
}

.selector-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.selectors {
    grid-column: 1 / span 2;
    grid-row: 1;
}

.grid-spacer {
    grid-column: 3;
    grid-row: 1;
}

.quickcode {
    grid-column: 4;
    grid-row: 1;
    display: flex;
    justify-content: center;
}

.chapter-selector label {
    font-weight: 600;
    color: #1565c0;
}

.chapter-selector input[type="number"],
.chapter-selector select {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid #2196f3;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    color: #1565c0;
    background-color: white;
    cursor: pointer;
}

.pbbcc-input {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: #1565c0;
    padding: 6px 15px;
    background-color: white;
    border: 2px solid #2196f3;
    border-radius: 4px;
    width: 100px;
    text-align: center;
    text-transform: uppercase;
}

.pbbcc-input:focus {
    outline: none;
    border-color: #0d47a1;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.pbbcc-input.invalid {
    border-color: #dc3545;
    background-color: #fff8f8;
}

.chapter-selector select:hover {
    border-color: #1976d2;
}

.chapter-selector select:focus {
    outline: none;
    border-color: #0d47a1;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.radio-group {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    padding-left: 0;
    grid-column: 1 / span 2;
    grid-row: 2;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    color: #1565c0;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    cursor: pointer;
    accent-color: #2196f3;
}

.level-id {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    padding-left: 0;
    grid-column: 4;
    grid-row: 2;
}

.level-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 3;
    grid-row: 2;
}

.level-toggle label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #1565c0;
    cursor: pointer;
}

.level-toggle input[type="checkbox"] {
    cursor: pointer;
    accent-color: #2196f3;
}

.level-id input {
    margin: 0;
}

.level-id input.invalid {
    border-color: #dc3545;
    background: #fff8f8;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.15);
}

.levels-disabled .radio-group label {
    color: #9aa7b0 !important;
}

.levels-disabled .level-id input {
    color: #999;
    border-color: #ccc;
    background: #f3f3f3;
    box-shadow: none;
}

.levels-disabled .nav-buttons button {
    background-color: #e0e0e0;
    border-color: #ccc;
    color: #999;
    cursor: not-allowed;
    opacity: 0.5;
}

.nav-buttons {
    display: flex;
    gap: 5px;
    padding-left: 0;
    justify-content: center;
    grid-column: 5;
    grid-row: 2;
}

.nav-buttons button {
    width: 70px;
    height: 40px;
    padding: 0;
    font-size: 28px;
    font-weight: bold;
    background-color: white;
    border: 2px solid #2196f3;
    border-radius: 4px;
    color: #2196f3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.nav-buttons button:hover {
    background-color: #2196f3;
    color: white;
}

.nav-buttons button:active {
    transform: scale(0.95);
}

.nav-buttons button:disabled {
    background-color: #e0e0e0;
    border-color: #ccc;
    color: #999;
    cursor: not-allowed;
    opacity: 0.5;
}

.nav-buttons button:disabled:hover {
    background-color: #e0e0e0;
    border-color: #ccc;
    color: #999;
    cursor: not-allowed;
    opacity: 0.5;
}

.highlight {
    background-color: #ffe08a;
    border-radius: 2px;
    box-shadow: inset 0 0 0 1px rgba(229, 143, 0, 0.6);
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 0;
    justify-content: center;
    grid-column: 5;
    grid-row: 1;
}

.lang-toggle-label {
    font-weight: 600;
    color: #1565c0;
}

.lang-toggle label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    color: #1565c0;
    cursor: pointer;
}

.lang-toggle input[type="radio"] {
    cursor: pointer;
    accent-color: #2196f3;
}

.container {
    display: flex;
    height: calc(100vh - 70px);
    width: 100vw;
}

.panel-title {
    padding: 6px 10px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    color: #1565c0;
    background: #f5f9ff;
    text-align: center;
    white-space: normal;
    line-height: 1.35;
    cursor: pointer;
}

.panel-title .title-part {
    font-weight: 500;
}

.panel-title .title-sep {
    font-weight: 600;
}

.panel-title .title-book {
    font-weight: 600;
}

.panel-title .chapter-line {
    margin-top: 2px;
    font-weight: 600;
}

.panel {
    width: calc(50% - 10px);
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ccc;
}

#panel1 .content {
    direction: rtl;
}

#panel1 .content > * {
    direction: ltr;
}

.panel:last-child {
    border-right: none;
}

.sync-dial-container {
    width: 40px;
    height: 100%;
    background-color: #f5f5f5;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ns-resize;
    z-index: 10;
}

.dial-knob {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border: 1px solid #999;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: transform 0.1s;
}

.dial-knob::after {
    content: '↕';
    color: #555;
    font-size: 18px;
    font-weight: bold;
}

.dial-knob:active {
    background: #ddd;
    transform: scale(0.95);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0;
}

.control-group label {
    font-weight: 600;
    min-width: auto;
    padding-right: 5px;
}

.control-group input[type="file"] {
    flex: 1;
}

.control-group input[type="text"] {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    text-align: right;
}

.control-group button {
    padding: 6px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.control-group button:hover {
    background-color: #0056b3;
}

.content-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
    height: 100%;
}

.left-panel {
    flex-direction: row;
}

.right-panel {
    flex-direction: row;
}

.line-num-row {
    padding: 0 5px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #666;
    user-select: none;
    -webkit-user-select: none; /* Safari */
}

.left-panel .line-num-row {
    text-align: left;
    padding-left: 10px;
}

.right-panel .line-num-row {
    text-align: right;
    padding-right: 10px;
}

.content {
    flex: 1;
    display: flex;
    overflow-y: scroll;
    overflow-x: auto;
    background-color: white;
    scrollbar-width: auto;
    height: 100%;
}

/* Left panel content direction */
#panel1-content {
    direction: rtl; /* Moves scrollbar to left */
}

#panel1-content > * {
    direction: ltr; /* Reset content direction */
}

.line-numbers-container {
    width: 50px;
    height: 100%;
    overflow: hidden; /* Hide scrollbars */
    background-color: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    flex-shrink: 0;
    display: none;
    flex-direction: column;
}

.left-panel .line-numbers-container {
    border-right: none;
    border-left: 1px solid #e0e0e0;
}

.dial-knob {
    width: 32px;
    height: 20%;
    border-radius: 16px;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border: 1px solid #999;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none; /* Safari */
    transition: transform 0.1s;
    touch-action: none; /* Crucial for Safari touch events */
    cursor: ns-resize;
}

.content::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

.content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 8px;
}

.content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.content::-webkit-scrollbar-corner {
    background: #f1f1f1;
}

.line-row {
    display: flex;
    align-items: flex-start;
    width: 100%;
    background-color: white;
}

.line-num {
    width: 50px;
    min-width: 50px;
    text-align: right;
    padding-right: 10px;
    padding-left: 5px;
    background-color: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    color: #666;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    user-select: none;
    flex-shrink: 0;
}

.line-text {
    flex: 1;
    padding: 0 15px;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    overflow-wrap: break-word;
}
.path-group {
    display: none;
}

body.show-paths .path-group {
    display: flex;
}

body.show-paths .line-numbers-container {
    display: flex;
    flex-direction: column;
}
