
/* ============================================================
   sm-book.css  –  SM Book Creator
   All selectors prefixed sm-book- to avoid Bootstrap conflicts
   Requires: Bootstrap 3.4 (loaded separately)
   ============================================================ */

/* ============================================================
   GOOGLE FONTS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700;900&family=Inter:wght@300;400;500;600;700&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
    --smb-primary:       #4f46e5;
    --smb-primary-dark:  #3730a3;
    --smb-primary-light: #e0e7ff;
    --smb-accent:        #7c3aed;
    --smb-danger:        #dc2626;
    --smb-success:       #16a34a;
    --smb-warning:       #d97706;


/* ============================================================
   UNIFIED BUTTON THEME - Clean, Modern, Professional
   ============================================================ */

/* All buttons - reset Bootstrap and apply clean theme */
.btn, button:not(.sm-book-export-btn):not(.sm-book-modal-close):not(.sm-book-menu-toggle):not(.sm-account-tab):not(.sm-book-login-tabs button) {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-weight: 500 !important;
    border-radius: 6px !important;
    border-width: 1px !important;
    border-style: solid !important;
    transition: all 0.2s ease !important;
    /* display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important; */
    gap: 6px !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    text-decoration: none !important;
    /* Remove ugly focus outline */
    outline: none !important;
    box-shadow: none !important;
}

/* Remove black border on focus/active */
.btn:focus, .btn:active, .btn.active,
button:focus, button:active, button.active {
    outline: none !important;
    box-shadow: none !important;
}

/* Standard button sizes - BIGGER and more usable */
.btn-xs {
    font-size: 12px !important;
    padding: 6px 12px !important;
    height: 32px !important;
    line-height: 1 !important;
}

.btn-sm {
    font-size: 13px !important;
    padding: 8px 16px !important;
    height: 36px !important;
    line-height: 1 !important;
}

.btn:not(.btn-xs):not(.btn-sm) {
    font-size: 14px !important;
    padding: 10px 20px !important;
    height: 40px !important;
    line-height: 1 !important;
}

/* Button color themes - Clean and modern */
.btn-primary {
    background: var(--smb-primary) !important;
    border-color: var(--smb-primary) !important;
    color: white !important;
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--smb-primary-dark) !important;
    border-color: var(--smb-primary-dark) !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3) !important;
}

.btn-default {
    background: white !important;
    border-color: #d1d5db !important;
    color: #374151 !important;
}

.btn-default:hover, .btn-default:focus {
    background: #f9fafb !important;
    border-color: #9ca3af !important;
    color: #111827 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.btn-danger {
    background: var(--smb-danger) !important;
    border-color: var(--smb-danger) !important;
    color: white !important;
}

.btn-danger:hover, .btn-danger:focus {
    background: #b91c1c !important;
    border-color: #b91c1c !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3) !important;
}

.btn-success {
    background: var(--smb-success) !important;
    border-color: var(--smb-success) !important;
    color: white !important;
}

.btn-success:hover, .btn-success:focus {
    background: #15803d !important;
    border-color: #15803d !important;
    color: white !important;
}

/* Disabled state */
.btn:disabled, .btn.disabled,
button:disabled, button.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

.btn:active, button:active {
    transform: translateY(0) !important;
}


/* ============================================================
   SVG ICONS — ενιαίο μέγεθος
   ============================================================ */
.sm-icon {
    width: 15px;
    height: 15px;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    pointer-events: none;
}

/* Toolbar buttons */
.sm-book-tb-btn .sm-icon {
    width: 14px;
    height: 14px;
}

/* Bottom bar buttons */
.sm-book-bottom-btn .sm-icon {
    width: 14px;
    height: 14px;
}

/* Export buttons - special layout */
.sm-book-export-btn {
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
    color: #374151;
    line-height: 1.4;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 85px;
    letter-spacing: 0.3px;
}

.sm-book-export-btn .sm-icon {
    width: 24px;
    height: 24px;
}

.sm-book-export-btn small { 
    font-size: 10px; 
    font-weight: 700; 
    display: block; 
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sm-book-export-btn:hover { 
    border-color: var(--smb-primary); 
    color: var(--smb-primary); 
    background: var(--smb-primary-light); 
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

    --smb-gray-50:  #f9fafb;
    --smb-gray-100: #f3f4f6;
    --smb-gray-200: #e5e7eb;
    --smb-gray-300: #d1d5db;
    --smb-gray-400: #9ca3af;
    --smb-gray-500: #6b7280;
    --smb-gray-600: #4b5563;
    --smb-gray-700: #374151;
    --smb-gray-800: #1f2937;
    --smb-gray-900: #111827;

    --smb-sidebar-w:  380px;
    --smb-topbar-h:   52px;
    --smb-radius:     8px;
    --smb-radius-lg:  12px;
    --smb-shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --smb-shadow:     0 4px 6px -1px rgba(0,0,0,.1),  0 2px 4px -1px rgba(0,0,0,.06);
    --smb-shadow-lg:  0 10px 25px -3px rgba(0,0,0,.12), 0 4px 6px -2px rgba(0,0,0,.07);
}

/* ============================================================
   RESET / BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

.sm-book-root {
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--smb-gray-700);
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
#sm-view-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--smb-gray-100);
}

/* Top navigation bar */
.sm-book-topbar {
    height: var(--smb-topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--smb-gray-200);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    flex-shrink: 0;
    z-index: 30;
    box-shadow: var(--smb-shadow-sm);
}

.sm-book-topbar-brand {
    font-family: 'Lora', serif;
    font-weight: 600;
    font-size: 17px;
    color: var(--smb-primary);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sm-book-topbar-brand::before {
    content: '📖';
    font-size: 18px;
}

.sm-book-topbar-sep { flex: 1; }

.sm-book-topbar-user {
    font-size: 12px;
    color: var(--smb-gray-500);
    font-weight: 500;
    padding: 4px 10px;
    background: var(--smb-gray-100);
    border-radius: 20px;
}

/* Main content area (sidebar + editor) */
#sm-view-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* ============================================================
   GLOBAL LOADING SPINNER
   ============================================================ */
#sm-global-loading {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 16px;
}

#sm-global-loading .sm-book-spin-lg {
    width: 40px;
    height: 40px;
    border: 3px solid var(--smb-gray-200);
    border-top-color: var(--smb-primary);
    border-radius: 50%;
    animation: sm-spin 0.7s linear infinite;
}

