/* =========================================================
   DESIGN SYSTEM
========================================================= */

:root {
    --brand: #D2E426;
    --brand-dark: #B7C719;
    --brand-soft: #F3F7C8;
    --brand-ultra: #FAFCEB;

    --ink: #191B16;
    --text: #2B2D27;
    --muted: #7B7E75;
    --light-text: #A1A49C;

    --bg: #F7F8F4;
    --surface: #FFFFFF;
    --surface-2: #FBFCF9;

    --border: #E7E9E2;

    --blue: #DDEEFF;
    --green: #E1F5DD;
    --orange: #FFF0DD;

    --sidebar: 220px;

    --shadow:
        0 4px 18px rgba(25,27,22,.045);
}


/* =========================================================
   RESET
========================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: var(--bg);
    color: var(--text);

    overflow: hidden;
}

button,
input {
    font: inherit;
}


/* =========================================================
   APP
========================================================= */

.app {
    width: 100%;
    height: 100vh;

    display: flex;
}


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    width: var(--sidebar);

    height: 100vh;

    background: var(--surface);

    border-right: 1px solid var(--border);

    display: flex;
    flex-direction: column;

    flex-shrink: 0;

    padding: 12px 10px;
}


/* =========================================================
   BRAND
========================================================= */

.sidebar-brand {
    height: 48px;

    display: flex;
    align-items: center;

    gap: 10px;

    padding: 0 8px;

    margin-bottom: 10px;
}

.brand-mark {
    width: 28px;
    height: 28px;

    background: var(--brand);

    border-radius: 8px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 10px;

    font-weight: 900;

    color: var(--ink);
}

.brand-name {
    font-size: 13px;

    font-weight: 850;

    letter-spacing: -.2px;

    white-space: nowrap;
}


/* =========================================================
   NAVIGATION
========================================================= */

.nav {
    display: flex;
    flex-direction: column;

    gap: 3px;
}

.nav-button {
    width: 100%;
    height: 38px;

    border: 0;

    border-radius: 9px;

    background: transparent;

    display: flex;
    align-items: center;

    gap: 11px;

    padding: 0 10px;

    color: var(--muted);

    font-size: 12px;

    font-weight: 600;

    cursor: pointer;

    text-align: left;

    transition:
        background .18s ease,
        color .18s ease,
        transform .18s ease;
}

.nav-button:hover {
    background: var(--brand-ultra);

    color: var(--ink);
}

.nav-button.active {
    background: var(--brand-soft);

    color: var(--ink);

    font-weight: 750;
}

.nav-button:active {
    transform: scale(.98);
}

.nav-icon {
    width: 20px;

    display: flex;
    justify-content: center;

    font-size: 15px;
}


/* =========================================================
   SIDEBAR BOTTOM
========================================================= */

.sidebar-bottom {
    margin-top: auto;

    border-top: 1px solid var(--border);

    padding-top: 10px;
}


/* =========================================================
   MAIN
========================================================= */

.main {
    flex: 1;

    min-width: 0;

    height: 100vh;

    display: flex;
    flex-direction: column;
}


/* =========================================================
   TOP BAR
========================================================= */

.topbar {
    height: 58px;

    background: var(--surface);

    border-bottom: 1px solid var(--border);

    display: flex;
    align-items: center;

    gap: 18px;

    padding: 0 18px;

    flex-shrink: 0;
}


/* =========================================================
   SEARCH
========================================================= */

.search {
    width: min(460px, 55%);

    height: 34px;

    background: #F6F7F4;

    border: 1px solid var(--border);

    border-radius: 9px;

    display: flex;
    align-items: center;

    padding: 0 11px;

    gap: 8px;
}

.search-icon {
    color: #9A9D95;

    font-size: 13px;
}

.search input {
    width: 100%;

    border: 0;

    outline: 0;

    background: transparent;

    color: var(--text);

    font-size: 11px;
}

.search input::placeholder {
    color: #A5A8A0;
}


/* =========================================================
   TOP ACTIONS
========================================================= */

.top-actions {
    margin-left: auto;

    display: flex;
    align-items: center;

    gap: 8px;
}

