/* ============================================================
   inMynd Web UI — Dark theme, mobile-first
   ============================================================ */

:root {
    /* Palette - Dark Grey / Black */
    --bg-primary: #121212;
    --bg-secondary: #1a1a1a;
    --bg-card: #202020;
    --bg-card-alt: #282828;
    --bg-input: #1a1a1a;
    --bg-hover: #2c2c2c;
    --bg-outer: #080808;

    /* Letters - White / Light Grey */
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #a0a0a0;

    /* Highlights - Pastel Orange */
    --accent: #ff7351;
    --accent-glow: rgba(255, 170, 102, 0.15);
    --accent-transparent: rgba(255, 170, 102, 0.3);
    --accent-light: #ffc299;

    /* Last resource - Light Blue */
    --success: #90caf9;
    --error: #e57373;
    --warning: #ffb74d;

    --border: rgba(255, 255, 255, 0.15);
    --shadow: rgba(0, 0, 0, 0.5);

    /* Typography - Computer Modern */
    --font-sans: 'Computer Modern Serif', Georgia, serif;
    --font-mono: 'Computer Modern Typewriter', monospace;
    --font-note: 'Computer Modern Serif', Georgia, serif;

    /* Sizing (sharp edges for academic paper layout) */
    --radius: 4px;
    --radius-sm: 2px;
    --header-h: 56px;
    --input-h: 64px;
    --quick-h: 48px;

    /* Safe area for PWA on notched phones */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

html.light-mode {
    /* Palette - Light Grey / Soft Off-white */
    --bg-primary: #fcfbfa;       /* warm paper off-white */
    --bg-secondary: #f3efe9;     /* warm grey-beige for panels/headers */
    --bg-card: #ffffff;          /* clean white for main cards/messages */
    --bg-card-alt: #eae6e1;      /* slightly darker warm beige for list items/welcome code blocks */
    --bg-input: #ffffff;         /* clean white for inputs */
    --bg-hover: #e2dfdb;         /* hover background */
    --bg-outer: #e2dfdb;         /* desktop body background (outside the app wrapper) */

    /* Letters - Dark Grey / Charcoal */
    --text-primary: #1c1c1c;     /* soft off-black for main reading */
    --text-secondary: #3c3c3c;   /* dark charcoal for secondary texts */
    --text-muted: #706f6c;       /* muted brownish-grey for timestamps, hints */

    /* Highlights - Darker Pastel Orange for better contrast on white backgrounds */
    --accent: #d24f33;           /* classic warm orange-red with high contrast */
    --accent-glow: rgba(210, 79, 51, 0.08);
    --accent-transparent: rgba(210, 79, 51, 0.18);
    --accent-light: #e56c52;

    /* Semantics - more contrast */
    --success: #2e7d32;
    --error: #c62828;
    --warning: #ef6c00;

    --border: rgba(0, 0, 0, 0.12); /* subtle light mode borders */
    --shadow: rgba(0, 0, 0, 0.06); /* subtle light mode shadow */
}

/* ---- Reset & Scrollbars ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: underline;
}

a:hover,
a:active {
    color: var(--accent-light);
}

/* ============================================================
   Layout shell
   ============================================================ */

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 640px;
    margin: 0 auto;
    position: relative;
}

/* ---- Header ---- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 16px;
    padding-top: var(--safe-top);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

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

.header-logo {
    font-size: 24px;
    line-height: 1;
}

.header-title {
    font-weight: bold;
    font-size: 18px;
    color: var(--text-primary);
}

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

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 18px;
    transition: background 0.2s, color 0.2s;
}

.btn-logout:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

/* ---- Quick actions ---- */
.quick-actions {
    display: none;
}

.quick-actions::-webkit-scrollbar {
    display: none;
}

.quick-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-btn:hover,
.quick-btn:active {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* ---- Chat area ---- */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Welcome */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.welcome-hint {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.welcome-hint code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-light);
}