/* ============================================================
   LOGIN VIEW
   ============================================================ */
#sm-view-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #fdf4ff 100%);
    padding: 24px;
}

.sm-book-login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--smb-shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.sm-book-login-header {
    background: linear-gradient(135deg, var(--smb-primary) 0%, var(--smb-accent) 100%);
    padding: 32px 32px 24px;
    color: #fff;
    text-align: center;
}

.sm-book-login-header h1 {
    font-family: 'Lora', serif;
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 6px;
    color: #fff;
}

.sm-book-login-header p {
    font-size: 13px;
    opacity: .8;
    margin: 0;
}

.sm-book-login-tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    background: transparent;
}

.sm-book-login-tabs button {
    flex: 1;
    padding: 8px 8px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all .2s;
}

.sm-book-login-tabs button.active {
    color: #111827;
    font-weight: 600;
    border-bottom-color: var(--smb-primary);
}

.sm-book-login-tabs button:hover:not(.active) {
    color: #374151;
}

.sm-book-login-body { padding: 28px 32px 32px; }

.sm-book-login-body .form-group { margin-bottom: 16px; }
.sm-book-login-body label { font-size: 12px; font-weight: 700; color: var(--smb-gray-600); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 6px; }
.sm-book-login-body .form-control { border-radius: var(--smb-radius); border-color: var(--smb-gray-300); font-size: 14px; }
.sm-book-login-body .form-control:focus { border-color: var(--smb-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }

.sm-book-alert { border-radius: var(--smb-radius); font-size: 13px; padding: 10px 14px; margin-bottom: 16px; }
.sm-book-alert-danger  { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.sm-book-alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.sm-book-alert-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af; }

/* ============================================================
   SETUP / WIZARD VIEW
   ============================================================ */
#sm-view-setup {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #fdf4ff 100%);
    padding: 60px 24px;
    overflow-y: auto;
}

.sm-book-setup-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--smb-shadow-lg);
    width: 100%;
    max-width: 860px;
    padding: 48px;
}

.sm-book-setup-hero {
    text-align: center;
    margin-bottom: 40px;
}

.sm-book-setup-hero .sm-book-icon { font-size: 52px; display: block; margin-bottom: 16px; }

.sm-book-setup-hero h1 {
    font-family: 'Lora', serif;
    font-size: 32px;
    font-weight: 700;
    color: var(--smb-gray-900);
    margin: 0 0 8px;
}

.sm-book-setup-hero p { font-size: 16px; color: var(--smb-gray-500); margin: 0; }

.sm-book-setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.sm-book-setup-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.sm-book-setup-label label { font-size: 13px; font-weight: 700; color: var(--smb-gray-700); text-transform: uppercase; letter-spacing: .4px; margin: 0; }

.sm-book-setup-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--smb-gray-200);
}

.sm-book-setup-submit {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--smb-primary), var(--smb-accent));
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all .2s;
    letter-spacing: .3px;
    margin-top: 24px;
}
.sm-book-setup-submit:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(79,70,229,.35); }
.sm-book-setup-submit:disabled { opacity: .6; cursor: not-allowed; }

/* ============================================================
   SIDEBAR
   ============================================================ */
#sm-book-sidebar {
    width: var(--smb-sidebar-w);
    background: #fff;
    border-right: 1px solid var(--smb-gray-200);
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
    overflow: hidden;
    z-index: 20;
}

.sm-book-sidebar-header {
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--smb-gray-100);
    background: var(--smb-gray-50);
}

.sm-book-sidebar-title {
    font-family: 'Calibri', Arial, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--smb-gray-900);
    line-height: 1.3;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sm-book-sidebar-subtitle {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--smb-gray-400);
    font-weight: 600;
}

/* Action buttons row */
.sm-book-sidebar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--smb-gray-100);
    flex-wrap: wrap;
}