.top-button {
    height: 34px;

    border: 1px solid var(--border);

    background: white;

    border-radius: 9px;

    padding: 0 12px;

    color: var(--text);

    cursor: pointer;

    font-size: 11px;

    font-weight: 650;

    transition:
        background .18s ease,
        border .18s ease,
        transform .15s ease;
}

.top-button:hover {
    background: var(--brand-ultra);

    border-color: var(--brand);
}

.top-button:active {
    transform: scale(.97);
}

.new-button {
    background: var(--brand);

    border-color: var(--brand);

    color: var(--ink);

    font-weight: 800;

    padding: 0 15px;
}

.new-button:hover {
    background: #D9EA3B;

    border-color: #D9EA3B;
}

.icon-button {
    width: 34px;

    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar {
    width: 34px;
    height: 34px;

    border-radius: 50%;

    background: var(--ink);

    color: var(--brand);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 10px;

    font-weight: 850;

    cursor: pointer;
}


/* =========================================================
   CONTENT
========================================================= */

.content {
    flex: 1;

    min-height: 0;

    overflow: auto;

    padding: 18px;
}

.dashboard {
    max-width: 1450px;

    margin: 0 auto;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        250px;

    gap: 18px;
}

.main-column {
    min-width: 0;
}


/* =========================================================
   SECTION HEADING
========================================================= */

.section-heading {
    display: flex;

    align-items: center;

    justify-content: space-between;

    margin-bottom: 10px;
}

.section-heading h2 {
    font-size: 12px;

    font-weight: 800;

    color: var(--ink);
}

.section-heading button {
    border: 0;

    background: transparent;

    color: #68700B;

    font-size: 10px;

    cursor: pointer;

    font-weight: 650;
}


/* =========================================================
   QUICK CAPTURE
========================================================= */

.quick-grid {
    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 10px;

    margin-bottom: 18px;
}

.quick-card {
    min-height: 98px;

    border: 1px solid var(--border);

    border-radius: 12px;

    background: var(--surface);

    padding: 13px;

    cursor: pointer;

    position: relative;

    overflow: hidden;

    text-align: left;

    transition:
        transform .2s ease,
        box-shadow .2s ease,
        border .2s ease;
}

.quick-card:hover {
    transform: translateY(-2px);

    box-shadow: var(--shadow);

    border-color: #DDE1D3;
}

.quick-card.create {
    background: var(--brand);

    border-color: var(--brand);
}

.quick-card.create::after {
    content: "";

    position: absolute;

    width: 110px;
    height: 110px;

    border-radius: 50%;

    background: rgba(255,255,255,.14);

    right: -35px;
    top: -50px;
}

.quick-icon {
    width: 27px;
    height: 27px;

    border-radius: 8px;

    background: #F0F1ED;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 13px;

    margin-bottom: 10px;

    position: relative;
    z-index: 2;
}

.create .quick-icon {
    background: rgba(255,255,255,.35);
}

.quick-title {
    font-size: 11px;

    font-weight: 800;

    position: relative;
    z-index: 2;
}

.quick-description {
    margin-top: 3px;

    color: var(--muted);

    font-size: 9px;

    line-height: 1.35;

    position: relative;
    z-index: 2;
}

.create .quick-description {
    color: #434A19;
}


/* =========================================================
   STATS
========================================================= */

.stats-grid {
    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 10px;

    margin-bottom: 18px;
}

.stat-card {
    min-height: 72px;

    border-radius: 11px;

    padding: 11px 13px;

    border: 1px solid rgba(0,0,0,.025);

    position: relative;
}

.stat-blue {
    background: var(--blue);
}

.stat-green {
    background: var(--green);
}

.stat-orange {
    background: var(--orange);
}

.stat-value {
    font-size: 20px;

    line-height: 1;

    font-weight: 850;

    color: var(--ink);
}

.stat-label {
    margin-top: 5px;

    font-size: 9px;

    font-weight: 600;
}

.stat-change {
    margin-top: 3px;

    font-size: 8px;

    color: #4F8B49;
}


/* =========================================================
   RECENT DOCUMENTS
========================================================= */

.documents-card {
    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: 12px;

    overflow: hidden;
}

.document-row {
    min-height: 51px;

    display: flex;
    align-items: center;

    padding: 7px 12px;

    border-bottom: 1px solid #F0F1ED;

    cursor: pointer;

    transition:
        background .15s ease;
}

.document-row:last-child {
    border-bottom: 0;
}

.document-row:hover {
    background: #FAFBF7;
}

.document-icon {
    width: 28px;
    height: 28px;

    border-radius: 50%;

    background: var(--brand-ultra);

    color: #68700B;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 12px;

    flex-shrink: 0;

    margin-right: 10px;
}

.document-info {
    min-width: 0;

    flex: 1;
}

.document-name {
    font-size: 10px;

    font-weight: 750;

    color: var(--text);

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}

.document-description {
    margin-top: 2px;

    font-size: 8px;

    color: var(--muted);

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}

.document-date {
    font-size: 8px;

    color: var(--light-text);

    white-space: nowrap;

    margin-left: 10px;
}

.more {
    width: 24px;

    border: 0;

    background: transparent;

    color: #A1A49D;

    cursor: pointer;

    font-size: 14px;
}


/* =========================================================
   RIGHT COLUMN
========================================================= */

.right-column {
    display: flex;

    flex-direction: column;

    gap: 12px;
}

.right-card {
    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: 12px;

    padding: 14px;

    box-shadow:
        0 2px 8px rgba(25,27,22,.025);
}

.right-card-title {
    font-size: 11px;

    font-weight: 800;

    margin-bottom: 13px;
}


/* =========================================================
   INSIGHTS
========================================================= */

.insight-row {
    display: flex;

    align-items: center;

    gap: 9px;

    padding: 8px 0;

    border-bottom: 1px solid #F0F1ED;
}

.insight-row:last-child {
    border-bottom: 0;
}

.insight-icon {
    width: 27px;
    height: 27px;

    border-radius: 8px;

    background: var(--brand-ultra);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 12px;
}

.insight-info {
    flex: 1;
}

.insight-label {
    font-size: 8px;

    color: var(--muted);
}

.insight-value {
    margin-top: 2px;

    font-size: 14px;

    font-weight: 800;
}

.insight-growth {
    color: #4E9A4A;

    font-size: 8px;

    font-weight: 700;
}


/* =========================================================
   WEEKLY ACTIVITY
========================================================= */

.chart {
    height: 100px;

    position: relative;

    margin-top: 5px;

    overflow: hidden;
}

.chart-grid {
    position: absolute;

    left: 0;
    right: 0;

    top: 10px;
    bottom: 20px;

    background:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 28px,
            #F0F1ED 29px
        );
}

