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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: auto;
    height: 100%;
}

/* App Container */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: auto;
    transition: all 0.5s ease;
}

/* Light Mode Colors */
.app.light-mode {
    background-color: #f5f1eb;
    color: #92400e;
}

/* Dark Mode Colors */
.app.dark-mode {
    background-color: #121212;
    color: white;
}

/* Header */
.header {
    height: 56px;
    border-bottom: 1px solid;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 30;
    user-select: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(12px);
    position: relative;
}

.light-mode .header {
    background-color: rgba(255, 255, 255, 0.8);
    border-bottom-color: rgba(146, 64, 14, 0.1);
}

.dark-mode .header {
    background-color: rgba(30, 30, 30, 0.8);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.logo-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.title {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.025em;
    transition: all 0.3s ease;
}

.title-x {
    font-weight: 700;
    font-size: 20px;
    font-family: 'Brush Script MT', 'Lucida Handwriting', cursive;
    font-style: italic;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
    display: inline-block;
    margin: 0 2px;
    transform: rotate(-5deg);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        filter: brightness(1);
        transform: scale(1);
    }
    50% {
        filter: brightness(1.2);
        transform: scale(1.05);
    }
}

.light-mode .title {
    color: #92400e;
}

.dark-mode .title {
    color: white;
}

.dark-mode .title-x {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 8px rgba(96, 165, 250, 0.4);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-right: 56px;
}

/* Desktop: toolbar in header row between title and help */
@media (min-width: 901px) {
    .header {
        display: flex;
        flex-wrap: nowrap;
        height: 56px;
        overflow: visible;
    }

    .header > .format-toolbar {
        margin-left: auto;
        flex-shrink: 0;
        overflow: visible;
    }

    .header-right {
        margin-left: 8px;
    }
}

/* Format Toolbar */
.format-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    border-radius: 8px;
    user-select: none;
}

.light-mode .format-toolbar {
    background: rgba(30, 30, 30, 0.06);
    border: 1px solid rgba(146, 64, 14, 0.12);
}

.dark-mode .format-toolbar {
    background: rgba(18, 18, 18, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.fmt-group {
    position: relative;
}

.fmt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.light-mode .fmt-btn {
    color: rgba(60, 60, 60, 0.85);
}

.light-mode .fmt-btn:hover,
.light-mode .fmt-btn.active {
    background: rgba(0, 0, 0, 0.06);
    color: #1a1a1a;
}

.dark-mode .fmt-btn {
    color: rgba(200, 210, 220, 0.9);
}

.dark-mode .fmt-btn:hover,
.dark-mode .fmt-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.dark-mode .fmt-btn.active {
    color: #60a5fa;
}

.fmt-style-label {
    font-weight: 500;
    font-size: 13px;
    min-width: 2.5ch;
    text-align: left;
}

.fmt-chevron {
    width: 12px;
    height: 12px;
    opacity: 0.6;
}

.fmt-icon {
    width: 16px;
    height: 16px;
}

.fmt-letter {
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
}

.fmt-bold {
    font-weight: 800;
}

.fmt-italic {
    font-style: italic;
    font-weight: 600;
}

.fmt-strike {
    text-decoration: line-through;
    font-weight: 600;
}

.fmt-underline {
    text-decoration: underline;
    font-weight: 600;
}

.fmt-clear-icon {
    position: relative;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.05em;
}

.fmt-clear-b {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.85;
}

.fmt-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 100;
    min-width: 200px;
    padding: 6px 0;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: visible;
}

.light-mode .format-toolbar .fmt-menu {
    background: #fff;
    border: 1px solid rgba(146, 64, 14, 0.12);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.light-mode .format-toolbar .fmt-menu-item {
    color: rgba(30, 30, 30, 0.92);
}

.light-mode .format-toolbar .fmt-menu-item:hover,
.light-mode .format-toolbar .fmt-style-item.active {
    background: rgba(0, 0, 0, 0.05);
}

.light-mode .format-toolbar .fmt-menu-item-muted {
    color: rgba(30, 30, 30, 0.45);
    opacity: 1;
}

.light-mode .format-toolbar .fmt-menu-divider {
    background: rgba(0, 0, 0, 0.08);
}

.dark-mode .fmt-menu {
    background: #252525;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.fmt-style-menu {
    min-width: 220px;
}

.fmt-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px 10px 14px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.92);
    font-family: 'Inter', sans-serif;
    transition: background 0.12s ease;
    position: relative;
}

.fmt-menu-item:hover,
.fmt-style-item.active {
    background: rgba(255, 255, 255, 0.08);
}

.fmt-style-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: #3b82f6;
    border-radius: 0 2px 2px 0;
}

.fmt-preview {
    display: block;
    color: inherit;
    font-family: 'Inter', sans-serif;
    line-height: 1.2;
}

.fmt-preview-title {
    font-size: 1.35rem;
    font-weight: 700;
}

.fmt-preview-h1 {
    font-size: 1.2rem;
    font-weight: 700;
}

.fmt-preview-h2 {
    font-size: 1.05rem;
    font-weight: 600;
}

.fmt-preview-h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.fmt-preview-h4 {
    font-size: 0.88rem;
    font-weight: 600;
}

.fmt-preview-body {
    font-size: 0.85rem;
    font-weight: 400;
}

.fmt-preview-description {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.75;
}

.fmt-table-menu {
    min-width: 200px;
    padding: 0;
    overflow: visible;
    left: auto;
    right: 0;
}

.fmt-table-menu .fmt-submenu {
    left: auto;
    right: calc(100% - 4px);
}

.fmt-table-insert-section {
    padding: 12px;
}

.fmt-table-heading {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 10px;
    font-weight: 500;
}

.fmt-table-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-bottom: 10px;
}

.fmt-table-cell {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
}

.fmt-table-cell.selected {
    background: rgba(59, 130, 246, 0.35);
    border-color: #3b82f6;
}

/* Light mode table picker — high-contrast grid (toolbar + portaled mobile menus) */
.light-mode .format-toolbar .fmt-table-menu .fmt-table-grid .fmt-table-cell,
.fmt-menu-portal-light .fmt-table-grid .fmt-table-cell {
    border: 2px solid #2563eb !important;
    background: #93c5fd !important;
}

.light-mode .format-toolbar .fmt-table-menu .fmt-table-grid .fmt-table-cell.selected,
.fmt-menu-portal-light .fmt-table-grid .fmt-table-cell.selected {
    background: #1d4ed8 !important;
    border-color: #1e3a8a !important;
}

.fmt-menu-portal-light .fmt-table-heading {
    color: rgba(30, 30, 30, 0.65) !important;
}

.fmt-menu-portal-light .fmt-table-size-label {
    color: rgba(30, 30, 30, 0.55) !important;
}

.fmt-menu-portal-light .fmt-table-insert-section .fmt-menu-item {
    color: rgba(30, 30, 30, 0.92) !important;
}

.light-mode .format-toolbar .fmt-table-menu .fmt-table-heading {
    color: rgba(30, 30, 30, 0.65) !important;
}

.light-mode .format-toolbar .fmt-table-menu .fmt-table-size-label {
    color: rgba(30, 30, 30, 0.55) !important;
}

.light-mode .format-toolbar .fmt-table-menu .fmt-table-insert-section .fmt-menu-item,
.light-mode .format-toolbar .fmt-table-menu .fmt-table-cascade-root > .fmt-menu-item-muted,
.light-mode .format-toolbar .fmt-table-menu .fmt-table-cascade-root > .fmt-cascade-item > .fmt-cascade-trigger {
    color: rgba(30, 30, 30, 0.92) !important;
}