.sm-book-action-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--smb-gray-200);
    border-radius: var(--smb-radius);
    background: #fff;
    color: var(--smb-gray-600);
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    flex-shrink: 0;
}
.sm-book-action-btn:hover           { background: var(--smb-gray-100); color: var(--smb-gray-900); }
.sm-book-action-btn:disabled        { opacity: .35; cursor: not-allowed; }
.sm-book-action-btn.sm-book-action-primary { background: var(--smb-primary); border-color: var(--smb-primary); color: #fff; }
.sm-book-action-btn.sm-book-action-primary:hover { background: var(--smb-primary-dark); }
.sm-book-action-btn.sm-book-action-danger  { color: var(--smb-danger); border-color: #fecaca; }
.sm-book-action-btn.sm-book-action-danger:hover  { background: #fef2f2; }
.sm-book-action-btn.sm-book-action-indigo  { color: var(--smb-primary); background: var(--smb-primary-light); border-color: #c7d2fe; }
.sm-book-action-btn.sm-book-action-indigo:hover  { background: #c7d2fe; }
.sm-book-action-btn.sm-book-action-green   { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.sm-book-action-btn.sm-book-action-green:hover   { background: #dcfce7; }
.sm-book-action-btn.sm-book-action-purple  { color: #7e22ce; background: #faf5ff; border-color: #e9d5ff; }
.sm-book-action-btn.sm-book-action-purple:hover  { background: #f3e8ff; }
.sm-book-action-btn.ml-auto { margin-left: auto; }
.sm-book-sep-v { width: 1px; height: 20px; background: var(--smb-gray-200); flex-shrink: 0; }

/* Fix numbering bar */
.sm-book-sidebar-fix { padding: 8px 12px; border-bottom: 1px solid var(--smb-gray-100); }

.sm-book-fix-btn {
    width: 100%;
    padding: 7px 12px;
    background: var(--smb-primary-light);
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--smb-primary);
    cursor: pointer;
    transition: all .15s;
    text-align: center;
}
.sm-book-fix-btn:hover:not(:disabled) { background: #c7d2fe; }
.sm-book-fix-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Chapter list */
.sm-book-chapter-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sm-book-sidebar-item {
    display: flex;
    align-items: flex-start;
    padding: 8px 10px 8px 24px;
    border-radius: var(--smb-radius);
    cursor: pointer;
    transition: all .15s;
    margin-bottom: 2px;
    border: 1px solid transparent;
    user-select: none;
    position: relative;
}
.sm-book-sidebar-item:hover  { background: var(--smb-gray-50); }
.sm-book-sidebar-item.active { background: #eef2ff; border-color: #c7d2fe; }

.sm-book-grip {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    cursor: grab;
    opacity: 0;
    transition: opacity .15s;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 2px 3px;
}
.sm-book-grip span {
    display: flex;
    gap: 2px;
}
.sm-book-grip span i {
    display: block;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: var(--smb-gray-400);
}
.sm-book-sidebar-item:hover .sm-book-grip { opacity: 1; }
.sm-book-grip:active { cursor: grabbing; }

.sm-sidebar-icon-done  { width: 16px; height: 16px; flex-shrink: 0; }
.sm-sidebar-icon-empty { width: 16px; height: 16px; flex-shrink: 0; color: var(--smb-gray-300); }
.sm-sidebar-icon-page  { width: 14px; height: 14px; flex-shrink: 0; color: var(--smb-gray-400); }

.sm-book-item-icon { display: flex; align-items: center; margin-right: 8px; flex-shrink: 0; }

.sm-book-item-info { flex: 1; min-width: 0; }

.sm-book-item-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .7px;
    color: var(--smb-gray-400);
    margin-bottom: 1px;
}
.sm-book-sidebar-item.active .sm-book-item-label { color: var(--smb-primary); }

.sm-book-item-title {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--smb-gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sm-book-sidebar-item.active .sm-book-item-title { color: var(--smb-gray-900); font-weight: 600; }

/* Bottom bar */
.sm-book-sidebar-bottom {
    padding: 12px;
    border-top: 1px solid var(--smb-gray-200);
    background: var(--smb-gray-50);
}

.sm-book-bottom-row1 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.sm-book-bottom-row2 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }

/* ============================================================
   CHAPTER PANEL  (right side)
   ============================================================ */
#sm-book-chapter-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

/* Chapter header bar */
#sm-book-chapter-header { flex-shrink: 0; }

.sm-book-ch-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: #fff;
    border-bottom: 1px solid var(--smb-gray-200);
    gap: 16px;
    box-shadow: var(--smb-shadow-sm);
    z-index: 10;
    position: relative;
}

.sm-book-ch-header-left { flex: 1; min-width: 0; }

.sm-book-ch-meta-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }

.sm-book-type-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .8px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all .15s;
    white-space: nowrap;
}
.sm-book-type-badge.is-chapter { background: #eef2ff; color: var(--smb-primary); border-color: #c7d2fe; }
.sm-book-type-badge.is-page    { background: var(--smb-gray-100); color: var(--smb-gray-600); border-color: var(--smb-gray-300); }
.sm-book-type-badge:hover { opacity: .8; }

.sm-book-label-input {
    font-size: 12px;
    font-weight: 600;
    color: var(--smb-primary);
    letter-spacing: .8px;
    background: transparent;
    border: none;
    outline: none;
    padding: 2px 4px;
    border-radius: 4px;
    max-width: 160px;
}
.sm-book-label-input:hover, .sm-book-label-input:focus { background: var(--smb-gray-100); }

.sm-book-title-input {
    width: 100%;
    font-size: 18px;
    font-family: 'Calibri', Arial, sans-serif;
    font-weight: 600;
    color: var(--smb-gray-900);
    background: transparent;
    border: none;
    outline: none;
    padding: 0 4px;
    border-radius: 4px;
}
.sm-book-title-input:hover, .sm-book-title-input:focus { background: var(--smb-gray-50); }
.sm-book-title-input::placeholder { color: var(--smb-gray-300); }

.sm-book-ch-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.sm-book-btn-settings { font-size: 12px !important; font-weight: 600 !important; }
.sm-book-btn-generate { font-size: 13px !important; font-weight: 700 !important; letter-spacing: .2px; }

/* Chapter settings panel */
#sm-book-chapter-settings-panel {
    display: none;
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid var(--smb-gray-200);
    padding: 16px 20px;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.sm-book-settings-panel { display: flex; gap: 16px; flex-wrap: wrap; width: 100%; }
.sm-book-settings-section { min-width: 160px; }
.sm-book-settings-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--smb-gray-400); margin-bottom: 6px; }
.sm-book-margins-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sm-book-margin-lbl { font-size: 10px; color: var(--smb-gray-400); text-transform: capitalize; display: block; margin-bottom: 2px; }
.sm-book-margin-input { width: 100%; padding: 4px 6px; border: 1px solid var(--smb-gray-300); border-radius: 4px; font-size: 12px; background: #fff; }
.sm-book-settings-select { width: 100%; padding: 5px 8px; border: 1px solid var(--smb-gray-300); border-radius: 5px; font-size: 12px; background: #fff; color: var(--smb-gray-700); }
.sm-book-settings-ta { width: 100%; padding: 6px 8px; border: 1px solid var(--smb-gray-300); border-radius: 5px; font-size: 12px; background: #fff; resize: vertical; min-height: 64px; }

/* ============================================================
   TOOLBAR
   ============================================================ */
#sm-book-toolbar {
    flex-shrink: 0;
    width: 100%;
    min-width: 0;
    background: #fff;
    border-bottom: 1px solid var(--smb-gray-200);
    z-index: 15;
}

.sm-book-toolbar-row {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px 12px;
    overflow-x: auto;
    overflow-y: visible;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
}
.sm-book-toolbar-row::-webkit-scrollbar { height: 3px; }
.sm-book-toolbar-row::-webkit-scrollbar-thumb { background: var(--smb-gray-200); border-radius: 2px; }

.sm-book-tb-btn {
    height: 30px;
    min-width: 28px;
    padding: 0 7px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--smb-gray-600);
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
    white-space: nowrap;
    flex-shrink: 0;
}
.sm-book-tb-btn:hover  { background: var(--smb-gray-100); color: var(--smb-gray-900); }
.sm-book-tb-btn.active { background: #eef2ff; color: var(--smb-primary); border-color: #c7d2fe; }
.sm-book-tb-btn.sm-book-tb-refine { color: var(--smb-primary); background: #eef2ff; border-color: #c7d2fe; font-size: 12px; font-weight: 700; padding: 0 10px; gap: 4px; }
.sm-book-tb-btn.sm-book-tb-refine:hover { background: #c7d2fe; }
.sm-book-tb-btn.sm-book-tb-danger { color: var(--smb-danger); }
.sm-book-tb-btn.sm-book-tb-danger:hover { background: #fef2f2; }
.sm-book-tb-btn.sm-book-tb-h { font-size: 11px; font-weight: 800; padding: 0 6px; }

.sm-book-tb-sep     { width: 1px; height: 18px; background: var(--smb-gray-200); margin: 0 3px; flex-shrink: 0; }
.sm-book-tb-sep-ctx { width: 1px; height: 16px; background: #c7d2fe; margin: 0 4px; flex-shrink: 0; }

.sm-book-tb-group {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--smb-gray-200);
    border-radius: 6px;
    background: var(--smb-gray-50);
    padding: 2px 4px;
    gap: 2px;
}

.sm-book-tb-select {
    height: 28px;
    padding: 0 6px;
    border: 1px solid var(--smb-gray-200);
    border-radius: 5px;
    font-size: 12px;
    background: #fff;
    color: var(--smb-gray-700);
    cursor: pointer;
}
.sm-book-tb-font-sel { min-width: 130px; max-width: 150px; }

.sm-book-tb-px-label { font-size: 9px; font-weight: 800; color: var(--smb-gray-400); letter-spacing: .5px; padding-left: 2px; }

.sm-book-tb-input-num {
    width: 48px;
    height: 26px;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--smb-gray-800);
    padding: 0;
}
.sm-book-tb-input-num:focus { outline: none; }

/* Custom font-size spinner (δεν κλέβει focus από editor) */
.sm-book-tb-fontsize-wrap { gap: 0; }
.sm-book-tb-fs-display {
    display: inline-block;
    min-width: 30px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--smb-gray-800);
    cursor: text;
    border-radius: 4px;
    padding: 0 4px;
    user-select: none;
}
.sm-book-tb-fs-display:focus {
    outline: 2px solid var(--smb-primary);
    user-select: text;
    cursor: text;
}
.sm-book-fs-up, .sm-book-fs-down {
    width: 20px !important;
    height: 26px !important;
    padding: 0 !important;
    font-size: 9px !important;
    min-width: unset !important;
    border: none !important;
    background: transparent !important;
    color: var(--smb-gray-500) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.sm-book-fs-up:hover, .sm-book-fs-down:hover {
    color: var(--smb-primary) !important;
    background: var(--smb-gray-100) !important;
}

.sm-book-tb-headings { gap: 1px; border-radius: 6px; }

/* File input label button - matches toolbar buttons exactly */
.sm-book-tb-file-label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sm-book-color-swatch {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: 1px solid var(--smb-gray-300);
    cursor: pointer;
    background: #000;
    flex-shrink: 0;
    transition: border-color .15s;
}
.sm-book-color-swatch:hover { border-color: var(--smb-primary); }

/* ── Custom Color Panel ── */
.sm-color-panel {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--smb-gray-200);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.18);
    width: 230px;
    padding: 0;
    overflow: hidden;
}
.sm-cp-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--smb-gray-100);
}
.sm-cp-section:last-of-type { border-bottom: none; }
.sm-cp-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--smb-gray-400);
    margin-bottom: 8px;
}
.sm-cp-hex-row {
    display: flex;
    align-items: center;
    border: 1px solid var(--smb-gray-300);
    border-radius: 7px;
    overflow: hidden;
    background: #f9fafb;
    margin-bottom: 8px;
}
.sm-cp-hash {
    padding: 0 8px;
    font-size: 13px;
    color: var(--smb-gray-400);
    font-weight: 600;
    border-right: 1px solid var(--smb-gray-200);
    background: #f3f4f6;
    line-height: 30px;
}
.sm-cp-hex-inp {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    font-family: monospace;
    padding: 4px 8px;
    outline: none;
    color: var(--smb-gray-800);
    text-transform: uppercase;
}
.sm-cp-actions {
    display: flex;
    gap: 6px;
}
.sm-cp-btn {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--smb-gray-200);
    border-radius: 6px;
    background: #fff;
    font-size: 11.5px;
    color: var(--smb-gray-600);
    cursor: pointer;
    transition: all .12s;
    text-align: center;
}
.sm-cp-btn:hover { background: var(--smb-gray-50); border-color: var(--smb-gray-300); }
.sm-cp-favs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.sm-cp-add-btn {
    font-size: 10.5px;
    color: var(--smb-primary);
    background: none;
    border: 1px solid var(--smb-primary);
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    padding: 2px 7px;
    transition: background .12s;
}
.sm-cp-add-btn:hover { background: #eef2ff; }
.sm-cp-favs-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.sm-cp-fav-wrap {
    position: relative;
    display: inline-block;
}
.sm-cp-fav {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform .12s, border-color .12s;
    display: block;
}
.sm-cp-fav:hover { transform: scale(1.12); border-color: rgba(0,0,0,.2); }
.sm-cp-fav-del {
    display: none;
    position: absolute;
    top: -4px; right: -4px;
    width: 13px; height: 13px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 8px;
    line-height: 13px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    z-index: 1;
}
.sm-cp-fav-wrap:hover .sm-cp-fav-del { display: block; }
.sm-cp-os-btn {
    display: block;
    width: 100%;
    padding: 9px 14px;
    border: none;
    border-top: 1px solid var(--smb-gray-100);
    background: #f9fafb;
    font-size: 12px;
    color: var(--smb-gray-500);
    cursor: pointer;
    text-align: center;
    transition: color .12s, background .12s;
    box-sizing: border-box;
}
.sm-cp-os-btn:hover { background: #f3f4f6; color: var(--smb-primary); }

.sm-book-help-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--smb-gray-300);
    background: var(--smb-gray-100);
    color: var(--smb-gray-500);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 4px;
    vertical-align: middle;
}

/* Contextual toolbar rows */
.sm-book-tb-contextual {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    border-top: 2px solid #c7d2fe;
    background: #f5f7ff;
    padding: 4px 8px;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: visible;
    width: 100%;
    box-sizing: border-box;
    min-height: 34px;
}
.sm-book-tb-contextual::-webkit-scrollbar { height: 2px; }
.sm-book-tb-contextual::-webkit-scrollbar-thumb { background: #c7d2fe; border-radius: 2px; }

/* IMAGE contextual toolbar — icon-only compact, fits ~300px */
.sm-book-tb-image-ctx .sm-book-tb-btn {
    height: 26px;
    min-width: 26px;
    padding: 0 5px;
    flex-shrink: 0;
}
.sm-book-tb-image-ctx .sm-book-tb-group {
    background: #eef2ff;
    border-color: #c7d2fe;
    flex-shrink: 0;
}
.sm-book-tb-image-ctx #sm-book-btn-lock-ratio {
    color: #4f46e5;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
}
.sm-book-tb-image-ctx #sm-book-btn-lock-ratio.active {
    background: #4f46e5;
    color: #fff;
}
.sm-book-tb-image-ctx .sm-book-tb-danger {
    color: #dc2626;
    border: 1px solid #fca5a5;
    background: #fff5f5;
}
.sm-book-tb-image-ctx .sm-book-tb-danger:hover { background: #fee2e2; }

.sm-book-tb-ctx-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .7px;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    flex-shrink: 0;
}
.sm-book-tb-badge-image { background: #eef2ff; color: var(--smb-primary); }
.sm-book-tb-badge-table { background: #f0fdf4; color: #15803d; }


/* ============================================================
   EDITOR AREA
   ============================================================ */
#sm-book-editor-area {
    flex: 1;
    overflow-y: auto;
    background: var(--smb-gray-100);
    padding: 32px;
    position: relative;
}

#sm-book-editor-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100%;
    position: relative;
}

#sm-book-editor {
    outline: none;
    background: #fff;
    border-radius: 2px;
    position: relative;
    /* Width and padding set dynamically by sm-book-editor-styles */
}