.chart svg {
    position: absolute;

    left: 0;
    top: 10px;

    width: 100%;
    height: 65px;
}

.chart-labels {
    position: absolute;

    bottom: 0;

    left: 0;
    right: 0;

    display: flex;

    justify-content: space-between;

    font-size: 7px;

    color: #B0B2AC;
}


/* =========================================================
   AI SCORE
========================================================= */

.score {
    display: flex;

    align-items: center;

    justify-content: space-between;
}

.score-number {
    font-size: 28px;

    font-weight: 900;

    letter-spacing: -1px;
}

.score-good {
    display: inline-block;

    margin-top: 3px;

    padding: 3px 6px;

    border-radius: 5px;

    background: var(--brand-soft);

    color: #5F690C;

    font-size: 8px;

    font-weight: 800;
}

.score-ring {
    width: 58px;
    height: 58px;

    position: relative;
}

.score-ring svg {
    width: 100%;
    height: 100%;

    transform: rotate(-90deg);
}

.score-ring circle {
    fill: none;

    stroke-width: 5;
}

.score-ring .track {
    stroke: #ECEDE8;
}

.score-ring .progress {
    stroke: var(--brand);

    stroke-linecap: round;

    stroke-dasharray: 145;

    stroke-dashoffset: 12;
}

.score-ring span {
    position: absolute;

    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 8px;

    font-weight: 800;
}


/* =========================================================
   RECENT ACTIVITY
========================================================= */

.activity {
    display: flex;

    gap: 9px;

    padding: 8px 0;

    border-bottom: 1px solid #F0F1ED;
}

