*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Courier New', Courier, monospace;
}

body {
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    margin: 0;
    font-family: 'Noto Serif SC', 'Microsoft YaHei', serif;
    background-image: radial-gradient(#9C27B015 1px, transparent 1px);
    background-size: 30px 30px;
    overflow: hidden;
}

.cursor {
    position: absolute;
    top: 0;
    left: 20px;
    pointer-events: none;
}

.cursor .text {
    position: absolute;
    font-size: 1.5em;
    color: #8400ff;
    text-shadow: 0 0 15px #631bb5,
        0 0 50px #a448dd;
    text-transform: uppercase;
    transform: translate(-50%, -50%);
}

.container {
    width: 450px;
    height: 600px;
    background-color: rgba(255, 255, 255, 0.92);
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(138, 43, 226, 0.2);
    padding: 30px;
    text-align: center;
    border: 1px solid #e0e0e0;
    backdrop-filter: blur(10px);
    overflow: hidden;
    position: relative;
    background-image:
        /* 纸张褶皱：淡灰色半透明细纹理，避免遮挡内容 */
        repeating-linear-gradient(135deg, rgba(200, 200, 200, 0.08) 0px, rgba(200, 200, 200, 0.13) 2px, transparent 4px, transparent 18px),
        repeating-linear-gradient(45deg, rgba(210, 210, 210, 0.06) 0px, rgba(210, 210, 210, 0.10) 1.5px, transparent 4px, transparent 16px),
        /* 原有背景图，保持透明度，不影响文字可读性 */
        url('https://picsum.photos/id/307/800/1000');
    background-size:
        100% 100%,
        100% 100%,
        cover;
    background-position:
        center,
        center,
        center;
    /* 书页上下边缘渐变 */
    box-shadow:
        0 8px 30px rgba(138, 43, 226, 0.2),
        inset 0 18px 18px -12px rgba(180, 180, 180, 0.18),
        /* 顶部书页厚度 */
        inset 0 -18px 16px -12px rgba(180, 180, 180, 0.21);
    /* 底部书页厚度 */
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.92);
    z-index: -1;
}