#sm-book-editor:focus { box-shadow: 0 6px 24px rgba(79,70,229,.12); }

/* Placeholder */
#sm-book-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--smb-gray-300);
    pointer-events: none;
    font-style: italic;
}

/* Show invisibles */
.sm-book-show-invisibles p::after,
.sm-book-show-invisibles h1::after,
.sm-book-show-invisibles h2::after,
.sm-book-show-invisibles h3::after,
.sm-book-show-invisibles h4::after,
.sm-book-show-invisibles h5::after {
    content: '¶';
    color: #94a3b8;
    display: inline;
    margin-left: 4px;
    pointer-events: none;
    user-select: none;
    font-weight: normal;
    opacity: .5;
}

/* ============================================================
   METADATA EDITOR PANEL
   ============================================================ */
#sm-book-metadata-panel {
    flex: 1;
    overflow-y: auto;
    background: var(--smb-gray-100);
    padding: 0;
}

.sm-book-metadata-wrap {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 0 60px;
    font-family: 'Inter', sans-serif;
}

/* Config header banner */
.sm-meta-config-header {
    background: linear-gradient(135deg, var(--smb-primary) 0%, var(--smb-accent) 100%);
    padding: 28px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
}
.sm-meta-config-header-inner h1 {
    font-size: 24px; font-weight: 700; color: #fff; margin: 0 0 4px;
    display: flex; align-items: center;
}
.sm-meta-config-header-inner p { font-size: 13px; color: rgba(255,255,255,.75); margin: 0; }
.sm-meta-help-btn {
    width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5);
    background: transparent; color: #fff; font-size: 14px; font-weight: 700;
    cursor: pointer; flex-shrink: 0;
}

