:root {
    --bg: #f8fafc; --card: #ffffff; --text: #1e293b;
    --border: #e2e8f0; --primary: #2563eb; --editor-bg: #ffffff;
    --highlight-complex: #ffd500;
    --highlight-complex-bg: rgba(255, 213, 0, 0.2);
    --highlight-passive: #9333ea;
    --highlight-passive-bg: rgba(147, 51, 234, 0.2);
    --highlight-clutter: #ef4444;
    --highlight-clutter-bg: rgba(239, 68, 68, 0.2);
}

body.dark-mode {
    --bg: #0f172a; --card: #1e293b; --text: #f1f5f9;
    --border: #334155; --primary: #60a5fa; --editor-bg: #1e293b;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    margin: 0;
    transition: all 0.3s ease;
}

bold {font-weight:bold;}
italic {font-style:italic;}

div.logo img {width:100%;}

div.nav-controls {display:flex;}

/* Sidebar Toggle Logic */
body.clean-mode .sidebar {
    display: none !important;
}

body.clean-mode .complex-word, 
body.clean-mode .passive-highlight, 
body.clean-mode .clutter-highlight {
    background-color: transparent !important;
    border-bottom: none !important;
}

.app-container {
    display: flex;
    max-width: 1200px;
    margin: 20px auto;
    gap: 20px;
    padding: 0 20px;
}

.editor-section { flex: 3; }
.sidebar { flex: 1; }

#themeToggle {padding-right:10px;}
div.nav-controls {margin: 0px auto;max-width:1200px;padding-left:5px;}
div.nav-controls div.view-toggle, div.editor-header div.view-toggle {padding-left:10px;display:flex;align-items:center;}
div.nav-controls div.view-toggle span, div.editor-header div.view-toggle span {font-size:small;padding:0.4rem;}
div.nav-controls button, div.editor-header button {padding:4px 12px;}
div.editor-header div {display:inline-block; padding-left:0.5rem;}
span.dress-right {margin-right:2rem;}
span.dress-right {margin-right:auto;}
#save-status {color: #64748b; font-size: 0.85rem;margin-left:10px;}

div.editor-header small {color: #64748b; margin-left: 10px; font-weight: normal;}
div.editor-header button {padding:6.4px 12px;}
div.editor-header button i {margin-left:0.5em;margin-right:0.25em;}

.editor-header {
    padding-left: 5px;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* The switch - the box around the slider */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 25px;
  /* height: 34px; */
}

/* Hide default HTML checkbox */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* The slider */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.stat-card {
    background: var(--card);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    text-align: center;
}

.stat-item{
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-label {
    margin-right:2rem;
    text-align: left;
}

.stat-value {
    text-align: right;
}

.sidebar .stat-card.draftwrite-promo-card {
    background: #1e293b;
    padding: 30px 20px !important;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    text-align: center;
    color: #ffffff;
}

div.draftwrite-promo-card img {
    width: 100%;
    max-width: 300px;
    height:auto;
    margin: 0 auto;
}

div.midpage-ad img {
    width: 100%;
    max-width: 900px;
    height:auto;
    margin: 0 auto;
}

.editor-toolbar {
    background: var(--card);
    border: 1px solid var(--border);
    border-bottom: none;
    padding: 5px;
    border-radius: 12px 12px 0 0;
}
.editor-toolbar button {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    cursor: pointer;
    padding: 5px;
    margin: 0 2px;
    border-radius: 4px;
    min-width: 28px;
    text-align:center;
}
.editor-toolbar button:hover {
    background: var(--bg);
    border-color: var(--border);
}

.editor-toolbar select {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
    margin: 0 2px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
}
.editor-toolbar select:hover {
    background: var(--bg);
    border-color: var(--border);
}
.editor-toolbar .toolbar-number {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    cursor: pointer;
    padding: 4px 2px;
    margin: 0 2px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
    width: 46px;
}
.editor-toolbar .toolbar-number:hover {
    background: var(--bg);
    border-color: var(--border);
}
.font-size-picker {
    position: relative;
    display: inline-block;
}
.font-size-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    z-index: 1000;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    min-width: 56px;
    max-height: 200px;
    overflow-y: auto;
}
.font-size-dropdown.open {
    display: block;
}
.font-size-option {
    padding: 5px 10px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.font-size-option:hover {
    background: var(--bg);
}
.toolbar-label {
    font-size: 0.75rem;
    color: var(--text-muted, var(--text));
    opacity: 0.6;
    user-select: none;
    margin-right: -4px;
}
.toolbar-color-swatch {
    width: 26px;
    height: 26px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    margin: 0 2px;
    vertical-align: middle;
}
.toolbar-color-swatch:hover {
    border-color: var(--primary, #2563eb);
}
.editor-toolbar .toolbar-separator {
    display: inline-block;
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
    vertical-align: middle;
    opacity: 0.5;
}

/* Quick Apply Margins */
.b-05 {margin-bottom:5px;}
.t-05 {margin-top:5px;}
.l-05 {margin-left:5px;}
.r-05 {margin-right:5px;}
.b-10 {margin-bottom:10px;}
.t-10 {margin-top:10px;}
.l-10 {margin-left:10px;}
.r-10 {margin-right:10px;}
.b-15 {margin-bottom:15px;}
.t-15 {margin-top:15px;}
.l-15 {margin-left:15px;}
.r-15 {margin-right:15px;}
.b-20 {margin-bottom:20px;}
.t-20 {margin-top:20px;}
.l-20 {margin-left:20px;}
.r-20 {margin-right:20px;}
.b-25 {margin-bottom:25px;}
.t-25 {margin-top:25px;}
.l-25 {margin-left:25px;}
.r-25 {margin-right:25px;}
.b-30 {margin-bottom:30px;}
.t-30 {margin-top:30px;}
.l-30 {margin-left:30px;}
.r-30 {margin-right:30px;}
.b-40 {margin-bottom:40px;}
.t-40 {margin-top:40px;}
.l-40 {margin-left:40px;}
.r-40 {margin-right:40px;}


#editableArea {
    min-height: 500px;
    padding: 30px;
    background: var(--editor-bg);
    border-radius: 0 0 12px 12px;
    border: 1px solid var(--border);
    outline: none;
    line-height: 1.6;
    color: var(--text);
}

#editableArea h1, #editableArea h2, #editableArea h3, #editableArea h4, #editableArea h5, #editableArea h6 {text-align:center;}

#editableArea.drag-over {
    border: 2px dashed var(--primary);
    background-color: rgba(37, 99, 235, 0.05);
}

#editableArea.is-empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    pointer-events: none;
    display: block;
}