/* ---- Chat messages ---- */
.msg {
    animation: msgIn 0.3s ease-out;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.msg-user {
    align-self: flex-end;
    max-width: 85%;
    padding: 10px 14px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-right: 3px solid var(--accent);
    border-radius: var(--radius) var(--radius) 4px var(--radius);
    font-family: var(--font-sans);
    font-size: 14px;
    word-break: break-word;
    white-space: pre-wrap;
}

.msg-bot {
    align-self: flex-start;
    max-width: 90%;
    padding: 14px 16px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 4px var(--radius) var(--radius) var(--radius);
    word-break: break-word;
    white-space: pre-wrap;
}

.msg-bot.error {
    border-color: rgba(255, 107, 107, 0.3);
    background: rgba(255, 107, 107, 0.08);
}

.msg-bot:has(.web-gym-card) {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    max-width: 100%;
}

.msg-bot pre {
    font-family: var(--font-mono);
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Toggable Todos Styling */
.todo-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    white-space: normal;
    /* Ignore parent pre-wrap spacing */
    width: 800px;
    max-width: 100%;
}



.todo-web-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: background 0.2s, border-color 0.2s;
}

.todo-web-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-transparent);
}

.todo-web-item.completed {
    opacity: 0.55;
    background: rgba(32, 32, 32, 0.4);
}

.todo-web-item label {
    font-family: var(--font-note);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    flex: 1;
    line-height: 1.4;
    transition: color 0.2s, text-decoration 0.2s;
}

.todo-web-item.completed label {
    text-decoration: line-through;
    color: var(--text-muted);
}

.todo-checkbox {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.todo-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

.todo-add-input {
    flex: 1;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.todo-add-input::placeholder {
    color: var(--text-muted);
}

.todo-add-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.todo-add-btn {
    height: 36px;
    padding: 0 16px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm, 6px);
    background: transparent;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.todo-add-btn:hover {
    background: var(--accent);
    color: #ffffff;
}

.todo-add-btn:disabled,
.todo-add-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.msg-bot .file-link {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: bold;
    transition: border-color 0.2s, color 0.2s;
}

.msg-bot .file-link:hover {
    border-color: var(--accent-light);
    color: var(--accent-light);
}

/* Loading dots */
.msg-loading {
    align-self: flex-start;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px var(--radius) var(--radius) var(--radius);
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(0.8);
    }

    40% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* ---- Input bar ---- */
.input-bar {
    position: relative;
    flex-shrink: 0;
    padding: 10px 16px;
    padding-bottom: calc(10px + var(--safe-bottom));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.btn-new-messages {
    position: absolute;
    top: -44px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--accent);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px var(--shadow);
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
    white-space: nowrap;
    animation: newMsgBtnIn 0.2s ease-out;
}

.btn-new-messages[hidden] {
    display: none;
}

.btn-new-messages:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    transform: translateX(-50%) translateY(-1px);
}

.btn-new-messages:active {
    transform: translateX(-50%) translateY(0);
}

@keyframes newMsgBtnIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    animation: previewFadeIn 0.2s ease-out;
}

@keyframes previewFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.image-preview-wrapper {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-input);
}

.image-preview-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius);
}

.btn-clear-image {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    border: none;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px var(--shadow);
    transition: background 0.2s, transform 0.15s;
    padding: 0;
}

.btn-clear-image:hover {
    background: var(--accent-light);
    transform: scale(1.1);
}

.btn-clear-image:active {
    transform: scale(0.9);
}

.btn-attach {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s, color 0.2s, transform 0.15s, background-color 0.2s;
}

.btn-attach:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.05);
}

.btn-attach:active {
    transform: scale(0.95);
}

.btn-attach.has-image {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(255, 115, 81, 0.08);
}

.btn-attach:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#commandInput {
    flex: 1;
    min-height: 44px;
    max-height: 160px;
    padding: 11px 16px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    resize: none;
    overflow-y: auto;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#commandInput::placeholder {
    color: var(--text-muted);
}

#commandInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--accent);
    border-radius: 50%;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s, color 0.2s, transform 0.15s;
}

.btn-send:hover {
    border-color: var(--accent-light);
    color: var(--accent-light);
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   Login page
   ============================================================ */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: auto;
    background: var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 24px;
}

.login-card {
    padding: 40px 32px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 8px 40px var(--shadow);
}

