* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f5f7; /* Apple浅灰背景 */
    --card: #ffffff;
    --text: #1d1d1f;
    --subtext: #6e6e73;
    --accent: #007aff; /* iOS蓝 */
    --success: #34c759; /* iOS绿 */
    --error: #ff3b30; /* iOS红 */
    --shadow: 0 12px 28px rgba(0,0,0,0.08);
    --radius: 18px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    text-align: center;
    margin-bottom: 28px;
    color: var(--text);
}

header h1 {
    font-size: 44px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 16px;
    color: var(--subtext);
}

main {
    background: rgba(255,255,255,0.75);
    backdrop-filter: saturate(180%) blur(16px);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.search-section { margin-bottom: 20px; }

.search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

#wordInput {
    flex: 1;
    padding: 14px 16px;
    border: 1px solid #e6e6ea;
    border-radius: 12px;
    font-size: 17px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

#wordInput:focus {
    outline: none;
    border-color: #b2b2b6;
    box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}

.search-btn {
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.2s ease;
    min-width: 120px;
}

.search-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 16px rgba(0,122,255,0.25); }
.search-btn:active { transform: translateY(0); box-shadow: none; }
.search-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.search-tips { color: var(--subtext); font-size: 14px; }

.results-section {
    margin-bottom: 20px;
    padding: 20px;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #eef0f3;
}

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

.result-header h2 { color: var(--text); font-size: 24px; }

.result-actions { display: flex; gap: 10px; }