/* Config body */
.sm-meta-config-body {
    padding: 32px 40px;
    background: #fff;
    border-top: none;
}

/* Field labels */
.sm-meta-field-label {
    display: block;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .6px; color: var(--smb-gray-400); margin-bottom: 6px;
}

/* Field group */
.sm-meta-field-group { margin-bottom: 20px; }
.sm-meta-field-group .form-control { font-size: 14px; }

/* Title input */
.sm-meta-title-input { font-size: 28px !important; font-weight: 800; height: auto !important; padding: 12px 16px !important; color: #111827; }

/* Premise row: textarea left, selects right */
.sm-meta-premise-row { display: grid; grid-template-columns: 1fr 280px; gap: 24px; margin-bottom: 8px; }
.sm-meta-side-cols { display: flex; flex-direction: column; }
.sm-meta-premise-ta { min-height: 200px; font-size: 13px !important; resize: vertical; }

/* Section titles */
.sm-meta-section-title {
    font-size: 16px; font-weight: 700; color: var(--smb-gray-800);
    display: flex; align-items: center; gap: 8px;
    margin: 28px 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--smb-gray-100);
}

/* AI Writing Logic grid */
.sm-meta-ai-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}
.sm-meta-ai-card {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px;
    border: 1.5px solid var(--smb-gray-200);
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s;
    background: #fff;
}
.sm-meta-ai-card b { display: block; font-size: 13px; font-weight: 700; color: var(--smb-gray-800); margin-bottom: 3px; }
.sm-meta-ai-card small { display: block; font-size: 11px; color: var(--smb-gray-500); line-height: 1.5; }
.sm-meta-ai-card:hover { border-color: var(--smb-primary); }
.sm-meta-ai-card.checked { border-color: var(--smb-primary); background: #eef2ff; }
.sm-meta-ai-card input[type=checkbox] { flex-shrink: 0; accent-color: var(--smb-primary); width: 16px; height: 16px; margin-top: 2px; }

/* Typography header row */
.sm-meta-typo-header {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 4px;
}
.sm-meta-typo-header .sm-meta-field-group { margin-bottom: 0; }
.sm-meta-typo-header .form-control { font-size: 13px; }

/* New typography table */
.sm-fmt-table-wrap { overflow-x: auto; border: 1px solid var(--smb-gray-200); border-radius: 10px; }
.sm-fmt-table-new {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 700px;
}
.sm-fmt-table-new thead tr {
    border-bottom: 1px solid var(--smb-gray-200);
    background: #f9fafb;
}
.sm-fmt-table-new th {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--smb-gray-400);
    padding: 10px 14px; white-space: nowrap;
}
.sm-fmt-table-new td { padding: 12px 14px; vertical-align: middle; }
.sm-fmt-table-new tbody tr { border-bottom: 1px solid var(--smb-gray-100); }
.sm-fmt-table-new tbody tr:last-child { border-bottom: none; }
.sm-fmt-th-label { width: 120px; }
.sm-fmt-th-right { text-align: right; padding-right: 16px !important; }
.sm-fmt-label { padding-left: 16px !important; }
.sm-fmt-label b { font-size: 13px; font-weight: 700; color: var(--smb-gray-700); }
.sm-fmt-field-label { display: block; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--smb-gray-400); margin-bottom: 4px; }

