/* assets/style.css - TabNook Main Stylesheet */
/* Version: 1.13 - Fixed mobile landscape layout to prevent widget z-axis stacking */

/* ===== CSS Variable Definitions ===== */
:root {
    /* These theme variables are set inline in index.php from database values */
    /* Listed here for reference:
     --tn-primary-900, --tn-primary-700, --tn-primary-500, --tn-primary-300
     --tn-accent-700, --tn-accent-600, --tn-accent-500
     --tn-background, --tn-danger, --tn-border, --tn-success
     --widget-bg, --widget-fg, --page-bg, --page-fg
  */

    /* Legacy variable mappings */
    --tn-teal-900: var(--tn-primary-900);
    --tn-teal-700: var(--tn-primary-700);
    --tn-teal-500: var(--tn-primary-500);
    --tn-teal-300: var(--tn-primary-300);
    --tn-orange-700: var(--tn-accent-700);
    --tn-orange-600: var(--tn-accent-600);
    --tn-orange-500: var(--tn-accent-500);
    --tn-cream: var(--tn-background);
    --tn-add: var(--tn-success);

    /* Layout dimensions */
    --sidebar-w: 260px;
    --sidebar-collapsed: 28px;
}

/* ===== Base Styles ===== */
body {
    background: var(--tn-background) !important;
}

/* ===== Navbar ===== */
.navbar {
    background: linear-gradient(90deg, var(--tn-primary-900), var(--tn-primary-700));
    flex-wrap: nowrap !important;
    /* Prevent wrapping */
    gap: 0.5rem;
}

/* Right side container - protect from shrinking */
.navbar>.ms-auto {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
}

.navbar-brand {
    flex: 0 0 auto;
    /* Don't grow or shrink */
}

.brand-img {
    height: 84px;
    display: block;
    transition: height 0.3s ease;
}

.brand-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.brand-tagline {
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(0.7rem, 1.2vw, 1rem);
    margin-top: 0.25rem;
    white-space: nowrap;
    transition: font-size 0.3s ease;
}

/* Responsive navbar adjustments */
@media (max-width: 1500px) {
    .navbar .btn {
        padding: 0.35rem 0.65rem;
        font-size: 0.875rem;
    }

    .navbar .btn img {
        width: 24px !important;
        height: 24px !important;
    }
}

@media (max-width: 1300px) {
    .navbar .btn {
        padding: 0.3rem 0.55rem;
        font-size: 0.85rem;
    }

    .navbar .btn img {
        width: 22px !important;
        height: 22px !important;
    }
}

@media (max-width: 1100px) {
    .brand-img {
        height: 75px;
    }

    .navbar .btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }

    .navbar .btn img {
        width: 20px !important;
        height: 20px !important;
    }
}

@media (max-width: 950px) {
    .brand-img {
        height: 70px;
    }
}

@media (max-width: 800px) {
    .brand-img {
        height: 60px;
    }

    .navbar .btn {
        padding: 0.25rem 0.45rem;
        font-size: 0.75rem;
    }

    .navbar .btn img {
        width: 18px !important;
        height: 18px !important;
    }
}


/* ===== Weather and Greeting Card ===== */
.weather-greeting-card {
    background: linear-gradient(135deg, #E8F4F8 0%, #FFFFFF 100%);
    border-radius: 10px;
    border: 2px solid var(--tn-primary-300);
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 6px rgba(30, 138, 122, 0.15);
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-right: 1rem;
    min-width: 0;
    /* Allow shrinking */
    flex: 0 1 auto;
    /* Don't grow, but allow shrinking */
    transition: all 0.3s ease;
}

.weather-greeting-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.greeting-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    overflow: hidden;
    flex-shrink: 1;
}

.greeting-text {
    color: var(--tn-primary-900);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.greeting-name {
    color: var(--tn-primary-700);
    font-size: 0.75rem;
    opacity: 0.9;
}

.weather-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 1px solid var(--tn-border);
    padding-left: 1rem;
    min-width: 0;
    flex-shrink: 1;
}

.weather-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #91ebfd;
    /* Much more opaque white */
    border: 1px solid rgba(30, 138, 122, 0.2);
    /* Subtle teal border */
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    /* Stronger shadow */
}

.weather-icon {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
    /* Add shadow to icon itself */
}

/* Fix red/orange sun to be yellow for sunny and partly cloudy icons */
.weather-icon.sunny {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 1.2)) hue-rotate(45deg) saturate(31.3);
}

.weather-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    overflow: hidden;
}

.weather-temp {
    color: var(--tn-primary-900);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1;
}