/* Force high contrast text in dark mode, overriding pasted inline styles */
body.dark-mode #editableArea,
body.dark-mode #editableArea *:not(a) {
    color: var(--text) !important;
}

body.dark-mode #editableArea {
    background-color: #152232;
}

body.dark-mode #editableArea a {
    color: var(--primary) !important;
}

/* FAQ Section and Glossary */
.faq-section, #glossary, .seo-content {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

#glossary dt {
    font-weight: 700;
    margin-top: 1.5rem;
    color: var(--primary);
    font-size: 1.1rem;
}

#glossary dd {
    margin-left: 0;
    margin-top: 0.5rem;
    line-height: 1.6;
    padding-left: 1rem;
    border-left: 3px solid var(--border);
}

details {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 15px;
    cursor: pointer;
}

summary {
    font-weight: 600;
    color: var(--primary);
    list-style: none;
}

summary::-webkit-details-marker { display: none; }

details p {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.5;
}

/* Modal Styles*/
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-header h2 span { color: var(--primary); }
.alert-h2 {color:#ef4444;}
.congrats-h2 {color:#10b981;}

.modal-button-row {display: flex;justify-content: flex-end;gap: 10px;margin-top: 20px;}
.alert-modal-btn {padding:10px 20px; background:#ef4444; color:white; border:none; border-radius:4px; cursor:pointer;font-weight:bold; margin-top:10px;}
.caution-modal-btn {padding:8px 16px; background:#ef4444; color:white; border:none; border-radius:4px; cursor:pointer;}
.confirm-modal-btn {padding:8px 16px; background:#2563eb; color:white; border:none; border-radius:4px; cursor:pointer;}
.congrats-modal-btn {padding:10px 20px; background:#10b981; color:white; border:none; border-radius:4px; cursor:pointer; font-weight:bold; margin-top:10px;}
.inverse-modal-btn {padding:8px 16px; border:1px solid #ccc; background:white; border-radius:4px; cursor:pointer;}

.select-box {width: 100%; padding: 10px; margin: 10px 0; border: 1px solid var(--border); border-radius: 4px; font-size: 1rem; background-color: white;}
.modal-textbox {width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem;}

/* Settings Modal */
.settings-modal {
    max-width: 620px;
    width: 95%;
    padding: 0;
    background: var(--card, white);
    color: var(--text, #1e293b);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    flex-shrink: 0;
}
.settings-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-close-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text, #1e293b);
    line-height: 1;
    padding: 0 4px;
    opacity: 0.6;
}
.settings-close-btn:hover { opacity: 1; }
.settings-body {
    overflow-y: auto;
    padding: 0 24px;
    flex: 1;
}
.settings-section {
    padding: 16px 0;
    border-bottom: 1px solid var(--border, #e2e8f0);
}
.settings-section:last-child { border-bottom: none; }
.settings-section h3 {
    margin: 0 0 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary, #2563eb);
}
.settings-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px 16px;
    align-items: center;
}
.settings-grid > label {
    font-size: 0.85rem;
    font-weight: 500;
}
.settings-grid select,
.settings-grid input[type="number"] {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg, #f8fafc);
    color: var(--text, #1e293b);
}
.settings-grid input[type="color"] {
    padding: 2px 4px;
    height: 32px;
    width: 100%;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    cursor: pointer;
    background: var(--bg, #f8fafc);
}
.settings-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-inline input[type="number"] {
    width: 70px;
    flex-shrink: 0;
}
.settings-inline input[type="color"] {
    width: 36px;
    height: 32px;
    flex-shrink: 0;
    padding: 2px 4px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    cursor: pointer;
}
.settings-unit {
    font-size: 0.8rem;
    color: var(--text, #1e293b);
    opacity: 0.6;
}
.settings-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal !important;
    margin: 0;
}
.settings-toggle input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary, #2563eb);
}
.settings-toggle span {
    font-size: 0.85rem;
}
.settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border, #e2e8f0);
    flex-shrink: 0;
}
.settings-gear-btn {
    padding: 6px 10px;
}

/* Feature List */
.feature-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.feature-list li {
    margin-bottom: 12px;
    font-size: 0.95rem;
    display: flex;
    align-items: flex-start;
}

/* Highlighting styles */
.complex-word {
    background-color: var(--highlight-complex-bg);
    border-bottom: 2px solid var(--highlight-complex);
}
.passive-highlight {
    background-color: var(--highlight-passive-bg);
    border-bottom: 2px solid var(--highlight-passive);
}
.clutter-highlight {
    background-color: var(--highlight-clutter-bg);
    border-bottom: 2px solid var(--highlight-clutter);
    cursor: pointer;
}

/* Legend styles */
.legend-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    align-items: center;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.legend-item label { font-size: 0.8rem; }
.legend-item input[type="color"] {
    width: 24px; height: 24px; padding: 0;
    border: 1px solid var(--border); border-radius: 4px;
    background: transparent; cursor: pointer;
}

/* Back to Top Button */
#backToTopBtn {
    display: none; /* Hidden by default */
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99;
    font-size: 24px;
    border: none;
    outline: none;
    background-color: var(--primary);
    color: white;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: background-color 0.3s, transform 0.3s;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#backToTopBtn:hover {
    background-color: #1d4ed8; /* Darker shade fallback */
    filter: brightness(0.9); /* Works for variable colors */
    transform: translateY(-3px);
}

/* Print Styles */
@media print {
    body {
        background-color: white !important;
        color: black !important;
    }
    .navbar, .sidebar, .editor-header, .editor-toolbar, 
    .seo-content, .faq-section, #glossary, footer, #backToTopBtn,
    .modal-overlay {
        display: none !important;
    }

    .app-container {
        display: block;
        margin: 0;
        padding: 0;
        max-width: 100%;
    }

    #editableArea {
        border: none;
        padding: 0;
        min-height: auto;
        color: black !important;
    }
}

/* Full Screen Mode */
:fullscreen .faq-section,
:fullscreen #glossary,
:fullscreen footer,
:fullscreen #backToTopBtn {
    display: none !important;
}

:fullscreen body {
    overflow-y: auto;
}

:fullscreen .app-container {
    display: flex;
    max-width: 100%;
    margin: 0;
    padding: 0 20px;
    align-items: flex-start;
}

:fullscreen .editor-section {
    padding: 40px 20px;
}

:fullscreen #editableArea {
    min-height: 80vh;
    border: none;
}

/* Full Screen Mode - WebKit Support */
:-webkit-full-screen .faq-section,
:-webkit-full-screen #glossary,
:-webkit-full-screen footer,
:-webkit-full-screen #backToTopBtn {
    display: none !important;
}

:-webkit-full-screen body {
    overflow-y: auto;
}

:-webkit-full-screen .app-container {
    display: flex;
    max-width: 100%;
    margin: 0;
    padding: 0 20px;
    align-items: flex-start;
}

:-webkit-full-screen .editor-section {
    padding: 40px 20px;
}

:-webkit-full-screen #editableArea {
    min-height: 80vh;
    border: none;
}

/* Set margin for first stat-card in seo-content */
.seo-content .sidebar .stat-card:first-child {
    margin-top: 50px;
    padding-top:15px;
    padding-bottom:15px;
    margin-bottom:20px;
}

/* Minimize size of stat-cards in app-container */
.app-container .sidebar .stat-card {margin:15px 0;padding:15px 20px;}
.app-container .sidebar .stat-card h4 {font-size:0.8rem;margin-top:0px;margin-bottom:10px;}
.app-container .sidebar .stat-card p {font-size:0.8rem;margin-top:10px;margin-bottom:0;}
.stat-card .stat-grid .stat-item .stat-label {font-size:0.8rem;}
.stat-card .stat-grid .stat-item .stat-value {font-size:0.8rem;}

/* Minimize size of stat-cards in seo-content */
.seo-content .sidebar .stat-card {margin:15px 0;padding:15px 20px;}
.seo-content .sidebar .stat-card h4 {font-size:0.8rem;margin-top:0px;margin-bottom:10px;}
.seo-content .sidebar .stat-card p {font-size:0.8rem;margin-top:10px;margin-bottom:0;}

#share-card button {color:#f1f5f9 !important;}

.timer {font-size: 2rem; font-weight: 700; color: var(--primary); margin: 10px 0;}
.timer-btn-row {display: flex; gap: 10px; margin-bottom: 10px;}
.timer-btn {flex: 1;}

/* SEO Content Text Color */
.seo-content .editor-section {color: #475569;}
.seo-content .editor-section h3 {color: var(--primary);}

body.dark-mode .seo-content .editor-section {color: var(--text);}
body.dark-mode .seo-content .editor-section h3 {color: var(--primary);}

/* Visual Graph Styles */
.graph-container {
/*  margin: 20px 0; */
    margin: 15px 0;
    position: relative;
}
/* Base style for all tracks */
.graph-track { 
    height: 24px;
    background: var(--border); /* Default background */
    position: relative; /* For positioning children */
    width: 100%;
    border-radius: 4px; /* Default to rectangular */
}

/* Flesch-Kincaid specific arrow shape */
.graph-track-fk {
    background: transparent;
}

.graph-track-fk::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    clip-path: polygon(0% 0%, 93% 0%, 100% 50%, 93% 100%, 0% 100%);
    border-radius: 4px 0 0 4px;
    z-index: 0;
}

/* Base style for ideal zones */
.graph-ideal-zone {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #4ade80; /* Green color */
    opacity: 0.7;
    z-index: 1; /* Ensure it's above the track but below the marker */
}
.graph-target-label {color:#10b981; font-weight:bold;}

/* Flesch-Kincaid specific positioning */
/* This was previously .graph-ideal-zone, now it's a modifier */
.graph-ideal-zone-fk {
    position: absolute;
    top: 0; bottom: 0;
    background-color: #4ade80;
    left: 38.8%; /* 7/18 */
    width: 11.2%; /* (9-7)/18 */
    opacity: 0.7;
    z-index: 1;
}
/* Flesch Reading Ease specific positioning */
.graph-ideal-zone-fre {
    left: 60%; /* 60/100 */
    width: 10%; /* (70-60)/100 */
}

/* Gunning Fog specific arrow shape */
.graph-track-gf {
    background: transparent;
}

.graph-track-gf::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    clip-path: polygon(0% 0%, 93% 0%, 100% 50%, 93% 100%, 0% 100%);
    border-radius: 4px 0 0 4px;
    z-index: 0;
}
.graph-ideal-zone-gf {
    left: 20%; /* 6/30 */
    width: 16.66%; /* (11-6)/30 */
}

/* SMOG specific arrow shape */
.graph-track-smog {
    background: transparent;
}
.graph-track-smog::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    clip-path: polygon(0% 0%, 93% 0%, 100% 50%, 93% 100%, 0% 100%);
    border-radius: 4px 0 0 4px;
    z-index: 0;
}
.graph-ideal-zone-smog {
    left: 0%; /* (4-4)/14 */
    width: 28.57%; /* (8-4)/14 */
}

