/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #111827;
    background-color: #ffffff;
    overflow: hidden;
}

/* Mobile Warning */
.mobile-warning {
    display: none;
    padding: 20px;
    text-align: center;
    background-color: #fef3c7;
    color: #92400e;
}

@media (max-width: 1023px) {
    .mobile-warning {
        display: block;
    }
    .app-container {
        display: none !important;
    }
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.mobile-nav-bar {
    display: none;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    height: 60px;
}

.toolbar-left {
    width: 40%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.book-title {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #d946ef 0%, #ec4899 50%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.backup-status {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    white-space: nowrap;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #d946ef 0%, #ec4899 50%, #a855f7 100%);
    color: #ffffff;
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #c924e0 0%, #db2777 50%, #9333ea 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(217, 70, 239, 0.4);
}

.btn-secondary {
    background-color: #f9fafb;
    color: #111827;
    border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
    background-color: #f3f4f6;
}

.btn-block {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
    margin-bottom: 0;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 160px;
    z-index: 1000;
}

.dropdown-menu.active {
    display: block;
}

.dropdown-menu button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #111827;
}

.dropdown-menu button:hover {
    background-color: #f9fafb;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Tree Panel */
.tree-panel {
    width: 35%;
    background-color: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
}

.tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.tree-actions {
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background-color: #ffffff;
    display: flex;
    gap: 8px;
}

/* Tree Item Styles */
.tree-item {
    margin-bottom: 4px;
}

.tree-item-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
}

.tree-item-header:hover {
    background-color: #f3f4f6;
}

.tree-item-header.selected {
    background-color: #dbeafe;
    color: #1e40af;
}

.tree-item-toggle {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    cursor: pointer;
    font-size: 12px;
}

.tree-item-icon {
    margin-right: 8px;
    font-size: 14px;
    color: #6b7280;
    width: 16px;
    display: inline-block;
    text-align: center;
}

.tree-item-icon i {
    vertical-align: middle;
}

.tree-item-title {
    flex: 1;
    font-weight: 500;
}

.tree-item-title.editing {
    background-color: #ffffff;
    border: 1px solid #2563eb;
    border-radius: 3px;
    padding: 2px 6px;
    outline: none;
}

.tree-item-actions {
    display: none;
    gap: 4px;
}

.tree-item-header:hover .tree-item-actions {
    display: flex;
}

.tree-item-action {
    padding: 2px 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 12px;
}

.tree-item-action:hover {
    color: #111827;
}

.tree-item-children {
    margin-left: 20px;
}

.tree-item-children.collapsed {
    display: none;
}

/* Editor Panel */
.editor-panel {
    width: 60%;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    transition: width 0.3s ease;
}

.editor-panel.notes-open {
    width: 50%;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.toolbar-spacer {
    flex: 1;
}

#manual-save-btn {
    margin-left: auto;
}

.save-status {
    color: #6b7280;
    font-size: 13px;
    font-style: italic;
}

.version-badge {
    font-size: 12px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 8px;
    border-radius: 4px;
    margin-right: 8px;
    font-weight: 500;
}

.editor-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    font-size: 16px;
}

.empty-state.hidden {
    display: none;
}

/* Pell Editor Customization */
.pell {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pell-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    border: 1px solid #e5e7eb;
    border-top: none;
    background: #ffffff;
}

.pell-content:focus {
    outline: none;
    border-color: #2563eb;
}

.pell-content p {
    margin-bottom: 1em;
}

.pell-actionbar {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-bottom: none;
    padding: 8px;
}

.pell-button {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    cursor: pointer;
    height: 30px;
    margin: 0 4px;
    padding: 0 8px;
    font-size: 14px;
}

.pell-button:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.pell-button-selected {
    background: #dbeafe !important;
    border-color: #2563eb !important;
}

/* Speech-to-text button states */
#speech-btn {
    color: #6b7280;
    transition: color 0.3s, background-color 0.3s;
}

#speech-btn.recording {
    color: #ef4444;
    background: #fee2e2;
    border-color: #ef4444;
    animation: pulse 1.5s infinite;
}

#speech-btn.error {
    color: #f59e0b;
    background: #fef3c7;
    border-color: #f59e0b;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-small {
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