.weather-desc {
    color: var(--tn-primary-700);
    font-size: 0.7rem;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.weather-location {
    color: var(--tn-primary-700);
    font-size: 0.65rem;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.weather-loading {
    color: var(--tn-primary-700);
    font-size: 0.8rem;
    font-style: italic;
}

.weather-error {
    color: var(--tn-danger);
    font-size: 0.75rem;
}

/* Responsive adjustments for weather card */
@media (max-width: 1500px) {
    .weather-greeting-card {
        padding: 0.65rem 0.9rem;
        gap: 0.85rem;
    }

    .weather-temp {
        font-size: 1.15rem;
    }

    .greeting-text {
        font-size: 0.85rem;
    }

    .brand-tagline {
        font-size: 0.85rem;
    }
}

@media (max-width: 1300px) {
    .weather-greeting-card {
        padding: 0.6rem 0.8rem;
        gap: 0.75rem;
    }

    .weather-temp {
        font-size: 1.1rem;
    }

    .greeting-text {
        font-size: 0.8rem;
    }

    .brand-tagline {
        font-size: 0.75rem;
    }
}

@media (max-width: 1100px) {
    .weather-greeting-card {
        padding: 0.55rem 0.7rem;
        gap: 0.7rem;
    }

    .weather-icon-wrapper {
        width: 36px;
        height: 36px;
        padding: 4px;
        border-radius: 8px;
        background: #91ebfd;
        border: 1px solid rgba(30, 138, 122, 0.2);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    }

    .weather-icon {
        width: 36px;
        height: 36px;
    }

    .weather-temp {
        font-size: 1.05rem;
    }

    .greeting-text {
        font-size: 0.75rem;
    }

    .weather-desc,
    .weather-location {
        font-size: 0.65rem;
    }

    .brand-tagline {
        font-size: 0.65rem;
    }
}

@media (max-width: 950px) {
    .weather-greeting-card {
        padding: 0.5rem 0.65rem;
    }

    .weather-icon-wrapper {
        width: 32px;
        height: 32px;
        padding: 4px;
        border-radius: 8px;
        background: #91ebfd;
        border: 1px solid rgba(30, 138, 122, 0.2);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    }

    .weather-icon {
        width: 32px;
        height: 32px;
    }

    .weather-temp {
        font-size: 1rem;
    }

    .greeting-text {
        font-size: 0.7rem;
    }

    .weather-desc,
    .weather-location {
        font-size: 0.6rem;
    }

    .brand-tagline {
        display: none;
    }
}

@media (max-width: 1100px) {

    /* Hide greeting section, show only weather */
    .greeting-section {
        display: none;
    }

    .weather-section {
        border-left: none;
        padding-left: 0;
    }
}

@media (max-width: 768px) {
    .weather-greeting-card {
        display: none;
    }
}

/* ===== Quotes Container ===== */
.quotes-container {
    flex: 1 1 0;
    margin: 0 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
    justify-content: center;
    min-width: 0;
    /* Allow shrinking below content size */
    overflow: hidden;
    /* Hide overflow instead of letting it spill */
}

.quote-card {
    background: linear-gradient(135deg, #FFF9F0 0%, #FFEFD5 100%);
    border-radius: 8px;
    border-left: 4px solid var(--tn-accent-500);
    padding: 0.7rem 0.9rem;
    padding-right: 2rem;
    padding-left: 1.5rem;
    box-shadow: 0 2px 8px rgba(239, 138, 23, 0.15);
    flex: 0 1 auto;
    /* Allow shrinking */
    width: auto;
    max-width: 450px;
    /* Start with a smaller default max */
    min-width: 180px;
    /* Minimum before hiding */
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    transition: opacity 0.3s ease, max-width 0.3s ease, padding 0.3s ease, font-size 0.3s ease;
}

.quote-card::before {
    content: '"';
    position: absolute;
    left: 0.3rem;
    top: -0.2rem;
    font-size: 2.5rem;
    color: var(--tn-accent-500);
    opacity: 0.3;
    font-family: Georgia, serif;
    line-height: 1;
}

.quote-card.hiding {
    opacity: 0;
}

.quote-close {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: transparent;
    border: none;
    color: var(--tn-primary-700);
    opacity: 0.5;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
    font-size: 1rem;
    transition: opacity 0.2s;
}

.quote-close:hover {
    opacity: 0.8;
}

.quote-text {
    color: #5D4E37;
    font-size: 0.9rem;
    line-height: 1.4;
    margin: 0;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    word-wrap: break-word;
}

.quote-author {
    color: var(--tn-primary-700);
    font-size: 0.8rem;
    text-align: right;
    margin-top: 0.25rem;
    opacity: 0.8;
    white-space: nowrap;
}

/* Responsive adjustments for quotes - progressive narrowing */
/* Start narrowing much earlier to prevent navbar wrapping */
@media (max-width: 1900px) {
    .quote-card {
        max-width: 380px;
        padding: 0.65rem 0.85rem;
        padding-right: 1.9rem;
        padding-left: 1.4rem;
    }

    .quote-text {
        font-size: 0.75rem;
    }
}

@media (max-width: 1750px) {
    .quote-card {
        max-width: 340px;
        padding: 0.6rem 0.8rem;
        padding-right: 1.8rem;
        padding-left: 1.2rem;
    }

    .quote-text {
        font-size: 0.72rem;
    }

    .quote-card::before {
        font-size: 2rem;
    }
}

@media (max-width: 1600px) {
    .quote-card {
        max-width: 300px;
        padding: 0.55rem 0.75rem;
        padding-right: 1.7rem;
        padding-left: 1.1rem;
    }

    .quote-text {
        font-size: 0.7rem;
    }
}

@media (max-width: 1500px) {
    .quote-card {
        max-width: 270px;
        padding: 0.5rem 0.7rem;
        padding-right: 1.6rem;
        padding-left: 1rem;
    }

    .quote-text {
        font-size: 0.68rem;
        line-height: 1.3;
    }

    .quotes-container {
        gap: 0.6rem;
        margin: 0 0.8rem;
    }
}

@media (max-width: 1400px) {
    .quote-card {
        max-width: 240px;
        padding: 0.45rem 0.65rem;
        padding-right: 1.5rem;
        padding-left: 0.95rem;
    }

    .quote-text {
        font-size: 0.65rem;
        line-height: 1.25;
    }

    .quote-card::before {
        font-size: 1.75rem;
        left: 0.25rem;
    }

    .quotes-container {
        gap: 0.5rem;
        margin: 0 0.7rem;
    }
}

@media (max-width: 1300px) {
    .quote-card {
        max-width: 210px;
        padding: 0.4rem 0.6rem;
        padding-right: 1.4rem;
        padding-left: 0.85rem;
    }

    .quote-text {
        font-size: 0.62rem;
        line-height: 1.2;
    }

    .quote-card::before {
        font-size: 1.5rem;
        left: 0.2rem;
    }

    .quotes-container {
        gap: 0.4rem;
        margin: 0 0.6rem;
    }
}

@media (max-width: 1200px) {
    .quote-card {
        max-width: 190px;
        padding: 0.35rem 0.55rem;
        padding-right: 1.3rem;
        padding-left: 0.75rem;
    }

    .quote-text {
        font-size: 0.6rem;
        line-height: 1.15;
    }

    .quotes-container {
        gap: 0.35rem;
        margin: 0 0.5rem;
    }
}

@media (max-width: 1400px) {

    /* Hide third quote earlier */
    .quote-card:nth-child(3) {
        display: none;
    }

    .quote-card {
        max-width: 280px;
    }
}

@media (max-width: 1100px) {
    .quote-card {
        max-width: 240px;
        /* Give remaining quotes more room */
    }
}

@media (max-width: 1100px) {

    /* Hide second quote */
    .quote-card:nth-child(2) {
        display: none;
    }

    .quote-card {
        max-width: 320px;
        /* Give last quote more room */
    }
}

@media (max-width: 950px) {
    .quote-card {
        max-width: 280px;
    }
}

@media (max-width: 900px) {

    /* Hide all quotes completely */
    .quotes-container {
        display: none;
    }
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-collapsed);
    color: #fff;
    background: linear-gradient(180deg, var(--tn-primary-900), var(--tn-primary-700));
    min-height: calc(100vh - 92px);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .08);
    position: relative;
    overflow: hidden;
    transition: width .25s ease;
    flex: 0 0 auto;
}

.sidebar:hover,
.sidebar:focus-within {
    width: var(--sidebar-w);
}

.sidebar:not(:hover):not(:focus-within) .header,
.sidebar:not(:hover):not(:focus-within) #topicsList {
    opacity: 0;
    pointer-events: none;
    user-select: none;
}

/* Always visible sidebar styles */
.sidebar.always-visible {
    width: var(--sidebar-w) !important;
}

.sidebar.always-visible .header,
.sidebar.always-visible #topicsList {
    opacity: 1 !important;
    pointer-events: auto !important;
    user-select: auto !important;
}

.sidebar.always-visible .hover-hint {
    display: none !important;
}

.sidebar .hover-hint {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .25);
    color: #fff;
    font-size: .75rem;
    letter-spacing: .03em;
    padding: .35rem .3rem;
    border-radius: .375rem;
    transition: opacity .2s ease;
    pointer-events: none;
}

.sidebar:hover .hover-hint,
.sidebar:focus-within .hover-hint {
    opacity: 0;
}

.sidebar .header {
    padding: .75rem;
    border-bottom: 1px solid rgba(255, 255, 255, .15);
}

.sidebar .header span {
    color: #ffc107;
}

.sidebar .topic-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .5rem .35rem .25rem;
    user-select: none;
    white-space: nowrap;
}

.drag-handle {
    color: rgba(255, 255, 255, .8);
    cursor: grab;
    padding: .2rem .3rem;
}

.drag-handle:active {
    cursor: grabbing;
}

.sidebar .topic-link {
    flex: 1 1 auto;
    min-width: 0;
    padding: .35rem .5rem;
    color: #fff;
    text-decoration: none;
    border-radius: .375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .topic-link:hover {
    background: rgba(255, 255, 255, .10);
}

.sidebar .topic-link.active {
    background: rgba(255, 255, 255, .18);
}

.sidebar .topic-actions .icon-btn {
    color: #fff;
    opacity: .95;
}

.sidebar .empty {
    padding: .75rem;
    color: rgba(255, 255, 255, .85);
    font-size: .9rem;
}

/* ===== Buttons ===== */
.btn-outline-primary {
    --bs-btn-color: var(--tn-primary-300);
    --bs-btn-border-color: var(--tn-primary-300);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--tn-primary-300);
    --bs-btn-hover-border-color: var(--tn-primary-300);
}

.btn.btn-primary {
    background: var(--tn-accent-500);
    border-color: var(--tn-accent-500);
}

.btn.btn-primary:hover {
    background: var(--tn-accent-600);
    border-color: var(--tn-accent-600);
}

/* Icon button styles */
.btn img {
    vertical-align: middle;
    display: inline-block;
}

.btn-outline-light img {
    filter: brightness(0) invert(1);
}

.btn-outline-light:hover img {
    filter: brightness(0.9) invert(1);
}

.btn-outline-primary img,
.btn-outline-secondary img {
    opacity: 0.8;
}

.btn-outline-danger img {
    opacity: 0.8;
}

.btn:hover img {
    opacity: 1;
}

.btn-primary img {
    filter: brightness(0) invert(1);
}

/* ===== Navigation Tabs ===== */
.nav-tabs .nav-link.active {
    background: #fff;
    border-color: var(--tn-primary-300) var(--tn-primary-300) #fff;
    color: var(--tn-primary-900);
    font-weight: 600;
}

.nav-tabs .nav-link {
    color: var(--tn-primary-700);
    cursor: pointer;
}

.nav-tabs .nav-link:hover {
    color: var(--tn-primary-300);
}

/* Sortable styles for page tabs */
.nav-tabs .sortable-ghost {
    opacity: 0.4;
    background: var(--tn-primary-300);
}

.nav-tabs .sortable-chosen {
    background: rgba(30, 138, 122, 0.1);
}

.nav-tabs .nav-item {
    cursor: move;
}

/* ===== Widgets Grid ===== */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
    grid-auto-rows: min-content;
    /* Changed from fixed row height */
    grid-auto-flow: dense;
    gap: var(--gap-px, 8px);
}

.card {
    border: 2px solid var(--tn-primary-300);
    box-shadow: 0 2px 8px rgba(14, 90, 90, .06);
    display: flex;
    flex-direction: column;
    min-height: 150px;
    /* Minimum height for empty widgets */
    max-height: 80vh;
    /* Prevent widgets from being taller than viewport */
}

.card-header {
    background: linear-gradient(90deg, var(--tn-primary-500), var(--tn-primary-300));
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .25);
    cursor: default;
}

.card[data-widget-type="1"] .card-body,
/* Links */
.card[data-widget-type="2"] .card-body {
    /* ToDos */
    flex: 0 1 auto;
    /* Allow shrinking but not growing beyond content */
    overflow: visible;
    max-height: none;
    /* background: linear-gradient(90deg, var(--tn-accent-600), var(--tn-accent-500)); */
}