.btn-secondary {
    padding: 10px 16px;
    background: #e9e9eb;
    color: var(--text);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

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

.btn-primary {
    padding: 12px 18px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    transition: transform 0.08s ease, box-shadow 0.2s ease;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 16px rgba(0,122,255,0.25); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }

.loading { text-align: center; padding: 28px; }

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin { 0%{transform: rotate(0deg);} 100%{transform: rotate(360deg);} }

.etymology-text { line-height: 1.75; color: #2c2c2e; white-space: pre-line; }
.etymology-text h1, .etymology-text h2, .etymology-text h3 { color: var(--text); margin-top: 18px; margin-bottom: 8px; }
.etymology-text p { margin-bottom: 12px; }

.history-section { border-top: 1px solid #eee; padding-top: 22px; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-header h3 { color: var(--text); font-size: 18px; }

.history-list { display: grid; gap: 12px; grid-template-columns: 1fr; }

.history-item { width: 100%; max-width: 100%; padding: 14px; background: #fff; border-radius: 12px; border: 1px solid #eef0f3; cursor: pointer; transition: transform 0.1s ease, box-shadow 0.2s ease; }
.history-item:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

.history-word { font-weight: 600; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.history-time { color: var(--subtext); font-size: 13px; }
.history-preview { color: #6e6e73; font-size: 13px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: break-word; overflow-wrap: anywhere; }

.history-section, main { overflow: hidden; }
.results-section { overflow: visible; }
#whyAnswer { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }

.etymology-text { line-height: 1.8; color: #2c2c2e; white-space: normal; word-break: break-word; overflow-wrap: anywhere; }
.etymology-text h1 { font-size: 22px; margin: 12px 0 8px; font-weight: 700; letter-spacing: -0.01em; }
.etymology-text h2 { font-size: 20px; margin: 12px 0 8px; font-weight: 650; }
.etymology-text h3 { font-size: 18px; margin: 10px 0 6px; font-weight: 600; }
.etymology-text p { margin: 8px 0; color: #3a3a3c; }
.etymology-text ul, .etymology-text ol { margin: 6px 0 10px 18px; padding-left: 8px; }
.etymology-text li { margin: 4px 0; }
.etymology-text strong { color: #1d1d1f; }
.etymology-text em { color: #333; }
.etymology-text hr { border: none; border-top: 1px solid #eceef1; margin: 12px 0; }
.etymology-text h1, .etymology-text h2, .etymology-text h3 { color: var(--text); margin-top: 18px; margin-bottom: 8px; }
.etymology-text p { margin-bottom: 12px; }

.empty-history { text-align: center; padding: 28px; color: var(--subtext); }
.empty-history p.small { font-size: 13px; margin-top: 8px; opacity: 0.9; }

footer { text-align: center; color: var(--subtext); }
.footer-content { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }

.api-status { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; background: #ffc107; animation: pulse 2s infinite; }
.status-indicator.connected { background: var(--success); }
.status-indicator.error { background: var(--error); }
@keyframes pulse { 0%{opacity:1;} 50%{opacity:0.5;} 100%{opacity:1;} }

.modal { position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.28); display: flex; justify-content: center; align-items: center; }
.modal-content { background: rgba(255,255,255,0.85); backdrop-filter: saturate(180%) blur(16px); padding: 26px; border-radius: 16px; max-width: 520px; width: 92%; text-align: center; position: relative; box-shadow: var(--shadow); }
.close { position: absolute; right: 16px; top: 14px; font-size: 22px; cursor: pointer; color: #999; }
.close:hover { color: var(--text); }

.message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    z-index: 1001;
    animation: slideIn 0.25s ease;
    box-shadow: 0 8px 16px rgba(52,199,89,0.3);
}

@keyframes slideIn { from{transform: translateX(100%); opacity:0;} to{transform: translateX(0); opacity:1;} }

@media (max-width: 768px) {
    .container { padding: 15px; }
    header h1 { font-size: 36px; }
    main { padding: 20px; }
    .search-box { flex-direction: column; }
    .search-btn { width: 100%; }
    .result-header { flex-direction: column; gap: 10px; align-items: flex-start; }
    .footer-content { flex-direction: column; text-align: center; }
}


/* 思考过程面板样式 */
.thinking-panel {
    margin-top: 12px;
    padding: 14px;
    background: #ffffffcc;
    backdrop-filter: saturate(180%) blur(12px);
    border: 1px solid #eef0f3;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-height: 220px;
    overflow: auto;
}
.thinking-panel.expanded {
    max-height: none;
    overflow: visible;
}
.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--subtext);
    font-size: 14px;
}
.thinking-header .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.8s infinite;
}
.thinking-title {
    font-weight: 600;
}
.thinking-content {
    font-size: 14px;
    color: #3a3a3c;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.thinking-content .step {
    display: inline; /* 改为行内，避免每块独占一行 */
    margin-right: 2px;
}

/* 轻微打字效果 */
@keyframes typing { from { opacity: 0.6 } to { opacity: 1 } }
.typing { animation: typing 0.25s ease; }
/* 多问为什么 面板样式 */
.why-panel { margin-top: 16px; padding: 16px; background: #fff; border: 1px solid #eef0f3; border-radius: 12px; box-shadow: var(--shadow); }
.why-header { margin-bottom: 10px; }
.why-header h3 { font-size: 18px; color: var(--text); margin-bottom: 4px; }
.why-header .small { color: var(--subtext); font-size: 13px; }
.why-inputs { display: grid; grid-template-columns: 1fr; gap: 10px; }
.why-item { display: flex; align-items: center; gap: 8px; }
.why-prefix { background: #f2f2f7; color: var(--text); border: 1px solid #e6e6ea; padding: 8px 10px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.why-input { flex: 1; padding: 10px 12px; border: 1px solid #e6e6ea; border-radius: 10px; font-size: 15px; }
.why-input:focus { outline: none; border-color: #b2b2b6; box-shadow: 0 0 0 3px rgba(0,122,255,0.15); }
.why-actions { margin-top: 8px; display: flex; justify-content: flex-end; }
@media (min-width: 768px) { .why-inputs { grid-template-columns: 1fr 1fr 1fr; } }
.thinking-content {
    font-size: 14px;
    color: #3a3a3c;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 10px;
    background: #ffffff;
    border: 1px solid #eef0f3;
    border-radius: 999px;
    box-shadow: var(--shadow);
    transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.brand-mark {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #007aff 0%, #34c759 100%);
    border-radius: 50%;
    box-shadow: 0 6px 12px rgba(0,0,0,0.12);
    font-size: 14px;
}
.brand-name {
    font-size: 14px;
    color: var(--subtext);
    letter-spacing: 0.2px;
}
.brand-logo:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0,0,0,0.12); background: #fff; }
@media (max-width: 768px) {
    .brand-name { font-size: 13px; }
    .brand-mark { width: 18px; height: 18px; font-size: 12px; }
}
.thinking-content {
    font-size: 14px;
    color: #3a3a3c;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* 用户栏 */
.user-bar { margin-top: 12px; display: flex; justify-content: center; gap: 10px; align-items: center; }
.user-info { color: var(--text); font-size: 14px; font-weight: 600; }
.auth-actions { display: inline-flex; gap: 8px; }

/* 认证弹窗样式 */
.modal-content.auth { max-width: 480px; }
.tabs { display: inline-flex; gap: 8px; margin: 10px 0; }
.tab-btn { padding: 8px 12px; background: #f2f2f7; border: 1px solid #e6e6ea; border-radius: 10px; cursor: pointer; font-size: 14px; }
.tab-btn.active { background: #fff; box-shadow: var(--shadow); }
.auth-body { display: grid; gap: 12px; margin-top: 8px; }
.auth-section { display: grid; gap: 10px; }
.auth-section input { padding: 10px 12px; border: 1px solid #e6e6ea; border-radius: 10px; font-size: 15px; }
.auth-section input:focus { outline: none; border-color: #b2b2b6; box-shadow: 0 0 0 3px rgba(0,122,255,0.15); }
.auth-body .small { color: var(--subtext); font-size: 13px; }

/* 认证按钮适配 */
#logoutBtn { background: #e9e9eb; }
#openAuthBtn { background: #e9e9eb; }

}