/* Coleman-Liau specific double arrow shape */
.graph-track-cl {
    background: transparent;
}
.graph-track-cl::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    clip-path: polygon(0% 50%, 7% 0%, 93% 0%, 100% 50%, 93% 100%, 7% 100%);
    border-radius: 0;
    z-index: 0;
}
.graph-ideal-zone-cl {
    left: 40%; /* (7-1)/15 */
    width: 20%; /* (10-7)/15 */
}

/* ARI specific arrow shape */
.graph-track-ari {
    background: transparent;
}
.graph-track-ari::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    clip-path: polygon(0% 0%, 93% 0%, 100% 50%, 93% 100%, 0% 100%);
    border-radius: 4px 0 0 4px;
    z-index: 0;
}
.graph-ideal-zone-ari {
    left: 40%; /* (7-1)/15 */
    width: 13.33%; /* (9-7)/15 */
}

/* Dale-Chall specific double arrow shape */
.graph-track-dc {
    background: transparent;
}
.graph-track-dc::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    clip-path: polygon(0% 50%, 7% 0%, 93% 0%, 100% 50%, 93% 100%, 7% 100%);
    border-radius: 0;
    z-index: 0;
}
.graph-ideal-zone-dc {
    left: 0%; 
    width: 39.2%; /* (6.9-4.9)/5.1 */
}