/* Spinner input */
/* Native browser spinner inputs - no custom arrows */
.sm-fmt-spin-wrap { display: inline-flex; align-items: center; }
.sm-fmt-spin {
    width: 62px;
    padding: 4px 6px;
    border: 1px solid var(--smb-gray-300);
    border-radius: 6px;
    font-size: 12px;
    text-align: center;
}
/* Hide custom spin buttons (they are removed from HTML) */
.sm-fmt-spin-btns { display: none; }
.sm-fmt-spin-up, .sm-fmt-spin-dn { display: none; }

/* Style B/I/U toggle buttons */
.sm-fmt-style-btns { display: flex; gap: 3px; }
.sm-fmt-style-btn {
    width: 26px; height: 26px; border-radius: 5px;
    border: 1px solid var(--smb-gray-200); background: #fff;
    cursor: pointer; font-size: 13px; color: var(--smb-gray-600);
    display: flex; align-items: center; justify-content: center;
    transition: all .12s;
}
.sm-fmt-style-btn:hover { border-color: var(--smb-primary); color: var(--smb-primary); }
.sm-fmt-style-btn.active { border-color: var(--smb-primary); background: #eef2ff; color: var(--smb-primary); }

/* Line spacing select */
.sm-fmt-select {
    height: 30px; padding: 2px 4px; font-size: 12px;
    border: 1px solid var(--smb-gray-300); border-radius: 6px;
    background: #fff; min-width: 60px;
}

/* Inline fields row */
.sm-meta-inline-fields { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.sm-meta-inline-fields .sm-meta-field-group { margin-bottom: 0; }

/* Keep old fmt-color */
.sm-book-fmt-color { width: 36px; height: 30px; border: 1px solid var(--smb-gray-300); border-radius: 6px; cursor: pointer; padding: 1px; }

.sm-book-fav-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.sm-book-fav-color {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid rgba(0,0,0,.1);
    transition: transform .15s;
    display: inline-block;
}
.sm-book-fav-color:hover { transform: scale(1.15); border-color: var(--smb-primary); }
.sm-book-fav-color.active { transform: scale(1.15); border-color: var(--smb-primary); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--smb-primary); }

/* ============================================================
   MODALS
   ============================================================ */
.sm-book-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    backdrop-filter: blur(3px);
    padding: 16px;
}

.sm-book-modal-box {
    background: #fff;
    border-radius: var(--smb-radius-lg);
    box-shadow: var(--smb-shadow-lg);
    width: 100%;
    max-width: 480px;
    overflow: hidden;
    animation: sm-modal-in .18s ease-out;
}
.sm-book-modal-lg { max-width: 580px; }
.sm-book-modal-gen { max-width: 560px; max-height: 92vh; overflow-y: auto; }
.sm-book-modal-xl { max-width: 760px; }