/* Allow Links and ToDo widgets to grow beyond 80vh when needed */
.card[data-widget-type="1"],
.card[data-widget-type="2"] {
    max-height: none;
    overflow: visible;
}

/* Keep Notes widgets with scroll */
.card[data-widget-type="4"] .card-body {
    /* Notes */
    flex: 1 1 auto;
    overflow: auto;
    min-height: 200px;
    max-height: 500px;
    /* background: linear-gradient(90deg, var(--tn-accent-700), var(--tn-accent-600)); */
}

.card-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: visible;
}

.card-body>.list-group {
    flex: 1 1 auto;
    overflow: auto;
    min-height: 0;
}


/* ===== Links Widget ===== */
.links-flow {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .5rem;
    align-content: flex-start;
    padding-bottom: 0.5rem;
}

.link-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .5rem;
    border: 1px solid var(--tn-primary-300);
    border-radius: 999px;
    background: #fff;
    text-decoration: none;
    font-size: .9rem;
    line-height: 1.1;
    color: var(--tn-primary-700);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    max-width: 100%;
}

.link-chip:hover {
    background: #f3fffd;
    border-color: var(--tn-primary-500);
    color: var(--tn-primary-900);
}

.link-chip .favicon {
    width: 16px;
    height: 16px;
    margin: 0;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}

.link-chip span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 16rem;
}

.favicon {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}

/* ===== Cross-Page Drag & Drop Styles ===== */
.drag-over {
    background: rgba(30, 138, 122, 0.15) !important;
    box-shadow: 0 0 0 2px var(--tn-primary-500) !important;
    transition: all 0.2s ease;
}

.nav-link.drag-over {
    background: rgba(30, 138, 122, 0.2) !important;
    border-color: var(--tn-primary-500) !important;
    transform: scale(1.05);
}

.topic-link.drag-over {
    background: rgba(255, 255, 255, 0.25) !important;
    border-radius: 0.375rem;
}

.card-header[draggable="true"] {
    cursor: move;
}

.card-header[draggable="true"]:active {
    cursor: grabbing;
}

.card[data-widget-id].dragging {
    opacity: 0.5;
}

#pageSelectionModal .list-group-item:hover {
    background: var(--tn-primary-300);
    color: white;
}

/* ===== Icon Buttons ===== */
.icon-btn {
    border: none;
    background: transparent;
    padding: .1rem .2rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform .07s ease, filter .1s ease;
}

.icon-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.icon-add i {
    color: var(--tn-add);
}

.icon-edit i {
    color: #ffffff;
}

.card-body .icon-edit i {
    color: var(--tn-primary-500);
}

.icon-del i {
    color: #ffffff;
}

.card-body .icon-del i {
    color: var(--tn-danger);
}

/* ===== Notes Widget ===== */
.note-title {
    font-weight: 600;
    margin-bottom: .1rem;
}

.note-text {
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* ===== ToDos Widget (Nestable) ===== */
.dd {
    max-width: 100%;
    word-wrap: break-word;
}

.dd-item>.dd-list {
    margin-left: 1rem;
}

.dd-handle {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    background: #fff;
    border: 1px solid var(--tn-border);
    padding: .5rem .75rem;
    border-radius: .5rem;
    gap: .5rem;
    flex-wrap: nowrap;
    height: auto !important;
    line-height: 1.35;
    overflow: visible;
    word-break: break-word;
}

.min-w-0 {
    min-width: 0;
}

.todo-title {
    display: block;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    margin-top: .1rem;
}

/* ===== Todo Completion Confetti Effect ===== */
/* Explosion trajectories - burst upward and outward, then fall */
@keyframes confetti-burst-1 {
    0% {
        transform: translate(0, 0) rotateZ(0deg);
        opacity: 1;
    }

    50% {
        transform: translate(-40px, -80px) rotateZ(360deg);
        opacity: 1;
    }

    65% {
        opacity: 0.5;
    }

    100% {
        transform: translate(-60px, 100px) rotateZ(720deg);
        opacity: 0;
    }
}

@keyframes confetti-burst-2 {
    0% {
        transform: translate(0, 0) rotateZ(0deg);
        opacity: 1;
    }

    50% {
        transform: translate(40px, -90px) rotateZ(-360deg);
        opacity: 1;
    }

    65% {
        opacity: 0.5;
    }

    100% {
        transform: translate(70px, 100px) rotateZ(-720deg);
        opacity: 0;
    }
}

@keyframes confetti-burst-3 {
    0% {
        transform: translate(0, 0) rotateZ(0deg);
        opacity: 1;
    }

    50% {
        transform: translate(-10px, -100px) rotateZ(360deg);
        opacity: 1;
    }

    65% {
        opacity: 0.5;
    }

    100% {
        transform: translate(-20px, 110px) rotateZ(720deg);
        opacity: 0;
    }
}

@keyframes confetti-burst-4 {
    0% {
        transform: translate(0, 0) rotateZ(0deg);
        opacity: 1;
    }

    50% {
        transform: translate(30px, -85px) rotateZ(-360deg);
        opacity: 1;
    }

    65% {
        opacity: 0.5;
    }

    100% {
        transform: translate(50px, 105px) rotateZ(-720deg);
        opacity: 0;
    }
}

@keyframes confetti-burst-5 {
    0% {
        transform: translate(0, 0) rotateZ(0deg);
        opacity: 1;
    }

    50% {
        transform: translate(-30px, -95px) rotateZ(360deg);
        opacity: 1;
    }

    65% {
        opacity: 0.5;
    }

    100% {
        transform: translate(-45px, 115px) rotateZ(720deg);
        opacity: 0;
    }
}

/* Large celebration trajectories - bigger, more dramatic */
@keyframes confetti-burst-large-1 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(-60px, -120px) rotateZ(540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(-90px, 150px) rotateZ(1080deg) scale(1.5);
        opacity: 0;
    }
}

@keyframes confetti-burst-large-2 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(70px, -130px) rotateZ(-540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(100px, 150px) rotateZ(-1080deg) scale(1.5);
        opacity: 0;
    }
}

@keyframes confetti-burst-large-3 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(-20px, -140px) rotateZ(540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(-30px, 160px) rotateZ(1080deg) scale(1.5);
        opacity: 0;
    }
}

@keyframes confetti-burst-large-4 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(50px, -125px) rotateZ(-540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(80px, 155px) rotateZ(-1080deg) scale(1.5);
        opacity: 0;
    }
}

@keyframes confetti-burst-large-5 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(-50px, -135px) rotateZ(540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(-70px, 165px) rotateZ(1080deg) scale(1.5);
        opacity: 0;
    }
}

@keyframes confetti-burst-large-6 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(15px, -145px) rotateZ(-540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(25px, 170px) rotateZ(-1080deg) scale(1.5);
        opacity: 0;
    }
}

@keyframes confetti-burst-large-7 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(-40px, -115px) rotateZ(540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(-55px, 145px) rotateZ(1080deg) scale(1.5);
        opacity: 0;
    }
}

@keyframes confetti-burst-large-8 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(65px, -110px) rotateZ(-540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(95px, 140px) rotateZ(-1080deg) scale(1.5);
        opacity: 0;
    }
}

@keyframes confetti-burst-large-9 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(5px, -150px) rotateZ(540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(10px, 175px) rotateZ(1080deg) scale(1.5);
        opacity: 0;
    }
}

@keyframes confetti-burst-large-10 {
    0% {
        transform: translate(0, 0) rotateZ(0deg) scale(1);
        opacity: 1;
    }

    40% {
        transform: translate(-55px, -105px) rotateZ(-540deg) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.6;
    }

    100% {
        transform: translate(-75px, 135px) rotateZ(-1080deg) scale(1.5);
        opacity: 0;
    }
}