.graph-marker {
    position: absolute;
    top: 0; bottom: 0;
    width: 4px;
    background-color: var(--primary);
    left: 0;
    transition: left 0.3s ease-out;
    z-index: 5;
    cursor: help;
}

/* Tooltip Bubble */
.graph-marker:hover::after {
    content: attr(data-score);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text);
    color: var(--bg);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    margin-bottom: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    pointer-events: none;
}

/* Tooltip Triangle */
.graph-marker:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--text);
    margin-bottom: -4px;
    pointer-events: none;
}

/* General purpose tooltip for stat badges */
.has-tooltip {
    position: relative;
    cursor: help;
}

.has-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text);
    color: var(--bg);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: normal;
    width: 220px;
    text-align: left;
    margin-bottom: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.has-tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text);
    margin-bottom: -2px;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.has-tooltip:hover::after,
.has-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

.custom-tooltip {
    position: absolute;
    background-color: var(--text);
    color: var(--bg);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
    width: 220px;
    text-align: left;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    z-index: 10000;
    pointer-events: auto;
}

.custom-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text);
}

.tooltip-fix-btn {
    background: var(--primary);
    color: white !important; /* Override potential inherited text color */
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    margin-top: 8px;
    cursor: pointer;
    display: block;
    font-size: 0.75rem;
}
.graph-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 8px;
}