.login-logo {
    font-size: 48px;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

.login-title {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-error {
    padding: 10px 14px;
    margin-bottom: 16px;
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 14px;
}

.login-form .input-group {
    margin-bottom: 16px;
}

.login-form input[type="password"] {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-login {
    width: 100%;
    height: 48px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: transparent;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.btn-login:hover {
    border-color: var(--accent-light);
    color: var(--accent-light);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 480px) {
    .login-card {
        padding: 32px 24px;
    }

    .quick-btn {
        padding: 5px 12px;
        font-size: 12px;
    }
}

/* ============================================================
   Desktop Responsive Layout
   ============================================================ */

@media (min-width: 768px) {
    body {
        background: var(--bg-outer);
    }

    #app {
        display: grid;
        grid-template-columns: 260px 1fr;
        grid-template-rows: var(--header-h) 1fr auto;
        max-width: 1440px;
        margin: 0 auto;
        height: 100%;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        background: var(--bg-primary);
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
    }

    .app-header {
        grid-column: 1 / span 2;
        grid-row: 1;
        border-bottom: 1px solid var(--border);
    }

    .quick-actions {
        display: flex;
        grid-column: 1;
        grid-row: 2 / span 2;
        flex-direction: column;
        overflow-x: visible;
        overflow-y: hidden;
        border-bottom: none;
        border-right: 1px solid var(--border);
        padding: 20px 16px;
        gap: 16px;
        height: 100%;
        background: var(--bg-secondary);
        justify-content: flex-start;
    }

    .quick-btn {
        width: 100%;
        text-align: left;
        padding: 12px 16px;
        justify-content: flex-start;
        border-radius: var(--radius);
        white-space: normal;
    }

    .chat-area {
        grid-column: 2;
        grid-row: 2;
        padding: 24px;
    }

    .input-bar {
        grid-column: 2;
        grid-row: 3;
        border-top: 1px solid var(--border);
        background: var(--bg-primary);
        padding: 16px 24px;
    }
}

/* ============================================================
   Aesthetic Updates — Pastel Orange, Markdown & Notes
   ============================================================ */

.bullet-orange {
    color: var(--accent);
    margin-right: 6px;
    font-size: 14px;
    vertical-align: middle;
}

.text-orange {
    color: var(--accent);
}

.text-blue {
    color: #64b5f6;
}

.env-badge {
    margin-left: 0.35em;
    font-style: italic;
    font-weight: normal;
    color: #64b5f6;
    font-size: 0.85em;
}

.login-title .env-badge {
    font-size: 0.65em;
    vertical-align: middle;
}

/* ---- Notes (/get) ---- */
.web-notes-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 800px;
    max-width: 100%;
    white-space: normal;
    /* Ignore parent pre-wrap spacing */
}



.web-note-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.2s, border-color 0.2s;
}

.web-note-card:hover {
    border-color: var(--accent-transparent);
}

.web-note-ref {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 6px;
    margin: 0 2px;
    border-radius: 4px;
    background: rgba(255, 115, 81, 0.12);
    color: var(--accent-light, #ff8c6b);
    font-family: var(--font-mono, monospace);
    font-size: 0.88em;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--accent-transparent, rgba(255, 115, 81, 0.25));
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    cursor: pointer;
}

.web-note-ref:hover {
    background: var(--accent-transparent, rgba(255, 115, 81, 0.25));
    border-color: var(--accent);
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-1px);
}

.web-note-backlinks {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
}

.web-note-backlinks-label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.web-note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.web-note-id {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-muted);
}

.web-note-body,
.web-note-body-preview {
    font-family: var(--font-note);
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.38;
}

/* Headings inside notes */
.web-note-body h1,
.web-note-body h2,
.web-note-body h3,
.web-note-body-preview h1,
.web-note-body-preview h2,
.web-note-body-preview h3 {
    font-family: var(--font-note);
    color: var(--text-primary);
    margin-top: 8px;
    margin-bottom: 2px;
}

.web-note-body h1,
.web-note-body-preview h1 {
    font-size: 20px;
}

