/* ========== font ========== */
@font-face {
    font-family: 'MyFont';
    src: url('/static/MyFont.otf');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Font2';
    src: url('/static/Font2.otf');
    font-weight: normal;
    font-style: normal;
}

/* ========== layout for all ========== */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 0;
    background: url('/static/indexImage.png') no-repeat center center / cover;
    background-attachment: fixed;
    background-size: cover;
}

.hidden {
    display: none !important;
}

/* ========== login page ========== */
.login-body {
    background: url('/static/bgImage.png') no-repeat center center / cover;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 750px;
    min-height: 100vh;
    margin: 0;
}

.login-title {
    font-family: 'MyFont', serif;
    font-size: 70px;
    color: #3b2f2f;
    width: 420px;
    text-align: center;
    margin-bottom: 15px;
    margin-top: -100px;
}

.login-container {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #333;
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
    width: 360px;
}

.login-form label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 316px;
    margin: 0 auto 20px auto;
    font-family: 'MyFont', serif;
    font-size: 22px;
}

.login-form input {
    width: 210px;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    box-sizing: border-box;
}

.primary-btn {
    width: 316px;
    margin: 5px 22px;
    padding: 5px;
    background: #d8a87b;
    border-radius: 14px;
    color: #fff;
    font-weight: 600;
    border: none;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    font-family: 'MyFont', serif;
    font-size: 20px;
    transition: 0.25s ease;
}

.primary-btn:hover {
    background: #c8966f;
    transform: scale(1.05);
}

.error-msg {
    background: #b91c1c;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 10px;
    color: white;
    text-align: center;
}

.hint {
    font-size: 12px;
    margin: 5px 35px;
    color: #9ca3af;
    text-align: center;
}

/* ========== title/header ========== */
.app-title {
    font-family: 'MyFont', serif;
    font-size: 40px;
    font-weight: 600;
    color: #3b2f2f;
    margin-top: 10px;
    text-align: center;
    flex: 1;
}

.user-row {
    margin-left: 140px;
}

.app-user {
    font-family: 'Font2', sans-serif;
    font-size: 40px;
}

#section-chat #start-conversation-btn {
    position: absolute;
    top: 65px;
    left: 300px;
    font-family: 'MyFont', sans-serif;
    font-size: 22px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 10px;
    background: #f3e9dd;
    border: none;
    cursor: pointer;
    transition: 0.25s ease;
}

#section-chat #start-conversation-btn:hover {
    transform: scale(1.08);
    background: #e8d9c7;
}

/* ========== nav bar ========== */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: #cdc9c4;
    border-top: none;
}

.bottom-nav .nav-btn {
    flex: 1;
    height: 100%;
    border: none;
    cursor: pointer;
    background: transparent;
    font-family: 'MyFont', sans-serif;
    font-size: 30px;
    font-weight: 400;
    color: black;
    transition: 0.25s ease;
}

.bottom-nav .nav-btn.active {
    background: rgba(255, 255, 255, 0.25);
    font-weight: 600;
}

.bottom-nav .nav-btn:hover {
    background: #2d3648;
    color: white;
    transform: scale(1.05);
}

/* ========== Chat page ========== */
.chat-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    margin-top: 30px;
    margin-left: 20px;
}

.chat-left,
.chat-right {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    height: 480px;
    box-sizing: border-box;
    overflow-y: auto;
}

.chat-left {
    font-family: 'Font2', sans-serif;
    font-size: 30px;
    line-height: 1.3;
    width: 1200px;
}

.chat-right {
    width: 600px;
}

.chat-left h3 {
    font-family: 'MyFont', sans-serif;
    font-size: 30px;
    margin-top: 0;
    margin-bottom: 20px;
    line-height: 1;
}

.chat-right h4 {
    font-family: 'MyFont', sans-serif;
    font-size: 30px;
    margin-top: 0;
    margin-bottom: 20px;
    line-height: 1;
}

.chat-left.normal-width {
    width: 600px;
}