.light-mode .format-toolbar .fmt-table-menu .fmt-submenu,
.light-mode .format-toolbar .fmt-table-menu .fmt-submenu-level-2,
.light-mode .format-toolbar .fmt-table-menu .fmt-submenu-level-3 {
    background: #f8fafc !important;
    border: 1px solid rgba(146, 64, 14, 0.12) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}

.light-mode .format-toolbar .fmt-table-menu .fmt-submenu .fmt-menu-item,
.light-mode .format-toolbar .fmt-table-menu .fmt-submenu .fmt-cascade-trigger {
    color: rgba(30, 30, 30, 0.92) !important;
}

.light-mode .format-toolbar .fmt-table-menu .fmt-submenu .fmt-menu-chevron {
    color: rgba(30, 30, 30, 0.55);
    opacity: 1;
}

.light-mode .format-toolbar .fmt-table-menu .fmt-submenu .fmt-menu-item:hover,
.light-mode .format-toolbar .fmt-table-menu .fmt-submenu .fmt-cascade-item.fmt-cascade-open > .fmt-cascade-trigger,
.light-mode .format-toolbar .fmt-table-menu .fmt-submenu .fmt-cascade-item:hover > .fmt-cascade-trigger {
    background: rgba(0, 0, 0, 0.05) !important;
    color: rgba(30, 30, 30, 0.92) !important;
}

.fmt-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

/* Link modal */
.fmt-link-modal .fmt-link-modal-content {
    max-width: 420px;
    width: 100%;
    padding: 24px;
}

.fmt-link-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.dark-mode .fmt-link-title {
    color: #fff;
}

.light-mode .fmt-link-title {
    color: #1a1a1a;
}

.fmt-link-field {
    display: block;
    margin-bottom: 16px;
}

.fmt-link-label {
    display: block;
    font-size: 12px;
    margin-bottom: 6px;
    opacity: 0.6;
}

.fmt-link-input {
    width: 100%;
    padding: 10px 0;
    border: none;
    border-bottom: 2px solid rgba(59, 130, 246, 0.5);
    background: transparent;
    font-size: 14px;
    outline: none;
    font-family: 'Inter', sans-serif;
}

.dark-mode .fmt-link-input {
    color: #fff;
}

.light-mode .fmt-link-input {
    color: #1a1a1a;
}

.fmt-link-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
}

.fmt-link-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
}

.fmt-link-btn-primary {
    background: #4b5563;
    color: #fff;
}

.fmt-link-btn-secondary {
    background: #374151;
    color: #fff;
}

