/* ============================================================
   📜 33-offline-mode.css (V8 完整版)
   配套 32-offline-mode.js 使用
   风格基准: 06-contacts.css (Playfair Display + 古铜金 #C3A772)
   ============================================================ */

/* ========== 0. 容器：全屏 + 从下方淡入 ========== */
#om-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    background: #f5f0e8;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    overflow: hidden;
    pointer-events: none;
}
#om-container.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ========== 1. 三层页面通用 ========== */
.om-page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: #f5f0e8;
    overflow: hidden;
}
.om-page.active {
    display: flex;
    animation: om-page-in 0.35s ease;
}
@keyframes om-page-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========== 2. 第①层：Mode 选择页 ========== */
.om-mode-header {
    padding: 60px 30px 16px;
    text-align: center;
}
.om-mode-title-en {
    font-family: 'Playfair Display', serif;
    font-size: 32px;
    color: #C3A772;
    font-weight: 600;
    letter-spacing: 1.5px;
}
.om-mode-title-cn {
    font-size: 13px;
    color: #8a7e6c;
    margin-top: 6px;
    letter-spacing: 2px;
}
.om-mode-options {
    flex: 1;
    padding: 24px 30px 100px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    justify-content: center;
}
.om-mode-option {
    background: #fff;
    border: 1.5px solid #d4c5a8;
    border-radius: 16px;
    padding: 24px 22px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}
.om-mode-option:hover {
    border-color: #C3A772;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(195, 167, 114, 0.18);
}
.om-mode-option:active {
    transform: translateY(0);
}
.om-mode-option-title {
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    color: #C3A772;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.om-mode-option-sub {
    font-size: 15px;
    color: #4a3f2f;
    margin-top: 8px;
    font-weight: 500;
}
.om-mode-option-desc {
    font-size: 12px;
    color: #8a7e6c;
    margin-top: 6px;
    line-height: 1.5;
}

/* ========== 3. 通用返回按钮（左下角圆形） ========== */
.om-back-btn {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #C3A772;
    color: #C3A772;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
    padding: 0;
}
.om-back-btn:hover {
    background: #C3A772;
    color: #fff;
    transform: scale(1.05);
}
.om-back-btn svg {
    display: block;
}

/* ========== 4. 第②层：配置页 ========== */
.om-config-header {
    padding: 40px 30px 18px;
    text-align: center;
    background: #f5f0e8;
    border-bottom: 1px solid #e8dfd0;
    flex-shrink: 0;
}
.om-config-title-en {
    font-family: 'Playfair Display', serif;
    font-size: 26px;
    color: #C3A772;
    font-weight: 600;
}
.om-config-title-cn {
    font-size: 13px;
    color: #8a7e6c;
    margin-top: 4px;
    letter-spacing: 1.5px;
}
.om-config-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 28px 120px;
    -webkit-overflow-scrolling: touch;
}
.om-config-field {
    margin-bottom: 22px;
}
.om-config-field > label {
    display: block;
    font-size: 14px;
    color: #4a3f2f;
    margin-bottom: 10px;
    font-weight: 500;
    letter-spacing: 0.3px;
}
.om-field-hint {
    font-size: 11px;
    color: #a89a82;
    font-weight: normal;
    margin-left: 4px;
}
.om-config-field input[type="text"],
.om-config-field input[type="number"],
.om-config-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d4c5a8;
    border-radius: 10px;
    background: #fff;
    font-size: 14px;
    color: #4a3f2f;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.om-config-field input:focus,
.om-config-field textarea:focus {
    border-color: #C3A772;
    outline: none;
}
.om-config-field textarea {
    resize: vertical;
    min-height: 70px;
    line-height: 1.5;
}

/* Radio 单选组 */
.om-radio-group {
    display: flex;
    gap: 10px;
}
.om-radio-item {
    flex: 1;
    padding: 10px 8px;
    border: 1.5px solid #d4c5a8;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    background: #fff;
    font-size: 13px;
    color: #4a3f2f;
    transition: all 0.2s;
    user-select: none;
}
.om-radio-item input {
    display: none;
}
.om-radio-item:has(input:checked) {
    background: #C3A772;
    color: #fff;
    border-color: #C3A772;
    font-weight: 500;
}

/* 字数范围 */
.om-word-range {
    display: flex;
    align-items: center;
    gap: 10px;
}
.om-word-range input {
    flex: 1;
    text-align: center;
    min-width: 0;
}
.om-word-divider {
    color: #C3A772;
    font-size: 16px;
    font-weight: bold;
}
.om-word-unit {
    font-size: 12px;
    color: #8a7e6c;
}

/* 世界书列表 */
.om-worldbook-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.om-wb-item {
    padding: 12px 14px;
    border: 1px solid #d4c5a8;
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #4a3f2f;
    cursor: pointer;
    transition: all 0.2s;
}
.om-wb-item:hover {
    border-color: #C3A772;
}
.om-wb-item input[type="checkbox"] {
    accent-color: #C3A772;
    width: 16px;
    height: 16px;
}
.om-wb-empty {
    padding: 16px;
    text-align: center;
    color: #a89a82;
    font-size: 12px;
    background: #fff;
    border: 1px dashed #d4c5a8;
    border-radius: 10px;
}