.book-spine {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 15px;
    /* 加宽到15px */
    background:
        /* 暗纹渐变：紫色深浅交错 */
        repeating-linear-gradient(135deg,
            #6d3ab7 0px, #6d3ab7 2.5px,
            #7b46c5 2.5px, #7b46c5 5px),
        linear-gradient(90deg, #673AB7 65%, #9C27B0 100%);
    border-radius: 4px 0 0 4px;
    /* 右侧书页阴影 */
    box-shadow:
        1px 0 0 0 #e3e0ed,
        /* 书页边缘浅线 */
        3px 0 8px -2px rgba(60, 40, 120, 0.11);
    /* 右侧书页阴影 */
    z-index: 2;
}

h1 {
    color: #8B00FF;
    margin-bottom: 25px;
    font-weight: 700;
    text-shadow: 1px 1px 3px rgba(139, 0, 255, 0.1);
}

.input-container {
    position: relative;
    margin-bottom: 10px;
}

.example-text {
    position: absolute;
    left: 20px;
    top: -20px;
    font-size: 12px;
    color: #666;
    text-align: left;
}

input[type="text"] {
    width: 90%;
    padding: 14px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    /* 保持 transition 简洁只针对相关属性 */
    box-sizing: border-box;
}

input[type="text"]:focus {
    border-color: #8B00FF;
    animation: breath-shadow 1.6s ease-in-out infinite;
    box-shadow: 0 0 0 0px #8B00FF33;
}

/* 呼吸阴影动画 */
@keyframes breath-shadow {
    0% {
        box-shadow: 0 0 0 0px #8B00FF22;
    }

    50% {
        box-shadow: 0 0 12px 3px #8B00FF44;
    }

    100% {
        box-shadow: 0 0 0 0px #8B00FF22;
    }
}

input[type="text"]:focus {
    border-color: #8B00FF;
    box-shadow: 0 0 0 4px rgba(139, 0, 255, 0.1);
}

input[type="text"]:invalid {
    border-color: #ff4444;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
}

button {
    background: linear-gradient(135deg, #9C27B0, #673AB7);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(139, 0, 255, 0.2);
}

button:active {
    transform: translateY(0);
}

button.reset-btn {
    background: linear-gradient(135deg, #757575, #424242);
}

#thinking {
    color: #8B00FF;
    margin: 25px 0;
    font-style: italic;
    font-weight: 500;
    height: 24px;
}

.book-animation {
    perspective: 1000px;
    height: 24px;
}

.page {
    display: inline-block;
    width: 15px;
    height: 24px;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 2px;
    margin: 0 -2px;
    transform-origin: left center;
    animation: flip 1.5s infinite ease-in-out;
}

.page:nth-child(2) {
    animation-delay: 0.1s;
}

.page:nth-child(3) {
    animation-delay: 0.2s;
}

.page:nth-child(4) {
    animation-delay: 0.3s;
}

.page:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes flip {

    0%,
    100% {
        transform: rotateY(0deg);
        opacity: 1;
    }

    50% {
        transform: rotateY(-180deg);
        opacity: 0.3;
    }
}

#result {
    background:
        /* 墨水晕染细微纹理 */
        radial-gradient(circle at 60% 40%, rgba(150, 0, 255, 0.07) 0%, rgba(200, 100, 255, 0.01) 70%, transparent 100%),
        linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 1.5px dashed;
    /* 渐变虚线边框 */
    border-image: repeating-linear-gradient(90deg, #8B00FF, #9C27B0 100%) 1;
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
    text-align: left;
    min-height: 150px;
    white-space: pre-line;
    font-size: 17px;
    line-height: 1.8;
    color: #333;
    font-family: 'Ma Shan Zheng', cursive;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;

    /* 出现动画：从下往上+轻微放大 */
    .result-fade-anim {
        animation: result-fadeInUpScale 0.8s ease-out;
    }

    /* 防止多次重复动画出现 */
    will-change: transform,
    opacity;
}

@keyframes result-fadeInUpScale {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    60% {
        opacity: 1;
        transform: translateY(-4px) scale(1.03);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#result::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('https://picsum.photos/id/106/800/800');
    background-size: cover;
    opacity: 0.05;
    z-index: 0;
}

#result>* {
    position: relative;
    z-index: 1;
}

#result strong {
    color: #8B00FF;
    font-family: 'Noto Serif SC', serif;
}

#result em {
    color: #d32f2f;
    font-style: normal;
}

.actions {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.action-btn {
    background: none;
    border: 1px solid #8B00FF;
    color: #8B00FF;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease,
        /* 图标旋转动画 */
        /* 让内部 svg/i 继承动画 */
        /* 这里 transition 只写自身，不影响子元素 */
    ;
}

/* 图标动画部分——假设按钮内的图标为svg或<i> */
.action-btn svg,
.action-btn i {
    transition: transform 0.3s ease;
}

.action-btn:hover {
    background-color: #8B00FF11;
    color: #9C27B0;
    border-color: #9C27B0;
}

.action-btn:hover svg,
.action-btn:hover i {
    transform: rotate(15deg);
}

.action-btn:active svg,
.action-btn:active i {
    transform: rotate(0deg);
}

.action-btn:hover {
    background-color: rgba(139, 0, 255, 0.1);
}

@media (max-width: 480px) {
    .container {
        width: 90%;
        height: auto;
        min-height: 600px;
    }

    .button-group {
        flex-direction: column;
        align-items: center;
    }

    button {
        width: 100%;
        justify-content: center;
    }
}

.theme-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9C27B0, #673AB7);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(139, 0, 255, 0.3);
    transition: all 0.3s ease;
    padding: 0;
    /* 清除默认按钮内边距 */
}

.theme-toggle-btn:hover {
    transform: rotate(15deg) scale(1.1);
    /*  hover时轻微旋转放大，增加互动感 */
    box-shadow: 0 4px 12px rgba(139, 0, 255, 0.4);
}

/* 2. 暗黑模式核心样式（body[data-theme="dark"] 触发） */
body[data-theme="dark"] {
    background-color: #1a1a2e;
    /* 深色背景，偏紫调，符合神秘感 */
    background-image: radial-gradient(#9C27B00A 1px, transparent 1px);
    /* 弱化背景纹理，避免刺眼 */
}

/* 暗黑模式下的容器样式 */
body[data-theme="dark"] .container {
    background-color: #24243e;
    /* 卡片深背景 */
    border: 1px solid #3a3a5a;
    /* 深色边框，降低对比度 */
    box-shadow: 0 8px 30px rgba(138, 43, 226, 0.15);
    /* 弱化阴影 */
}

body[data-theme="dark"] .container::before {
    background-color: rgba(36, 36, 62, 0.95);
    /* 覆盖层同步变深 */
}

/* 暗黑模式下的文字与输入框 */
body[data-theme="dark"] h1 {
    color: #b16ef3;
    /* 标题紫色变浅，更适配深色背景 */
    text-shadow: 1px 1px 3px rgba(177, 110, 243, 0.2);
}

body[data-theme="dark"] .example-text {
    color: #aaa;
    /* 示例文字变浅 */
}

body[data-theme="dark"] input[type="text"] {
    background-color: #3a3a5a;
    /* 输入框深色背景 */
    border-color: #4a4a6a;
    /* 输入框边框 */
    color: #eee;
    /* 输入文字变白 */
}

body[data-theme="dark"] input[type="text"]:focus {
    border-color: #b16ef3;
    /* 聚焦时边框紫色变浅 */
    box-shadow: 0 0 0 4px rgba(177, 110, 243, 0.15);
}

body[data-theme="dark"] input[type="text"]::placeholder {
    color: #888;
    /* 占位符文字变浅 */
}

/* 暗黑模式下的按钮 */
body[data-theme="dark"] button:not(.theme-toggle-btn):not(.reset-btn):not(.action-btn) {
    background: linear-gradient(135deg, #b16ef3, #7e47c5);
    /* 主按钮紫色变浅，增强亮度 */
}

body[data-theme="dark"] .reset-btn {
    background: linear-gradient(135deg, #888, #555);
    /* 重置按钮同步变深 */
}

body[data-theme="dark"] .action-btn {
    border-color: #b16ef3;
    /* 功能按钮边框变浅 */
    color: #b16ef3;
}

body[data-theme="dark"] .action-btn:hover {
    background-color: rgba(177, 110, 243, 0.1);
    /*  hover背景同步适配 */
}

/* 暗黑模式下的结果区与动画 */
body[data-theme="dark"] #thinking {
    color: #b16ef3;
    /* 思考文字变浅 */
}

body[data-theme="dark"] .page {
    background-color: #3a3a5a;
    /* 书页动画背景变深 */
    border-color: #4a4a6a;
}

body[data-theme="dark"] #result {
    background: linear-gradient(135deg, #3a3a5a, #2a2a4a);
    /* 结果区深色背景 */
    border-image: linear-gradient(to right, #b16ef3, #7e47c5) 1;
    /* 渐变虚线同步变浅 */
    color: #eee;
    /* 结果文字变白 */
}

body[data-theme="dark"] #result strong {
    color: #b16ef3;
    /* 强调文字变浅 */
}

body[data-theme="dark"] #result em {
    color: #ff6b6b;
    /* 命运启示文字保留红色，增强对比 */
}