.web-note-body h2,
.web-note-body-preview h2 {
    font-size: 18px;
}

.web-note-body h3,
.web-note-body-preview h3 {
    font-size: 16px;
}

.web-note-body p,
.web-note-body-preview p {
    margin-bottom: 4px;
}

.web-note-body ul,
.web-note-body ol,
.web-note-body-preview ul,
.web-note-body-preview ol {
    padding-left: 20px;
    margin-left: 0;
    margin-bottom: 4px;
    margin-top: 0;
}

/* Pull lists closer to preceding paragraphs */
.web-note-body p+ul,
.web-note-body-preview p+ul,
.web-note-body p+ol,
.web-note-body-preview p+ol {
    margin-top: -2px;
}

.web-note-body li,
.web-note-body-preview li {
    margin-bottom: 1px;
}

/* Inline code and pre blocks */
code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.85em;
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-light);
    padding: 2px 5px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    word-break: break-word;
}

pre {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    background: #181818;
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 8px;
    font-size: 0.85em;
    line-height: 1.5;
    color: var(--text-primary);
}

pre.hljs,
.web-note-body-preview pre code.hljs {
    background: #181818;
}

.web-note-body-preview.is-folded .web-note-preview-inner {
    max-height: calc(var(--note-fold-lines, 20) * 15px * 1.38);
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
}

.web-note-body-preview.is-expanded .web-note-preview-inner {
    max-height: none;
    -webkit-mask-image: none;
    mask-image: none;
}

.web-note-fold-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.web-note-fold-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

pre code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    font-size: inherit !important;
    color: inherit !important;
    word-break: normal;
}

.web-note-body blockquote,
.web-note-body-preview blockquote {
    border-left: 3px solid var(--border);
    padding-left: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 6px;
}

.web-note-body img,
.web-note-body-preview img,
.msg-bot img {
    max-width: 100%;
    max-height: 120px;
    /* Vertically limited to roughly 5-6 lines of text */
    height: auto;
    object-fit: contain;
    border-radius: var(--radius);
    margin: 12px 0;
    border: 1px solid var(--border);
    display: block;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s, box-shadow 0.2s;
}

.web-note-body img:hover,
.web-note-body-preview img:hover,
.msg-bot img:hover {
    transform: scale(1.02);
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Lightbox Modal for Enlarging Images */
.lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: zoom-out;
}

.lightbox-modal.active .lightbox-content {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    user-select: none;
}

.lightbox-close:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.05);
}

/* Web Help, Tags, Dataenv layouts */
.web-tags-container,
.web-help-container,
.web-dataenv-container {
    width: 100%;
    margin-top: 4px;
}

.web-tags-title,
.web-help-title,
.web-dataenv-title,
.web-notes-title,
.web-gym-title,
.todo-title,
.web-agenda-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    margin-bottom: 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

/* Tags list */
.web-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.web-tag-badge {
    display: inline-block;
    padding: 4px 8px;
    background: var(--accent-glow);
    border: 1px solid var(--accent-transparent);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    user-select: none;
}

.web-tag-badge:hover {
    background: var(--accent-transparent);
    border-color: var(--accent);
}

/* Help List */
.web-help-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.web-help-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
}

.web-help-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.web-help-cmd {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 13px;
    white-space: nowrap;
}

.web-help-desc {
    font-size: 13px;
    color: var(--text-muted);
    text-align: right;
}

/* Dataenv List */
.web-dataenv-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.web-dataenv-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.web-dataenv-value {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.web-dataenv-override-warning {
    font-size: 12px;
    color: var(--accent-light);
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 8px;
}

/* ============================================================
   Gym Card Web Styles
   ============================================================ */

.web-gym-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(32, 32, 32, 0.95) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin: 4px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-primary);
    width: 100%;
    transition: opacity 0.15s ease;
    white-space: normal;
}

.web-gym-card.web-gym-loading-state {
    opacity: 0.6;
    pointer-events: none;
    cursor: wait;
}

@keyframes gymCardEntrance {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

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

.web-gym-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.web-gym-back-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font-sans);
    transition: all 0.2s ease;
}

.web-gym-back-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(255, 115, 81, 0.1);
}

