:root {
    --bg-color: #f5ecd9;        /* 古い紙のような温かいクリーム色 */
    --text-main: #4a3f33;
    --ink: #2f2a22;
    --accent: #c07a3e;          /* 育っていくあたたかさ（テラコッタ） */
    --accent-dim: rgba(192, 122, 62, 0.25);
    --paper-card: rgba(255, 255, 255, 0.5);
    --input-bg: rgba(255, 255, 255, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Shippori Mincho', serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.8;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.diary-header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 14px 20px;
}

.diary-header h1 {
    font-size: 1rem;
    font-weight: normal;
    letter-spacing: 2px;
    color: var(--accent);
    opacity: 0.85;
}

.header-link {
    position: absolute;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--accent);
    opacity: 0.7;
    font-size: 0.85rem;
    cursor: pointer;
}

#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s ease, transform 1s ease;
    max-width: 85%;
}

.message.active {
    opacity: 1;
    transform: translateY(0);
}

.message.diary {
    align-self: flex-start;
    color: var(--text-main);
    padding-left: 12px;
    border-left: 1px solid var(--accent-dim);
}

.message.user {
    align-self: flex-end;
    color: var(--ink);
    background: var(--paper-card);
    padding: 16px;
    border-radius: 8px 8px 0 8px;
    font-size: 0.95rem;
}

#input-area {
    padding: 12px 20px 16px;
    background: linear-gradient(to top, var(--bg-color) 80%, transparent);
}

.input-wrapper {
    background: var(--input-bg);
    border: 1px solid rgba(74, 63, 51, 0.15);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

textarea {
    background: transparent;
    border: none;
    color: var(--ink);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    outline: none;
    max-height: 45vh;
}

textarea::placeholder {
    color: rgba(74, 63, 51, 0.35);
}

.controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.3s ease;
}

.action-btn {
    background: transparent;
    color: var(--accent);
    padding: 8px 20px;
    font-size: 0.9rem;
    letter-spacing: 1px;
    border: 1px solid var(--accent-dim);
    border-radius: 20px;
}

.action-btn:hover {
    background: var(--accent-dim);
}

.hidden {
    display: none !important;
}

/* 振り返りモーダル（今日の日記のまとめ） */
#reflection-modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(245, 236, 217, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 1s ease;
}

#reflection-modal.hidden-modal {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    padding: 40px 24px;
    text-align: center;
    max-width: 400px;
}

#reflection-title {
    color: var(--accent);
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: normal;
}

#reflection-message {
    font-size: 0.95rem;
    color: var(--ink);
    margin-bottom: 20px;
}

#reflection-growth {
    font-size: 0.85rem;
    color: var(--accent);
    opacity: 0.85;
    margin-bottom: 16px;
}

/* 充実度スコアを暖色の濃淡バーで可視化する */
.richness-bar-wrap {
    width: 100%;
    height: 10px;
    border-radius: 6px;
    background: rgba(74, 63, 51, 0.1);
    margin: 0 auto 32px;
    overflow: hidden;
}

.richness-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s ease;
}

#close-modal {
    background: transparent;
    color: var(--ink);
    border: 1px solid rgba(74, 63, 51, 0.25);
    padding: 12px 32px;
    border-radius: 24px;
    font-size: 0.9rem;
}

/* 全画面モーダル共通（これまでの記録） */
.fullscreen-modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(245, 236, 217, 0.98);
    z-index: 200;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.fullscreen-modal.hidden-modal {
    opacity: 0; pointer-events: none;
}

.shelf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid rgba(74, 63, 51, 0.08);
}

.shelf-header h2 {
    color: var(--accent); font-size: 1.1rem; font-weight: normal;
}

.close-btn { font-size: 1.5rem; opacity: 0.7; background: transparent; color: var(--ink); }

.shelf-grid {
    flex: 1; overflow-y: auto; padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.shelf-item {
    position: relative;
    background: var(--paper-card);
    border: 1px solid rgba(74, 63, 51, 0.12);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(74, 63, 51, 0.08);
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

.shelf-item:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.shelf-item .d-date { font-size: 0.7rem; opacity: 0.5; margin-bottom: 6px; }
.shelf-item .d-title { font-size: 0.9rem; color: var(--ink); margin-bottom: 10px; }
.shelf-item .d-growth { font-size: 0.75rem; color: var(--accent); opacity: 0.8; margin-top: 8px; }

.log-chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.status-text {
    font-size: 0.8rem;
    color: var(--accent);
    opacity: 0.7;
    text-align: center;
    margin-top: 8px;
    min-height: 1.2em;
}