.confetti-container {
    position: absolute;
    pointer-events: none;
    z-index: 9999;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.confetti-particle {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    pointer-events: none;
    left: 50%;
    top: 10px;
}

/* Small confetti - apply different burst animations */
.confetti-particle.small {
    animation-duration: 1s;
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation-fill-mode: forwards;
}

.confetti-particle.small:nth-child(1) {
    background: #ff6b6b;
    animation-name: confetti-burst-1;
}

.confetti-particle.small:nth-child(2) {
    background: #4ecdc4;
    animation-name: confetti-burst-2;
    animation-delay: 0.05s;
}

.confetti-particle.small:nth-child(3) {
    background: #ffe66d;
    animation-name: confetti-burst-3;
    animation-delay: 0.1s;
}

.confetti-particle.small:nth-child(4) {
    background: #a8e6cf;
    animation-name: confetti-burst-4;
    animation-delay: 0.15s;
}

.confetti-particle.small:nth-child(5) {
    background: #ff8ed4;
    animation-name: confetti-burst-5;
    animation-delay: 0.2s;
}

/* Large confetti - more dramatic burst */
.confetti-particle.large {
    animation-duration: 1.4s;
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    animation-fill-mode: forwards;
    width: 7px;
    height: 7px;
}

.confetti-particle.large:nth-child(1) {
    background: #ff6b6b;
    animation-name: confetti-burst-large-1;
}

.confetti-particle.large:nth-child(2) {
    background: #4ecdc4;
    animation-name: confetti-burst-large-2;
    animation-delay: 0.05s;
}

.confetti-particle.large:nth-child(3) {
    background: #ffe66d;
    animation-name: confetti-burst-large-3;
    animation-delay: 0.1s;
}

.confetti-particle.large:nth-child(4) {
    background: #a8e6cf;
    animation-name: confetti-burst-large-4;
    animation-delay: 0.15s;
}

.confetti-particle.large:nth-child(5) {
    background: #ff8ed4;
    animation-name: confetti-burst-large-5;
    animation-delay: 0.2s;
}

.confetti-particle.large:nth-child(6) {
    background: #95e1d3;
    animation-name: confetti-burst-large-6;
    animation-delay: 0.25s;
}

.confetti-particle.large:nth-child(7) {
    background: #ffc8dd;
    animation-name: confetti-burst-large-7;
    animation-delay: 0.3s;
}

.confetti-particle.large:nth-child(8) {
    background: #ffafcc;
    animation-name: confetti-burst-large-8;
    animation-delay: 0.35s;
}

.confetti-particle.large:nth-child(9) {
    background: #bde0fe;
    animation-name: confetti-burst-large-9;
    animation-delay: 0.4s;
}

.confetti-particle.large:nth-child(10) {
    background: #cdb4db;
    animation-name: confetti-burst-large-10;
    animation-delay: 0.45s;
}

/* Star burst effect for large celebration */
@keyframes star-burst {
    0% {
        transform: translate(-50%, 0) scale(0) rotate(0deg);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -100px) scale(1.5) rotate(180deg);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -150px) scale(0.5) rotate(360deg);
        opacity: 0;
    }
}

.confetti-star {
    position: absolute;
    left: 50%;
    top: 10px;
    width: 16px;
    height: 16px;
    color: #ffd700;
    font-size: 16px;
    animation: star-burst 0.8s ease-out forwards;
    transform-origin: center;
    pointer-events: none;
}

.dd-handle .form-check-input {
    margin-top: .2rem;
}

.item-icons {
    flex: 0 0 auto;
    align-self: flex-start;
}

.dd-item>button[data-action="collapse"],
.dd-item>button[data-action="expand"] {
    border: none;
    background: none;
    cursor: pointer;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    font-size: 0;
    line-height: 1;
    overflow: hidden;
    white-space: nowrap;
}

.dd-item>button[data-action="collapse"]::before,
.dd-item>button[data-action="expand"]::before {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 12px;
    line-height: 1;
    display: inline-block;
    content: "";
}

.dd-item>button[data-action="collapse"]::before {
    content: "\f078";
}

.dd-item>button[data-action="expand"]::before {
    content: "\f054";
}

.dd-item.dd-collapsed>button[data-action="collapse"] {
    display: none !important;
}

.dd-item:not(.dd-collapsed)>button[data-action="expand"] {
    display: none !important;
}

/* ===== Settings Modal ===== */
.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section-title {
    color: var(--tn-primary-900);
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--tn-primary-300);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-card {
    background: white;
    padding: 1.25rem;
    border-radius: 0.75rem;
    border: 2px solid var(--tn-primary-300);
    box-shadow: 0 2px 8px rgba(14, 90, 90, 0.06);
}

.settings-card:hover {
    box-shadow: 0 4px 12px rgba(14, 90, 90, 0.1);
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

#settingsModal .form-control,
#settingsModal .form-select {
    border: 1px solid var(--tn-primary-300);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

#settingsModal .form-control:focus,
#settingsModal .form-select:focus {
    border-color: var(--tn-primary-500);
    box-shadow: 0 0 0 0.2rem rgba(30, 138, 122, 0.15);
}

#settingsModal .form-label {
    font-weight: 500;
    color: var(--tn-primary-700);
    margin-bottom: 0.35rem;
}

#settingsModal .modal-content {
    border: none;
    border-radius: 0.75rem;
    overflow: hidden;
}

#settingsModal .modal-header {
    border-bottom: none;
    padding: 1.25rem;
}

#settingsModal .modal-footer {
    padding: 1rem 1.25rem;
}

#settingsModal .btn-primary:hover {
    background: var(--tn-accent-600) !important;
    border-color: var(--tn-accent-600) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 138, 23, 0.25);
}

#settingsModal .btn-secondary {
    background: transparent;
    color: var(--tn-primary-700);
    border: 1px solid var(--tn-primary-300);
}

#settingsModal .btn-secondary:hover {
    background: var(--tn-primary-300);
    color: white;
    border-color: var(--tn-primary-300);
}

#settingsModal small.text-muted {
    font-size: 0.8rem;
    color: var(--tn-primary-700) !important;
    opacity: 0.7;
}

#settingsModal small.text-muted i {
    font-size: 0.9rem;
}

/* Required field indicator */
#settingsModal .form-label:has(+ input:required)::after {
    content: " *";
    color: var(--tn-danger);
}

/* Animate modal entrance */
#settingsModal .modal-dialog {
    animation: slideDown 0.3s ease;
}

/* ===== Modal Base Styling ===== */
.modal-content {
    background: var(--widget-bg);
    color: var(--widget-fg);
    border: 2px solid var(--tn-primary-300);
    border-radius: 0.75rem;
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(90deg, var(--tn-primary-900), var(--tn-primary-700));
    color: white;
    border-bottom: none;
    padding: 1.25rem;
}

.modal-footer {
    background: var(--tn-background);
    border-top: 2px solid var(--tn-primary-300);
    padding: 1rem 1.25rem;
}

.modal-body {
    background: var(--widget-bg);
    color: var(--widget-fg);
}

/* Form elements in modals */
.modal .form-control,
.modal .form-select {
    background: var(--widget-bg);
    color: var(--widget-fg);
    border: 1px solid var(--tn-primary-300);
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.modal .form-control:focus,
.modal .form-select:focus {
    background: var(--widget-bg);
    color: var(--widget-fg);
    border-color: var(--tn-primary-500);
    box-shadow: 0 0 0 0.2rem rgba(30, 138, 122, 0.15);
}

.modal .form-label {
    font-weight: 500;
    color: var(--widget-fg);
    margin-bottom: 0.35rem;
}

/* Modal buttons */
.modal .btn-primary {
    background: var(--tn-accent-500);
    border-color: var(--tn-accent-500);
    color: white;
}

.modal .btn-primary:hover {
    background: var(--tn-accent-600);
    border-color: var(--tn-accent-600);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 138, 23, 0.25);
}

.modal .btn-secondary {
    background: transparent;
    color: var(--widget-fg);
    border: 1px solid var(--tn-primary-300);
}

.modal .btn-secondary:hover {
    background: var(--tn-primary-300);
    color: white;
    border-color: var(--tn-primary-300);
}

.modal .btn-outline-danger {
    color: var(--tn-danger);
    border-color: var(--tn-danger);
}

.modal .btn-outline-danger:hover {
    background: var(--tn-danger);
    border-color: var(--tn-danger);
    color: white;
}

/* Close button styling */
.modal .btn-close {
    filter: invert(1);
}

/* Specific modal enhancements */
.modal .text-muted {
    color: var(--widget-fg) !important;
    opacity: 0.7;
}

/* Table styling in modals */
.modal .table {
    color: var(--widget-fg);
}

.modal .table th {
    border-color: var(--tn-border);
    color: var(--widget-fg);
}

.modal .table td {
    border-color: var(--tn-border);
    color: var(--widget-fg);
}

.modal .table-responsive {
    border: 1px solid var(--tn-border);
    border-radius: 0.375rem;
}

/* ===== Settings Modal Specific ===== */
.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section-title {
    color: var(--widget-fg);
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--tn-primary-300);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-card {
    background: var(--widget-bg);
    color: var(--widget-fg);
    padding: 1.25rem;
    border-radius: 0.75rem;
    border: 2px solid var(--tn-primary-300);
    box-shadow: 0 2px 8px rgba(14, 90, 90, 0.06);
}

.settings-card:hover {
    box-shadow: 0 4px 12px rgba(14, 90, 90, 0.1);
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

#settingsModal small.text-muted {
    font-size: 0.8rem;
    color: var(--widget-fg) !important;
    opacity: 0.7;
}

#settingsModal small.text-muted i {
    font-size: 0.9rem;
}

/* Required field indicator */
.modal .form-label:has(+ input:required)::after {
    content: " *";
    color: var(--tn-danger);
}