.activity:last-child {
    border-bottom: 0;
}

.activity-icon {
    width: 25px;
    height: 25px;

    border-radius: 7px;

    background: var(--brand-ultra);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 10px;

    flex-shrink: 0;
}

.activity-text {
    font-size: 8px;

    line-height: 1.4;
}

.activity-text strong {
    display: block;

    font-size: 9px;

    margin-bottom: 2px;
}

.activity-time {
    color: var(--light-text);
}


/* =========================================================
   CREATE MODAL OVERLAY
========================================================= */

.overlay {
    position: fixed;

    inset: 0;

    background: rgba(20,22,16,.25);

    backdrop-filter: blur(4px);

    opacity: 0;

    pointer-events: none;

    transition: opacity .25s ease;

    z-index: 100;
}

.overlay.open {
    opacity: 1;

    pointer-events: auto;
}


/* =========================================================
   CREATE MODAL
========================================================= */

.create-modal {
    position: fixed;

    left: 50%;
    top: 50%;

    transform:
        translate(-50%, -45%)
        scale(.97);

    width: min(620px, calc(100% - 30px));

    background: white;

    border-radius: 18px;

    padding: 24px;

    border: 1px solid var(--border);

    box-shadow:
        0 30px 80px rgba(0,0,0,.18);

    opacity: 0;

    pointer-events: none;

    transition:
        opacity .25s ease,
        transform .25s ease;

    z-index: 110;
}

.create-modal.open {
    opacity: 1;

    pointer-events: auto;

    transform:
        translate(-50%, -50%)
        scale(1);
}


/* =========================================================
   MODAL HEADER
========================================================= */

.modal-head {
    display: flex;

    justify-content: space-between;

    align-items: flex-start;

    margin-bottom: 20px;
}

.modal-title {
    font-size: 19px;

    font-weight: 850;

    color: var(--ink);
}

.modal-subtitle {
    margin-top: 5px;

    color: var(--muted);

    font-size: 10px;
}

.close {
    width: 32px;
    height: 32px;

    border-radius: 50%;

    border: 1px solid var(--border);

    background: white;

    cursor: pointer;

    font-size: 17px;

    color: var(--muted);

    transition:
        background .18s ease,
        color .18s ease;
}

.close:hover {
    background: var(--brand-soft);

    color: var(--ink);
}


/* =========================================================
   UPLOAD OPTIONS
========================================================= */

.modal-options {
    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 12px;
}

.modal-option {
    border: 1px solid var(--border);

    background: white;

    border-radius: 14px;

    padding: 18px;

    min-height: 155px;

    cursor: pointer;

    text-align: left;

    transition:
        border .2s ease,
        background .2s ease,
        transform .2s ease,
        box-shadow .2s ease;
}

.modal-option:hover {
    border-color: var(--brand);

    background: var(--brand-ultra);

    transform: translateY(-3px);

    box-shadow:
        0 10px 25px rgba(25,27,22,.07);
}

.modal-option:active {
    transform: translateY(-1px) scale(.99);
}


/* =========================================================
   FILE ICON
========================================================= */

.modal-icon {
    width: 42px;
    height: 42px;

    border-radius: 11px;

    background: var(--brand);

    color: var(--ink);

    display: flex;
    align-items: center;
    justify-content: center;

    margin-bottom: 15px;

    font-size: 10px;

    font-weight: 900;

    letter-spacing: -.3px;
}

.modal-option strong {
    display: block;

    font-size: 12px;

    margin-bottom: 6px;

    color: var(--ink);
}

.modal-option span {
    color: var(--muted);

    font-size: 9px;

    line-height: 1.5;

    display: block;
}


/* =========================================================
   FILE NAME / STATUS
========================================================= */

.upload-status {
    margin-top: 14px;

    min-height: 0;

    padding: 0;

    border-radius: 9px;

    font-size: 9px;

    transition: all .2s ease;
}

.upload-status.show {
    padding: 10px 12px;

    background: var(--brand-ultra);

    border: 1px solid #E7EDB2;

    color: #596208;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1100px) {

    :root {
        --sidebar: 190px;
    }

    .dashboard {
        grid-template-columns: 1fr;
    }

    .right-column {
        display: grid;

        grid-template-columns:
            repeat(3, 1fr);
    }
}