@keyframes sm-modal-in {
    from { opacity: 0; transform: scale(.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.sm-book-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--smb-primary) 0%, var(--smb-accent) 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}
.sm-book-modal-header.sm-book-modal-indigo { background: linear-gradient(135deg, var(--smb-primary) 0%, var(--smb-accent) 100%); }

.sm-book-modal-close {
    background: transparent;
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all .15s;
}
.sm-book-modal-close:hover { color: #fff; background: rgba(255,255,255,.15); }

.sm-book-modal-body { padding: 20px; }
.sm-book-modal-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--smb-gray-500); margin-bottom: 10px; }
.sm-book-modal-textarea { width: 100%; border: 1px solid var(--smb-gray-300); border-radius: var(--smb-radius); padding: 10px 12px; font-size: 13px; min-height: 90px; resize: vertical; background: #fff; }

.sm-book-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    background: var(--smb-gray-50);
    border-top: 1px solid var(--smb-gray-200);
}

/* Generation modal options */
.sm-book-gen-section-label {
    font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
    color: var(--smb-gray-500); margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
}
/* GOAL = vertical column, LENGTH/CREATIVITY = horizontal row */
.sm-book-gen-goals   { display: flex; flex-direction: column; gap: 6px; }
.sm-book-gen-lengths { display: flex; flex-direction: row; gap: 8px; }

/* Base button */
.sm-book-gen-opt {
    border: 1.5px solid var(--smb-gray-200);
    border-radius: 8px;
    padding: 10px 14px;
    background: #fff;
    text-align: left;
    cursor: pointer;
    transition: all .15s;
    flex: 1;
    overflow: hidden;
    width: 100%;
}
/* Goal buttons: title bold left + description wrapping */
.sm-book-gen-goals .sm-book-gen-opt b {
    display: inline; font-size: 13px; font-weight: 700; color: var(--smb-gray-800);
}
.sm-book-gen-goals .sm-book-gen-opt small {
    display: block; font-size: 11.5px; color: var(--smb-gray-500);
    line-height: 1.5; margin-top: 3px; white-space: normal;
}
/* Length/Creativity buttons: stacked title + subtitle, centered */
.sm-book-gen-lengths .sm-book-gen-opt {
    text-align: center; padding: 10px 8px;
}
.sm-book-gen-lengths .sm-book-gen-opt b {
    display: block; font-size: 13px; font-weight: 700; color: var(--smb-gray-800);
}
.sm-book-gen-lengths .sm-book-gen-opt small {
    display: block; font-size: 11px; color: var(--smb-gray-400);
    margin-top: 2px; white-space: nowrap;
}
.sm-book-gen-opt:hover  { border-color: var(--smb-primary); background: #fafafa; }
.sm-book-gen-opt.active { border-color: var(--smb-primary); background: #eef2ff; box-shadow: 0 0 0 3px rgba(79,70,229,.08); }
.sm-book-gen-opt.active b { color: var(--smb-primary); }
.sm-book-gen-lengths .sm-book-gen-opt.active small { color: var(--smb-primary); opacity: .8; }

/* Extension modal */
.sm-book-ext-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--smb-gray-200); border-radius: var(--smb-radius); }
.sm-book-ext-proposal { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--smb-gray-100); font-size: 13px; cursor: pointer; }
.sm-book-ext-proposal:last-child { border-bottom: none; }
.sm-book-ext-proposal.active { background: #eef2ff; }
.sm-book-ext-proposal input { margin-top: 2px; flex-shrink: 0; }

/* Refine modal presets */
.sm-book-refine-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sm-book-refine-preset {
    border: 1px solid var(--smb-gray-200);
    border-radius: 7px;
    padding: 9px 12px 9px 10px;
    background: #fff;
    font-size: 13px;
    font-weight: 400;
    color: var(--smb-gray-700);
    text-align: left;
    cursor: pointer;
    transition: all .12s;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
}
.sm-book-refine-preset::before {
    content: '';
    width: 14px;
    height: 14px;
    min-width: 14px;
    border: 1.5px solid var(--smb-gray-300);
    border-radius: 3px;
    background: #fff;
    transition: all .12s;
}
.sm-book-refine-preset:hover { border-color: #a5b4fc; background: #f5f3ff; }
.sm-book-refine-preset.active { border-color: #c7d2fe; background: #eef2ff; color: var(--smb-primary); font-weight: 500; }
.sm-book-refine-preset.active::before {
    background: var(--smb-primary);
    border-color: var(--smb-primary);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 10px;
    background-repeat: no-repeat;
    background-position: center;
}


/* HTML Export Theme - 2 cards layout */
.sm-ht-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 8px;
}
.sm-ht-card {
    background: #f9fafb;
    border: 1px solid var(--smb-gray-200);
    border-radius: 10px;
    padding: 16px 20px;
}
.sm-ht-card-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--smb-gray-400);
    margin-bottom: 14px;
}
.sm-ht-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--smb-gray-100);
    font-size: 13px;
    color: var(--smb-gray-700);
}
.sm-ht-row:last-child { border-bottom: none; }
.sm-ht-row input[type=color] {
    width: 44px; height: 28px;
    border: 1px solid var(--smb-gray-200);
    border-radius: 5px;
    cursor: pointer; padding: 1px;
}
.sm-ht-num {
    width: 60px; text-align: center;
    border: 1px solid var(--smb-gray-300);
    border-radius: 6px; padding: 3px 6px;
    font-size: 13px;
}