/* Modal sizing overrides */
.modal-dialog.modal-lg {
    max-width: 800px;
    /* Limit large modals to reasonable width */
}

.modal-dialog {
    max-width: 500px;
    /* Standard modal width */
}

/* Specific modal width adjustments */
#manageLinksModal .modal-dialog {
    max-width: 700px;
    /* Links modal needs some extra width for the table */
}

#addHTMLNoteModal .modal-dialog,
#editHTMLNoteModal .modal-dialog {
    max-width: 800px;
    /* HTML note modals need more space for editor */
}

#settingsModal .modal-dialog {
    max-width: 800px;
    /* Settings modal keeps larger width */
}

/* Animate modal entrance */
.modal-dialog {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive improvements for smaller screens */
@media (max-width: 1400px) {
    .card {
        max-height: 70vh;
    }
}

@media (max-width: 992px) {
    .widgets-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .card {
        max-height: 60vh;
    }
}

@media (max-width: 768px) {
    .widgets-grid {
        grid-template-columns: 1fr;
    }

    .card {
        max-height: 50vh;
    }
}

/* ===== Fancy Notes Widget ===== */
.fancy-note-content {
    padding: 0.5rem;
    border: 1px solid var(--tn-border);
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.5);
    min-height: 60px;
    max-height: 400px;
    overflow-y: auto;
    flex: 1 1 auto;
}

/* Make Fancy Notes widget body flexible */
.card[data-widget-type="5"] .card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: hidden;
    min-height: 100px;
}

.card[data-widget-type="5"] .widget-htmlnotes {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.card[data-widget-type="5"] .list-group-item {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.card[data-widget-type="5"] .list-group-item>div {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.card[data-widget-type="5"] .list-group-item .me-auto {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    width: -webkit-fill-available;
}

/* Fancy Notes header gradient */
.card[data-widget-type="5"] .card-header {
    background: linear-gradient(90deg, var(--tn-primary-500), var(--tn-primary-300));
}

/* ===== Quill Editor Styles ===== */
.quill-resizable-container {
    min-height: 250px;
    min-width: 50%;
    width: 100%;
    max-width: none;
    /* Remove max-width constraint */
    max-height: none;
    /* Use viewport height for max */
    resize: both;
    overflow: auto;
    border: 1px solid var(--tn-border);
    border-radius: 0.375rem;
    position: relative;
}

/* Make modal adapt to resizable content */
#addHTMLNoteModal .modal-dialog,
#editHTMLNoteModal .modal-dialog {
    max-width: 90vw;
    width: auto;
    display: flex;
    justify-content: center;
}

#addHTMLNoteModal .modal-content,
#editHTMLNoteModal .modal-content {
    width: auto;
    min-width: 500px;
    /* Minimum width for usability */
    max-width: 90vw;
}

#addHTMLNoteModal .modal-body,
#editHTMLNoteModal .modal-body {
    width: auto;
    display: flex;
    flex-direction: column;
}

/* Ensure the form adapts to container width */
#addHTMLNoteForm,
#editHTMLNoteForm {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Ensure modal can accommodate expanded editor */
.modal-dialog.modal-lg {
    max-width: 90vw;
    /* Allow modal to grow wider */
}

.modal-body {
    overflow-x: auto;
    /* Allow horizontal scrolling if needed */
}

.ql-toolbar {
    border: 1px solid var(--tn-border);
    border-radius: 0.375rem 0.375rem 0 0;
    background: rgba(255, 255, 255, 0.9);
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    /* Ensure toolbar spans full width */
}

.ql-container {
    border: none;
    background: white;
    min-height: 200px;
    height: 100%;
    width: 100%;
    /* Ensure container spans full width */
}

.ql-editor {
    min-height: 200px;
}

.fancy-note-content h1 {
    font-size: 1.5rem;
}

.fancy-note-content h2 {
    font-size: 1.3rem;
}

.fancy-note-content h3 {
    font-size: 1.1rem;
}

.fancy-note-content h4 {
    font-size: 1rem;
}

/* ===== Midnight Dark Theme (Theme ID 8) ===== */
body[data-theme-id="8"] .card {
    background: var(--widget-bg) !important;
    color: var(--widget-fg) !important;
}