@media (max-width: 800px) {

    :root {
        --sidebar: 68px;
    }

    .sidebar {
        padding: 10px 7px;
    }

    .brand-name,
    .nav-label {
        display: none;
    }

    .sidebar-brand {
        justify-content: center;

        padding: 0;
    }

    .nav-button {
        justify-content: center;

        padding: 0;
    }

    .topbar {
        padding: 0 10px;
    }

    .search {
        width: 50%;
    }

    .quick-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }

    .right-column {
        grid-template-columns:
            repeat(2, 1fr);
    }
}


@media (max-width: 550px) {

    body {
        overflow: auto;
    }

    .app {
        min-height: 100vh;
    }

    .content {
        padding: 12px;
    }

    .quick-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .right-column {
        grid-template-columns: 1fr;
    }

    .search {
        width: 100%;
    }

    .new-button {
        padding: 0 9px;
    }

    .new-label {
        display: none;
    }

    .modal-options {
        grid-template-columns: 1fr;
    }

    .create-modal {
        padding: 18px;

        max-height: 90vh;

        overflow-y: auto;
    }
}


/* =========================================================
   SAVED DIARY SYSTEM
   Added without changing the original dashboard layout.
========================================================= */

.quick-card.diary-card {
    padding: 0;
    background: #171913;
    border-color: #171913;
    color: #fff;
    min-height: 98px;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.quick-card.diary-card:hover {
    border-color: #171913;
    box-shadow: 0 8px 22px rgba(25,27,22,.10);
}

.diary-cover {
    position: relative;
    min-height: 98px;
    height: 100%;
    padding: 12px 13px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.diary-cover::before {
    content: "";
    position: absolute;
    width: 95px;
    height: 95px;
    right: -40px;
    top: -47px;
    border-radius: 50%;
    border: 18px solid rgba(210,228,38,.14);
}

.diary-cover::after {
    content: "";
    position: absolute;
    width: 55px;
    height: 55px;
    left: -27px;
    bottom: -31px;
    border-radius: 50%;
    border: 1px solid rgba(210,228,38,.20);
}

.diary-brand {
    position: relative;
    z-index: 2;
    color: var(--brand);
    font-size: 6px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: .8px;
}

.diary-type {
    position: absolute;
    right: 12px;
    top: 11px;
    z-index: 2;
    font-size: 6px;
    font-weight: 800;
    color: rgba(255,255,255,.48);
}

.diary-content {
    position: relative;
    z-index: 2;
    min-width: 0;
    margin-top: 6px;
}

.diary-line {
    width: 19px;
    height: 3px;
    border-radius: 3px;
    background: var(--brand);
    margin-bottom: 6px;
}

.diary-name {
    font-size: 11px;
    line-height: 1.15;
    font-weight: 850;
    color: #fff;
    max-width: 135px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diary-meta {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.diary-date {
    font-size: 6px;
    color: rgba(255,255,255,.45);
    white-space: nowrap;
}

.diary-open {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 900;
    flex-shrink: 0;
}

/* Make the placeholder consume no visible space. */
.saved-diaries-placeholder {
    display: none;
}

/* Delete button shown on diary hover. */
.diary-delete {
    position: absolute;
    right: 7px;
    bottom: 7px;
    z-index: 5;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    color: rgba(255,255,255,.75);
    cursor: pointer;
    font-size: 10px;
    opacity: 0;
    transition: opacity .18s ease, background .18s ease;
}

.diary-card:hover .diary-delete {
    opacity: 1;
}

.diary-delete:hover {
    background: rgba(255,255,255,.24);
    color: #fff;
}

/* =========================================================
   AI ANALYSIS OVERLAY
========================================================= */

.ai-analysis-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(247,248,244,.92);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.ai-analysis-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.ai-analysis-card {
    width: min(430px, calc(100% - 30px));
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 25px 70px rgba(25,27,22,.12);
}

.ai-orbit {
    width: 62px;
    height: 62px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    font-weight: 900;
    position: relative;
    animation: diaryPulse 1.5s ease-in-out infinite;
}

.ai-orbit::before,
.ai-orbit::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(210,228,38,.55);
}

.ai-orbit::before {
    inset: -8px;
    animation: diarySpin 2.5s linear infinite;
}

.ai-orbit::after {
    inset: -16px;
    border-color: rgba(210,228,38,.20);
    animation: diarySpin 4s linear infinite reverse;
}

.ai-analysis-title {
    font-size: 16px;
    font-weight: 850;
    color: var(--ink);
}

.ai-analysis-subtitle {
    margin-top: 6px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.5;
}

.ai-file-name {
    margin: 12px auto 0;
    max-width: 300px;
    padding: 6px 10px;
    border-radius: 20px;
    background: var(--brand-ultra);
    border: 1px solid #E7EDB2;
    color: #596208;
    font-size: 7px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-progress {
    margin-top: 18px;
    text-align: left;
}

.ai-step {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 27px;
    color: #A1A49C;
    font-size: 8px;
    opacity: .38;
    transition: opacity .2s ease, color .2s ease;
}

.ai-step.active,
.ai-step.done {
    opacity: 1;
    color: var(--text);
}

.ai-step-dot {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #ECEDE8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
}

.ai-step.active .ai-step-dot,
.ai-step.done .ai-step-dot {
    background: var(--brand);
    color: var(--ink);
}

@keyframes diaryPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes diarySpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* =========================================================
   NAME DIARY MODAL
========================================================= */

.diary-name-modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -45%) scale(.97);
    width: min(430px, calc(100% - 30px));
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 30px 80px rgba(0,0,0,.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 210;
}

.diary-name-modal.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.diary-name-icon {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--brand);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 900;
    margin-bottom: 14px;
}

.diary-name-title {
    font-size: 17px;
    font-weight: 850;
    color: var(--ink);
}

.diary-name-subtitle {
    margin-top: 5px;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.5;
}

.diary-name-label {
    display: block;
    margin-top: 18px;
    margin-bottom: 6px;
    font-size: 8px;
    font-weight: 750;
    color: var(--text);
}

.diary-name-input {
    width: 100%;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: 0;
    padding: 0 11px;
    color: var(--text);
    background: #FBFCF9;
    font-size: 10px;
}

.diary-name-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(210,228,38,.14);
}

.diary-name-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.diary-name-btn {
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 0 13px;
    cursor: pointer;
    font-size: 9px;
    font-weight: 750;
    background: #fff;
    color: var(--text);
}

.diary-name-btn.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--ink);
    font-weight: 850;
}