/* Help modal */
.sm-book-help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sm-book-help-item b  { font-size: 13px; font-weight: 700; color: var(--smb-gray-800); }
.sm-book-help-item p  { font-size: 12px; color: var(--smb-gray-500); margin: 3px 0 0; line-height: 1.4; }
.sm-book-help-tones { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.sm-book-help-tone { background: var(--smb-gray-50); border-radius: 8px; padding: 12px; border: 1px solid var(--smb-gray-200); }
.sm-book-help-tone b { display: block; font-size: 12px; margin-bottom: 4px; }
.sm-book-help-tone p { font-size: 12px; color: var(--smb-gray-500); margin: 0; line-height: 1.4; }

/* ============================================================
   FULL-SCREEN MODALS  (Duplicate Finder, Smart Audit)
   ============================================================ */
#sm-book-dup-modal,
#sm-book-audit-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    background: var(--smb-gray-100);
}

.sm-book-fullscreen-modal { display: flex; width: 100%; height: 100%; overflow: hidden; }

.sm-book-fs-sidebar {
    width: 300px;
    background: #fff;
    border-right: 1px solid var(--smb-gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
    overflow: hidden;
}

.sm-book-fs-sidebar-header { padding: 16px; border-bottom: 1px solid var(--smb-gray-200); flex-shrink: 0; }
.sm-book-fs-sidebar-header h3 { font-size: 16px; font-weight: 700; color: var(--smb-primary); margin: 0 0 10px; }

.sm-book-fs-list { flex: 1; overflow-y: auto; padding: 8px; }

.sm-book-fs-list-item {
    padding: 10px 12px;
    border: 1px solid var(--smb-gray-200);
    border-radius: var(--smb-radius);
    background: #fff;
    cursor: pointer;
    margin-bottom: 6px;
    transition: all .15s;
}
.sm-book-fs-list-item:hover  { border-color: var(--smb-primary); }
.sm-book-fs-list-item.active { border-color: var(--smb-primary); background: #eef2ff; box-shadow: 0 0 0 1px var(--smb-primary); }

.sm-book-fs-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.sm-book-fs-topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--smb-gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    box-shadow: var(--smb-shadow-sm);
}

.sm-book-fs-content { flex: 1; overflow: hidden; }

/* Duplicate comparison grid */
.sm-book-dup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; height: 100%; }
.sm-book-dup-pane { display: flex; flex-direction: column; background: #fff; border-radius: var(--smb-radius-lg); border: 1px solid var(--smb-gray-200); overflow: hidden; }
.sm-book-dup-pane-header { padding: 12px 16px; border-bottom: 1px solid var(--smb-gray-100); background: var(--smb-gray-50); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.sm-book-dup-editor { flex: 1; overflow-y: auto; padding: 20px; font-family: 'Merriweather', serif; font-size: 14px; line-height: 1.8; color: var(--smb-gray-700); outline: none; }

.sm-book-dup-badge { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 10px; background: #eef2ff; color: var(--smb-primary); }
.sm-book-dup-badge.high { background: #fef2f2; color: var(--smb-danger); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#sm-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.sm-book-toast {
    padding: 10px 16px;
    border-radius: var(--smb-radius);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--smb-shadow);
    opacity: 0;
    transform: translateY(8px);
    transition: all .25s ease;
    max-width: 300px;
}
.sm-book-toast.show { opacity: 1; transform: translateY(0); }
.sm-book-toast-info    { background: var(--smb-gray-800); color: #fff; }
.sm-book-toast-success { background: #166534; color: #fff; }
.sm-book-toast-error   { background: #991b1b; color: #fff; }

/* ============================================================
   SPIN ANIMATION
   ============================================================ */
.sm-book-spin { display: inline-block; animation: sm-spin .7s linear infinite; }
@keyframes sm-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ============================================================
   SCROLLBARS  (WebKit)
   ============================================================ */
.sm-book-chapter-list::-webkit-scrollbar,
#sm-book-editor-area::-webkit-scrollbar,
#sm-book-metadata-panel::-webkit-scrollbar,
.sm-book-fs-list::-webkit-scrollbar,
.sm-book-modal-body::-webkit-scrollbar,
.sm-book-dup-editor::-webkit-scrollbar { width: 6px; }

.sm-book-chapter-list::-webkit-scrollbar-track,
#sm-book-editor-area::-webkit-scrollbar-track,
#sm-book-metadata-panel::-webkit-scrollbar-track,
.sm-book-fs-list::-webkit-scrollbar-track,
.sm-book-dup-editor::-webkit-scrollbar-track { background: transparent; }

.sm-book-chapter-list::-webkit-scrollbar-thumb,
#sm-book-editor-area::-webkit-scrollbar-thumb,
#sm-book-metadata-panel::-webkit-scrollbar-thumb,
.sm-book-fs-list::-webkit-scrollbar-thumb,
.sm-book-dup-editor::-webkit-scrollbar-thumb { background: var(--smb-gray-300); border-radius: 3px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    :root { --smb-sidebar-w: 260px; }
    .sm-book-setup-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    #sm-book-sidebar { position: fixed; top: var(--smb-topbar-h); left: 0; bottom: 0; transform: translateX(-100%); transition: transform .25s ease; z-index: 50; width: 280px; box-shadow: var(--smb-shadow-lg); }
    #sm-book-sidebar.open { transform: translateX(0); }
    .sm-book-setup-card { padding: 28px 20px; }
    .sm-book-dup-grid { grid-template-columns: 1fr; }
    .sm-book-fs-sidebar { width: 100%; }
}

/* ============================================================
   ACCOUNT MODAL TABS
   ============================================================ */
.sm-account-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
}

.sm-account-tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -2px;
}

.sm-account-tab:hover:not(.active) {
    color: #374151;
}

.sm-account-tab.active {
    color: #111827;
    font-weight: 600;
    border-bottom-color: var(--smb-primary);
}

.sm-account-tab-content {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