.web-gym-header .web-gym-title {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.web-gym-subtitle {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 10px 0 4px 0;
}

/* Columns Layout */
.web-gym-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

@media (max-width: 560px) {
    .web-gym-columns {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

.web-gym-column {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
}

.web-gym-col-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 4px;
    margin-bottom: 6px;
}

.web-gym-set-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.web-gym-set-list li {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.03);
}

.web-gym-set-num {
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.web-gym-empty {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 4px 0;
}

.web-gym-controls {
    background: rgba(255, 115, 81, 0.03);
    border: 1px solid rgba(255, 115, 81, 0.15);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.web-gym-inputs-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 10px;
}

.web-gym-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.web-gym-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.web-gym-control-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.web-gym-adjuster {
    display: flex;
    align-items: center;
    gap: 6px;
}

.web-gym-adj-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card-alt);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    user-select: none;
}

.web-gym-adj-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-hover);
}

.web-gym-adj-btn:active {
    transform: scale(0.9);
}

.web-gym-number-input {
    width: 65px;
    height: 36px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    text-align: center;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: bold;
    outline: none;
    -moz-appearance: textfield;
}

.web-gym-number-input::-webkit-outer-spin-button,
.web-gym-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.web-gym-unit {
    font-size: 12px;
    color: var(--text-muted);
    width: 30px;
    display: inline-block;
    text-align: left;
}

.web-gym-add-set-btn {
    width: 100%;
    height: 40px;
    border-radius: 6px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 15px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(255, 115, 81, 0.2);
}

.web-gym-add-set-btn:hover {
    background: var(--accent-light);
    box-shadow: 0 4px 16px rgba(255, 115, 81, 0.3);
}

.web-gym-add-set-btn:active {
    transform: translateY(1px);
}

/* Actions Section */
.web-gym-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 16px;
}

.web-gym-action-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card-alt);
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.web-gym-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

/* Exercise Selection Grid/List */
.web-gym-search {
    width: 100%;
    height: 40px;
    padding: 0 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}

.web-gym-search:focus {
    border-color: var(--accent);
}

.web-gym-new-exercise-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.web-gym-new-name {
    flex: 1;
    height: 38px;
    padding: 0 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
}

.web-gym-btn-new-exercise {
    padding: 0 16px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.web-gym-btn-new-exercise:hover {
    background: var(--accent);
    color: #fff;
}

.web-gym-recent-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.web-gym-recent-badge {
    background: rgba(255, 115, 81, 0.1);
    border: 1px solid rgba(255, 115, 81, 0.3);
    color: var(--accent-light);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.web-gym-recent-badge:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.web-gym-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 6px;
}

.web-gym-exercise-item {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card-alt);
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 14px;
    transition: all 0.15s ease;
}

.web-gym-exercise-item:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent-transparent);
    padding-left: 18px;
}

/* Workout Summary View */
.web-gym-summary-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
}

.web-gym-summary-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
}

.web-gym-summary-ex-name {
    font-weight: 700;
    color: var(--accent-light);
    font-size: 16px;
    margin-bottom: 8px;
    font-family: var(--font-sans);
}

.web-gym-summary-sets {
    list-style: none;
    padding-left: 12px;
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.web-gym-summary-sets li {
    font-size: 14px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.web-gym-action-btn.btn-success {
    background: rgba(144, 202, 249, 0.1);
    border-color: rgba(144, 202, 249, 0.3);
    color: var(--success);
}

.web-gym-action-btn.btn-success:hover {
    background: var(--success);
    color: var(--bg-primary);
    border-color: var(--success);
}

.web-gym-action-btn.btn-danger {
    background: rgba(229, 115, 115, 0.1);
    border-color: rgba(229, 115, 115, 0.3);
    color: var(--error);
}

.web-gym-action-btn.btn-danger:hover {
    background: var(--error);
    color: var(--bg-primary);
    border-color: var(--error);
}

@media (max-width: 480px) {
    .web-gym-new-exercise-row {
        flex-direction: column;
        align-items: flex-end;
    }

    .web-gym-new-name {
        width: 100%;
    }

    .web-gym-btn-new-exercise {
        height: 38px;
    }
}

@media (max-width: 560px) {
    .web-gym-inputs-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ============================================================
   Markdown Raw vs. Preview Toggles
   ============================================================ */

.btn-group-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    overflow: hidden;
    padding: 2px;
}

.btn-group-toggle .toggle-btn {
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-sans);
    outline: none;
}

.btn-group-toggle .toggle-btn:hover {
    color: var(--text-primary);
}

.btn-group-toggle .toggle-btn.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ---- Note Card Toggles & Raw Body ---- */
.web-note-toggle {
    margin-left: auto;
}

.web-note-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    margin-left: 8px;
    transition: color 0.2s, transform 0.15s;
    border-radius: var(--radius-sm);
}

