/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #8B4513;
    --primary-light: #D2691E;
    --bg-color: #FDF5E6;
    --card-bg: #FFFAF0;
    --text-color: #2F1810;
    --text-light: #5D4037;
    --border-color: #DEB887;
    --shadow: 0 2px 8px rgba(139, 69, 19, 0.15);
    --yang-color: #8B4513;
    --yin-color: #8B4513;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #FDF5E6 0%, #FAE6C8 100%);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
}

/* 英文版字体 - 神秘占卜风格 */
body.lang-en {
    font-family: "Cormorant Garamond", "Georgia", serif;
    font-size: 17px;
    line-height: 1.7;
}

/* 英文版标题 - 使用 Cinzel 古典风格 */
body.lang-en .header h1 {
    font-family: "Cinzel", "Times New Roman", serif;
    font-size: 26px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
}

body.lang-en .subtitle {
    font-family: "Cormorant Garamond", "Georgia", serif;
    font-style: italic;
    font-size: 16px;
    letter-spacing: 1px;
}

/* 英文版卦象卡片标题 - 强制两行显示保持对齐 */
body.lang-en .hexagram-card h3 {
    max-width: 75px;
    text-align: center;
    line-height: 1.5;
    margin-left: auto;
    margin-right: auto;
}

/* 英文版按钮 */
body.lang-en .btn-primary {
    font-family: "Cinzel", "Times New Roman", serif;
    font-size: 15px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 16px 28px;
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 50%, #cd853f 100%);
    box-shadow: 0 4px 16px rgba(139, 69, 19, 0.35);
}

body.lang-en .btn-secondary {
    font-family: "Cinzel", "Times New Roman", serif;
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 14px 24px;
    background: linear-gradient(135deg, #6B5B95 0%, #8B7BB5 50%, #9B8DC7 100%);
}

body.lang-en .btn-reset {
    font-family: "Cinzel", "Times New Roman", serif;
    font-size: 14px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* 英文版标签和提示 */
body.lang-en label,
body.lang-en .method-option span,
body.lang-en .info-label {
    font-size: 15px;
    letter-spacing: 0.3px;
}

body.lang-en .hint {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 14px;
    font-style: normal;
}

/* 英文版信息行 */
body.lang-en .info-row {
    font-size: 15px;
    padding: 10px 0;
    align-items: flex-start;
}

body.lang-en .info-label {
    font-family: "Cinzel", "Times New Roman", serif;
    font-size: 13px;
    letter-spacing: 0.5px;
    text-transform: capitalize;
    color: #8b7355;
    width: 85px;
    font-weight: 500;
}

body.lang-en .info-row span:last-child {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 16px;
    color: #5a4a3a;
}

body.lang-en .info-row.method-row {
    background: linear-gradient(90deg, #f8f5f0 0%, #fff 100%);
    padding: 12px 16px;
    margin: -16px -16px 12px -16px;
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid #e8ddd0;
}

body.lang-en .info-row.relation {
    margin-top: 12px;
    padding-top: 16px;
    background: linear-gradient(90deg, #faf8f5 0%, #fff 100%);
    margin-left: -16px;
    margin-right: -16px;
    margin-bottom: -16px;
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 16px;
    border-radius: 0 0 8px 8px;
}

body.lang-en .info-row.relation span:last-child {
    font-weight: 600;
    color: #8b4513;
    font-size: 15px;
    line-height: 1.5;
}

body.lang-en .hexagram-info {
    padding: 16px;
    background: #fff;
    border: 1px solid #e8ddd0;
    box-shadow: 0 2px 8px rgba(139, 69, 19, 0.06);
}

/* 英文版章节标题 */
body.lang-en h3 {
    font-family: "Cinzel", "Times New Roman", serif;
    letter-spacing: 1px;
}

/* 英文版解读内容 - 符合西方阅读习惯 */
body.lang-en .interpretation-content {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 16px;
    line-height: 1.6;
    letter-spacing: 0.2px;
    color: #3d3225;
}

body.lang-en .interpretation-content .md-h1,
body.lang-en .interpretation-content .md-h2,
body.lang-en .interpretation-content .md-h3 {
    font-family: "Cinzel", "Times New Roman", serif;
    color: #8b4513;
    letter-spacing: 1px;
    border-bottom: 1px solid #d4c4a8;
    padding-bottom: 6px;
    text-transform: none;
}

body.lang-en .interpretation-content .md-h1 {
    font-size: 18px;
    margin-top: 20px;
    margin-bottom: 10px;
}

body.lang-en .interpretation-content .md-h2 {
    font-size: 17px;
    margin-top: 18px;
    margin-bottom: 8px;
}

body.lang-en .interpretation-content .md-h3 {
    font-size: 16px;
    margin-top: 16px;
    margin-bottom: 6px;
}

body.lang-en .interpretation-content .md-p {
    text-align: left;
    text-indent: 0;
    margin: 8px 0;
}

body.lang-en .interpretation-content strong {
    color: #6b4423;
    font-weight: 600;
}

body.lang-en .interpretation-content em {
    font-style: italic;
    color: #8b6914;
}

body.lang-en .interpretation-content .md-quote {
    font-style: italic;
    background: #faf8f5;
    border-left: 3px solid #c4a574;
    padding: 10px 14px;
    margin: 12px 0;
    border-radius: 0 6px 6px 0;
}

body.lang-en .interpretation-content .md-li {
    margin: 6px 0;
    padding-left: 20px;
}

body.lang-en .interpretation-content .md-li::before {
    content: '•';
    color: #8b4513;
    font-size: 14px;
}

body.lang-en .interpretation-content .md-hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #c4a574 50%, transparent 100%);
    margin: 16px 0;
}

/* 英文版解读区域标题 */
body.lang-en .interpretation-section h3 {
    font-family: "Cinzel", "Times New Roman", serif;
    font-size: 14px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #8b4513;
    border-bottom: 2px solid #c4a574;
    padding-bottom: 10px;
}

/* 英文版解读区域整体 */
body.lang-en .interpretation-section {
    background: linear-gradient(180deg, #fffcf8 0%, #faf6f0 100%);
    border: 1px solid #e8ddd0;
}

/* 英文版打赏区域 */
body.lang-en .donate-text {
    font-family: "Cinzel", "Times New Roman", serif;
    font-size: 16px;
    letter-spacing: 1px;
}

body.lang-en .donate-subtext {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 15px;
    font-style: normal;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 32px;
    position: relative;
}

/* 顶部工具栏 */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    z-index: 100;
    pointer-events: none;
}

.top-bar > * {
    pointer-events: auto;
}

/* About 按钮 */
.about-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    background: var(--card-bg);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(139, 69, 19, 0.15);
}

.about-btn:hover {
    background: var(--primary-color);
    color: white;
}

.about-icon {
    font-size: 18px;
    font-weight: bold;
    font-family: "Cinzel", Georgia, serif;
}

/* 语言切换按钮 */
.lang-switch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    background: var(--card-bg);
    color: var(--primary-color);
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: var(--shadow);
}

.lang-switch:hover {
    background: var(--primary-color);
    color: white;
}

.lang-switch:active {
    transform: scale(0.95);
}

/* 头部 */
.header {
    text-align: center;
    padding: 24px 0;
    margin-bottom: 16px;
}

.header h1 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 4px;
    font-weight: 600;
}