.diary-name-btn:hover {
    border-color: var(--brand);
}

/* =========================================================
   SIMPLE EDITABLE DIARY VIEW
========================================================= */

.editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(247,248,244,.96);
    display: none;
    overflow: auto;
}

.editor-overlay.open {
    display: block;
}

.editor-shell {
    width: min(1050px, calc(100% - 28px));
    margin: 20px auto;
}

.editor-top {
    height: 50px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 12px;
    margin-bottom: 12px;
}

.editor-back {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.editor-title {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-save {
    height: 31px;
    border: 0;
    border-radius: 8px;
    padding: 0 12px;
    background: var(--brand);
    color: var(--ink);
    font-size: 9px;
    font-weight: 850;
    cursor: pointer;
}

.editor-page {
    width: min(794px, 100%);
    min-height: 1000px;
    margin: 0 auto;
    padding: 42px;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(25,27,22,.06);
}

.editor-page h1 {
    font-size: 20px;
    margin-bottom: 18px;
    outline: none;
}

.editor-page p,
.editor-page div[contenteditable="true"] {
    font-size: 10px;
    line-height: 1.7;
    color: var(--text);
    outline: none;
}

.editor-note {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 8px;
    background: var(--brand-ultra);
    border: 1px solid #E7EDB2;
    color: #596208;
    font-size: 8px;
}

@media (max-width: 800px) {
    .quick-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 550px) {
    .quick-grid {
        grid-template-columns: 1fr;
    }

    .editor-page {
        padding: 24px;
    }
}



.template-designer{
    position:fixed;
    inset:0;
    background:#f5f6f8;
    z-index:5000;

    display:none;
    flex-direction:column;
}

.template-designer.open{
    display:flex;
}

.designer-header{
    height:70px;

    background:white;

    display:flex;
    align-items:center;
    justify-content:space-between;

    padding:0 25px;

    border-bottom:1px solid #ddd;
}

.designer-title{
    font-size:20px;
    font-weight:700;
}

.designer-actions{
    display:flex;
    gap:10px;
}

#saveTemplateBtn{
    border:none;

    background:#D2E426;

    padding:10px 20px;

    border-radius:8px;

    cursor:pointer;

    font-weight:600;
}


#closeDesignerBtn{
    border:none;

    background:#e5e5e5;

    padding:10px 20px;

    border-radius:8px;

    cursor:pointer;
}