.web-note-delete-btn:hover {
    color: var(--error);
    transform: scale(1.15);
}

.web-note-delete-btn:active {
    transform: scale(0.9);
}

.web-note-body-raw pre {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius);
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ---- Todo Layout Adjustments for Toggling ---- */
.todo-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.todo-header-row .todo-title {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.todo-web-item {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: start;
    gap: 12px;
    padding: 10px 12px;
}

.todo-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 20px;
    transition: color 0.2s;
    touch-action: none;
}

.todo-drag-handle:hover {
    color: var(--accent);
}

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

.todo-web-item.dragging {
    opacity: 0.4;
    border: 1px dashed var(--accent);
    background: var(--bg-hover);
}

.todo-item-left {
    display: flex;
    align-items: center;
    height: 20px;
}

.todo-item-left .todo-checkbox {
    margin-top: 0;
}

.todo-item-content {
    flex: 1;
    min-width: 0;
}

.todo-item-content label {
    font-family: var(--font-note);
    margin: 0;
    width: 100%;
    display: block;
}

.todo-item-content label p {
    margin-bottom: 0;
}

.todo-item-content label p:not(:last-child) {
    margin-bottom: 8px;
}

.todo-item-right {
    display: flex;
    align-items: center;
    height: 20px;
}

.todo-item-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    padding: 0;
}

.todo-item-toggle:hover {
    color: var(--accent);
    border-color: var(--accent-transparent);
    background: rgba(255, 115, 81, 0.05);
}

.todo-item-toggle.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-glow);
}

/* Make bold letters bolder and stand out in the dark theme */
strong,
b {
    font-weight: 800;
    /* Use heavier weight if available / fallback */
    color: var(--text-primary);
    /* Ensure it's full white contrast */
    text-shadow: 0.3px 0 0.1px currentColor, -0.3px 0 0.1px currentColor;
    /* Subtle horizontal thickening */
}

/* ---- Editable raw note and todo components ---- */
.web-note-raw-textarea {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 13px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    line-height: 1.5;
    resize: none;
    outline: none;
    display: block;
    overflow-y: hidden;
}

.web-note-raw-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.web-note-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.web-note-save-btn,
.web-note-cancel-btn {
    padding: 6px 14px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.web-note-save-btn {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
}

.web-note-save-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
}

.web-note-cancel-btn {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
}

.web-note-cancel-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.todo-label-raw {
    display: block;
    width: 100%;
}

.todo-raw-textarea {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 13px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: var(--radius);
    color: var(--text-primary);
    line-height: 1.5;
    resize: none;
    outline: none;
    display: block;
    overflow-y: hidden;
}

.todo-raw-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.todo-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.todo-save-btn,
.todo-cancel-btn {
    padding: 4px 12px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.todo-save-btn {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
}

.todo-save-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
}

.todo-cancel-btn {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
}

.todo-cancel-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================================
   Search Interface Styling (Desktop and Mobile)
   ============================================================ */

/* ---- Desktop Search ---- */
.desktop-search-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    gap: 16px;
}

#desktopSearchInput {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#desktopSearchInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#desktopSearchResults {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}



/* ---- Mobile Search Header Button ---- */
.btn-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-header-icon:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

@media (min-width: 768px) {
    #mobileSearchBtn {
        display: none;
    }
}