.header .subtitle {
    font-size: 14px;
    color: var(--text-light);
}

/* 区块通用样式 */
section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

section label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 8px;
}

/* 问题输入 */
.question-section textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    resize: none;
    background: #fff;
    color: var(--text-color);
}

.question-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 起卦方式选择 */
.method-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.method-option {
    flex: 1;
    min-width: calc(33% - 8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.method-option input {
    display: none;
}

.method-option span {
    font-size: 14px;
    color: var(--text-light);
}

.method-option:has(input:checked) {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.method-option:has(input:checked) span {
    color: #fff;
}

/* 额外输入区 */
.extra-input {
    margin-top: 12px;
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

.hidden {
    display: none !important;
}

/* 时间起卦选项 */
.time-options {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.time-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.time-option input {
    margin-right: 6px;
}

.time-option:has(input:checked) {
    border-color: var(--primary-color);
    background: #FFF8F0;
}

.custom-time {
    margin-top: 8px;
}

.datetime-group {
    display: flex;
    gap: 10px;
}

.datetime-group input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

/* 文字起卦选项 */
.text-options {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.text-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.text-option input {
    margin-right: 6px;
}

.text-option:has(input:checked) {
    border-color: var(--primary-color);
    background: #FFF8F0;
}

.text-hint {
    text-align: center;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 6px;
}

.text-hint p {
    margin: 4px 0;
    font-size: 13px;
    color: var(--text-light);
}

.single-char {
    text-align: center;
}

.single-char input {
    width: 100%;
    max-width: 200px;
    padding: 12px;
    font-size: 24px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    letter-spacing: 8px;
}

.single-char input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.number-group {
    display: flex;
    gap: 12px;
}

.number-group input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    text-align: center;
}

.hint {
    font-size: 12px;
    color: #999;
    margin-top: 8px;
    text-align: center;
}

/* 物象选择器 */
.trigram-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.selector-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.selector-group label {
    font-size: 13px;
    margin-bottom: 2px;
}

.selector-group select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    background: #fff;
}

.btn-wanwu {
    width: 100%;
    padding: 10px;
    margin-top: 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.wanwu-table {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.8;
}

.wanwu-item {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border-color);
}

.wanwu-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.wanwu-item strong {
    color: var(--primary-color);
}

/* 按钮样式 */
.btn-primary {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: linear-gradient(135deg, #a0a0a0 0%, #c0c0c0 100%);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #6B5B95 0%, #9B8DC7 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 16px;
    box-shadow: 0 4px 12px rgba(107, 91, 149, 0.3);
}

.btn-secondary:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-reset {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    color: var(--text-light);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    margin-top: 16px;
}

/* 卦象显示区 */
.hexagram-section {
    background: var(--card-bg);
}

.hexagram-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.hexagram-card {
    flex: 1;
    text-align: center;
    padding: 16px 8px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.hexagram-card h3 {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 12px;
}

.hexagram-lines {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.hexagram-line {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 8px;
    position: relative;
}

.hexagram-line.yang {
    background: var(--yang-color);
    border-radius: 2px;
}

.hexagram-line.yin {
    background: transparent;
    display: flex;
    justify-content: space-between;
}

.hexagram-line.yin::before,
.hexagram-line.yin::after {
    content: '';
    display: block;
    width: 25px;
    height: 8px;
    background: var(--yin-color);
    border-radius: 2px;
}

/* 动爻标记 - 使用额外的 span 元素 */
.hexagram-line .moving-marker {
    position: absolute;
    right: -22px;
    font-size: 12px;
    color: #e74c3c;
    font-weight: bold;
}

.hexagram-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
}

.hexagram-arrow {
    font-size: 24px;
    color: var(--text-light);
}

/* 卦象信息 */
.hexagram-info {
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.info-row {
    display: flex;
    padding: 6px 0;
    font-size: 14px;
}

.info-row:not(:last-child) {
    border-bottom: 1px dashed #eee;
}

.info-row.method-row {
    background: var(--bg-color);
    margin: -12px -12px 8px -12px;
    padding: 8px 12px;
    border-radius: 6px 6px 0 0;
    font-size: 13px;
    color: var(--text-light);
}

.info-label {
    width: 70px;
    color: var(--text-light);
    flex-shrink: 0;
}

.info-row.relation {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.info-row.relation span:last-child {
    font-weight: 600;
    color: var(--primary-color);
}

/* 解卦结果 */
.interpretation-section {
    background: var(--card-bg);
}

.interpretation-section h3 {
    font-size: 16px;
    color: var(--primary-color);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.interpretation-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-color);
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 8px;
}

/* Markdown 样式 */
.interpretation-content .md-h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 20px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.interpretation-content .md-h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 18px 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.interpretation-content .md-h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 16px 0 8px 0;
}

.interpretation-content .md-p {
    margin: 10px 0;
    text-align: justify;
}

.interpretation-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

.interpretation-content em {
    font-style: italic;
    color: var(--text-light);
}

.interpretation-content .md-hr {
    border: none;
    border-top: 1px dashed var(--border-color);
    margin: 16px 0;
}

.interpretation-content .md-quote {
    margin: 12px 0;
    padding: 10px 15px;
    background: var(--bg-color);
    border-left: 3px solid var(--primary-color);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: var(--text-light);
}

.interpretation-content .md-li {
    margin: 6px 0;
    padding-left: 20px;
    position: relative;
    list-style: none;
}

.interpretation-content .md-li::before {
    content: '•';
    position: absolute;
    left: 6px;
    color: var(--primary-color);
    font-weight: bold;
}

.interpretation-content .md-li-num {
    margin: 6px 0;
    padding-left: 8px;
    list-style: none;
}

.interpretation-content .md-li-num .num {
    color: var(--primary-color);
    font-weight: 600;
    margin-right: 4px;
}

.interpretation-content .loading {
    text-align: center;
    color: var(--text-light);
    padding: 30px 20px;
    font-size: 14px;
}

.interpretation-content .loading::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* 滚动条样式 */
.interpretation-content::-webkit-scrollbar {
    width: 6px;
}

.interpretation-content::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 3px;
}

.interpretation-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.interpretation-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* 打赏区域 */
.donate-section {
    margin-top: 24px;
    padding-top: 20px;
    text-align: center;
}

.donate-divider {
    width: 60%;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    margin: 0 auto 20px auto;
}

.donate-text {
    font-size: 15px;
    color: var(--primary-color);
    margin-bottom: 6px;
    font-weight: 500;
}

.donate-subtext {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.donate-qrcode {
    width: 160px;
    height: 160px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    object-fit: contain;
    background: white;
    padding: 8px;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-light);
    font-size: 13px;
    background: transparent;
    box-shadow: none;
}

.about-link {
    display: block;
    margin-top: 12px;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.about-link:hover {
    opacity: 1;
    text-decoration: underline;
}

body.lang-en .about-link {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-style: italic;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* 响应式调整 */
@media (max-width: 360px) {
    .container {
        padding: 12px;
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    .method-option {
        min-width: calc(50% - 8px);
    }
    
    .hexagram-display {
        gap: 8px;
    }
    
    .hexagram-card {
        padding: 12px 4px;
    }
}
