/* =========================================
   全局变量与基础重置
   ========================================= */
:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --bg-color: #f8f9fa;
    --text-color: #2c3e50;
    --border-color: #e0e6ed;
    --color-prefix: #e74c3c;
    --color-root: #f39c12;
    --color-suffix: #27ae60;
    --color-meta: #8e44ad;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

.hidden { display: none !important; }

/* =========================================
   主容器与瀑布流布局
   ========================================= */
.container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px; /* 极简高级感，控制最宽边界 */
    margin: 0 auto;
    padding: 15px;
    gap: 20px; 
    overflow-x: hidden; 
}

/* =========================================
   头部与 Logo
   ========================================= */
.app-header {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-img {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* =========================================
   搜索区域 (强力横向锁定，防止按钮掉落)
   ========================================= */
.search-box {
    display: flex;
    width: 100%;
    gap: 10px;    /* 搜索框和按钮之间的固定间距 */
}

#word-input {
    flex-grow: 1; /* 死死霸占剩余空间 */
    padding: 12px 16px;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
}

#word-input:focus { 
    border-color: var(--primary-color); 
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

#search-btn {
    padding: 0 20px;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap; /* 绝对禁止内部文字换行 */
    box-shadow: 0 4px 6px rgba(52, 152, 219, 0.2);
    transition: transform 0.1s, background-color 0.2s;
}

#search-btn:hover { background-color: var(--primary-dark); }
#search-btn:active { transform: scale(0.95); }

/* =========================================
   单词解释与发音区域
   ========================================= */
.word-details {
    margin-top: 20px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.word-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.word-title {
    font-size: 2rem;
    font-weight: 800;
    color: #2c3e50;
    margin: 0;
}

.phonetic {
    font-size: 1.1rem;
    color: #7f8c8d;
    font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
}

.definition {
    font-size: 1.1rem;
    color: #34495e;
    line-height: 1.6;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.play-audio-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s;
}

.play-audio-btn:hover { transform: scale(1.1); }

/* =========================================
   积木拆解结果区域
   ========================================= */
.parts-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 10px 0;
}

.part-lego {
    background: white;
    padding: 12px 18px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 4px solid transparent;
}

.part-lego:hover, .part-lego.active {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

/* 积木颜色系统 */
.part-lego.prefix { 
    background-color: #fceae9; 
    border-bottom: 4px solid var(--color-prefix); 
}
.part-lego.prefix .part-text { color: var(--color-prefix); }

.part-lego.root { 
    background-color: #fef5e6; 
    border-bottom: 4px solid var(--color-root); 
}
.part-lego.root .part-text { color: var(--color-root); }

.part-lego.meta_root, .part-lego.meta_word { 
    background-color: #f4eefe; 
    border-bottom: 4px solid var(--color-meta); 
}
.part-lego.meta_root .part-text, .part-lego.meta_word .part-text { color: var(--color-meta); }

.part-lego.suffix { 
    background-color: #eaf7f0; 
    border-bottom: 4px solid var(--color-suffix); 
}
.part-lego.suffix .part-text { color: var(--color-suffix); }

.part-text {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.part-type {
    font-size: 0.75rem;
    color: #95a5a6;
    text-transform: uppercase;
}

.part-meaning {
    font-size: 0.85rem;
    color: #34495e;
    margin-top: 3px;
    text-align: center;
}

/* =========================================
   同源范例展示区域
   ========================================= */
.examples-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    min-height: 100px;
}

.placeholder-text {
    text-align: center;
    color: #bdc3c7;
    font-style: italic;
    margin-top: 20px;
}

.examples-title {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.example-item {
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
}

.example-word {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.1rem;
    margin-right: 10px;
}

.example-meaning {
    color: #555;
    font-size: 0.95rem;
}

/* =========================================
   底部历史记录 (标签云形)
   ========================================= */
.history-panel {
    margin-top: 20px;
    border-top: 1px dashed #bdc3c7;
    padding-top: 20px;
}

.history-panel h3 { 
    margin-bottom: 15px; 
    font-size: 1rem; 
    color: #7f8c8d; 
}

.history-list {
    display: flex;
    flex-wrap: wrap; /* 满行自动换行 */
    gap: 10px;
    list-style: none;
    padding: 0;
}

.history-item {
    background-color: #f1f2f6;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #34495e;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover { 
    background-color: #dfe6e9; 
}

.clear-btn {
    margin-top: 15px;
    padding: 6px 15px;
    background: transparent;
    border: 1px solid #e74c3c;
    color: #e74c3c;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.clear-btn:hover {
    background-color: #e74c3c;
    color: white;
}