/* Footer */
footer {
    text-align:center;
    padding: 40px;
    border-top: 1px solid #e2e8f0;
    font-size: 0.9rem;
    color: #64748b;
}

footer .stat-card h4 {font-size: 0.85rem; margin:0 0 10px 0;}
footer .stat-card p {font-size: 0.75rem; color:#64748b; margin-bottom:10px;}

body.dark-mode footer {color: var(--text) !important;}
body.dark-mode footer .stat-card p {color: var(--text) !important;}

/* Sentence Variance Chart */
.variance-chart {
    display: flex;
    align-items: flex-end;
    height: 40px;
    margin-top: 15px;
    gap: 2px;
    opacity: 0.8;
    border-bottom: 1px solid var(--border);
}

.variance-bar {
    flex: 1;
    background-color: var(--primary);
    border-radius: 2px 2px 0 0;
    min-width: 3px;
    transition: height 0.3s ease;
}

.variance-bar:hover {
    opacity: 0.6;
    cursor: help;
}

/* Style Card Flex Layout */
.style-flex-container {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
}

.style-left-col, .style-right-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#sentiment-badge, #tone-badge {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary);
}

/* Tone-based Card Backgrounds */
.stat-card {transition: background-color 0.3s ease, border-color 0.3s ease;}
.stat-card.tone-academic { background-color: #f1f5f9; border-color: #cbd5e1; }
.stat-card.tone-conversational { background-color: #f0fdf4; border-color: #86efac; }
.stat-card.tone-casual { background-color: #fffbeb; border-color: #fde047; }
.stat-card.tone-urgent { background-color: #fef2f2; border-color: #fca5a5; }
.stat-card.tone-professional { background-color: #f8fafc; border-color: #cbd5e1; }
.stat-card.tone-persuasive { background-color: #faf5ff; border-color: #d8b4fe; }
.stat-card.tone-technical { background-color: #ecfeff; border-color: #67e8f9; }
.stat-card.tone-legal { background-color: #f1f5f9; border-color: #94a3b8; }
.stat-card.tone-medical { background-color: #f0fdfa; border-color: #5eead4; }
.stat-card.tone-financial { background-color: #f0fdf4; border-color: #86efac; }
.stat-card.tone-marketing { background-color: #fff7ed; border-color: #fdba74; }
.stat-card.tone-creative { background-color: #fdf2f8; border-color: #f9a8d4; }

/* Dark Mode Tone Overrides (Subtle Tints) */
body.dark-mode .stat-card.tone-academic { background-color: rgba(59, 130, 246, 0.15); border-color: #475569; }
body.dark-mode .stat-card.tone-conversational { background-color: rgba(34, 197, 94, 0.15); border-color: #15803d; }
body.dark-mode .stat-card.tone-casual { background-color: rgba(234, 179, 8, 0.15); border-color: #a16207; }
body.dark-mode .stat-card.tone-urgent { background-color: rgba(239, 68, 68, 0.15); border-color: #b91c1c; }
body.dark-mode .stat-card.tone-professional { background-color: rgba(100, 116, 139, 0.15); border-color: #475569; }
body.dark-mode .stat-card.tone-persuasive { background-color: rgba(168, 85, 247, 0.15); border-color: #7e22ce; }
body.dark-mode .stat-card.tone-technical { background-color: rgba(6, 182, 212, 0.15); border-color: #0e7490; }
body.dark-mode .stat-card.tone-legal { background-color: rgba(148, 163, 184, 0.15); border-color: #64748b; }
body.dark-mode .stat-card.tone-medical { background-color: rgba(20, 184, 166, 0.15); border-color: #0d9488; }
body.dark-mode .stat-card.tone-financial { background-color: rgba(34, 197, 94, 0.15); border-color: #15803d; }
body.dark-mode .stat-card.tone-marketing { background-color: rgba(249, 115, 22, 0.15); border-color: #c2410c; }
body.dark-mode .stat-card.tone-creative { background-color: rgba(236, 72, 153, 0.15); border-color: #be185d; }

.custom-button {
  background-image: linear-gradient(123deg, #355bc4 7%, #3783d6 24%, #69d0da 64%, #3783d6 85%);
  /* background-image: linear-gradient(123deg, #355bc4 7%, #3783d6 24%, #69d0da 44%, #3783d6 85%); */
  color: #ffffff;
  border: none;
  border-radius: 4px;
  /* padding: 4px 12px; */
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0px 4px 6px 0px #000000;
  transition: all 0.3s ease;
  background-size: 200% 100%;
  background-position: left;
}

.custom-button:hover, body.dark-mode .custom-button:hover {
  color: #ffffff;
  box-shadow: 0px 4px 6px 0px #000000;
  background-position: right;
}

body.dark-mode .custom-button {
  background-image: linear-gradient(135deg, #355bc4 30%, #3683d6 41%, #355bc4 63%, #272e91 100%);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  /* padding: 4px 12px; */
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0px 4px 6px 0px #000000;
  transition: all 0.3s ease;
  background-size: 200% 100%;
  background-position: left;}


/* --- RESPONSIVE DESIGN --- */

/* Tablet Portrait and below */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        gap: 30px;
    }

    .editor-section, .sidebar {
        width: 100%;
        flex: none; /* Disable flex-grow/shrink */
    }
}

/* Mobile phones */
@media (max-width: 768px) {
    .app-container {
        padding: 0 10px;
        margin: 10px auto;
    }

    .editor-header, .editor-toolbar {
        flex-wrap: wrap;
        padding: 5px;
        gap: 5px;
    }

    #editableArea {
        padding: 20px 15px;
        min-height: 400px;
    }

    /* Stack tone and sentiment on mobile */
    .style-flex-container {
        flex-direction: column;
        gap: 20px;
    }

    .seo-content, .faq-section, #glossary {
        padding: 0 10px;
        display: block; /* Fix for vertical header text */
    }

    .seo-content h1, .seo-content h2, .seo-content h3, .seo-content h4,
    .faq-section h1, .faq-section h2, .faq-section h3, .faq-section h4,
    #glossary h1, #glossary h2, #glossary h3, #glossary h4 {
        width: 100%;
        display: block;
        box-sizing: border-box;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    #backToTopBtn {display: none !important;}

    .editor-header .btn-label {display: none !important;}
}