body[data-theme-id="8"] .card .list-group-item {
    background: #4B5563 !important;
    color: var(--widget-fg) !important;
    border-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .modal-content {
    background: #374151 !important;
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .modal-header,
body[data-theme-id="8"] .modal-footer {
    border-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .form-control,
body[data-theme-id="8"] .form-select {
    background: #1F2937 !important;
    color: #F3F4F6 !important;
    border-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .form-control:focus,
body[data-theme-id="8"] .form-select:focus {
    background: #1F2937 !important;
    color: #F3F4F6 !important;
    border-color: var(--tn-primary-500) !important;
}

body[data-theme-id="8"] .nav-tabs .nav-link {
    color: #D1D5DB !important;
}

body[data-theme-id="8"] .nav-tabs .nav-link.active {
    background: var(--widget-bg) !important;
    color: var(--widget-fg) !important;
    border-color: var(--tn-primary-300) var(--tn-primary-300) var(--widget-bg) !important;
}

body[data-theme-id="8"] .dd-handle {
    background: #4B5563 !important;
    border-color: var(--tn-border) !important;
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .link-chip {
    background: #4B5563 !important;
    border-color: var(--tn-primary-300) !important;
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .link-chip:hover {
    background: #6B7280 !important;
}

body[data-theme-id="8"] .dropdown-menu {
    background: #374151 !important;
    border-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .dropdown-item {
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .dropdown-item:hover {
    background: #4B5563 !important;
}

body[data-theme-id="8"] .card-header {
    background: linear-gradient(90deg, #2D3748, #4A5568) !important;
    color: #F3F4F6 !important;
    border-bottom: 1px solid var(--tn-border) !important;
}

body[data-theme-id="8"] .card[data-widget-type="2"] .card-header {
    background: linear-gradient(90deg, #0c1d30, #0c2338) !important;
}

body[data-theme-id="8"] .card[data-widget-type="4"] .card-header {
    background: linear-gradient(90deg, #1d1337, #311c61) !important;
}

body[data-theme-id="8"] .card[data-widget-type="5"] .card-header {
    background: linear-gradient(90deg, #021d15, #042d1f) !important;
}

body[data-theme-id="8"] .weather-greeting-card {
    background: rgba(55, 65, 81, 0.95) !important;
}

body[data-theme-id="8"] .greeting-text,
body[data-theme-id="8"] .weather-temp {
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .greeting-name,
body[data-theme-id="8"] .weather-desc,
body[data-theme-id="8"] .weather-location {
    color: #D1D5DB !important;
}

body[data-theme-id="8"] .weather-section {
    border-left-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .fancy-note-content {
    background: rgba(75, 85, 99, 0.5) !important;
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .ql-toolbar {
    background: #4B5563 !important;
    border-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .ql-container {
    background: #374151 !important;
    color: #F3F4F6 !important;
    border-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .ql-editor {
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .ql-toolbar .ql-stroke {
    stroke: #D1D5DB !important;
}

body[data-theme-id="8"] .ql-toolbar .ql-fill {
    fill: #D1D5DB !important;
}

body[data-theme-id="8"] .ql-toolbar .ql-picker-label {
    color: #D1D5DB !important;
}

.bi-plus-circle-fill {
    color: #ffffff !important;
}

/* ===== RemindToDo Styles ===== */
.remindtodo-topic {
    background: rgba(255, 193, 7, 0.1);
    border-left: 3px solid #ffc107;
}

.remindtodo-widget {
    border-color: #ffc107;
    min-height: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.remindtodo-widget .card-header {
    background: linear-gradient(90deg, #ffc107, #ffca28);
    flex: 0 0 auto;
}

.remindtodo-widget .card-body {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

#remindtodoList {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
}

#remindtodoList .list-group {
    margin-bottom: 0;
}

#remindtodoList .icon-btn {
    opacity: 0.7;
    transition: opacity 0.2s;
}

#remindtodoList li:hover .icon-btn {
    opacity: 1;
}

.remindtodo-check {
    cursor: pointer;
}

/* Ensure the error and loading states don't overflow */
#remindtodoLoading,
#remindtodoError {
    flex: 0 0 auto;
}

/* ===== ToReadLater Styles ===== */
.toreadlater-topic {
    background: rgba(76, 175, 80, 0.1);
    border-left: 3px solid #4CAF50;
}

.toreadlater-toolbar {
    padding: 0;
    margin: 0;
}

.toreadlater-shell {
    display: flex;
    gap: 12px;
    align-items: stretch;
    height: calc(100vh - 250px);
}

.toreadlater-pane-left {
    flex: 0 0 360px;
    width: 360px;
}

.toreadlater-pane-right {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
}

/* ToReadLater email list */
.toreadlater-sidebar {
    height: calc(100vh - 400px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.msg-list-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

.msg-list-item.active {
    background: var(--tn-primary-300) !important;
    opacity: 0.9;
}

.msg-list-item.unread {
    border-left: 3px solid #4CAF50;
    padding-left: 12px !important;
}

.msg-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 72%;
}

.msg-title.unread {
    font-weight: 600;
}

.msg-meta {
    color: var(--tn-primary-700);
    opacity: 0.7;
}

.badge-soft {
    background: rgba(76, 175, 80, 0.15);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.35);
}

.badge-unread {
    background: rgba(76, 175, 80, 0.25);
    color: #4CAF50;
    border: 1px solid rgba(76, 175, 80, 0.45);
    font-size: 0.7rem;
    padding: 2px 6px;
}

/* ToReadLater reading pane */
.toreadlater-reading-card {
    border: 2px solid var(--tn-primary-300);
    box-shadow: 0 2px 8px rgba(14, 90, 90, .06);
    background: var(--widget-bg);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.toreadlater-reading {
    height: calc(100vh - 280px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
}

.reading-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

#messageBody {
    background: var(--tn-background);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--tn-border);
}

#messageBody img {
    max-width: 100%;
    height: auto;
}

#messageBody table {
    width: auto;
    max-width: 100%;
}

/* Light mode for reading pane */
.toreadlater-reading-card.light-mode {
    background: #ffffff;
    border: 1px solid #dee2e6;
}

.toreadlater-reading-card.light-mode .card-body {
    color: #212529;
}

.toreadlater-reading-card.light-mode .text-muted {
    color: #6c757d !important;
}

.toreadlater-reading-card.light-mode .badge-soft {
    background: rgba(13, 110, 253, .1);
    color: #0d6efd;
    border: 1px solid rgba(13, 110, 253, .2);
}

.toreadlater-reading-card.light-mode .badge-unread {
    background: rgba(13, 110, 253, .15);
    color: #0d6efd;
    border: 1px solid rgba(13, 110, 253, .3);
}

.toreadlater-reading-card.light-mode #messageBody {
    background: #f8f9fa;
    color: #212529;
}

/* Mode toggle button */
.btn-mode-toggle {
    background: transparent;
    border: 1px solid var(--tn-border);
    color: var(--tn-primary-700);
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-mode-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--tn-primary-500);
    color: var(--tn-primary-900);
}

.toreadlater-reading-card.light-mode .btn-mode-toggle {
    border: 1px solid #dee2e6;
    color: #495057;
}

.toreadlater-reading-card.light-mode .btn-mode-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: #adb5bd;
    color: #212529;
}

/* Label input row */
.label-row {
    display: flex;
    gap: 8px;
}

/* Pulse animation for fetch button hint */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
    }

    100% {
        transform: scale(1);
    }
}

/* Responsive adjustments for ToReadLater */
@media (max-width: 992px) {
    .toreadlater-shell {
        flex-direction: column;
        height: auto;
    }

    .toreadlater-pane-left {
        flex: 1 1 auto;
        width: 100%;
        max-height: 300px;
    }

    .toreadlater-pane-right {
        flex: 1 1 auto;
        width: 100%;
    }

    .toreadlater-sidebar {
        height: 200px;
    }

    .toreadlater-reading {
        height: 400px;
    }
}

/* Dark theme adjustments for ToReadLater */
body[data-theme-id="8"] .toreadlater-reading-card {
    background: #374151 !important;
    border-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .toreadlater-reading-card .card-body {
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .msg-list-item {
    background: #1F2937 !important;
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .msg-list-item.active {
    background: #4B5563 !important;
}

body[data-theme-id="8"] .msg-list-item:hover {
    background: #374151 !important;
}

body[data-theme-id="8"] #messageBody {
    background: #1F2937 !important;
    color: #F3F4F6 !important;
    border-color: var(--tn-border) !important;
}

/* ===== Gmail Calendar Styles ===== */
.gmailcalendar-topic {
    background: rgba(66, 133, 244, 0.1);
    border-left: 3px solid #4285F4;
}

.gmailcalendar-container {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    min-height: 650px;
}

#calendarContent {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Dark theme adjustments for Gmail Calendar */
body[data-theme-id="8"] .gmailcalendar-container {
    background: #374151;
}

body[data-theme-id="8"] #gmailCalendarFrame {
    filter: invert(0.9) hue-rotate(180deg);
}

/* ===== VideoDigest Styles ===== */
.videodigest-topic {
    background: rgba(255, 87, 34, 0.1);
    border-left: 3px solid #FF5722;
}

.videodigest-widget {
    border-color: #FF5722;
    min-height: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.videodigest-widget .card-header {
    background: linear-gradient(90deg, #FF5722, #FF7043);
    flex: 0 0 auto;
}

.videodigest-widget .card-body {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

#videodigestContent {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Dark theme adjustments for VideoDigest */
body[data-theme-id="8"] .videodigest-widget {
    background: #374151;
    border-color: #FF5722;
}

body[data-theme-id="8"] .videodigest-widget .card-body {
    color: #F3F4F6;
}

/* VideoDigest Two-Column Layout */
.videodigest-toolbar {
    padding: 0;
    margin: 0;
}

.videodigest-shell {
    display: flex;
    gap: 12px;
    align-items: stretch;
    height: calc(100vh - 250px);
}

.videodigest-pane-left {
    flex: 0 0 360px;
    width: 360px;
}

.videodigest-pane-right {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
}

/* VideoDigest video list */
.videodigest-sidebar {
    height: calc(100vh - 400px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.video-list-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

.video-list-item.active {
    background: var(--tn-primary-300) !important;
    opacity: 0.9;
}

.video-list-item.video-unwatched {
    border-left: 3px solid #FF5722;
    padding-left: 12px !important;
}

.video-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-size: 0.95rem;
}

.video-title.video-unwatched {
    font-weight: 600;
}

.video-meta {
    color: var(--tn-primary-700);
    opacity: 0.7;
    font-size: 0.75rem;
}

.badge-unwatched {
    background: rgba(255, 87, 34, 0.25);
    color: #FF5722;
    border: 1px solid rgba(255, 87, 34, 0.45);
    font-size: 0.7rem;
    padding: 2px 6px;
}

/* VideoDigest reading pane */
.videodigest-reading-card {
    border: 2px solid var(--tn-primary-300);
    box-shadow: 0 2px 8px rgba(14, 90, 90, .06);
    background: var(--widget-bg);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.videodigest-reading {
    height: calc(100vh - 280px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
}

.reading-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.video-summary-content {
    background: var(--tn-background);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--tn-border);
    line-height: 1.6;
}

.video-summary-content p {
    margin-bottom: 1rem;
}

.video-summary-content p:last-child {
    margin-bottom: 0;
}

.video-summary-content h1,
.video-summary-content h2,
.video-summary-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--tn-primary-900);
}

.video-summary-content h1 {
    font-size: 1.5rem;
}

.video-summary-content h2 {
    font-size: 1.3rem;
}

.video-summary-content h3 {
    font-size: 1.1rem;
}

.video-summary-content ul,
.video-summary-content ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

/* Responsive adjustments for VideoDigest */
@media (max-width: 992px) {
    .videodigest-shell {
        flex-direction: column;
        height: auto;
    }

    .videodigest-pane-left {
        flex: 1 1 auto;
        width: 100%;
        max-height: 300px;
    }

    .videodigest-pane-right {
        flex: 1 1 auto;
        width: 100%;
    }

    .videodigest-sidebar {
        height: 200px;
    }

    .videodigest-reading {
        height: 400px;
    }
}

/* Dark theme adjustments for VideoDigest reading pane */
body[data-theme-id="8"] .videodigest-reading-card {
    background: #374151 !important;
    border-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .videodigest-reading-card .card-body {
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .video-list-item {
    background: #1F2937 !important;
    color: #F3F4F6 !important;
}

body[data-theme-id="8"] .video-list-item.active {
    background: #4B5563 !important;
}

body[data-theme-id="8"] .video-list-item:hover {
    background: #374151 !important;
}

body[data-theme-id="8"] .video-summary-content {
    background: #1F2937 !important;
    color: #F3F4F6 !important;
    border-color: var(--tn-border) !important;
}

body[data-theme-id="8"] .video-summary-content h1,
body[data-theme-id="8"] .video-summary-content h2,
body[data-theme-id="8"] .video-summary-content h3 {
    color: #F3F4F6 !important;
}

/* ===== MOBILE RESPONSIVE STYLES ===== */
/* Target phones and small tablets */
@media (max-width: 768px) {

    /* ===== Body and Layout ===== */
    body {
        overflow-x: hidden;
    }

    /* ===== Navbar Adjustments ===== */
    .navbar {
        padding: 0.5rem 0.75rem !important;
        flex-wrap: wrap !important;
    }

    .navbar-brand {
        order: 1;
    }

    .brand-img {
        height: 50px !important;
    }

    .brand-tagline {
        display: none;
    }

    /* Move navbar buttons to second row */
    .navbar .ms-auto {
        order: 3;
        width: 100%;
        margin-top: 0.5rem !important;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    .navbar .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    /* ===== Sidebar → Bottom Navigation ===== */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        min-height: auto !important;
        height: auto;
        max-height: 60vh;
        z-index: 1000;
        background: linear-gradient(180deg, var(--tn-primary-900), var(--tn-primary-700));
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    /* Collapsed state */
    .sidebar:not(.mobile-expanded) {
        transform: translateY(calc(100% - 50px));
    }

    .sidebar:not(.mobile-expanded) #topicsList {
        display: none;
    }

    /* Hide hover hint on mobile */
    .sidebar .hover-hint {
        display: none;
    }

    /* Show mobile toggle */
    .sidebar::before {
        content: 'Topics';
        display: block;
        text-align: center;
        padding: 0.75rem;
        color: white;
        font-weight: 600;
        cursor: pointer;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        background: rgba(0, 0, 0, 0.1);
    }

    .sidebar.mobile-expanded::before {
        content: 'Topics ▼';
    }

    .sidebar .header {
        padding: 0.75rem 1rem;
    }

    #topicsList {
        max-height: 40vh;
        overflow-y: auto;
    }

    /* Topic rows in mobile sidebar */
    .sidebar .topic-row {
        padding: 0.5rem 1rem;
    }

    /* ===== Main Content Area ===== */
    main {
        padding: 0.5rem !important;
        padding-bottom: 60px !important;
        /* Space for bottom nav */
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    #widgetsArea {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* ===== Page Tabs → Horizontal Scroll ===== */
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        border-bottom: 2px solid var(--tn-primary-300);
        margin-bottom: 0.5rem;
        scrollbar-width: thin;
    }

    .nav-tabs::-webkit-scrollbar {
        height: 3px;
    }

    .nav-tabs::-webkit-scrollbar-thumb {
        background: var(--tn-primary-300);
        border-radius: 3px;
    }

    .nav-tabs .nav-item {
        flex: 0 0 auto;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    /* ===== Action Buttons → FAB Menu ===== */
    .d-flex.align-items-center.justify-content-between.mb-2 {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem;
    }

    .d-flex.align-items-center.justify-content-between.mb-2>.d-flex {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Make buttons more touch-friendly */
    .btn-sm {
        padding: 0.5rem 1rem !important;
        font-size: 0.9rem !important;
    }

    .btn-sm img {
        width: 20px !important;
        height: 20px !important;
    }

    /* ===== Widgets → Single Column ===== */
    .widgets-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .widgets-grid .card {
        grid-column: 1 !important;
        max-height: none;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Widget headers */
    .card-header {
        padding: 0.75rem;
        font-size: 0.95rem;
    }

    .card-header .widget-actions {
        gap: 0.5rem;
    }

    .card-body {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* ===== Links Widget Mobile ===== */
    .links-flow {
        gap: 0.5rem;
    }

    .link-chip {
        font-size: 0.85rem;
        padding: 0.35rem 0.6rem;
        max-width: 100%;
    }

    .link-chip span {
        max-width: calc(100vw - 120px);
    }

    /* ===== ToDos Widget Mobile ===== */
    .dd-handle {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
        padding: 0.6rem;
    }

    .dd-handle>div {
        width: 100%;
    }

    .item-icons {
        width: 100%;
        justify-content: flex-end !important;
    }

    .todo-title {
        font-size: 0.9rem;
    }

    /* ===== Notes Widget Mobile ===== */
    .note-title {
        font-size: 0.95rem;
    }

    .note-text {
        font-size: 0.85rem;
    }

    /* Fix notes list item to stack vertically on mobile */
    .widget-notes .list-group-item {
        flex-direction: column;
        align-items: stretch !important;
    }

    .widget-notes .list-group-item .me-auto {
        width: 100%;
        min-width: 0;
        margin-right: 0 !important;
        margin-bottom: 0.5rem;
    }

    .widget-notes .list-group-item .item-icons {
        align-self: flex-end;
    }

    /* ===== Modals Mobile ===== */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem) !important;
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100vw - 1rem) !important;
    }

    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }

    /* Settings modal */
    #settingsModal .settings-card {
        padding: 1rem;
    }

    #settingsModal .row {
        margin: 0;
    }

    #settingsModal .col-md-6,
    #settingsModal .col-md-12 {
        padding: 0.5rem 0;
    }

    /* Manage links table */
    #manageLinksModal .table-responsive {
        font-size: 0.85rem;
    }

    #manageLinksModal td,
    #manageLinksModal th {
        padding: 0.5rem 0.25rem;
    }

    #manageLinksModal input[type="text"] {
        font-size: 0.85rem;
        padding: 0.35rem;
    }

    /* ===== Special Topics Mobile ===== */
    /* RemindToDo */
    .remindtodo-widget {
        min-height: 300px;
        max-height: 60vh;
    }

    /* ToReadLater */
    .toreadlater-shell {
        flex-direction: column;
        height: auto;
        gap: 1rem;
    }

    .toreadlater-pane-left,
    .toreadlater-pane-right {
        flex: 1 1 auto;
        width: 100%;
    }

    .toreadlater-pane-left {
        max-height: 40vh;
    }

    .toreadlater-sidebar {
        height: 35vh;
    }

    .toreadlater-reading {
        height: auto;
        min-height: 40vh;
        max-height: 60vh;
    }

    .reading-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start !important;
    }

    .msg-title {
        max-width: 100%;
    }

    /* Gmail Calendar */
    .gmailcalendar-container {
        padding: 0.5rem;
        min-height: 500px;
    }

    #gmailCalendarFrame {
        height: 500px !important;
    }

    /* VideoDigest */
    .videodigest-shell {
        flex-direction: column;
        height: auto;
        gap: 1rem;
    }

    .videodigest-pane-left,
    .videodigest-pane-right {
        flex: 1 1 auto;
        width: 100%;
    }

    .videodigest-pane-left {
        max-height: 40vh;
    }

    .videodigest-sidebar {
        height: 35vh;
    }

    .videodigest-reading {
        height: auto;
        min-height: 40vh;
        max-height: 60vh;
    }

    /* ===== Quill Editor Mobile ===== */
    .quill-resizable-container {
        min-height: 200px;
        resize: vertical;
    }

    .ql-toolbar {
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .ql-editor {
        min-height: 150px;
        font-size: 0.9rem;
    }

    /* ===== Footer Mobile ===== */
    .footer {
        padding: 1rem 0;
        font-size: 0.8rem;
        margin-bottom: 50px;
        /* Space for bottom nav */
    }

    /* ===== Touch Improvements ===== */
    /* Bigger touch targets */
    .icon-btn {
        padding: 0.4rem !important;
        min-width: 36px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Form elements */
    .form-control,
    .form-select {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
        padding: 0.6rem;
    }

    /* Checkboxes and radios */
    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
        margin-top: 0;
    }

    /* ===== Prevent horizontal scroll ===== */
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* ===== Setup Wizard Mobile ===== */
    #setupWizardModal .wizard-structure {
        font-size: 0.85rem;
    }

    #setupWizardModal .wizard-topic .card-header {
        padding: 0.5rem;
    }

    #setupWizardModal .wizard-page {
        padding: 0.5rem;
        margin-left: 0.5rem;
    }

    #setupWizardModal .wizard-widgets {
        margin-left: 0.5rem;
        font-size: 0.8rem;
    }
}

/* ===== Extra Small Phones (< 375px) ===== */
@media (max-width: 374px) {
    .brand-img {
        height: 40px !important;
    }

    .navbar .btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    .nav-tabs .nav-link {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .card-header {
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.85rem !important;
    }
}

/* ===== Landscape Mobile ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        max-height: 80vh;
    }

    #topicsList {
        max-height: 60vh;
    }

    .toreadlater-shell,
    .videodigest-shell {
        flex-direction: row;
    }

    .toreadlater-pane-left,
    .videodigest-pane-left {
        flex: 0 0 280px;
        max-height: none;
    }

    .toreadlater-sidebar,
    .videodigest-sidebar {
        height: calc(100vh - 350px);
    }

    /* Keep widgets in single column for narrow landscape viewports */
    .widgets-grid {
        grid-template-columns: 1fr !important;
    }

    .widgets-grid .card {
        grid-column: 1 / -1 !important;
    }
}

/* ===== Landscape Mobile - Wider devices (iPhone Pro Max, tablets) ===== */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: landscape) {
    /* Force single column layout for landscape on devices up to 1024px wide */
    /* This prevents widget overlap on devices like iPhone 14 Pro Max (932px) */
    .widgets-grid {
        grid-template-columns: 1fr !important;
    }

    .widgets-grid .card {
        grid-column: 1 / -1 !important;
        max-height: 70vh;
    }
}

/* ===== Newsletter Setup Wizard ===== */
.step-indicator {
    position: relative;
}

.step-indicator::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--tn-border);
    z-index: 0;
}