/* ========== conversation ========== */
.conversation-box {
    margin-top: 10px;
    padding: 8px;
    height: 260px;
    overflow-y: auto;
    background: #fafafa;
    border-radius: 6px;
    border: 1px solid #e1e1e1;
}

.msg {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    font-size: 24px;
    max-width: 70%;
    clear: both;
}

.msg.user {
    background: #e0f2fe;
    float: right;
    margin-left: auto;
}

.msg.ai {
    background: #f3e8ff;
    float: left;
    margin-right: auto;
}

/* ========== recording button ========== */
.record-controls {
    margin-top: 10px;
}

.record-controls button {
    font-family: 'MyFont', sans-serif;
    font-size: 20px;
    font-weight: 500;
    padding: 6px 14px;
    margin-right: 8px;
    border-radius: 8px;
    background: #eee;
    border: 1px solid #bbb;
    cursor: pointer;
    transition: 0.25s ease;
}

.record-controls button:not([disabled]):hover {
    transform: scale(1.1);
    background: #ddd;
}

.record-controls button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

#conversation-status {
    font-size: 24px;
    font-weight: 600;
    margin-top: 12px;
    color: #6b7280;
}

/* ========== preview diary ========== */
.diary-preview h5,
.diary-preview p {
    margin: 0 0 6px 0;
    line-height: 1.1;
}

#diary-title-chat {
    font-family: 'Font2', sans-serif;
    font-size: 40px;
    text-align: center;
}

#diary-date-chat,
#diary-mood-chat {
    font-family: 'Font2', sans-serif;
    color: #6b7280;
    font-size: 35px;
    text-align: right;
}

#diary-content-chat {
    font-family: 'Font2', sans-serif;
    font-size: 35px;
    white-space: pre-wrap;
}

/* ========== My Diaries page ========== */
.diary-search {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.diary-search input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d8cfc2;
    border-radius: 10px;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.85);
    transition: border 0.2s ease;
}

.diary-search input:focus {
    border: 1px solid #bfa48a;
    outline: none;
}

.diary-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    height: 420px;
    overflow-y: auto;
}

#diary-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 500px;
    background: white;
    border-radius: 12px;
    padding: 16px;
    overflow-y: auto;
    font-family: 'MyFont', serif;
    font-size: 20px;
}

#diary-list li {
    padding: 12px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s ease;
    font-family: 'MyFont', serif;
    font-size: 20px;
}

#diary-list li:hover {
    background: #f1f5f9;
}

.diary-date-header {
    font-family: serif !important;
    margin-top: 12px;
    font-weight: 600;
    font-size: 16px;
    color: #7a7a7a;
}

.diary-item {
    padding: 6px 0 6px 16px;
    cursor: pointer;
    font-size: 14px;
}

/* ========== diary details ========== */
.diary-detail {
    background: white;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    max-height: 600px;
    overflow-y: auto;
}

#diary-title {
    font-family: 'Font2', sans-serif;
    font-size: 28px;
    text-align: center;
    margin: 0 0 12px 0;
}

#diary-date,
#diary-time,
#diary-mood {
    font-family: 'Font2', sans-serif;
    font-size: 20px;
    text-align: right;
    color: #6b7280;
    margin: 4px 0;
}

#diary-content {
    font-family: 'Font2', sans-serif;
    font-size: 24px;
    flex: 1;
    overflow-y: auto;
    margin: 16px 0;
    white-space: pre-wrap;
    line-height: 1.6;
}

.diary-actions {
    display: flex;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

.diary-actions button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.diary-actions button:hover {
    background: #f3f4f6;
}

#section-diaries h3 {
    font-family: 'MyFont', serif;
    font-size: 30px;
    text-align: center;
    margin-top: 0px;
    margin-bottom: 10px;
}

#section-diaries {
    overflow: hidden;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
    margin-top: -40px !important;
}

#section-diaries button {
    font-family: 'MyFont', serif;
    font-size: 20px;
    padding: 8px 20px;
    border-radius: 12px;
    background: #f3e9dd;
    border: none;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    transition: 0.25s ease;
}

#section-diaries button:hover {
    background: #e8d8c7;
    transform: scale(1.05);
}