@media (max-width: 900px) {
    .header {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        height: auto;
        min-height: 0;
        align-items: stretch;
        row-gap: 0;
        padding: 0 12px;
        z-index: 40;
        overflow: visible;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .light-mode .header {
        background-color: #ffffff;
    }

    .dark-mode .header {
        background-color: #1c1c1c;
    }

    .header-left {
        grid-column: 1;
        grid-row: 1;
        height: 48px;
    }

    .header-right {
        grid-column: 2;
        grid-row: 1;
        margin-right: 0;
        height: 48px;
    }

    /* Mobile toolbar — Edge-style flat bar, horizontal scroll */
    .header > .format-toolbar {
        grid-column: 1 / -1;
        grid-row: 2;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 0;
        margin: 0 -12px;
        width: calc(100% + 24px);
        min-width: 0;
        min-height: 48px;
        padding: 6px 8px 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border: none;
        border-radius: 0;
        border-bottom: 1px solid rgba(128, 128, 128, 0.18);
        box-shadow: none;
        position: relative;
        z-index: 41;
    }

    .light-mode .header > .format-toolbar {
        background-color: #ffffff;
        border-bottom-color: rgba(146, 64, 14, 0.12);
    }

    .dark-mode .header > .format-toolbar {
        background-color: #1c1c1c;
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    .header > .format-toolbar::-webkit-scrollbar {
        display: none;
    }

    .header > .format-toolbar .fmt-group {
        position: static;
        display: flex;
        flex-shrink: 0;
        align-items: center;
    }

    .header > .format-toolbar > .fmt-group + .fmt-btn,
    .header > .format-toolbar > .fmt-btn + .fmt-btn,
    .header > .format-toolbar > .fmt-btn + .fmt-group,
    .header > .format-toolbar > .fmt-group + .fmt-group {
        border-left: 1px solid rgba(128, 128, 128, 0.22);
        margin-left: 2px;
        padding-left: 2px;
    }

    .dark-mode .header > .format-toolbar > .fmt-group + .fmt-btn,
    .dark-mode .header > .format-toolbar > .fmt-btn + .fmt-btn,
    .dark-mode .header > .format-toolbar > .fmt-btn + .fmt-group,
    .dark-mode .header > .format-toolbar > .fmt-group + .fmt-group {
        border-left-color: rgba(255, 255, 255, 0.1);
    }

    .light-mode .header > .format-toolbar > .fmt-group + .fmt-btn,
    .light-mode .header > .format-toolbar > .fmt-btn + .fmt-btn,
    .light-mode .header > .format-toolbar > .fmt-btn + .fmt-group,
    .light-mode .header > .format-toolbar > .fmt-group + .fmt-group {
        border-left-color: rgba(146, 64, 14, 0.14);
    }

    .format-toolbar .fmt-btn {
        min-width: 40px;
        width: 40px;
        height: 40px;
        padding: 0;
        flex-shrink: 0;
        border-radius: 6px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        cursor: pointer;
    }

    .format-toolbar button {
        touch-action: manipulation;
        cursor: pointer;
    }

    .format-toolbar #fmtStyleBtn {
        width: auto;
        min-width: 52px;
        padding: 0 8px;
        gap: 2px;
    }

    .format-toolbar .fmt-icon {
        width: 18px;
        height: 18px;
    }

    .format-toolbar .fmt-letter {
        font-size: 16px;
    }

    .format-toolbar .fmt-btn:active {
        opacity: 1;
        transform: none;
    }

    .light-mode .format-toolbar .fmt-btn:active,
    .light-mode .format-toolbar .fmt-btn[aria-expanded="true"] {
        background: rgba(0, 0, 0, 0.07);
    }

    .dark-mode .format-toolbar .fmt-btn:active,
    .dark-mode .format-toolbar .fmt-btn[aria-expanded="true"] {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    .format-toolbar .fmt-menu-item:active,
    .fmt-table-cell:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    .format-toolbar .fmt-menu-item {
        min-height: 48px;
        display: flex;
        align-items: center;
        touch-action: manipulation;
    }

    .format-toolbar .fmt-style-menu .fmt-style-item {
        flex-shrink: 0;
    }

    .format-toolbar .fmt-style-item {
        min-height: 48px;
    }

    .format-toolbar .fmt-style-label {
        max-width: none;
        font-size: 13px;
        font-weight: 500;
    }

    .format-toolbar .fmt-chevron {
        width: 14px;
        height: 14px;
        opacity: 0.55;
    }

    .format-toolbar .fmt-menu,
    .fmt-menu-portal {
        position: fixed;
        left: 12px;
        right: 12px;
        top: auto;
        bottom: auto;
        max-height: min(60vh, 420px);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        z-index: 1000;
        border-radius: 8px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.28);
        pointer-events: auto;
        touch-action: pan-y;
        overscroll-behavior: contain;
        isolation: isolate;
    }

    .format-toolbar .fmt-style-menu,
    .fmt-menu-portal.fmt-style-menu {
        max-height: min(65vh, 440px);
    }

    .fmt-menu-portal-light {
        background-color: #ffffff !important;
        border: 1px solid rgba(146, 64, 14, 0.12);
    }

    .fmt-menu-portal-light .fmt-menu-item,
    .fmt-menu-portal-light .fmt-cascade-trigger {
        color: rgba(30, 30, 30, 0.92);
    }

    .fmt-menu-portal-dark {
        background-color: #252525 !important;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .fmt-menu-portal-dark .fmt-menu-item,
    .fmt-menu-portal-dark .fmt-cascade-trigger {
        color: rgba(255, 255, 255, 0.92);
    }

    .fmt-menu-portal-dark .fmt-submenu,
    .fmt-menu-portal-dark .fmt-submenu-level-2,
    .fmt-menu-portal-dark .fmt-submenu-level-3 {
        background-color: #2f2f2f !important;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .fmt-menu-portal-light .fmt-submenu,
    .fmt-menu-portal-light .fmt-submenu-level-2,
    .fmt-menu-portal-light .fmt-submenu-level-3 {
        background-color: #f8fafc !important;
        border: 1px solid rgba(146, 64, 14, 0.12);
    }

    .header.fmt-toolbar-menu-open,
    .format-toolbar.fmt-toolbar-menu-open {
        overflow: visible;
    }

    .light-mode .format-toolbar .fmt-menu,
    .light-mode .fmt-menu-portal {
        background: #fff;
        border: 1px solid rgba(146, 64, 14, 0.12);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    }

    .light-mode .format-toolbar .fmt-menu-item,
    .light-mode .fmt-menu-portal .fmt-menu-item {
        color: rgba(30, 30, 30, 0.92);
    }

    .light-mode .format-toolbar .fmt-menu-item:hover,
    .light-mode .format-toolbar .fmt-style-item.active,
    .light-mode .fmt-menu-portal .fmt-menu-item:hover,
    .light-mode .fmt-menu-portal .fmt-style-item.active {
        background: rgba(0, 0, 0, 0.05);
    }

    .dark-mode .fmt-menu-portal {
        background: #252525;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .dark-mode .fmt-menu-portal .fmt-menu-item {
        color: rgba(255, 255, 255, 0.92);
    }

    .format-toolbar .fmt-table-menu,
    .format-toolbar .fmt-style-menu {
        left: 12px;
        right: 12px;
        max-width: none;
    }

    .fmt-table-cell {
        width: 36px;
        height: 36px;
    }

    .fmt-table-grid {
        grid-template-columns: repeat(5, 36px);
        justify-content: center;
    }

    .light-mode .fmt-table-menu .fmt-table-grid .fmt-table-cell,
    .fmt-menu-portal-light .fmt-table-grid .fmt-table-cell {
        border: 2px solid #2563eb !important;
        background: #93c5fd !important;
    }

    .light-mode .fmt-table-menu .fmt-table-grid .fmt-table-cell.selected,
    .fmt-menu-portal-light .fmt-table-grid .fmt-table-cell.selected {
        background: #1d4ed8 !important;
        border-color: #1e3a8a !important;
    }

    .fmt-table-menu .fmt-submenu {
        position: static;
        display: none;
        left: auto;
        right: auto;
        min-width: 0;
        box-shadow: none;
        padding: 0 0 0 12px;
    }

    .dark-mode .fmt-table-menu .fmt-submenu {
        background: transparent;
        border: none;
    }

    .light-mode .fmt-table-menu .fmt-submenu,
    .light-mode .fmt-table-menu .fmt-submenu-level-2,
    .light-mode .fmt-table-menu .fmt-submenu-level-3 {
        background: #f8fafc !important;
        border: 1px solid rgba(146, 64, 14, 0.12) !important;
        box-shadow: none !important;
        border-radius: 8px;
        margin: 2px 8px 6px;
        padding: 4px 0;
    }

    .light-mode .fmt-table-menu .fmt-submenu .fmt-menu-item,
    .light-mode .fmt-table-menu .fmt-submenu .fmt-cascade-trigger {
        color: rgba(30, 30, 30, 0.92) !important;
    }

    .light-mode .fmt-table-menu .fmt-submenu .fmt-menu-chevron {
        color: rgba(30, 30, 30, 0.55);
        opacity: 1;
    }

    .fmt-table-menu .fmt-cascade-item.fmt-cascade-open > .fmt-submenu {
        display: block;
    }

    .fmt-table-menu .fmt-cascade-item:hover > .fmt-submenu,
    .fmt-table-menu .fmt-submenu .fmt-cascade-item:hover > .fmt-submenu {
        display: none !important;
    }

    .fmt-table-menu .fmt-cascade-item.fmt-cascade-open > .fmt-submenu,
    .fmt-table-menu .fmt-submenu .fmt-cascade-item.fmt-cascade-open > .fmt-submenu {
        display: block !important;
    }

    .fmt-table-menu .fmt-menu-item,
    .fmt-table-menu .fmt-cascade-trigger {
        min-height: 44px;
        display: flex;
        align-items: center;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .dark-mode .fmt-table-menu .fmt-cascade-item.fmt-cascade-open > .fmt-cascade-trigger {
        background: rgba(128, 128, 128, 0.12);
    }

    .light-mode .fmt-table-menu .fmt-submenu .fmt-menu-item:hover,
    .light-mode .fmt-table-menu .fmt-submenu .fmt-cascade-item.fmt-cascade-open > .fmt-cascade-trigger {
        background: rgba(0, 0, 0, 0.05) !important;
        color: rgba(30, 30, 30, 0.92) !important;
    }

    .fmt-table-insert-section {
        overflow: visible;
    }

    .fmt-table-grid {
        width: 100%;
        max-width: 100%;
    }

    .paper-editor {
        -webkit-user-select: text;
        user-select: text;
    }

    .main {
        z-index: 1;
    }
}

@media (max-width: 900px) and (hover: none) and (pointer: coarse) {
    .paper-editor .wx-table td,
    .paper-editor .wx-table th {
        min-height: 44px;
        padding: 10px 12px;
    }

    .paper-editor .wx-col-resizer {
        width: 16px;
    }
}

.icon-btn {
    padding: 8px;
    border-radius: 8px;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.light-mode .icon-btn {
    color: rgba(146, 64, 14, 0.4);
}

.light-mode .icon-btn:hover {
    color: #92400e;
    background-color: rgba(146, 64, 14, 0.05);
}

.dark-mode .icon-btn {
    color: rgba(255, 255, 255, 0.4);
}

.dark-mode .icon-btn:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

.icon {
    width: 20px;
    height: 20px;
}

/* Main Area */
.main {
    flex: 1;
    position: relative;
    padding: 24px 32px 80px 32px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

@media (max-width: 768px) {
    .main {
        padding: 16px 16px 80px 16px;
    }
}

.papers-container {
    flex: 1;
    display: flex;
    gap: 32px;
    position: relative;
    perspective: 2000px;
    min-height: 0;
}

@media (max-width: 768px) {
    .papers-container {
        gap: 16px;
    }
}

.papers-container.single-paper {
    width: 100%;
    flex: 1;
    min-height: 0;
    align-self: stretch;
}

.papers-container.dual-paper {
    overflow: visible;
    flex-direction: row;
}

@media (max-width: 768px) {
    .papers-container.dual-paper {
        flex-direction: column;
    }
}

/* Paper Wrapper */
.paper-wrapper {
    position: relative;
    flex: 1;
    min-height: 650px;
    height: 650px;
    perspective: 2000px;
}

/* Paper */
.paper {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.light-mode .paper {
    background-color: white;
    border-color: rgba(146, 64, 14, 0.1);
    box-shadow: 0 25px 50px -12px rgba(146, 64, 14, 0.05);
}

.dark-mode .paper {
    background-color: #1e1e1e;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.paper.flipped {
    transform: rotateY(180deg);
}

/* Paper Side */
.paper-side {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(1px);
}

.back-side {
    transform: rotateY(180deg) translateZ(1px);
}

.light-mode .back-side {
    background-color: #fffdfa;
}

.dark-mode .back-side {
    background-color: #1a1a1a;
}

.paper.flipped .front-side {
    pointer-events: none;
    z-index: 0;
}

.paper.flipped .back-side {
    pointer-events: auto;
    z-index: 2;
}

.paper:not(.flipped) .front-side {
    pointer-events: auto;
    z-index: 2;
}

.paper:not(.flipped) .back-side {
    pointer-events: none;
    z-index: 0;
}

/* Paper Header Line */
.paper-header-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, #92400e, #d97706);
}

.dark-mode .front-side .paper-header-line {
    background: linear-gradient(to right, #2563eb, #7c3aed);
}

.dark-mode .back-side .paper-header-line {
    background: linear-gradient(to right, #7c3aed, #2563eb);
}

/* Paper Header */
.paper-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border-bottom: 1px solid;
}

.light-mode .paper-header {
    border-bottom-color: rgba(146, 64, 14, 0.05);
    background-color: rgba(251, 191, 36, 0.3);
}

.dark-mode .paper-header {
    border-bottom-color: rgba(255, 255, 255, 0.05);
    background-color: rgba(255, 255, 255, 0.05);
}

.paper-label {
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

.light-mode .paper-label {
    color: rgba(146, 64, 14, 0.4);
}

.dark-mode .paper-label {
    color: rgba(255, 255, 255, 0.4);
}

/* Paper Content */
.paper-content {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.paper-textarea {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: 100%;
    padding: 32px;
    background: transparent;
    border: none;
    resize: none;
    outline: none;
    font-size: 18px;
    line-height: 1.6;
    font-family: 'Crimson Text', Georgia, serif;
    transition: color 0.3s ease, background-color 0.3s ease;
    overflow-x: hidden;
    overflow-y: auto;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    box-sizing: border-box;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: none;
}

.paper-editor {
    -webkit-overflow-scrolling: touch;
    white-space: normal;
}

.paper-editor > * {
    max-width: 100%;
    display: block;
}

.paper-editor > .wx-table-wrap {
    flex-shrink: 0;
}

.paper-editor:empty::before {
    content: attr(data-placeholder);
    color: inherit;
    opacity: 0.5;
    pointer-events: none;
}

.paper-editor h1,
.paper-editor h2,
.paper-editor h3,
.paper-editor h4,
.paper-editor p {
    margin: 0 0 0.5em;
}

.paper-editor > p:has(+ .wx-table-wrap),
.paper-editor > div:has(+ .wx-table-wrap) {
    min-height: 1.6em;
}

.paper-editor > p + .wx-table-wrap,
.paper-editor > div + .wx-table-wrap,
.paper-editor > h1 + .wx-table-wrap,
.paper-editor > h2 + .wx-table-wrap,
.paper-editor > h3 + .wx-table-wrap,
.paper-editor > h4 + .wx-table-wrap {
    margin-top: 1.25em;
}

.paper-editor > .wx-table-wrap + p,
.paper-editor > .wx-table-wrap + div {
    margin-top: 0.5em;
}

.paper-editor .wx-table-wrap[contenteditable="false"] {
    user-select: none;
}

.paper-editor .wx-table-wrap[contenteditable="false"] td,
.paper-editor .wx-table-wrap[contenteditable="false"] th {
    user-select: text;
}

.paper-editor h1.wx-title {
    font-size: 2rem;
    font-weight: inherit;
    line-height: 1.2;
    margin-bottom: 0.75em;
}

.paper-editor h1:not(.wx-title) {
    font-size: 1.65rem;
    font-weight: inherit;
}

.paper-editor h2 {
    font-size: 1.4rem;
    font-weight: inherit;
}

.paper-editor h3 {
    font-size: 1.2rem;
    font-weight: inherit;
}

.paper-editor h4 {
    font-size: 1.05rem;
    font-weight: inherit;
}

.paper-editor p.wx-description {
    font-size: 0.9rem;
    font-weight: inherit;
    opacity: 0.75;
    line-height: 1.5;
}

/* Inline text styles (highlighted words within a line) */
.paper-editor [class*='wx-inline-'] {
    display: inline;
    font-weight: inherit;
    font-style: inherit;
}

.paper-editor u {
    text-decoration: underline;
}

.paper-editor s,
.paper-editor strike,
.paper-editor del {
    text-decoration: line-through;
}

.paper-editor .wx-inline-title {
    font-size: 2rem;
    line-height: 1.2;
}

.paper-editor .wx-inline-h1 {
    font-size: 1.65rem;
    line-height: 1.25;
}

.paper-editor .wx-inline-h2 {
    font-size: 1.4rem;
    line-height: 1.3;
}

.paper-editor .wx-inline-h3 {
    font-size: 1.2rem;
    line-height: 1.35;
}

.paper-editor .wx-inline-h4 {
    font-size: 1.05rem;
    line-height: 1.4;
}

.paper-editor .wx-inline-description {
    font-size: 0.9rem;
    opacity: 0.75;
    line-height: 1.5;
}

.paper-editor .wx-inline-body {
    font-size: inherit;
}

/* Prevent pasted content from shifting text to the right */
.paper-editor p,
.paper-editor div:not(.wx-table-wrap),
.paper-editor span:not([class*="wx-inline-"]) {
    margin-left: 0;
    padding-left: 0;
    text-indent: 0;
}

.paper-editor ul,
.paper-editor ol {
    margin: 0 0 0.75em;
    padding-left: 1.5em;
    padding-inline-start: 1.5em;
    margin-inline-start: 0;
    list-style-position: outside;
}

.paper-editor li {
    text-indent: 0;
    margin-inline-start: 0;
}

.paper-editor ul {
    list-style-type: disc;
}

.paper-editor ol {
    list-style-type: decimal;
}

.paper-editor li {
    display: list-item;
    margin: 0 0 0.25em;
}

/* Preserve text styles when lines become list items */
.paper-editor li.wx-list-title {
    font-size: 2rem;
    font-weight: inherit;
    line-height: 1.2;
}

.paper-editor li.wx-list-h1 {
    font-size: 1.65rem;
    font-weight: inherit;
    line-height: 1.25;
}

.paper-editor li.wx-list-h2 {
    font-size: 1.4rem;
    font-weight: inherit;
    line-height: 1.3;
}

.paper-editor li.wx-list-h3 {
    font-size: 1.2rem;
    font-weight: inherit;
    line-height: 1.35;
}

.paper-editor li.wx-list-h4 {
    font-size: 1.05rem;
    font-weight: inherit;
    line-height: 1.4;
}

.paper-editor li.wx-list-description {
    font-size: 0.9rem;
    font-weight: inherit;
    opacity: 0.75;
    line-height: 1.5;
}

/* Mobile / touch: keep bullets inside the text box so they don't overlap the paper edge */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
    .paper-editor ul,
    .paper-editor ol {
        list-style-position: inside;
        padding-left: 0;
        padding-inline-start: 0;
        margin-left: 0;
        margin-inline-start: 0;
    }

    .paper-editor li {
        display: list-item;
        list-style-position: inside;
        padding-left: 0;
        padding-inline-start: 0;
        margin-left: 0;
        margin-inline-start: 0;
        overflow: visible;
    }

    .paper-editor p,
    .paper-editor h1,
    .paper-editor h2,
    .paper-editor h3,
    .paper-editor h4 {
        margin-inline-start: 0;
        padding-inline-start: 0;
    }
}

.paper-editor ul ul,
.paper-editor ol ol,
.paper-editor ul ol,
.paper-editor ol ul {
    margin-top: 0.25em;
    margin-bottom: 0;
}

.paper-editor a,
.paper-editor a.wx-link {
    color: #2563eb;
    text-decoration: underline;
    cursor: pointer;
}

.paper-editor a:hover {
    color: #1d4ed8;
}

.dark-mode .paper-editor a,
.dark-mode .paper-editor a.wx-link {
    color: #60a5fa;
}

.dark-mode .paper-editor a:hover {
    color: #93c5fd;
}

.fmt-menu-item-danger {
    color: #f87171 !important;
}

.fmt-table-size-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    margin: 4px 0 8px;
}

/* Cascading table menus (Edit table → Insert / Select / Delete) */
.fmt-table-cascade-root {
    padding: 6px 0;
    overflow: visible;
}

.fmt-menu-static {
    cursor: default;
    pointer-events: none;
}

.fmt-menu-item-muted {
    opacity: 0.45;
    color: rgba(255, 255, 255, 0.7);
}

.fmt-cascade-item {
    position: relative;
}

.fmt-cascade-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    text-align: left;
}

.fmt-menu-chevron {
    width: 14px;
    height: 14px;
    opacity: 0.65;
    flex-shrink: 0;
}

.fmt-submenu {
    display: none;
    position: absolute;
    left: calc(100% - 4px);
    top: 0;
    min-width: 172px;
    padding: 6px 0;
    border-radius: 10px;
    z-index: 120;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    background: #2b2b2b;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.light-mode .format-toolbar .fmt-submenu {
    background: #f8fafc;
    border: 1px solid rgba(146, 64, 14, 0.12);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.light-mode .format-toolbar .fmt-submenu .fmt-menu-item,
.light-mode .format-toolbar .fmt-submenu .fmt-cascade-trigger {
    color: rgba(30, 30, 30, 0.92);
}

.light-mode .format-toolbar .fmt-submenu .fmt-menu-item:hover,
.light-mode .format-toolbar .fmt-submenu .fmt-cascade-item:hover > .fmt-cascade-trigger,
.light-mode .format-toolbar .fmt-submenu .fmt-cascade-item.fmt-cascade-open > .fmt-cascade-trigger {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(30, 30, 30, 0.92);
}

.light-mode .format-toolbar .fmt-submenu .fmt-menu-item-muted {
    color: rgba(30, 30, 30, 0.45);
    opacity: 1;
}

.light-mode .format-toolbar .fmt-submenu .fmt-menu-chevron {
    color: rgba(30, 30, 30, 0.55);
    opacity: 1;
}

.fmt-cascade-item:hover > .fmt-submenu,
.fmt-submenu .fmt-cascade-item:hover > .fmt-submenu {
    display: block;
}

.fmt-submenu-level-2 {
    z-index: 121;
}

.fmt-submenu-level-3 {
    z-index: 122;
}

.fmt-table-menu .fmt-menu-item {
    padding: 10px 16px;
}

.paper-editor .wx-table-wrap.wx-table-selected {
    border-color: rgba(59, 130, 246, 0.7);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}

.paper-editor .wx-table td.wx-cell-selected,
.paper-editor .wx-table th.wx-cell-selected {
    background: rgba(59, 130, 246, 0.12);
    outline: 1px solid rgba(59, 130, 246, 0.4);
}

/* Table block in editor */
.paper-editor .wx-table-wrap {
    display: block;
    clear: both;
    position: relative;
    isolation: isolate;
    margin: 0 0 1.25em;
    border-radius: 8px;
    border: 1px solid rgba(128, 128, 128, 0.25);
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.paper-editor .wx-table-wrap + .wx-table-wrap {
    margin-top: 1.5em;
}

.paper-editor .wx-table-wrap.wx-table-active {
    border-color: rgba(59, 130, 246, 0.55);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.paper-editor .wx-table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.paper-editor .wx-table td,
.paper-editor .wx-table th {
    border: 1px solid rgba(128, 128, 128, 0.35);
    padding: 8px 10px;
    min-width: 48px;
    min-height: 32px;
    vertical-align: top;
    word-break: break-word;
}

.paper-editor .wx-col-resizers {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 0;
    pointer-events: none;
    z-index: 5;
}

.paper-editor .wx-col-resizer {
    position: absolute;
    width: 8px;
    margin-left: -4px;
    cursor: col-resize;
    pointer-events: auto;
    z-index: 6;
}

.paper-editor .wx-col-resizer:hover {
    background: rgba(59, 130, 246, 0.35);
}

.light-mode .paper-textarea {
    color: #451a03;
}

.dark-mode .paper-textarea {
    color: #e5e7eb;
}

/* Pasted Office/Excel inline colors inherit theme text in dark mode */
.dark-mode .paper-editor font[color] {
    color: inherit;
}

.paper-textarea::placeholder {
    opacity: 0.5;
}

.paper-textarea.hidden {
    filter: blur(32px);
    user-select: none;
    pointer-events: none;
    position: relative;
}

.paper-textarea.hidden::after {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    z-index: 1;
}

/* Hidden Overlay */
.hidden-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 50;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    border-radius: 16px;
}

.dark-mode .hidden-overlay {
    background: rgba(30, 30, 30, 0.75);
}

.hidden-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 16px;
}

.light-mode .hidden-icon {
    color: rgba(146, 64, 14, 0.3);
}

.dark-mode .hidden-icon {
    color: rgba(255, 255, 255, 0.3);
}

.unhide-btn {
    padding: 12px 22px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: 0.2s ease;
    position: relative;
    min-width: 120px;
    min-height: 40px;
    z-index: 100;
    pointer-events: auto;
}

.light-mode .unhide-btn {
    background: #A77F60;
}

.dark-mode .unhide-btn {
    background: #2563eb;
}

.light-mode .unhide-btn:hover {
    transform: scale(1.05);
    background: #8d6a4f;
}

.dark-mode .unhide-btn:hover {
    transform: scale(1.05);
    background: #1d4ed8;
}

/* Blur Blocks Layer */
.blur-blocks-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 20;
}

/* Scroll to Top Button */
.scroll-to-top-btn {
    position: fixed;
    bottom: 20px;
    right: 30px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.3s ease;
    opacity: 0.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.scroll-to-top-btn:hover {
    opacity: 1;
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.scroll-to-top-btn svg {
    width: 24px;
    height: 24px;
}

.light-mode .scroll-to-top-btn {
    background: #fbbf24;
    color: #92400e;
}

.dark-mode .scroll-to-top-btn {
    background: #2563eb;
    color: white;
}

.light-mode .scroll-to-top-btn:hover {
    background: #f59e0b;
}

.dark-mode .scroll-to-top-btn:hover {
    background: #1d4ed8;
}

/* Mobile and Tablet positioning for scroll to top button */
@media (max-width: 1024px) {
    .scroll-to-top-btn {
        right: 16px;
        bottom: 16px;
        width: 44px;
        height: 44px;
    }
    
    .scroll-to-top-btn svg {
        width: 22px;
        height: 22px;
    }
}

.blur-block {
    position: absolute;
    pointer-events: auto;
    border: 2px solid;
    border-radius: 12px;
    cursor: move;
    transition: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    will-change: transform;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.light-mode .blur-block {
    background-color: #fbbf24;
    border-color: #92400e;
}

.dark-mode .blur-block {
    background-color: #1e3a8a;
    border-color: #60a5fa;
}

.blur-block:hover {
    opacity: 1;
}

.blur-block-icon {
    width: 24px;
    height: 24px;
}

.light-mode .blur-block-icon {
    color: #92400e;
}

.dark-mode .blur-block-icon {
    color: #60a5fa;
}

.blur-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 24px;
    height: 24px;
    cursor: se-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    touch-action: none;
}

.blur-block:hover .blur-resize-handle {
    opacity: 1;
}

/* Always show resize handle on mobile/touch devices */
@media (hover: none) and (pointer: coarse) {
    .blur-resize-handle {
        opacity: 1;
    }
}

.blur-resize-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.light-mode .blur-resize-dot {
    background-color: rgba(146, 64, 14, 0.4);
}

.dark-mode .blur-resize-dot {
    background-color: rgba(96, 165, 250, 0.4);
}

.blur-remove-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 28px;
    height: 28px;
    color: white;
    border-radius: 50%;
    border: 2px solid;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    touch-action: none;
}

.blur-block:hover .blur-remove-btn {
    opacity: 1;
}

/* Always show remove button on mobile/touch devices */
@media (hover: none) and (pointer: coarse) {
    .blur-remove-btn {
        opacity: 1;
    }
}

.light-mode .blur-remove-btn {
    background-color: #92400e;
    border-color: white;
}

.dark-mode .blur-remove-btn {
    background-color: #2563eb;
    border-color: #121212;
}

.blur-remove-btn:hover {
    background-color: #dc2626 !important;
}

.blur-remove-icon {
    width: 14px;
    height: 14px;
}

/* Toolbar */
.toolbar {
    height: 64px;
    border-top: 1px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    z-index: 30;
    user-select: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(24px);
}

.light-mode .toolbar {
    background-color: rgba(255, 255, 255, 0.9);
    border-top-color: rgba(146, 64, 14, 0.1);
}

.dark-mode .toolbar {
    background-color: rgba(30, 30, 30, 0.9);
    border-top-color: rgba(255, 255, 255, 0.1);
}

.toolbar-content {
    max-width: 1024px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
}

@media (max-width: 640px) {
    .toolbar-content {
        gap: 4px;
    }
}

/* Tool Groups */
.tool-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.light-mode .tool-group {
    background-color: rgba(146, 64, 14, 0.05);
}

.dark-mode .tool-group {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Tool Buttons */
.tool-btn {
    padding: 8px;
    border-radius: 8px;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.light-mode .tool-btn {
    color: rgba(146, 64, 14, 0.6);
}

.light-mode .tool-btn:hover {
    background-color: white;
    color: #92400e;
}

.light-mode .tool-btn.active {
    background-color: #92400e;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dark-mode .tool-btn {
    color: rgba(255, 255, 255, 0.4);
}

.dark-mode .tool-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.dark-mode .tool-btn.active {
    background-color: #2563eb;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Flip Indicator */
.flip-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: white;
    animation: pulse 2s infinite;
}

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

/* Dual Button */
.dual-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    font-size: 12px;
}

.light-mode .dual-btn {
    color: rgba(146, 64, 14, 0.6);
}

.light-mode .dual-btn:hover {
    background-color: rgba(146, 64, 14, 0.05);
}

.light-mode .dual-btn.active {
    background-color: #fef3c7;
    color: #92400e;
}

.dark-mode .dual-btn {
    color: rgba(255, 255, 255, 0.4);
    background: transparent;
}

.dark-mode .dual-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

.dark-mode .dual-btn.active {
    background-color: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
}

.dual-text {
    display: none;
}

@media (min-width: 640px) {
    .dual-text {
        display: inline;
    }
}

/* Clear Button */
.clear-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: bold;
    font-size: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.light-mode .clear-btn {
    background-color: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.light-mode .clear-btn:hover {
    background-color: #dc2626;
    color: white;
}

.dark-mode .clear-btn {
    background-color: rgba(127, 29, 29, 0.2);
    color: #f87171;
    border-color: rgba(127, 29, 29, 0.2);
}

.dark-mode .clear-btn:hover {
    background-color: #dc2626;
    color: white;
}

.clear-text {
    display: none;
}

@media (min-width: 640px) {
    .clear-text {
        display: inline;
    }
}

/* Toolbar Divider */
.toolbar-divider {
    width: 1px;
    height: 24px;
    transition: all 0.3s ease;
}

.light-mode .toolbar-divider {
    background-color: rgba(146, 64, 14, 0.1);
}

.dark-mode .toolbar-divider {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Toolbar Spacer */
.toolbar-spacer {
    flex: 1;
}

/* Tooltip */
.tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    font-size: 10px;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.tool-btn:hover .tooltip {
    opacity: 1;
}

.light-mode .tooltip {
    background-color: #92400e;
    color: white;
}

.dark-mode .tooltip {
    background-color: #2563eb;
    color: white;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(146, 64, 14, 0.4);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.modal-content {
    position: relative;
    border-radius: 24px;
    padding: 32px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: center;
    animation: modalEnter 0.3s ease-out;
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.light-mode .modal-content {
    background-color: white;
}

.dark-mode .modal-content {
    background-color: #1e1e1e;
    color: white;
}

/* Clear Modal */
.clear-modal-content .modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    background-color: #fef2f2;
    color: #dc2626;
}

.clear-modal-content h2 {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 8px;
}

.clear-modal-content p {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 32px;
    opacity: 0.6;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.cancel-btn {
    flex: 1;
    padding: 12px 16px;
    font-weight: bold;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #fef3c7;
    color: #92400e;
}

.cancel-btn:hover {
    background-color: #fde68a;
}

.confirm-btn {
    flex: 1;
    padding: 12px 16px;
    font-weight: bold;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #dc2626;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(220, 38, 38, 0.2);
}

.confirm-btn:hover {
    background-color: #b91c1c;
}

/* Help Modal */
.help-modal-content {
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-align: left;
}

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

.light-mode .modal-header {
    border-bottom-color: rgba(146, 64, 14, 0.05);
}

.dark-mode .modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: bold;
}

.close-btn {
    padding: 8px;
    border-radius: 50%;
    border: none;
    background: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.light-mode .close-btn:hover {
    background-color: rgba(146, 64, 14, 0.05);
}

.dark-mode .close-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px 32px 32px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.light-mode .modal-body::-webkit-scrollbar-track {
    background: rgba(146, 64, 14, 0.05);
}

.dark-mode .modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.light-mode .modal-body::-webkit-scrollbar-thumb {
    background: rgba(146, 64, 14, 0.2);
    border-radius: 4px;
}

.dark-mode .modal-body::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.3);
    border-radius: 4px;
}

.light-mode .modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(146, 64, 14, 0.3);
}

.dark-mode .modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(96, 165, 250, 0.5);
}

.help-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.help-section.highlight {
    padding: 20px;
    border-radius: 12px;
    border: 2px solid;
}

.light-mode .help-section.highlight {
    background-color: #fef3c7;
    border-color: #fbbf24;
}

.dark-mode .help-section.highlight {
    background-color: rgba(96, 165, 250, 0.1);
    border-color: #60a5fa;
}

.help-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.help-icon {
    width: 20px;
    height: 20px;
}

.light-mode .help-icon {
    color: #92400e;
}

.dark-mode .help-icon {
    color: #60a5fa;
}

.help-section h3,
.help-section h4 {
    font-weight: bold;
    margin: 0;
}

.help-section h3 {
    font-size: 16px;
}

.help-section h4 {
    font-size: 15px;
}

.help-section p {
    font-size: 14px;
    line-height: 1.6;
    opacity: 0.8;
    margin: 0;
}

.help-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.help-shortcuts kbd {
    padding: 4px 8px;
    border: 1px solid;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-weight: bold;
}

.light-mode .help-shortcuts kbd {
    background-color: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.dark-mode .help-shortcuts kbd {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: #60a5fa;
}

.help-shortcuts span {
    font-size: 12px;
    opacity: 0.5;
}

.help-intro {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
    opacity: 0.9;
}

.help-tips-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.help-tips-list li {
    font-size: 14px;
    line-height: 1.6;
    padding-left: 24px;
    position: relative;
    opacity: 0.85;
}

.help-tips-list li::before {
    content: "•";
    position: absolute;
    left: 8px;
    font-weight: bold;
    font-size: 18px;
}

.light-mode .help-tips-list li::before {
    color: #92400e;
}

.dark-mode .help-tips-list li::before {
    color: #60a5fa;
}

.help-tips-list li strong {
    font-weight: 600;
    opacity: 1;
}

.light-mode .help-tips-list li strong {
    color: #92400e;
}

.dark-mode .help-tips-list li strong {
    color: #60a5fa;
}

.modal-footer {
    padding: 24px;
    text-align: center;
    border-top: 1px solid;
}

.light-mode .modal-footer {
    background-color: rgba(251, 191, 36, 0.5);
    border-top-color: rgba(146, 64, 14, 0.1);
}

.dark-mode .modal-footer {
    background-color: rgba(255, 255, 255, 0.05);
    border-top-color: rgba(255, 255, 255, 0.1);
}

.got-it-btn {
    padding: 8px 32px;
    color: white;
    font-weight: bold;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.light-mode .got-it-btn {
    background-color: #92400e;
}

.light-mode .got-it-btn:hover {
    background-color: #78350f;
}

.dark-mode .got-it-btn {
    background-color: #2563eb;
}

.dark-mode .got-it-btn:hover {
    background-color: #1d4ed8;
}

/* Responsive Design */
@media (max-width: 640px) {
    .main {
        padding: 16px;
    }
    
    .papers-container {
        gap: 16px;
    }
    
    .paper-textarea {
        padding: 16px 18px;
        font-size: 16px;
    }
    
    .toolbar-content {
        gap: 4px;
    }
    
    .modal {
        padding: 16px;
    }
    
    .modal-content {
        padding: 24px;
    }
    
    .modal-body {
        padding: 24px;
        gap: 24px;
    }
}

/* Site Footer */
.site-footer {
    background-color: white;
    border-top: 1px solid rgba(146, 64, 14, 0.1);
}

.dark-mode .site-footer {
    background-color: #1a1a1a;
    border-top-color: rgba(255, 255, 255, 0.1);
}

.footer-main {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 40px;
    padding: 40px 64px;
    max-width: 1200px;
    margin: 0 auto;
}

/* About Section */
.footer-about {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 2;
    max-width: 550px;
    align-items: flex-start;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: flex-start;
}

.footer-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.footer-name {
    font-family: 'Crimson Text', serif;
    font-size: 20px;
    font-weight: 600;
    color: #92400e;
    margin: 0;
    letter-spacing: -0.01em;
}

.dark-mode .footer-name {
    color: white;
}

.footer-bio {
    font-size: 12px;
    line-height: 1.6;
    color: rgba(146, 64, 14, 0.6);
    margin: 0;
    text-align: left;
}

.dark-mode .footer-bio {
    color: rgba(255, 255, 255, 0.55);
}

/* Games Section */
.footer-games {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 280px;
}

.games-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.game-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 12px;
    background-color: rgba(146, 64, 14, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: #92400e;
    font-size: 14px;
    font-weight: 500;
}

.dark-mode .game-link {
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.85);
}

.game-link:hover {
    background-color: #92400e;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(146, 64, 14, 0.25);
}

.dark-mode .game-link:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.game-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.game-link:hover .game-icon {
    transform: scale(1.1);
}

.game-name {
    font-weight: 600;
    letter-spacing: 0.025em;
}

/* Connect Section */
.footer-connect {
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-left: 24px;
}

.footer-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #92400e;
    margin: 0 0 16px 0;
}

.dark-mode .footer-title {
    color: rgba(255, 255, 255, 0.6);
}

.footer-social {
    display: flex;
    gap: 14px;
}

.social-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: rgba(146, 64, 14, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark-mode .social-icon {
    background-color: rgba(255, 255, 255, 0.1);
}

.social-icon svg {
    width: 18px;
    height: 18px;
    color: #92400e;
    transition: transform 0.3s ease;
}

.dark-mode .social-icon svg {
    color: rgba(255, 255, 255, 0.85);
}

.social-icon:hover {
    background-color: #92400e;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(146, 64, 14, 0.25);
}

.dark-mode .social-icon:hover {
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.social-icon:hover svg {
    color: white;
    transform: scale(1.1);
}

.dark-mode .social-icon:hover svg {
    color: white;
}

/* Tools Section */
.footer-tools {
    margin-top: 24px;
}

.tools-list {
    display: flex;
    flex-direction: row;
    gap: 6px;
    flex-wrap: wrap;
}

.tool-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    border-radius: 20px;
    background-color: rgba(146, 64, 14, 0.07);
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: #92400e;
    font-size: 12.5px;
    font-weight: 600;
    border: 1.5px solid rgba(146, 64, 14, 0.18);
    letter-spacing: 0.01em;
}

.dark-mode .tool-link {
    background-color: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.75);
    border-color: rgba(255, 255, 255, 0.13);
}

.tool-link:hover {
    background-color: #92400e;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(146, 64, 14, 0.28);
    border-color: #92400e;
}

.dark-mode .tool-link:hover {
    background-color: rgba(255, 255, 255, 0.14);
    color: white;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.35);
}

.tool-icon {
    width: 15px;
    height: 15px;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.tool-link:hover .tool-icon {
    transform: scale(1.15) rotate(6deg);
}

.tool-name {
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Sister Sites Buttons */
.sister-sites-list {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.sister-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 9px 13px 13px;
    border-radius: 12px;
    text-decoration: none;
    overflow: hidden;
    flex: 1;
    min-width: 110px;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.sister-btn:hover {
    transform: translateY(-3px);
}

/* NexaLibrary — light card style */
.nexa-btn {
    background: linear-gradient(135deg, #f7fbff 0%, #eef5fb 100%);
    border: 1.5px solid #c0d8ec;
    box-shadow: 0 2px 8px rgba(100, 149, 190, 0.1);
    color: #1a2a3a;
}

.nexa-btn:hover {
    box-shadow: 0 8px 24px rgba(100, 149, 190, 0.28);
    border-color: #7aaed4;
    background: linear-gradient(135deg, #eef5fb 0%, #ddeef8 100%);
}

.dark-mode .nexa-btn {
    background: linear-gradient(135deg, rgba(122,174,212,0.1) 0%, rgba(100,149,190,0.06) 100%);
    border-color: rgba(122, 174, 212, 0.28);
    color: rgba(255,255,255,0.88);
}

.dark-mode .nexa-btn:hover {
    background: linear-gradient(135deg, rgba(122,174,212,0.16) 0%, rgba(100,149,190,0.1) 100%);
    border-color: rgba(122, 174, 212, 0.55);
    box-shadow: 0 8px 24px rgba(100, 149, 190, 0.18);
}

/* TabStack — dark navy style */
.tabstack-btn {
    background: linear-gradient(135deg, #1e2d5a 0%, #16234a 100%);
    border: 1.5px solid rgba(80, 110, 200, 0.4);
    box-shadow: 0 2px 10px rgba(20, 35, 80, 0.3);
    color: #ffffff;
}

.tabstack-btn:hover {
    background: linear-gradient(135deg, #253672 0%, #1e2d5a 100%);
    box-shadow: 0 8px 24px rgba(20, 35, 80, 0.45);
    border-color: rgba(100, 140, 230, 0.6);
}

.dark-mode .tabstack-btn {
    background: linear-gradient(135deg, #1e2d5a 0%, #16234a 100%);
    border-color: rgba(58, 80, 160, 0.45);
}

.dark-mode .tabstack-btn:hover {
    background: linear-gradient(135deg, #253672 0%, #1e2d5a 100%);
    box-shadow: 0 8px 24px rgba(20, 35, 80, 0.5);
}

.sister-btn-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
    display: block;
}

.sister-btn-sub {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.65;
    display: block;
    letter-spacing: 0.01em;
}

.sister-x {
    font-family: 'Crimson Text', Georgia, serif;
    font-style: italic;
    font-weight: 600;
}

.nexa-x {
    color: #7aaed4;
}

.tabstack-x {
    color: #d4a24a;
}

.sister-btn-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 45%;
    border-radius: 0 3px 0 0;
    opacity: 0.85;
    transition: width 0.25s ease, opacity 0.25s ease;
}

.sister-btn:hover .sister-btn-bar {
    width: 65%;
    opacity: 1;
}

.nexa-bar {
    background: linear-gradient(90deg, #7aaed4, rgba(122,174,212,0));
}

.tabstack-bar {
    background: linear-gradient(90deg, #d4a24a, rgba(212,162,74,0));
}

/* TaskForge — dark navy style matching TabStack family */
.taskforge-btn {
    background: linear-gradient(135deg, #1e2d5a 0%, #16234a 100%);
    border: 1.5px solid rgba(80, 110, 200, 0.4);
    box-shadow: 0 2px 10px rgba(20, 35, 80, 0.3);
    color: #ffffff;
}

.taskforge-btn:hover {
    background: linear-gradient(135deg, #253672 0%, #1e2d5a 100%);
    box-shadow: 0 8px 24px rgba(20, 35, 80, 0.45);
    border-color: rgba(100, 140, 230, 0.6);
}

.dark-mode .taskforge-btn {
    background: linear-gradient(135deg, #1e2d5a 0%, #16234a 100%);
    border-color: rgba(58, 80, 160, 0.45);
}

.dark-mode .taskforge-btn:hover {
    background: linear-gradient(135deg, #253672 0%, #1e2d5a 100%);
    box-shadow: 0 8px 24px rgba(20, 35, 80, 0.5);
}

.taskforge-x {
    color: #d4a24a;
}

.taskforge-bar {
    background: linear-gradient(90deg, #d4a24a, transparent);
}

/* MergeSync tool-link accent */
.mergesync-link {
    background-color: rgba(120, 170, 120, 0.09);
    border-color: rgba(100, 155, 100, 0.28);
    color: #2a4a2a;
}

.dark-mode .mergesync-link {
    background-color: rgba(120, 170, 120, 0.08);
    border-color: rgba(120, 170, 120, 0.2);
    color: rgba(255, 255, 255, 0.82);
}

.mergesync-link:hover {
    background-color: #3a6b3a !important;
    color: white !important;
    border-color: #3a6b3a !important;
    box-shadow: 0 6px 16px rgba(58, 107, 58, 0.3) !important;
}

.dark-mode .mergesync-link:hover {
    background-color: rgba(100, 155, 100, 0.2) !important;
    color: white !important;
    border-color: rgba(120, 170, 120, 0.45) !important;
    box-shadow: 0 6px 16px rgba(58, 107, 58, 0.2) !important;
}

.mergesync-x {
    font-family: 'Crimson Text', Georgia, serif;
    font-style: italic;
    font-weight: 600;
    color: #c87d20;
}

/* Copyright Bar */
.footer-copyright {
    border-top: 1px solid rgba(146, 64, 14, 0.08);
    padding: 16px 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.dark-mode .footer-copyright {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.footer-copyright p {
    font-size: 11px;
    color: rgba(146, 64, 14, 0.5);
    margin: 0;
}

.dark-mode .footer-copyright p {
    color: rgba(255, 255, 255, 0.4);
}

.ad-placement {
    font-size: 10px !important;
    color: rgba(146, 64, 14, 0.4) !important;
}

.dark-mode .ad-placement {
    color: rgba(255, 255, 255, 0.3) !important;
}

.ad-placement a {
    color: #92400e;
    text-decoration: none;
    transition: color 0.2s ease;
}

.ad-placement a:hover {
    color: #78350f;
    text-decoration: underline;
}

.dark-mode .ad-placement a {
    color: #60a5fa;
}

.dark-mode .ad-placement a:hover {
    color: #93c5fd;
}

/* Responsive */
@media (max-width: 768px) {
    .footer-main {
        flex-direction: column;
        align-items: center;
        gap: 32px;
        padding: 32px 24px;
    }

    .footer-about {
        align-items: center;
        text-align: center;
        max-width: none;
        order: 1;
    }

    .footer-brand {
        flex-direction: column;
        align-items: center;
    }

    .footer-games {
        text-align: center;
        max-width: none;
        width: 100%;
        order: 2;
    }

    .games-grid {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .game-link {
        flex: 1;
        min-width: 100px;
        justify-content: center;
        padding: 8px 12px;
        font-size: 12px;
    }

    .game-icon {
        width: 16px;
        height: 16px;
    }

    .footer-connect {
        text-align: center;
        align-items: center;
        padding-left: 0;
        order: 3;
    }

    .footer-social {
        justify-content: center;
    }

    .footer-tools {
        margin-top: 20px;
    }

    .tools-list {
        align-items: center;
        flex-wrap: wrap;
        justify-content: center;
    }

    .tool-link {
        justify-content: center;
        flex: 1;
        min-width: 120px;
    }

    .sister-sites-list {
        flex-direction: row;
        gap: 10px;
    }

    .sister-btn {
        flex: 1;
        min-width: 130px;
    }
    
    .footer-bio {
        text-align: center;
    }

    .footer-copyright {
        padding: 12px 24px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .ad-placement {
        order: 2;
    }
}

/* Extra small devices (phones) */
@media (max-width: 480px) {
    .header {
        padding: 0 12px;
        height: auto;
    }
    
    .title {
        font-size: 13px;
    }
    
    .logo-img {
        width: 28px;
        height: 28px;
    }
    
    .main {
        padding: 12px 8px 72px 8px;
    }
    
    .paper-wrapper {
        min-height: 350px;
        height: 350px;
    }
    
    .paper-textarea {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .toolbar {
        height: auto;
        padding: 6px 8px;
    }
    
    .toolbar-content {
        gap: 3px;
        flex-wrap: wrap;
    }
    
    .tool-btn {
        padding: 6px;
    }
    
    .icon {
        width: 16px;
        height: 16px;
    }
    
    .dual-btn, .clear-btn {
        padding: 6px 8px;
        font-size: 10px;
    }
    
    .dual-text, .clear-text {
        display: none;
    }
    
    .footer-main {
        padding: 20px 12px;
        gap: 20px;
    }
    
    .footer-about {
        max-width: 100%;
    }
    
    .games-grid {
        flex-direction: column;
        width: 100%;
    }
    
    .game-link {
        width: 100%;
        min-width: auto;
        flex: none;
    }
    
    .tools-list {
        flex-direction: column;
        width: 100%;
        gap: 6px;
    }
    
    .tool-link {
        width: 100%;
        min-width: auto;
        flex: none;
    }

    .sister-sites-list {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .sister-btn {
        width: 100%;
        flex: none;
        min-width: auto;
    }
    
    .modal-content {
        max-width: 95%;
        padding: 16px;
    }
    
    .help-modal-content {
        max-width: 95%;
    }
    
    .modal-header {
        padding: 16px;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 16px;
        gap: 24px;
    }
    
    .help-section {
        gap: 10px;
    }
    
    .help-section.highlight {
        padding: 16px;
    }
    
    .help-section h3 {
        font-size: 15px;
    }
    
    .help-section h4 {
        font-size: 14px;
    }
    
    .help-section p {
        font-size: 13px;
    }
    
    .help-tips-list li {
        font-size: 13px;
        padding-left: 20px;
    }
    
    .help-shortcuts {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .modal-footer {
        padding: 16px;
    }
}

/* Content protection: block print / save-as-PDF of the page */
@media print {
    html,
    body {
        display: none !important;
        visibility: hidden !important;
    }
}

/* Discourage copying layout chrome; editors stay selectable for notes */
#app > header,
#app > footer,
.format-toolbar,
.modal-overlay,
.help-modal {
    -webkit-user-select: none;
    user-select: none;
}

img {
    -webkit-user-drag: none;
    user-drag: none;
}