body {
    min-height: 100vh;
    background-color: #f4e1b9;
    background-image: repeating-linear-gradient(
        90deg,
        #f4e1b9 0,
        #f4e1b9 12px,
        #f0dbb0 12px,
        #f0dbb0 24px,
        #f2ddb2 24px,
        #f2ddb2 36px
    );
    color: #2c3440;
}

.mobile-only {
    display: none;
}

.app-main {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.app-toast-wrap {
    position: fixed;
    bottom: 0.85rem;
    right: 0.85rem;
    z-index: 2000;
    pointer-events: none;
}

.app-toast {
    min-width: 220px;
    max-width: min(90vw, 360px);
    border-radius: 10px;
    padding: 0.7rem 0.95rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    color: #fff;
    font-weight: 600;
    opacity: 0;
    transform: translateY(-8px);
}

.app-toast.toast-show {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 180ms ease, transform 180ms ease;
}

.app-toast.toast-hide {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 1000ms ease, transform 1000ms ease;
}

.toast-success {
    background: #198754;
}

.toast-danger {
    background: #dc3545;
}

.toast-warning {
    background: #b58100;
}

.toast-info {
    background: #0d6efd;
}

.app-topbar {
    background: var(--app-nav-color, #ef402b);
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
}

.app-logo {
    font-size: 2rem;
    color: #fff;
    font-weight: 700;
    font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
    letter-spacing: 0.03em;
}

.app-logo:hover,
.app-logo:focus {
    color: #fff;
}

.navbar .btn {
    white-space: nowrap;
}

.auth-wrap {
    min-height: calc(100vh - 160px);
    align-items: flex-start;
    padding-top: 1rem;
}

.auth-card .card-header {
    background: #e7e7e7;
    color: #7b8088;
}

.auth-card input {
    background: #eff0c3;
}

.dashboard-empty,
.journal-card {
    border-radius: 10px;
}

.journal-card {
    background: var(--journal-bg, #2f79bb);
    color: #fff;
}

.journal-card .journal-title {
    font-family: Georgia, 'Times New Roman', serif;
}

.dashboard-user-message {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3a50;
}

.desktop-journal-book {
    position: relative;
    border-left: 20px solid rgba(36, 46, 59, 0.6);
    border-radius: 8px;
    padding: 1.1rem 1rem 0.95rem 1.1rem;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
}

.desktop-journal-panel {
    background: #eceff3;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.8rem;
}

.desktop-journal-panel .journal-title {
    color: #4f5863;
    text-align: center;
    padding: 0.95rem 0.65rem;
}

.desktop-journal-title-link {
    color: inherit;
    text-decoration: none;
}

.desktop-journal-title-link:hover,
.desktop-journal-title-link:focus {
    color: #2f3c4b;
    text-decoration: none;
}

.desktop-journal-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid #d2dae4;
}

.desktop-journal-action {
    border: 0;
    border-right: 1px solid #d2dae4;
    background: #f6f8fb;
    color: #5f6976;
    text-decoration: none;
    text-align: center;
    padding: 0.55rem 0.3rem;
    font-size: 1.1rem;
}

.desktop-journal-action:last-child {
    border-right: 0;
}

.desktop-journal-updated {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
}

.journal-color-picker {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.45rem;
}

.journal-color-swatch {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid #d2d8e0;
    border-radius: 999px;
    background: var(--swatch, #2f79bb);
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.12s ease;
}

.journal-color-swatch:hover {
    transform: translateY(-1px);
}

.journal-color-swatch.active {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
    border-color: #0d6efd;
}

.hsv-picker {
    border: 1px solid #d7dde5;
    border-radius: 10px;
    padding: 0.65rem;
    background: #f8f9fb;
    display: grid;
    gap: 0.6rem;
}

.hsv-sv {
    position: relative;
    width: 100%;
    height: 150px;
    border-radius: 8px;
    border: 1px solid #c8d0da;
    cursor: crosshair;
}

.hsv-sv-cursor {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.hsv-hue {
    width: 100%;
}

.hsv-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hsv-preview {
    width: 34px;
    height: 22px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.18);
}

.hsv-hex {
    margin: 0;
    font-size: 0.85rem;
    color: #4b5563;
}

.journal-workspace {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1rem;
    min-height: 72vh;
    --journal-accent: #2d84c7;
}

.journal-sidebar {
    background: #3f4754;
    color: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.sidebar-head {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.entry-list {
    max-height: calc(72vh - 120px);
    overflow-y: auto;
}

.journal-sidebar #entry-search {
    border-radius: 0;
}

.entry-link {
    display: block;
    padding: 0.75rem 1rem;
    color: #d8dce3;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.entry-link span {
    display: block;
    font-size: 0.82rem;
    opacity: 0.85;
}

.entry-link p {
    display: none;
}

.entry-link:hover {
    color: #fff;
}

.entry-link.active {
    background: var(--journal-accent);
    background: color-mix(in srgb, var(--journal-accent) 76%, #253443);
    color: #fff;
}

.journal-sidebar .btn-primary,
.mobile-new-entry-btn {
    background: var(--journal-accent);
    border-color: var(--journal-accent);
    border-color: color-mix(in srgb, var(--journal-accent) 72%, #15202c);
}

.journal-sidebar .btn-primary:hover,
.journal-sidebar .btn-primary:focus,
.mobile-new-entry-btn:hover,
.mobile-new-entry-btn:focus {
    background: var(--journal-accent);
    border-color: var(--journal-accent);
    background: color-mix(in srgb, var(--journal-accent) 84%, #0f1722);
    border-color: color-mix(in srgb, var(--journal-accent) 70%, #0c141d);
}

.editor-pane .card {
    border: none;
    border-radius: 8px;
}

.entry-title-input {
    min-height: calc(1.5em + 1rem + 2px);
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    padding: 0.5rem 0.75rem;
}

.prism-editor {
    position: relative;
    display: grid;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background: #fff;
    cursor: text;
}

.prism-editor__textarea,
.prism-editor__preview {
    grid-area: 1 / 1 / 2 / 2;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.08rem;
    line-height: 1.45;
    tab-size: 4;
}

.prism-editor__textarea {
    width: 100%;
    min-height: 320px;
    resize: vertical;
    border: 0;
    outline: none;
    padding: 0.75rem;
    background: transparent;
    color: transparent;
    caret-color: #353b45;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    overflow: auto;
    position: relative;
    z-index: 2;
}

.prism-editor__preview {
    margin: 0;
    padding: 0.75rem;
    pointer-events: none;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    overflow: hidden;
    color: #353b45;
    z-index: 1;
}

.prism-editor__preview code {
    display: block;
    color: inherit;
    line-height: inherit;
    font-family: inherit;
    font-size: inherit;
    font-weight: 400;
    letter-spacing: normal;
}

.prism-editor .code-line {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
}

.prism-editor .code-line-task {
    color: #1d4ed8;
}

.prism-editor .code-line-note {
    color: #1f7a3e;
}

.prism-editor .code-line-milestone {
    color: #7a2424;
}

.prism-editor .code-line-heading {
    color: #1f2937;
}

.prism-editor .code-line-done {
    color: #6b7280;
}

.prism-editor .token-hashtag {
    color: #364fc7;
}

.prism-editor .token-date {
    color: #0f766e;
}

.prism-editor .token-link {
    color: #0a58ca;
    text-decoration: underline;
}

.autosave-status {
    font-size: 0.84rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid transparent;
}

.autosave-idle {
    color: #5f6b7a;
    background: #eef1f5;
    border-color: #d7dde5;
}

.autosave-saving {
    color: #0f5132;
    background: #d1e7dd;
    border-color: #badbcc;
}

.autosave-saved {
    color: #0a58ca;
    background: #dbeafe;
    border-color: #b6d4fe;
}

.autosave-error {
    color: #842029;
    background: #f8d7da;
    border-color: #f1aeb5;
}

.editor-content {
    min-height: 420px;
    resize: none;
}

@media (max-width: 991px) {
    .desktop-journal-book {
        border-left-width: 12px;
    }

    .journal-workspace {
        grid-template-columns: 1fr;
    }

    .entry-list {
        max-height: 280px;
    }

    .editor-content {
        min-height: 320px;
    }
}

@media (max-width: 767px) {
    .mobile-only {
        display: block;
    }

    .desktop-section {
        display: none !important;
    }

    .page-dashboard .app-topbar,
    .page-journal .app-topbar {
        display: none;
    }

    .page-dashboard .app-main,
    .page-journal .app-main {
        max-width: 100%;
        padding: 0 !important;
        min-height: 100vh;
    }

    .app-logo {
        font-size: 1.7rem;
    }

    .app-topbar .container-fluid {
        align-items: flex-start;
    }

    .app-topbar .ms-auto {
        gap: 0.5rem !important;
    }

    .dashboard-create-form {
        width: 100%;
        flex-direction: column;
    }

    .dashboard-create-form .btn {
        width: 100%;
    }

    .mobile-page-header {
        background: var(--app-nav-color, #1e1f23);
        color: #fff;
        min-height: 60px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 0.55rem;
    }

    .mobile-page-header h1 {
        font-size: 1.05rem;
        margin: 0;
        font-weight: 700;
        max-width: 48vw;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }

    .mobile-back {
        color: #fff;
        text-decoration: none;
        font-size: 1.4rem;
        line-height: 1;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
    }

    .mobile-back.placeholder {
        visibility: hidden;
    }

    .mobile-icons {
        display: flex;
        align-items: center;
        gap: 0.2rem;
    }

    .mobile-icon-btn {
        background: transparent;
        border: 0;
        color: #d4d8df;
        font-size: 1.26rem;
        line-height: 1;
        text-decoration: none;
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        padding: 0;
    }

    .mobile-icon-btn:hover,
    .mobile-icon-btn:focus {
        color: #ffffff;
    }

    .pill {
        border: 1px solid #8b9099;
        border-radius: 999px;
        color: #eceff4;
        font-size: 0.68rem;
        padding: 0.12rem 0.35rem;
        font-weight: 700;
    }

    .mobile-new-journal {
        padding: 0.75rem 0.9rem 0.2rem;
        display: grid;
        gap: 0.55rem;
    }

    .mobile-new-journal .form-control {
        display: none;
    }

    .mobile-new-journal .btn {
        width: 100%;
        background: #3a99d8;
        border: 0;
        height: 42px;
        font-size: 1.1rem;
    }

    .mobile-journal-grid {
        padding: 0.7rem 0.9rem 1.4rem;
        display: grid;
        gap: 0.8rem;
    }

    .mobile-journal-book {
        display: block;
        min-height: 305px;
        border-radius: 4px;
        background: var(--journal-bg, #2f78bc);
        position: relative;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
        border-left: 26px solid #4c5665;
        padding: 40px 20px;
    }

    .mobile-journal-title-link {
        text-decoration: none;
        color: inherit;
        display: block;
    }

    .mobile-journal-title-link:hover,
    .mobile-journal-title-link:focus {
        color: inherit;
    }

    .mobile-journal-panel {
        background: #eceff3;
        border-radius: 6px;
        overflow: hidden;
    }

    .mobile-journal-panel h2 {
        margin: 0;
        color: #515862;
        padding: 18px 10px;
        text-align: center;
        font-family: Georgia, 'Times New Roman', serif;
        font-size: 2rem;
    }

    .mobile-journal-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        border-top: 1px solid #d4dbe3;
    }

    .mobile-journal-actions button {
        border: 0;
        background: transparent;
        color: #757f8d;
        text-align: center;
        padding: 10px 0;
        border-right: 1px solid #d4dbe3;
        font-size: 1.35rem;
    }

    .mobile-journal-actions button:last-child {
        border-right: 0;
    }

    .journal-workspace {
        background: #dcdee2;
        gap: 0.75rem;
        min-height: calc(100vh - 52px);
    }

    .journal-sidebar {
        border-radius: 0;
        background: #dcdee2;
        color: #444c58;
    }

    .sidebar-head {
        display: none;
    }

    .journal-sidebar form.p-3 {
        border: 0 !important;
        padding: 0.8rem 1rem !important;
    }

.entry-search-wrap {
    display: none;
    padding: 0 1rem 0.35rem;
}

.entry-search-wrap .form-control {
    border-radius: 0;
}

.entry-search-wrap.open {
    display: block;
}

    .entry-search-wrap .form-control {
        border: 1px solid #c4cbd7;
        background: #eef2f7;
    }

    .journal-sidebar .btn {
        width: 100%;
        background: #3a99d8;
        border: 0;
        font-size: 1.1rem;
        line-height: 1.1;
        padding: 0.62rem 0.9rem;
        border-radius: 4px;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
    }

    .mobile-new-entry-btn::before {
        content: '+';
        display: inline-block;
        width: 1.2rem;
        height: 1.2rem;
        line-height: 1.2rem;
        border: 1px solid rgba(255, 255, 255, 0.65);
        border-radius: 50%;
        font-size: 1rem;
    }

    .entry-link {
        margin: 0.6rem 1rem;
        border-radius: 4px;
        background: #f1f2f4;
        color: #4f5762;
        padding: 0.8rem 0.75rem;
        border: 1px solid #d9dde3;
    }

    .entry-link strong {
        color: #565e69;
        font-family: Georgia, 'Times New Roman', serif;
        font-size: 1.14rem;
        line-height: 1.2;
    }

    .entry-link p {
        display: block;
        margin: 0.28rem 0 0;
        color: #5f6875;
        font-size: 0.68rem;
        line-height: 1.2;
    }

    .entry-link span {
        margin-top: 0.45rem;
        color: #9ca3ad;
        opacity: 1;
        text-transform: uppercase;
        font-weight: 700;
        font-size: 0.72rem;
    }

    .mobile-mode-list .entry-link.active {
        background: #f1f2f4;
        color: #4f5762;
    }

    .mobile-mode-list .entry-link.active strong {
        color: #565e69;
    }

    .mobile-mode-list .entry-link.active p {
        color: #5f6875;
    }

    .mobile-mode-list .entry-link.active span {
        color: #9ca3ad;
    }

    .editor-pane .card-body {
        padding: 0;
    }

    .editor-pane .card {
        border-radius: 0;
        box-shadow: none !important;
        background: #f6f7f8;
    }

    .mobile-date-strip {
        background: #edf0f4;
        color: #89929e;
        border-top: 1px solid #cfd6df;
        border-bottom: 1px solid #cfd6df;
        padding: 0.5rem 0.75rem;
        font-size: 0.86rem;
    }

    .editor-title-row {
        display: none !important;
    }

    .page-journal .alert {
        display: none;
    }

    .page-journal .row.g-3 {
        margin: 0;
        gap: 0;
    }

    .page-journal #autosave-form {
        gap: 0 !important;
    }

    .page-journal .row.g-3 > div {
        padding: 0;
    }

    #entry-title-edit {
        border: 0;
        border-bottom: 1px solid #cfd6df;
        border-radius: 0;
        font-size: 1.95rem;
        font-family: Georgia, 'Times New Roman', serif;
        font-weight: 700;
        padding: 0.3rem 0.65rem;
        color: #7b8086;
        background: #f6f7f8;
        min-height: 2.25em;
        overflow-wrap: break-word;
        white-space: pre-wrap;
    }

    #entry-title-edit:focus {
        box-shadow: none;
    }

    .page-journal label.form-label {
        display: none;
    }

    #entry-date-input {
        display: none;
    }

    .editor-content {
        min-height: calc(100vh - 255px);
        border: 0;
        border-radius: 0;
        background: #f6f7f8;
        padding: 0.5rem 0.75rem 2rem;
        font-size: 1.05rem;
        line-height: 1.35;
        color: #7e838a;
    }

    .prism-editor {
        border: 0;
        border-top: 0;
        border-bottom: 1px solid #cfd6df;
        border-radius: 0;
        background: #f6f7f8;
    }

    .prism-editor__textarea,
    .prism-editor__preview {
        font-size: 0.96rem;
        line-height: 1.35;
        padding: 0.55rem 0.75rem 2rem;
    }

    .desktop-delete {
        display: none;
    }

    .mobile-mode-list .editor-pane {
        display: none;
    }

    .mobile-mode-edit .journal-sidebar {
        display: none;
    }
}

@media (min-width: 768px) {
    .page-dashboard .app-topbar,
    .page-journal .app-topbar {
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    .page-dashboard .app-topbar .btn-outline-light,
    .page-journal .app-topbar .btn-outline-light {
        border-color: rgba(255, 255, 255, 0.35);
    }
}