#section-diaries button:active {
    transform: scale(0.97);
}

/* ========== setting page ========== */
#section-settings {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 600px;
    margin: 0 auto;
}

#section-settings h3 {
    font-family: 'MyFont', sans-serif;
    font-size: 28px;
    margin-top: 0;
}

#section-settings button {
    font-family: 'MyFont', serif;
    font-size: 20px;
    padding: 10px 24px;
    border-radius: 12px;
    background: #f3e9dd;
    border: none;
    color: #3b2f2f;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    transition: 0.25s ease;
}

#section-settings button:hover {
    background: #e8d8c7;
    transform: scale(1.05);
}

#section-settings button:active {
    transform: scale(0.97);
}

#section-settings p {
    font-family: 'MyFont', serif;
    font-size: 20px;
    color: #3b2f2f;
}

/* ========== Diary Settings modal ========== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.35);
    z-index: 50;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 20px 24px;
    min-width: 520px;
    max-width: 720px;
    max-height: 80vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    font-family: 'Font2', sans-serif;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-header h3 {
    font-family: 'MyFont', serif;
    font-size: 28px;
    margin: 0;
    color: #3b2f2f;
}

.close-btn {
    border: none;
    background: transparent;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 999px;
    transition: 0.2s ease;
}

.close-btn:hover {
    background: #f3e9dd;
}

.modal-body {
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 12px;
}

.preference-group {
    margin-bottom: 16px;
}

.preference-group label {
    display: block;
    font-family: 'MyFont', serif;
    font-size: 20px;
    margin-bottom: 6px;
    color: #3b2f2f;
}

#diary-theme,
#diary-style,
#custom-instructions {
    width: 100%;
    box-sizing: border-box;
    border-radius: 10px;
    border: 1px solid #d8cfc2;
    padding: 10px 12px;
    font-size: 16px;
    font-family: 'Font2', sans-serif;
    background: rgba(255, 255, 255, 0.95);
    outline: none;
    transition: border 0.2s ease, box-shadow 0.2s ease;
}

#diary-theme:focus,
#diary-style:focus,
#custom-instructions:focus {
    border-color: #bfa48a;
    box-shadow: 0 0 0 2px rgba(191, 164, 138, 0.2);
}

#custom-instructions {
    resize: vertical;
}

/* 文本 + 语音按钮一行 */
.custom-input-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.voice-input-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6b7280;
}

.voice-btn {
    border: none;
    border-radius: 999px;
    padding: 6px 10px;
    background: #f3e9dd;
    cursor: pointer;
    font-size: 16px;
    transition: 0.2s ease;
}

.voice-btn:hover {
    background: #e8d8c7;
    transform: scale(1.05);
}

#voice-input-status {
    font-family: 'Font2', sans-serif;
}