/* ENTER OFFLINE 按钮 */
.om-enter-btn {
    position: absolute;
    bottom: 30px;
    right: 30px;
    padding: 14px 28px;
    background: #C3A772;
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 13px;
    letter-spacing: 2px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    z-index: 10;
    font-family: inherit;
}
.om-enter-btn:hover {
    background: #a88958;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(195, 167, 114, 0.4);
}
.om-enter-btn:active {
    transform: translateY(0);
}

/* ========== 5. 第③层：剧情页 ========== */
.om-chat-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px;
    background: #fff;
    border-bottom: 1px solid #e8dfd0;
    position: relative;
    flex-shrink: 0;
    z-index: 5;
}
.om-chat-close-btn {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #4a3f2f;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}
.om-chat-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}
.om-chat-titles {
    text-align: center;
}
.om-chat-title-en {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    color: #C3A772;
    font-weight: 600;
}
.om-chat-title-cn {
    font-size: 11px;
    color: #8a7e6c;
    margin-top: 2px;
    letter-spacing: 1px;
}

/* 消息区 */
.om-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f0e8;
    -webkit-overflow-scrolling: touch;
}
.om-msg {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    align-items: flex-start;
    animation: om-msg-in 0.3s ease;
}
@keyframes om-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.om-msg-user {
    flex-direction: row-reverse;
}
.om-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e8dfd0;
}
.om-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.om-msg-avatar svg {
    display: block;
}
.om-bubble-text {
    background: #fff;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    color: #4a3f2f;
    line-height: 1.6;
    max-width: 72%;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.om-msg-user .om-bubble-text {
    background: #C3A772;
    color: #fff;
}
.om-msg-user .om-bubble-text::selection {
    background: rgba(255, 255, 255, 0.3);
}

/* Loading 动画 */
.om-loading .om-bubble-text {
    background: #fff;
    padding: 14px 18px;
}
.om-loading-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #C3A772;
    margin: 0 2px;
    animation: om-bounce 1.2s infinite;
}
.om-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.om-loading-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes om-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 错误提示 */
.om-error .om-bubble-text {
    background: #fef0f0;
    color: #c33;
    border: 1px solid #fcc;
    white-space: pre-wrap;
}

/* 输入区 */
.om-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border-top: 1px solid #e8dfd0;
    flex-shrink: 0;
}
.om-input {
    flex: 1;
    border: 1px solid #d4c5a8;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    max-height: 100px;
    min-height: 36px;
    outline: none;
    color: #4a3f2f;
    background: #f5f0e8;
    transition: border-color 0.2s;
}
.om-input:focus {
    border-color: #C3A772;
    background: #fff;
}
.om-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #C3A772;
    color: #fff;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}
.om-send-btn:hover {
    background: #a88958;
    transform: scale(1.05);
}
.om-send-btn:active {
    transform: scale(0.95);
}
.om-send-btn:disabled {
    background: #d4c5a8;
    cursor: not-allowed;
}
.om-send-btn svg {
    display: block;
}

/* ========== 6. Action Sheet（关闭菜单） ========== */
.om-action-sheet {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: none;
    align-items: flex-end;
    pointer-events: none;
}
.om-action-sheet.active {
    display: flex;
    pointer-events: auto;
}
.om-action-sheet-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    animation: om-mask-in 0.25s ease;
}
@keyframes om-mask-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.om-action-sheet-panel {
    position: relative;
    width: 100%;
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: om-sheet-up 0.3s ease;
}
@keyframes om-sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.om-action-btn {
    padding: 14px;
    border: none;
    background: #f5f0e8;
    border-radius: 10px;
    font-size: 15px;
    color: #4a3f2f;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}
.om-action-btn:hover {
    background: #e8dfd0;
}
.om-action-quit {
    color: #C3A772;
    font-weight: 500;
}
.om-action-end {
    color: #c33;
    font-weight: 500;
}
.om-action-cancel {
    background: #fff;
    border: 1px solid #d4c5a8;
    margin-top: 6px;
}

/* ========== 7. 小屏适配 ========== */
@media (max-height: 700px) {
    .om-mode-header { padding: 40px 30px 12px; }
    .om-mode-title-en { font-size: 28px; }
    .om-mode-option { padding: 18px 18px; }
    .om-config-body { padding: 16px 24px 110px; }
}
@media (max-width: 360px) {
    .om-mode-options { padding: 20px 20px 100px; }
    .om-mode-option-title { font-size: 18px; }
    .om-config-body { padding: 18px 20px 110px; }
}

/* ========== 8. 安全区（iPhone 刘海/底部小白条） ========== */
@supports (padding: max(0px)) {
    .om-mode-header,
    .om-config-header,
    .om-chat-header {
        padding-top: max(40px, env(safe-area-inset-top));
    }
    .om-input-area {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}