.step-item {
    text-align: center;
    position: relative;
    z-index: 1;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.step-item.active .step-circle {
    background: var(--tn-accent-500);
    color: white;
}

.step-item.completed .step-circle {
    background: var(--tn-success);
    color: white;
}

.step-label {
    font-size: 0.875rem;
    color: #6c757d;
}

.step-item.active .step-label {
    color: var(--tn-primary-700);
    font-weight: 500;
}

.sender-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--tn-border);
}

.sender-item:hover {
    background: rgba(0, 0, 0, 0.02);
}

.sender-item:last-child {
    border-bottom: none;
}

/* Newsletter setup modal specific */
#newsletterSetupModal .modal-dialog {
    max-width: 800px;
}

#sendersList {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--tn-border);
    border-radius: 8px;
    padding: 1rem;
}

/* Dark theme adjustments for Newsletter Setup */
body[data-theme-id="8"] .sender-item {
    background: transparent;
}

body[data-theme-id="8"] .sender-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

body[data-theme-id="8"] #sendersList {
    background: #374151;
    border-color: var(--tn-border);
}

body[data-theme-id="8"] .step-circle {
    background: #4B5563;
    color: #D1D5DB;
}

body[data-theme-id="8"] .step-item.active .step-circle {
    background: var(--tn-accent-500);
    color: white;
}