.template-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.template-btn {
    border: none;
    border-radius: 12px;
    padding: 8px 10px;
    background: #f9f5ee;
    font-family: 'Font2', sans-serif;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.template-btn:hover {
    background: #f3e9dd;
    transform: translateY(-1px);
}

.modal-footer {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.secondary-btn {
    font-family: 'MyFont', serif;
    font-size: 18px;
    padding: 8px 18px;
    border-radius: 12px;
    border: 1px solid #d8cfc2;
    background: white;
    color: #3b2f2f;
    cursor: pointer;
    transition: 0.2s ease;
}

.secondary-btn:hover {
    background: #f3f4f6;
}

.modal-footer .primary-btn {
    width: auto;
    min-width: 170px;
    margin: 0;
    padding: 8px 20px;
    font-size: 18px;
}



/* ========== Edit Panel Styles ========== */
.chat-right h4 {
    font-family: 'MyFont', sans-serif;
    font-size: 28px;
    margin-top: 0;
    margin-bottom: 16px;
    text-align: center;
}

.edit-group {
    margin-bottom: 14px;
}

.edit-group label {
    display: block;
    font-family: 'MyFont', serif;
    font-size: 16px;
    margin-bottom: 4px;
    color: #3b2f2f;
}

.edit-input,
.edit-select {
    width: 100%;
    box-sizing: border-box;
    border-radius: 8px;
    border: 1px solid #d8cfc2;
    padding: 10px 12px;
    font-size: 15px;
    font-family: 'Font2', sans-serif;
    background: rgba(255, 255, 255, 0.95);
    outline: none;
    transition: border 0.2s ease;
}

.edit-input:focus,
.edit-select:focus,
.edit-textarea:focus {
    border-color: #bfa48a;
}

.edit-textarea {
    width: 100%;
    box-sizing: border-box;
    border-radius: 8px;
    border: 1px solid #d8cfc2;
    padding: 10px 12px;
    font-size: 15px;
    font-family: 'Font2', sans-serif;
    background: rgba(255, 255, 255, 0.95);
    outline: none;
    resize: vertical;
    min-height: 120px;
}

.regenerate-section {
    margin-top: 16px;
    padding: 12px;
    background: #faf8f5;
    border: 1px dashed #d8cfc2;
    border-radius: 10px;
}

.regenerate-section label {
    display: block;
    font-family: 'MyFont', serif;
    font-size: 14px;
    margin-bottom: 6px;
    color: #6b7280;
}

.regenerate-section .edit-input {
    margin-bottom: 8px;
}

.regenerate-section .secondary-btn {
    width: 100%;
}

.diary-edit-actions {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.diary-edit-actions .secondary-btn {
    flex: 1;
}

.diary-edit-actions .primary-btn {
    flex: 2;
    margin: 0;
    width: auto;
}

/* ========== Calendar Styles ========== */
.calendar-container {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.calendar-nav button {
    font-family: 'MyFont', serif;
    font-size: 16px;
    padding: 6px 14px;
    border-radius: 8px;
    background: #f3e9dd;
    border: none;
    cursor: pointer;
    transition: 0.2s ease;
}

.calendar-nav button:hover {
    background: #e8d8c7;
    transform: scale(1.05);
}

#calendar-title {
    font-family: 'Font2', serif;
    font-size: 22px;
    font-weight: 600;
    color: #3b2f2f;
    min-width: 180px;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-header {
    text-align: center;
    font-family: 'Font2', serif;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    padding: 8px 0;
}

.calendar-day {
    position: relative;
    text-align: center;
    padding: 10px 4px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Font2', sans-serif;
    font-size: 15px;
    transition: 0.2s ease;
    background: #fafafa;
}

.calendar-day:hover:not(.empty) {
    background: #f0ebe5;
    transform: scale(1.05);
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.today {
    border: 2px solid #d8a87b;
    font-weight: 600;
}

.calendar-day.has-diary {
    background: #e8f5e9;
    font-weight: 600;
}

.calendar-day.mood-positive {
    background: #c8e6c9;
}

.calendar-day.mood-negative {
    background: #ffcdd2;
}

.calendar-day.selected {
    background: #d8a87b !important;
    color: white;
}

.diary-count-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #d8a87b;
    color: white;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Calendar diary list */
.calendar-diary-section {
    background: white;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.calendar-diary-section h4 {
    font-family: 'MyFont', serif;
    font-size: 18px;
    margin: 0 0 8px 0;
    color: #3b2f2f;
}

#calendar-diary-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 120px;
    overflow-y: auto;
}

#calendar-diary-list li {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Font2', sans-serif;
    font-size: 14px;
    transition: 0.2s ease;
}

#calendar-diary-list li:hover {
    background: #f3e9dd;
}

#calendar-diary-list li.no-diary {
    color: #9ca3af;
    cursor: default;
}

#calendar-diary-list li.no-diary:hover {
    background: transparent;
}

.section-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 16px 0;
}

/* Diary detail date styles */
.diary-entry-date {
    font-family: 'Font2', sans-serif;
    font-size: 22px;
    color: #3b2f2f;
    margin: 4px 0;
    text-align: right;
}

.diary-created-info {
    font-family: 'Font2', sans-serif;
    font-size: 14px;
    color: #9ca3af;
    margin: 2px 0 12px 0;
    text-align: right;
}