/* date-app.css — 约会 App: novel-reading chat style */

/* ── List page ────────────────────────────────────────────────────── */
#date-list-page .header {
    background: #F5F0E8;
    border-bottom: 1px solid #DDD0B8;
}
#date-list-page .header-title {
    color: #5C3D2E;
}

/* ── Date pages: fixed overlay so they sit on top of #app-container ─ */
/* The date pages are injected into <body> after #app-container, which
   takes up the full 100vh in body's flex layout. Without fixed
   positioning the date pages would be pushed below the visible area
   and hidden by body{overflow:hidden}.                               */
#date-list-page.active,
#date-chat-page.active {
    position: fixed;
    inset: 0;
    z-index: 500;
    height: 100%;
}

/* ── Chat page container ──────────────────────────────────────────── */
/* Do NOT set display here — .page/.page.active control visibility.
   ID specificity would override .page{display:none} otherwise.     */
#date-chat-page {
    background: #F5F0E8;
    position: relative; /* anchor for floating elements + theme panel */
}

/* ── Floating back button ─────────────────────────────────────────── */
.date-float-back {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top, 0px));
    left: 14px;
    z-index: 30;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #D4C8B0;
    background: #F5F0E8cc;
    color: #8B6914;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    /* theme overrides via JS */
}
.date-float-back:active { opacity: 0.6; }

/* ── Floating character name ──────────────────────────────────────── */
.date-float-name {
    position: absolute;
    top: calc(20px + env(safe-area-inset-top, 0px));
    right: 16px;
    z-index: 20;
    font-size: 11px;
    color: #A09080;
    letter-spacing: 0.5px;
    font-family: -apple-system, sans-serif;
    pointer-events: none;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Novel content area ───────────────────────────────────────────── */
.date-novel-content {
    /* flex-grow:1 + min-height:0 from .content in styles.css */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.date-novel-scroll {
    flex: 1;
    overflow-y: auto;
    /* top padding makes room for the floating back button + status bar */
    padding: calc(62px + env(safe-area-inset-top, 0px)) 22px 16px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    background: #F5F0E8;
}

/* ── Message container ────────────────────────────────────────────── */
.date-novel-messages {
    max-width: 580px;
    margin: 0 auto;
    padding-bottom: 8px;
}

/* ── Date divider ─────────────────────────────────────────────────── */
.date-novel-date-divider {
    text-align: center;
    color: #A09080;
    font-size: 12px;
    letter-spacing: 1px;
    margin: 28px 0 20px;
    position: relative;
    font-family: -apple-system, sans-serif;
    user-select: none;
}
.date-novel-date-divider::before,
.date-novel-date-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 26%;
    height: 1px;
    background: #D4C8B0;
}
.date-novel-date-divider::before { right: 57%; }
.date-novel-date-divider::after  { left:  57%; }

/* ── AI messages — novel paragraph style ─────────────────────────── */
.date-novel-msg-assistant {
    margin: 0 0 24px;
    color: #2C1E14;
}

.date-para {
    margin: 0 0 14px;
    font-size: 16px;
    line-height: 1.95;
    font-family: 'Georgia', 'STKaiti', '华文楷体', '楷体', 'KaiTi', serif;
    word-break: break-all;
    text-align: justify;
    color: #2C1E14;
}
.date-para:last-child { margin-bottom: 0; }

.date-action {
    font-style: italic;
    color: #9B7A3A;
    font-weight: 400;
}

.date-speech { color: inherit; }

/* ── Message timestamp ────────────────────────────────────────────── */
.date-msg-time {
    display: block;
    font-size: 11px;
    color: #A09080;
    font-family: -apple-system, sans-serif;
    letter-spacing: 0.3px;
    margin-top: 6px;
    text-align: right;
    user-select: none;
}

/* ── User messages ────────────────────────────────────────────────── */
.date-novel-msg-user {
    margin: 4px 0 28px;
    padding: 10px 16px 10px 14px;
    background: rgba(255,252,245,0.75);
    border-left: 3px solid #C9A96E;
    border-radius: 0 8px 8px 0;
}
.date-novel-user-label {
    display: block;
    font-size: 11px;
    color: #B0A080;
    margin-bottom: 5px;
    font-family: -apple-system, sans-serif;
    letter-spacing: 0.5px;
}
.date-novel-user-text {
    font-size: 15px;
    color: #3D2B1F;
    line-height: 1.7;
    font-family: -apple-system, sans-serif;
    white-space: pre-wrap;
}

/* ── Typing indicator ─────────────────────────────────────────────── */
.date-typing-indicator {
    display: flex;
    gap: 6px;
    padding: 4px 0 20px;
    align-items: center;
}
.date-typing-dot {
    width: 7px;
    height: 7px;
    background: #C9A96E;
    border-radius: 50%;
    animation: dateTypingBounce 1.3s infinite ease-in-out;
}
.date-typing-dot:nth-child(2) { animation-delay: 0.22s; }
.date-typing-dot:nth-child(3) { animation-delay: 0.44s; }

@keyframes dateTypingBounce {
    0%, 75%, 100% { transform: translateY(0);   opacity: 0.45; }
    35%           { transform: translateY(-7px); opacity: 1;    }
}

/* ── Input area ───────────────────────────────────────────────────── */
.date-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 14px 12px;
    background: #EDE8DB;
    border-top: 1px solid #D4C8B0;
    box-sizing: border-box;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.date-input {
    flex: 1;
    background: #FFF9F2;
    border: 1px solid #D4C8B0;
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 15px;
    font-family: -apple-system, sans-serif;
    color: #3D2B1F;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    outline: none;
    line-height: 1.5;
    overflow-y: auto;
    box-sizing: border-box;
}
.date-input:focus {
    border-color: #C9A96E;
    box-shadow: 0 0 0 2px rgba(201,169,110,0.18);
}
.date-input::placeholder { color: #C0B090; }

.date-send-btn {
    background: #C9A96E;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-end;
    min-height: 42px;
    letter-spacing: 0.5px;
    transition: background 0.15s;
}
.date-send-btn:active   { background: #B8934A; }
.date-send-btn:disabled { background: #D4C4A0; cursor: default; }

/* ══════════════════════════════════════════════════════════════════ */
/* ── Reading preferences panel ───────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════════ */

.date-theme-panel {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.date-theme-panel.open {
    pointer-events: auto;
    opacity: 1;
}

.date-theme-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.32);
}

.date-theme-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #FEFAF4;
    border-radius: 20px 20px 0 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
}
.date-theme-panel.open .date-theme-sheet {
    transform: translateY(0);
}
.date-theme-sheet::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #D4C8B0;
    border-radius: 2px;
    margin: 12px auto 0;
}

/* Sheet header */
.date-theme-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 8px;
}
.date-theme-title {
    font-size: 15px;
    font-weight: 600;
    color: #3D2B1F;
    font-family: -apple-system, sans-serif;
}
.date-theme-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #EDE8DB;
    border-radius: 50%;
    font-size: 13px;
    color: #8B7355;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Preset chips ─────────────────────────────────────────────────── */