body[data-theme-id="8"] .step-item.completed .step-circle {
    background: var(--tn-success);
    color: white;
}

/* Setup Wizard Styles */
.wizard-topic {
    border: 2px solid #1E8A7A;
}

.wizard-topic.card {
    max-height: none !important;
}

.wizard-topic .card-header {
    padding: 0.75rem 1rem;
}

.wizard-topic .card-body {
    background: #ffffff;
}

.wizard-page {
    padding: 0.5rem;
    border-left: 3px solid #36A8A0;
    background: rgba(54, 168, 160, 0.05);
    border-radius: 0.25rem;
}

.wizard-widgets {
    font-size: 0.9rem;
}

.wizard-widgets .form-check {
    margin-bottom: 0.25rem;
}

#setupWizardModal .modal-dialog {
    max-height: 90vh;
}

#setupWizardModal .modal-body {
    max-height: calc(90vh - 200px);
}

/* ===== Link Drag & Drop Styles ===== */
.link-chip[draggable="true"] {
    cursor: pointer;
    /* Show pointer by default for links */
}

.link-chip[draggable="true"]:active {
    cursor: grabbing;
    /* Show grabbing cursor only when actively dragging */
}

.links-drop-target {
    background: rgba(30, 138, 122, 0.1) !important;
    border: 2px dashed var(--tn-primary-500) !important;
    border-radius: 0.375rem;
    min-height: 60px;
    position: relative;
}

.links-drop-target::after {
    content: 'Drop link here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--tn-primary-700);
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: none;
    opacity: 0.7;
}

/* Ensure links container has minimum height for empty state */
.links-flow {
    min-height: 40px;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.links-flow:empty {
    min-height: 60px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px dashed var(--tn-border);
}

/* Dark theme adjustments */
body[data-theme-id="8"] .links-drop-target {
    background: rgba(30, 138, 122, 0.2) !important;
}

body[data-theme-id="8"] .links-drop-target::after {
    color: #F3F4F6;
}

/* Fix for Sports section in wizard - remove height restriction */
.wizard-topic .wizard-pages {
    max-height: none !important;
    overflow: visible !important;
}

/* Files Widget Styles */
.widget-files-container {
    padding: 0.5rem;
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    padding: 0.5rem;
}

.file-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.file-item:hover {
    background-color: rgba(0, 96, 100, 0.05);
    transform: translateY(-2px);
}

.file-icon {
    font-size: 3rem;
    color: var(--tn-primary-300);
    margin-bottom: 0.5rem;
}

.file-name {
    font-size: 0.85rem;
    font-weight: 500;
    word-break: break-word;
    line-height: 1.2;
    max-height: 2.4em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.file-ext {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.25rem;
    text-transform: uppercase;
}

.file-ext {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.25rem;
    text-transform: uppercase;
}

/* AI Theme Generator Styles */
#aiThemePreview .card {
    border: 1px solid #dee2e6;
    font-size: 0.875rem;
}

#aiThemePreview .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

#aiThemeModal .modal-lg {
    max-width: 900px;
}

#aiThemeGenerating {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#aiThemeGenerating {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Premium Locked Button Styles */
.btn-premium-locked {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.btn-premium-locked:hover {
    opacity: 0.7;
}

/* Theme Gallery Styles */
.theme-card {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.theme-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.theme-preview-mini {
    position: relative;
    overflow: hidden;
}

.theme-preview-mini::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.3), transparent);
}

#themeGalleryGrid .card-body {
    padding: 1rem;
}

#themeGalleryGrid .card-footer {
    padding: 0.5rem;
}

#themeGalleryGrid .card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

#themePreviewContent .card {
    border: 1px solid #dee2e6;
    font-size: 0.875rem;
}

#themePreviewContent .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.bi-star-fill,
.bi-star-half {
    font-size: 0.875rem;
}

.bi-star {
    font-size: 0.875rem;
}

/* Pagination styling */
#themeGalleryPagination .pagination {
    margin: 0;
}

#themeGalleryPagination .page-link {
    color: var(--tn-primary-700);
    border-color: var(--tn-border);
}

#themeGalleryPagination .page-item.active .page-link {
    background-color: var(--tn-primary-500);
    border-color: var(--tn-primary-500);
}

#themeGalleryPagination .page-link:hover {
    background-color: var(--tn-primary-300);
    border-color: var(--tn-primary-300);
    color: white;
}

/* ============================================
   INBOX STYLES
   ============================================ */

#messageList .list-group-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

#messageList .list-group-item:hover {
    background-color: var(--bs-light);
}

#messageList .list-group-item.active {
    background-color: var(--tn-primary-500);
    border-color: var(--tn-primary-500);
    color: white;
}

#messageList .list-group-item.active .text-muted {
    color: rgba(255, 255, 255, 0.7) !important;
}

.message-body {
    line-height: 1.6;
    word-wrap: break-word;
}

.message-body p {
    margin-bottom: 1rem;
}

.message-body img {
    max-width: 100%;
    height: auto;
}

#replyEditor {
    outline: none;
}

#replyEditor:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

#inboxBtn img {
    transition: transform 0.2s;
}

#inboxBtn:hover img {
    transform: scale(1.1);
}

/* End Inbox Styles */

/* ===== Collaborative Topics Styles ===== */

/* Collaborative topic icon */
.collaborative-icon {
    color: #ffc107;
    margin-right: 0.35rem;
    font-size: 0.85em;
}

/* Collaborative topic row styling */
.sidebar .topic-row.collaborative-topic {
    position: relative;
}

/* Collaborative topic link - add left border indicator */
.sidebar .topic-row.collaborative-topic .topic-link {
    border-left: 3px solid #ffc107;
    padding-left: 0.5rem;
    margin-left: -3px;
}

/* Collaborative topic owned by user - green accent */
.sidebar .topic-row.collaborative-owner .topic-link {
    border-left-color: #28a745;
}

.sidebar .topic-row.collaborative-owner .collaborative-icon {
    color: #28a745;
}

/* Collaborative topic where user is a member - yellow/gold accent */
.sidebar .topic-row.collaborative-member .topic-link {
    border-left-color: #ffc107;
}

.sidebar .topic-row.collaborative-member .collaborative-icon {
    color: #ffc107;
}

/* Make collaborative button */
.sidebar .btn-make-collab {
    color: rgba(255, 255, 255, 0.7) !important;
}

.sidebar .btn-make-collab:hover {
    color: #ffc107 !important;
    background: rgba(255, 193, 7, 0.2);
    border-radius: 0.25rem;
}

/* Manage collaborators button */
.sidebar .btn-manage-collab {
    color: #ffc107 !important;
}

.sidebar .btn-manage-collab:hover {
    color: #fff !important;
    background: rgba(255, 193, 7, 0.3);
    border-radius: 0.25rem;
}

/* Leave collaborative button */
.sidebar .btn-leave-collab {
    color: #dc3545 !important;
    opacity: 0.8;
}

.sidebar .btn-leave-collab:hover {
    color: #fff !important;
    background: rgba(220, 53, 69, 0.3);
    border-radius: 0.25rem;
    opacity: 1;
}

/* End Collaborative Topics Styles */