:root {
    --db-bg: #edf1f2;
    --db-paper: #fffef9;
    --db-text: #252523;
    --db-muted: #77756f;
    --db-border: rgba(37, 37, 35, .12);
    --db-button: rgba(37, 37, 35, .06);
    --db-accent: #4f8ea3;
    --db-shadow: 0 24px 70px rgba(20, 30, 35, .14);
    --db-serif: Georgia, "Times New Roman", serif;
    --db-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.daybook-host {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.daybook-host[data-mode="desk"] {
    --db-bg: transparent;
    --db-paper: var(--glass-strong, rgba(255,255,255,.72));
    --db-text: var(--text, rgba(20,20,20,.92));
    --db-muted: var(--muted, rgba(20,20,20,.62));
    --db-border: var(--border-soft, rgba(0,0,0,.1));
    --db-button: var(--btn-bg, rgba(0,0,0,.06));
    --db-shadow: none;
}

.daybook,
.daybook * {
    box-sizing: border-box;
}

.daybook {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(190px, 28%) minmax(0, 1fr);
    overflow: hidden;
    color: var(--db-text);
    background: var(--db-bg);
    font-family: var(--db-ui);
}

.daybook-nav {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    overflow: hidden;
    border-right: 1px solid var(--db-border);
    background: color-mix(in srgb, var(--db-paper) 62%, transparent);
}

.daybook-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.daybook-brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--db-border);
    border-radius: 50%;
    font-size: 15px;
}

.daybook-brand div {
    display: flex;
    flex-direction: column;
}

.daybook-brand strong {
    font-family: var(--db-serif);
    font-size: 19px;
    font-weight: 500;
}

.daybook-brand span:last-child {
    color: var(--db-muted);
    font-size: 11px;
}

.daybook-today-btn,
.daybook-date-btn,
.daybook-refresh-btn {
    border: 1px solid var(--db-border);
    background: var(--db-button);
    color: inherit;
    cursor: pointer;
}

.daybook-today-btn {
    width: 100%;
    padding: 10px 12px;
    border-radius: 999px;
    font-weight: 650;
}

.daybook-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--db-muted);
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.daybook-refresh-btn,
.daybook-date-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
}

.daybook-history {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow: auto;
    padding-right: 3px;
}

.daybook-history-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.daybook-history-item:hover,
.daybook-history-item.is-active {
    border-color: var(--db-border);
    background: var(--db-button);
}

.daybook-history-item span {
    font-size: 12px;
    font-weight: 700;
}

.daybook-history-item small,
.daybook-history-empty {
    color: var(--db-muted);
    font-size: 11px;
    line-height: 1.35;
}

.daybook-nav-foot {
    margin-top: auto;
    color: var(--db-muted);
    font-size: 10px;
}

.daybook-page-wrap {
    min-width: 0;
    min-height: 0;
    padding: clamp(12px, 3vw, 34px);
    overflow: auto;
}

.daybook-page {
    width: min(820px, 100%);
    min-height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: clamp(22px, 5vw, 58px);
    border: 1px solid var(--db-border);
    border-radius: 22px;
    background: var(--db-paper);
    box-shadow: var(--db-shadow);
}

.daybook-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.daybook-greeting {
    margin: 0 0 7px;
    color: var(--db-muted);
    font-size: 12px;
}

.daybook-date {
    margin: 0;
    font-family: var(--db-serif);
    font-size: clamp(24px, 4vw, 42px);
    font-weight: 400;
    line-height: 1.08;
}

.daybook-date-controls {
    display: flex;
    gap: 7px;
}

.daybook-date-btn:disabled {
    opacity: .35;
    cursor: default;
}

.daybook-prompt {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 28px 0 20px;
    padding: 14px 16px;
    border: 1px solid var(--db-border);
    border-radius: 14px;
    background: var(--db-button);
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.daybook-prompt-label {
    color: var(--db-muted);
    font-size: 10px;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.daybook-prompt-text {
    font-family: var(--db-serif);
    font-size: 17px;
    line-height: 1.35;
}

.daybook-editor {
    width: 100%;
    flex: 1;
    min-height: 310px;
    resize: none;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--db-text);
    font-family: var(--db-serif);
    font-size: clamp(17px, 2vw, 21px);
    line-height: 1.72;
    caret-color: var(--db-accent);
}

.daybook-editor::placeholder {
    color: color-mix(in srgb, var(--db-muted) 65%, transparent);
}

.daybook-page-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 18px;
    color: var(--db-muted);
    font-size: 11px;
}

.daybook-save-status[data-state="saving"],
.daybook-save-status[data-state="unsaved"] {
    color: var(--db-accent);
}

.daybook-save-status[data-state="error"],
.daybook-save-status[data-state="local"] {
    font-weight: 650;
}

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

    .daybook-nav {
        max-height: 145px;
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid var(--db-border);
    }

    .daybook-brand,
    .daybook-history-head,
    .daybook-history,
    .daybook-nav-foot {
        display: none;
    }

    .daybook-page-wrap {
        padding: 10px;
    }

    .daybook-page {
        min-height: 100%;
        padding: 22px 18px;
        border-radius: 16px;
    }
}