.date-preset-row {
    display: flex;
    gap: 10px;
    padding: 6px 20px 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.date-preset-row::-webkit-scrollbar { display: none; }

.date-preset-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 20px;
    border: 2px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    font-family: -apple-system, sans-serif;
    transition: border-color 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}
.date-preset-chip.active {
    border-color: currentColor;
    box-shadow: 0 0 0 1px currentColor;
}

.date-preset-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

/* ── Divider ──────────────────────────────────────────────────────── */
.date-theme-divider {
    height: 1px;
    background: #E8E0D4;
    margin: 0 20px 2px;
}

/* ── Control rows ─────────────────────────────────────────────────── */
.date-theme-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 20px;
    border-bottom: 1px solid #F0E8DC;
}
.date-theme-control-row:last-child {
    border-bottom: none;
    padding-bottom: 20px;
}

.date-theme-ctrl-label {
    font-size: 14px;
    color: #5C3D2E;
    font-family: -apple-system, sans-serif;
}

/* Native color picker */
.date-theme-color-input {
    -webkit-appearance: none;
    appearance: none;
    width: 52px;
    height: 32px;
    border: 2px solid #D4C8B0;
    border-radius: 8px;
    padding: 2px;
    cursor: pointer;
    background: none;
}
.date-theme-color-input::-webkit-color-swatch-wrapper { padding: 0; border-radius: 5px; }
.date-theme-color-input::-webkit-color-swatch         { border: none; border-radius: 5px; }