.designer-body{
    flex:1;
    display:flex;
    overflow:auto;
}

.toolbox{
    width:250px;

    background:white;

    border-right:1px solid #ddd;

    padding:20px;

    overflow:auto;
}

.toolbox h3{
    margin-bottom:15px;
}

.tool-field{
    width:100%;

    padding:12px;

    margin-bottom:10px;

    border:1px solid #ddd;

    background:#fff;

    border-radius:8px;

    cursor:pointer;

    text-align:left;

    font-weight:600;
}

.tool-field:hover{
    background:#f7f7f7;
}

.pdf-workspace{
    flex:1;

    position:relative;

    overflow:auto;

    background:#cfcfcf;

    padding:30px;
}

#pdfCanvas{
    display:block;

    background:white;

    margin:auto;

    box-shadow:0 0 20px rgba(0,0,0,.15);
}



.form-field{
    position:absolute;

    min-width:80px;
    min-height:30px;

    background:#fffde8;

    border:2px dashed #D2E426;

    border-radius:6px;

    padding:6px;

    cursor:move;

    pointer-events:auto;

    resize:both;

    overflow:auto;

    font-size:13px;

    font-weight:600;
}

.template-name-modal{
    position:fixed;
    inset:0;

    background:rgba(0,0,0,.45);

    display:none;

    align-items:center;
    justify-content:center;

    z-index:6000;
}

.template-name-modal.open{
    display:flex;
}

.template-box{
    width:400px;

    background:white;

    padding:25px;

    border-radius:12px;
}

#templateNameInput{
    width:100%;

    height:45px;

    margin-top:15px;

    padding:10px;

    border:1px solid #ccc;

    border-radius:8px;
}

#confirmTemplateSave{
    margin-top:15px;

    width:100%;

    height:45px;

    border:none;

    background:#D2E426;

    border-radius:8px;

    cursor:pointer;
}

.form-viewer{
    position:fixed;
    inset:0;

    background:#f5f6f8;

    display:none;

    flex-direction:column;

    z-index:7000;
}

.form-viewer.open{
    display:flex;
}

.viewer-header{
    height:70px;

    background:white;

    border-bottom:1px solid #ddd;

    display:flex;

    align-items:center;

    gap:20px;

    padding:0 20px;
}



#viewerFieldLayer{
    position:absolute;
    left:0;
    top:0;
    width:100%;
    height:100%;
    pointer-events:none;
}

#viewerFieldLayer input,
#viewerFieldLayer textarea,
#viewerFieldLayer select{
    position:absolute;

    pointer-events:auto;
}


#viewerFieldLayer input,
#viewerFieldLayer select,
#viewerFieldLayer textarea{
 background:transparent;
    border:none;
    outline:none;
}

.overlay-input{
    position:absolute;

    background:transparent;

    border:none;

    outline:none;

    font-size:16px;

    width:100%;
}


.pdf-page{
    position:relative;
    display:inline-block;
    margin:auto;
}

.viewer-pdf-wrapper{
    position:relative;
    display:inline-block;
    margin:auto;
}

#pdfCanvas,
#viewerCanvas{
    display:block;
}

#fieldLayer{
    position:absolute;
    left:0;
    top:0;
}


.pdf-page,
.viewer-pdf-wrapper{
    position:relative;
    display:inline-block;
}

#pdfCanvas,
#viewerCanvas{
    display:block;
}

#fieldLayer{
    position:absolute;
    left:0;
    top:0;
    width:100%;
    height:100%;
}