/* X button in modal header */
.modal-header .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header .modal-close:hover {
    color: #111827;
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
}

.input-field {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 15px;
}

.input-field:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.input-field {
    resize: vertical;
    font-family: inherit;
}

.help-text {
    font-size: 12px;
    color: #6b7280;
    margin-top: -10px;
    margin-bottom: 15px;
}

.translate-options {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.translate-options label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
}

.translate-options input[type="radio"] {
    margin-right: 8px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

/* Settings Modal - Tab Navigation */
.settings-modal-content {
    max-width: 700px;
}

.settings-tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    background-color: #f9fafb;
    padding: 0 20px;
    overflow-x: auto;
}

.tab-button {
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-button i {
    margin-right: 6px;
}

.tab-button:hover {
    color: #111827;
    background-color: rgba(37, 99, 235, 0.05);
}

.tab-button.active {
    border-bottom-color: #2563eb;
    color: #2563eb;
    font-weight: 600;
}

.tab-content {
    padding: 25px;
    min-height: 350px;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Settings Sections */
.settings-section-divider {
    margin: 25px 0;
    padding-top: 20px;
    border-top: 2px solid #e5e7eb;
}

.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 15px;
}

/* API Keys Tab */
.api-key-group {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.api-key-group:last-child {
    border-bottom: none;
}

.api-test-btn {
    margin-top: 10px;
    background-color: #2563eb;
    color: white;
}

.api-test-btn:hover {
    background-color: #1d4ed8;
}

/* Cloud Backup Tab */
.cloud-account-section {
    margin-bottom: 20px;
}

/* Glossary Tab - Enhanced Design */
.glossary-add-section {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 20px;
}

.glossary-add-btn {
    padding: 10px 20px;
    font-size: 20px;
    min-width: 50px;
}

.glossary-search-section {
    margin-bottom: 15px;
    position: relative;
}

.glossary-search-section::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.glossary-search-section input {
    padding-left: 36px;
}

.glossary-table-container {
    margin: 15px 0;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

#glossary-table {
    width: 100%;
    border-collapse: collapse;
}

#glossary-table thead {
    background-color: #f9fafb;
    position: sticky;
    top: 0;
}

#glossary-table th {
    text-align: left;
    padding: 10px;
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
    color: #374151;
}

#glossary-table td {
    padding: 10px;
    border-bottom: 1px solid #e5e7eb;
}

#glossary-table tbody tr:hover {
    background-color: #f9fafb;
}

#glossary-table .delete-btn {
    background-color: #dc2626;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

#glossary-table .delete-btn:hover {
    background-color: #b91c1c;
}

.glossary-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e5e7eb;
}

.glossary-actions button i {
    margin-right: 6px;
}

.glossary-info {
    margin-top: 15px;
    padding: 10px;
    background-color: #dbeafe;
    border-radius: 6px;
    font-size: 13px;
    color: #1e40af;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.progress-fill {
    height: 100%;
    background-color: #2563eb;
    transition: width 0.3s ease;
    width: 0%;
}

#progress-text {
    font-weight: 500;
    color: #374151;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 300px;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideIn 0.3s ease;
    opacity: 0.95;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    background-color: #10b981;
    color: #ffffff;
}

.toast.error {
    background-color: #ef4444;
    color: #ffffff;
}

.toast.info {
    background-color: #3b82f6;
    color: #ffffff;
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    margin-left: 12px;
}

/* Sortable Drag Styles */
.sortable-ghost {
    opacity: 0.4;
    background-color: #dbeafe;
}

.sortable-drag {
    cursor: grabbing !important;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: rotate(2deg);
}

/* Cursor change when dragging is possible */
.tree-item-header {
    cursor: grab;
}

.tree-item-header:active {
    cursor: grabbing;
}

/* Visual feedback while dragging */
body.is-dragging {
    cursor: grabbing !important;
}

body.is-dragging * {
    cursor: grabbing !important;
}

/* Highlight drop zones */
.tree-item-children {
    transition: background-color 0.2s;
}

.tree-item-children:not(.collapsed) {
    min-height: 20px;
}

.sortable-chosen {
    background-color: #f3f4f6;
}

.sortable-fallback {
    display: none !important;
}

/* Backup List */
.backup-list-item {
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f9fafb;
}