/* ---- Mobile Search Modal ---- */
.search-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(18, 18, 18, 0.98);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.search-modal.active {
    display: block;
    opacity: 1;
}

.search-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
    padding-top: calc(16px + var(--safe-top));
    padding-bottom: calc(16px + var(--safe-bottom));
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

#mobileSearchInput {
    flex: 1;
    height: 48px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#mobileSearchInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.2s;
}

.btn-close-modal:hover {
    color: var(--accent);
}

/* ---- Search Results Common ---- */
.search-results-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-result-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    text-align: left;
}

.search-result-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.search-result-item:active {
    transform: translateY(1px);
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 11px;
    font-family: var(--font-sans);
}

.search-result-id {
    color: var(--accent);
    font-weight: bold;
}

.search-result-date {
    color: var(--text-muted);
}

.search-result-tags {
    font-size: 12px;
    color: var(--accent-light);
    margin-bottom: 4px;
    word-break: break-all;
}

.search-result-snippet {
    font-family: var(--font-note);
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.search-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ---- Search Loader/Spinner ---- */
.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input-wrapper input {
    width: 100% !important;
    padding-right: 36px !important; /* Ensure input text doesn't overlap the spinner */
}

.spinner-loader {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 140, 0, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    pointer-events: none;
    z-index: 5;
}

.spinner-loader.active {
    opacity: 1;
    animation: search-spin 0.6s linear infinite;
}

@keyframes search-spin {
    from {
        transform: translateY(-50%) rotate(0deg);
    }
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* ============================================================
   Sidebar Tabs & Placeholders (Views & Tags) Styling
   ============================================================ */

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    gap: 8px;
    justify-content: space-between;
    width: 100%;
}

.sidebar-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sidebar-tab-btn.active {
    color: var(--accent);
    background: var(--bg-card);
    border-color: var(--border);
    box-shadow: 0 2px 8px var(--shadow);
}

.sidebar-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
}

.sidebar-tab-content.active {
    display: flex;
}

.sidebar-placeholder {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    width: 100%;
}

.sidebar-placeholder h3 {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.placeholder-text {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
}

/* Views & Tags Lists */
.views-list, .tags-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}.view-item, .tag-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-item:hover, .tag-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

.view-item:active, .tag-item:active {
    transform: translateY(1px);
}

.view-icon {
    color: var(--accent);
    margin-right: 12px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.view-item:hover .view-icon {
    transform: scale(1.1);
}

.view-name {
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-secondary);
    flex: 1;
}

.tag-hash {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: bold;
    margin-right: 2px;
}

.tag-name {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
    flex: 1;
}

.view-count, .tag-count {
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--bg-card-alt);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.tag-loading-placeholder,
.tag-empty-placeholder,
.tag-error-placeholder {
    padding: 20px 8px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--font-sans);
}

/* Custom Views Styling */
.custom-view-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
    position: relative;
    user-select: none;
}

.custom-view-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

.custom-view-item.active {
    border-color: var(--accent);
    background: var(--bg-card-alt);
}

.custom-view-icon {
    color: var(--accent);
    margin-right: 12px;
    flex-shrink: 0;
}

.custom-view-name {
    flex: 1;
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--text);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-view-delete {
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
    margin-left: 6px;
}

.custom-view-item:hover .custom-view-delete {
    opacity: 1;
}

.custom-view-delete:hover {
    color: var(--accent);
}

/* Desktop Canvas */
.view-canvas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 99;
    overflow: hidden;
}

.canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    user-select: none;
    z-index: 10;
}

.canvas-title {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.canvas-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-canvas-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.btn-canvas-action:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.btn-canvas-close {
    padding: 6px;
}

.btn-canvas-close:hover {
    color: var(--accent);
}

.canvas-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    padding: 20px;
    background-color: var(--bg-card-alt);
    background-image: radial-gradient(var(--border) 1.5px, transparent 0);
    background-size: 24px 24px;
    background-position: 0px 0px;
    cursor: grab;
}

.canvas-content:active {
    cursor: grabbing;
}

.canvas-pan-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    pointer-events: none;
}

.canvas-pan-container > * {
    pointer-events: auto;
}