/* Font size stepper */
.date-font-size-ctrl {
    display: flex;
    align-items: center;
    background: #EDE8DB;
    border-radius: 20px;
    overflow: hidden;
}
.date-font-btn {
    width: 40px;
    height: 34px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 700;
    color: #5C3D2E;
    cursor: pointer;
    font-family: -apple-system, sans-serif;
}
.date-font-btn:active { background: #D4C8B0; }

.date-font-size-num {
    min-width: 28px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #3D2B1F;
    font-family: -apple-system, sans-serif;
    pointer-events: none;
}

/* ── Chip wrap (custom chips with delete badge) ───────────────────── */
.date-chip-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.date-chip-del {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #8B7355;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    font-weight: 700;
}
.date-chip-del:active { background: #5C3D2E; }

/* ── Add (+) button ───────────────────────────────────────────────── */
.date-add-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px dashed #D4C8B0;
    background: transparent;
    color: #9B8A72;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: -apple-system, sans-serif;
    transition: border-color 0.15s, color 0.15s;
}
.date-add-btn:active { border-color: #C9A96E; color: #C9A96E; }

/* ── Add form (accordion) ─────────────────────────────────────────── */
.date-add-form {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 20px;
    box-sizing: border-box;
}
.date-add-form.open {
    max-height: 300px;
}

.date-add-form-inner {
    padding: 10px 0 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid #E8E0D4;
}

.date-add-name-input {
    width: 100%;
    background: #FFF9F2;
    border: 1px solid #D4C8B0;
    border-radius: 10px;
    padding: 9px 13px;
    font-size: 14px;
    font-family: -apple-system, sans-serif;
    color: #3D2B1F;
    outline: none;
    box-sizing: border-box;
}
.date-add-name-input:focus { border-color: #C9A96E; }
.date-add-name-input::placeholder { color: #C0B090; }

.date-add-color-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.date-add-color-label {
    font-size: 13px;
    color: #5C3D2E;
    font-family: -apple-system, sans-serif;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.date-form-btns {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 2px;
}

.date-form-btn {
    padding: 8px 18px;
    border-radius: 16px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    font-family: -apple-system, sans-serif;
    cursor: pointer;
    transition: opacity 0.15s;
}
.date-form-btn:active { opacity: 0.7; }

.date-form-btn--cancel {
    background: #EDE8DB;
    color: #5C3D2E;
}

.date-form-btn--save {
    background: #C9A96E;
    color: #fff;
}

/* ── Input area plus button ───────────────────────────────────────── */
.date-input-plus-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid #D4C8B0;
    background: #EDE8DB;
    color: #8B6914;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
    transition: background 0.15s;
}
.date-input-plus-btn:active { background: #D4C8B0; }

/* ── Plus menu bottom sheet ───────────────────────────────────────── */
.date-plus-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 210;
}

.date-plus-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #FEFAF4;
    border-radius: 20px 20px 0 0;
    z-index: 211;
    padding: 16px 24px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
}
.date-plus-sheet::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #D4C8B0;
    border-radius: 2px;
    margin: 0 auto 16px;
}
.date-plus-sheet.open {
    transform: translateY(0);
}

.date-plus-grid {
    display: flex;
    gap: 0;
    justify-content: space-around;
}

.date-plus-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex: 1;
}
.date-plus-item:active .date-plus-icon { opacity: 0.6; }

.date-plus-icon {
    width: 58px;
    height: 58px;
    background: #fff;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #E8E0D4;
}
.date-plus-item span {
    font-size: 11px;
    color: #5C3D2E;
    font-family: -apple-system, sans-serif;
}

/* ── Suggest-reply panel ──────────────────────────────────────────── */
.date-suggest-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 220;
}

.date-suggest-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #FEFAF4;
    border-radius: 20px 20px 0 0;
    z-index: 221;
    padding: 0 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
}
.date-suggest-panel::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #D4C8B0;
    border-radius: 2px;
    margin: 12px auto 0;
}
.date-suggest-panel.open {
    transform: translateY(0);
}

.date-suggest-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0 10px;
}
.date-suggest-title {
    font-size: 15px;
    font-weight: 600;
    color: #3D2B1F;
    font-family: -apple-system, sans-serif;
}
.date-suggest-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #EDE8DB;
    border-radius: 50%;
    font-size: 13px;
    color: #8B7355;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.date-suggest-loading {
    padding: 20px 0;
    color: #A09080;
    font-size: 14px;
    font-family: -apple-system, sans-serif;
    text-align: center;
}

.date-suggest-text {
    font-size: 15px;
    color: #2C1E14;
    line-height: 1.75;
    font-family: -apple-system, sans-serif;
    padding: 12px 16px;
    background: rgba(255,252,245,0.8);
    border-left: 3px solid #C9A96E;
    border-radius: 0 8px 8px 0;
    margin-bottom: 14px;
    white-space: pre-wrap;
}

.date-suggest-actions {
    display: flex;
    justify-content: flex-end;
    padding-bottom: 4px;
}

.date-suggest-error {
    padding: 12px 0 16px;
    color: #C9614A;
    font-size: 13px;
    font-family: -apple-system, sans-serif;
}