.backup-list-item:hover {
    background-color: #f3f4f6;
}

.backup-info {
    flex: 1;
}

.backup-timestamp {
    font-weight: 500;
    color: #111827;
    margin-bottom: 4px;
}

.backup-details {
    font-size: 12px;
    color: #6b7280;
}

.backup-actions {
    display: flex;
    gap: 8px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-muted {
    color: #6b7280;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Flash animation for updated items */
@keyframes flash {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: #dbeafe; /* light blue */
    }
}

.tree-item.flash {
    animation: flash 0.6s ease-in-out;
}

/* Notes Panel */
.notes-panel {
    width: 15%;
    background-color: #fef9e7;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.3s ease;
}

.notes-panel.hidden {
    transform: translateX(100%);
    width: 0;
}

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background-color: #fef3c7;
}

.notes-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #92400e;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notes-header h3 i {
    font-size: 16px;
}

.notes-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    color: #92400e;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: rgba(146, 64, 14, 0.1);
}

#clear-notes-btn {
    color: #92400e;
}

#clear-notes-btn:hover {
    background-color: rgba(146, 64, 14, 0.15);
}

.notes-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.notes-container .pell {
    border: none;
}

.notes-container .pell-actionbar {
    background: #fef3c7;
    border: none;
    border-bottom: 1px solid #e5e7eb;
}

.notes-container .pell-content {
    background: #fefce8;
    border: none;
    font-size: 13px;
    line-height: 1.5;
}

.notes-panel .empty-state {
    background-color: #fefce8;
    flex: 1;
}

/* Show Notes Button (when panel is closed) */
.show-notes-btn {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background-color: #fef3c7;
    border: 1px solid #e5e7eb;
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 12px 8px;
    cursor: pointer;
    color: #92400e;
    font-size: 18px;
    box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: all 0.2s;
}

.show-notes-btn:hover {
    background-color: #fde68a;
    padding-right: 12px;
}

/* Notes indicator icon in tree */
.tree-item-notes-indicator {
    margin-left: 6px;
    color: #f59e0b;
    font-size: 12px;
}

/* Word count badge in tree */
.word-count-badge {
    font-size: 11px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    font-weight: normal;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f9fafb;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
} 

/* --- Mobile Button Overrides --- */
@media (max-width: 767px) {
  /* General buttons in toolbars */
  .toolbar .btn, .editor-toolbar .btn {
    padding: 6px 8px; /* Smaller vertical padding */
    font-size: 12px;   /* Smaller font */
    height: auto;      /* Ensure height is not fixed */
  }

  /* Bottom navigation bar buttons */
  .mobile-nav-bar .btn {
    padding: 8px 6px; /* Significantly smaller padding */
    font-size: 11px;  /* Smaller font */
  }
}

/* Image Viewer Styles */
.image-viewer {
    padding: 20px;
    overflow-y: auto;
    height: 100%;
}

.image-preview-section {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    text-align: center;
}