/* Draggable Note Paper */
.note-paper {
    position: absolute;
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: box-shadow 0.2s ease, transform 0.1s ease;
}

.note-paper.dragging {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    opacity: 0.95;
    z-index: 999 !important;
}

.paper-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-card-alt);
    border-bottom: 1px solid var(--border);
    cursor: move;
    user-select: none;
}

.paper-title {
    font-family: var(--font-sans);
    font-size: 11px;
    color: var(--text-muted);
}

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

.btn-paper-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.btn-paper-action:hover {
    color: var(--accent);
}

.paper-body {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    max-height: 280px;
    background: var(--bg-card);
}

.paper-body .web-note-card {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

.paper-body .web-note-header {
    display: flex !important;
    justify-content: flex-end;
    padding: 0 0 6px 0 !important;
    border-bottom: none !important;
    background: transparent !important;
}

.paper-body .web-note-id {
    display: none !important;
}

.paper-removed {
    padding: 24px 12px;
    text-align: center;
    color: var(--accent);
    font-weight: bold;
    font-style: italic;
    font-size: 13px;
    font-family: var(--font-sans);
}

/* Canvas Modal */
.canvas-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.canvas-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 380px;
    max-width: 90%;
    max-height: 75%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.canvas-modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-sans);
}

.modal-tab-group {
    display: flex;
    gap: 4px;
    background: var(--bg-card-alt);
    padding: 3px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.modal-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-tab-btn:hover {
    color: var(--text-primary);
}

.modal-tab-btn.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: 0 1px 4px var(--shadow);
}

.btn-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.btn-modal-close:hover {
    color: var(--accent);
}

.canvas-modal-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#addNoteSearchInput {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    margin-bottom: 10px;
    outline: none;
}

#addNoteSearchInput:focus {
    border-color: var(--accent);
}

.add-note-results-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.add-note-item {
    padding: 8px 10px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: all 0.2s;
}

.add-note-item:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.add-note-item-meta {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-sans);
    font-size: 10px;
    color: var(--text-muted);
}

.add-note-item-snippet {
    font-family: var(--font-note);
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Tag Suggestions Autocomplete ---- */
.tag-suggestions-box {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px var(--shadow);
    max-height: 180px;
    overflow-y: auto;
    width: 240px;
    z-index: 10000;
    display: none;
}

.tag-suggestions-box .suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-primary);
    transition: background 0.15s, box-shadow 0.15s;
}

.tag-suggestions-box .suggestion-item:hover,
.tag-suggestions-box .suggestion-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 2px var(--accent);
}

.tag-suggestions-box .suggestion-item .tag-name,
.tag-suggestions-box .suggestion-item .suggestion-cmd {
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-suggestions-box .suggestion-item .suggestion-cmd {
    font-family: var(--font-mono);
    font-size: 12px;
}

.tag-suggestions-box .suggestion-item .tag-count,
.tag-suggestions-box .suggestion-item .suggestion-desc {
    font-size: 11px;
    background: var(--border);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 10px;
    flex-shrink: 0;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-suggestions-box .suggestion-item:hover .tag-count,
.tag-suggestions-box .suggestion-item.active .tag-count {
    background: var(--border);
    color: var(--text-secondary);
}

/* ---- Resizable Note Paper Styles ---- */
.paper-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    cursor: se-resize;
    z-index: 15;
    background: linear-gradient(135deg, transparent 45%, var(--accent) 55%, transparent 60%, var(--accent) 70%);
    opacity: 0.4;
    transition: opacity 0.2s, transform 0.2s;
    border-bottom-right-radius: var(--radius);
}

.note-paper:hover .paper-resize-handle {
    opacity: 0.9;
}

.paper-resize-handle:hover {
    transform: scale(1.1);
    opacity: 1;
}

.note-paper.resizing {
    user-select: none;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

/* ---- Multi-Select Add Note Styles ---- */
.add-note-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.add-note-item.selected {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.add-note-item-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.add-note-item-checkbox {
    width: 18px;
    height: 18px;
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: all 0.2s;
    flex-shrink: 0;
}

.add-note-item.selected .add-note-item-checkbox {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}