.image-preview {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-alt-text {
    margin-top: 15px;
    color: #6b7280;
    font-size: 14px;
    font-style: italic;
}

.image-alt-text span {
    color: #111827;
    font-weight: 500;
}

.image-upload-section {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 25px;
}

.image-upload-section h3 {
    margin: 0 0 20px 0;
    font-size: 16px;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-option {
    margin-bottom: 20px;
}

.upload-option label {
    display: block;
    margin-bottom: 5px;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
}

.upload-divider {
    text-align: center;
    margin: 25px 0;
    position: relative;
}

.upload-divider::before,
.upload-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: #d1d5db;
}

.upload-divider::before {
    left: 0;
}

.upload-divider::after {
    right: 0;
}

.upload-divider span {
    background: #f9fafb;
    padding: 0 15px;
    color: #9ca3af;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#upload-replace-btn {
    margin-top: 10px;
    width: 100%;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* === MOBILE LAYOUT (< 768px) === */
@media (max-width: 767px) {
  /* Hide mobile warning, show app */
  .mobile-warning {
    display: none !important;
  }

  .app-container {
    display: flex !important;
  }

  /* Compact Toolbar */
  .toolbar {
    padding: 8px 12px;
    height: 50px;
    flex-wrap: wrap;
  }

  .toolbar-left {
    width: auto;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .book-title {
    font-size: 18px;
  }

  .backup-status {
    display: none; /* Hide op mobile */
  }

  .toolbar-right {
    gap: 6px;
  }

  .toolbar-right .btn {
    padding: 6px 10px;
    font-size: 13px;
  }

  /* Hide non-essential toolbar buttons */
  #book-settings-btn {
    display: none;
  }

  /* Main content - Single column */
  .main-content {
    flex-direction: column;
  }

  /* Tree panel - Hidden by default, shown as drawer */
  .tree-panel {
    position: fixed;
    left: 0;
    top: 50px;
    width: 80%;
    max-width: 300px;
    height: calc(100vh - 50px);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  }

  .tree-panel.active {
    transform: translateX(0);
  }

  /* Backdrop for drawer */
  .drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
  }

  .drawer-backdrop.active {
    display: block;
  }

  /* Editor panel - Full width */
  .editor-panel {
    width: 100% !important;
    flex: 1;
    position: relative;
    padding-bottom: 72px; /* keep nav bar from overlapping content */
  }


  /* Editor toolbar - Scrollable overflow */
  .editor-toolbar {
    padding: 8px 12px;
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .editor-toolbar .btn {
    padding: 6px 12px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .version-badge {
    font-size: 11px;
    padding: 3px 6px;
  }

  /* Hide undo/redo on mobile (save space) */
  #undo-btn, #redo-btn {
    display: none;
  }

  /* Pell editor - Touch optimized */
  .pell-actionbar {
    padding: 6px;
    overflow-x: auto;
  }

  .pell-button {
    height: 36px; /* Larger touch targets */
    min-width: 36px;
    padding: 0 10px;
    margin: 0 3px;
  }

  .pell-content {
    padding: 16px;
    font-size: 16px; /* Larger for readability */
    line-height: 1.7;
    -webkit-overflow-scrolling: touch;
  }

  /* Notes panel - Bottom sheet */
  .notes-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50vh;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }

  .notes-panel.active {
    transform: translateY(0);
  }

  .show-notes-btn {
    bottom: 20px;
    top: auto;
    transform: none;
    right: 20px;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }

  /* Mobile Navigation Bar */
  .mobile-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    gap: 4px;
    z-index: 1100;
    box-shadow: 0 -4px 12px rgba(17, 24, 39, 0.08);
  }

  .mobile-nav-bar .btn {
    flex: 1;
    margin: 0 2px;
    padding: 10px;
    font-size: 12px;
  }

  /* Tree items - Larger touch targets */
  .tree-item-header {
    padding: 12px 16px;
    min-height: 44px; /* iOS recommended minimum */
  }

  .tree-item-icon {
    font-size: 16px;
    width: 20px;
  }

  .tree-item-title {
    font-size: 15px;
  }

  /* Modals - Full screen on mobile */
  .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }

  /* Hamburger menu button */
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin-right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: #111827;
    font-size: 20px;
  }

  .hamburger-btn:hover {
    background-color: #f3f4f6;
    border-radius: 4px;
  }

  /* Selector items styling */
  .selector-item {
    padding: 12px 16px !important;
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
  }

  .selector-item:hover {
    background-color: #f3f4f6;
  }
}

/* === TABLET LAYOUT (768px - 1023px) === */
@media (min-width: 768px) and (max-width: 1023px) {
  .mobile-warning {
    display: none !important;
  }

  .app-container {
    display: flex !important;
  }

  /* 2-panel layout: Tree + Editor */
  .tree-panel {
    width: 30%;
    min-width: 250px;
  }

  .editor-panel {
    width: 70% !important;
  }

  /* Notes as overlay/drawer */
  .notes-panel {
    position: fixed;
    right: 0;
    top: 60px;
    width: 300px;
    height: calc(100vh - 60px);
    z-index: 1000;
    transform: translateX(100%);
  }

  .notes-panel.active {
    transform: translateX(0);
  }

  /* Larger touch targets */
  .btn {
    padding: 10px 18px;
  }

  .tree-item-header {
    padding: 10px 14px;
    min-height: 40px;
  }
}

/* Hamburger button - desktop hidden */
@media (min-width: 1024px) {
  .hamburger-btn {
    display: none;
  }

  .mobile-nav-bar {
    display: none;
  }
}
