:root {
  --md-sys-color-primary: #006495;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #cbe6ff;
  --md-sys-color-on-primary-container: #001e30;
  --md-sys-color-secondary-container: #cbe6ff;
  --md-sys-color-surface: #fdfcff;
  --md-sys-color-on-surface: #1a1c1e;
  --md-sys-color-surface-container: #f0f4f8;
  --md-sys-color-outline: #4e5663;
  
  /* MD3 Expressive #dce2e9*/
  --shape-corner-xl: 28px;
  --shape-corner-l: 24px;
  --shape-corner-m: 16px;
  
  --motion-easing-emphasized: cubic-bezier(0.2, 0.0, 0.0, 1.0);
  --safe-top: env(safe-area-inset-top, 20px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --md-sys-color-surface: #1a1c1e;
    --md-sys-color-on-surface: #e2e2e6;
    --md-sys-color-surface-container: #202429;
    --md-sys-color-primary-container: #004b73;
    --md-sys-color-primary: #93cae4;
    --md-sys-color-on-primary: #00324c;
    --md-sys-color-secondary-container: #3e4449;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: 'Roboto', system-ui, sans-serif; background: var(--md-sys-color-surface); color: var(--md-sys-color-on-surface); }

/* --- 1. 顶部栏 (Logo 绝对居中修复) --- */
.top-app-bar { 
    height: 64px; display: flex; align-items: center; justify-content: space-between; 
    padding: 0 16px; background: var(--md-sys-color-surface); 
    position: sticky; top: 0; z-index: 100; 
}

.logo-container {
    position: absolute; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; justify-content: center;
}

.app-logo { height: 28px; width: auto; }
@media (prefers-color-scheme: dark) { .app-logo { filter: brightness(0) invert(1); } }

/* 占位，防止左右按钮把logo挤歪 */
.action-group { display: flex; gap: 4px; }

/* --- 2. 核心布局 (Responsive Grid) --- */
.main-layout { 
    max-width: 1200px; margin: 0 auto; padding: 16px; 
    display: flex; flex-direction: column; gap: 24px; 
}

@media (min-width: 900px) {
    .main-layout {  
        display: grid; 
        grid-template-columns: 460px 1fr; 
                  /* ---  360px 1fr) --- */
        gap: 32px; align-items: start; 
    }
    .left-column { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 24px; }
    .mobile-only-area { display: none !important; }
    .desktop-only-area { display: block !important; }
}

@media (max-width: 899px) {
    .left-column { display: flex; flex-direction: column; gap: 20px; }
    .desktop-only-area { display: none !important; }
    .mobile-only-area { display: block !important; margin-top: 32px; }
}

/* --- 3. 新闻头条 (增强显示 & 交互) --- */
.headlines-section {
    position: relative; width: 100%; aspect-ratio: 11/10; 
    max-height: 400px;
    border-radius: var(--shape-corner-xl);
    overflow: hidden;
    touch-action: pan-y; /* 允许垂直滚动，拦截水平滑动 */
    background: var(--md-sys-color-surface-container);
}

.headline-item {
    position: absolute; inset: 0; opacity: 0; 
    transition: opacity 600ms ease-in-out;
    background-size: cover; background-position: center; z-index: 0;
}
.headline-item.active { opacity: 1; z-index: 1; }

.headline-overlay {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 15%, transparent 100%);
    padding: 24px 20px 24px; color: white;
    display: flex; flex-direction: column; gap: 6px;
}

/* 头条文字优化 */
.headline-title { font-size: 1.3rem; font-weight: bold; line-height: 1.3; }
.headline-desc {
    font-size: 0.9rem; opacity: 0.9;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    line-height: 1.4;
}
.headline-meta { font-size: 0.75rem; opacity: 0.7; margin-top: 4px; }

/* --- 4. 快捷服务 (折叠动画) --- */
.menu-grid { 
    display: grid; grid-template-columns: repeat(4, 1fr); 
    gap: 12px; row-gap: 20px;
    max-height: 90px; overflow: hidden;
    transition: max-height 0.4s var(--md-sys-motion-easing-emphasized);
}
.menu-grid.expanded { max-height: 500px; }
.card { background: var(--md-sys-color-surface-container); border-radius: var(--shape-corner-l); padding: 20px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.menu-item { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: inherit; gap: 8px; text-align: center; }
.menu-icon-box { 
    width: 48px; height: 48px; 
    background: var(--md-sys-color-primary-container); 
    color: var(--md-sys-color-on-primary-container); 
    border-radius: 16px; 
    display: flex; align-items: center; justify-content: center; 
}
.menu-item p { font-size: 0.75rem; font-weight: 500; opacity: 0.9; }

/* --- 5. 夜间模式 & 弹窗修复 --- */
dialog { 
    border: none; background: var(--md-sys-color-surface); 
    color: var(--md-sys-color-on-surface); /* 关键修复：文字颜色 */
    margin: auto; padding: 0; 
}
dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }

.fullscreen-dialog { width: 100%; height: 100%; max-width: 100%; max-height: 100%; }
.center-dialog { width: min(90%, 360px); border-radius: var(--shape-corner-xl); max-height: 80vh; }
.dialog-header { padding: 16px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid rgba(128,128,128, 0.1); }

/* 输入框 & 下拉框 夜间模式修复 */
.search-input-field { 
    flex: 1; border: none; background: transparent; 
    font-size: 1.1rem; outline: none; 
    color: var(--md-sys-color-on-surface); /* 强制继承颜色 */
}

.styled-select { 
    padding: 8px; border-radius: 8px; 
    border: 1px solid var(--md-sys-color-outline); 
    background: transparent; 
    color: var(--md-sys-color-on-surface); /* 强制继承颜色 */
}
.styled-select option {
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
}

/* 搜索结果 Chip */
.search-action-chip {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-surface);
    padding: 8px 16px; border-radius: 12px;
    margin-right: 8px; margin-bottom: 8px;
    font-size: 0.9rem; font-weight: 500; text-decoration: none;
}

/* --- 6. 归档 UI (MD3 Expressive 风格) --- */
.archive-toolbar { padding: 16px; display: flex; flex-direction: column; gap: 16px; background: var(--md-sys-color-surface); }
.year-selector { 
    display: flex; align-items: center; justify-content: space-between; 
    font-size: 1.5rem; font-weight: bold; 
    padding: 8px 16px; background: var(--md-sys-color-surface-container);
    border-radius: 16px;
}
.month-scroller { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 4px; scrollbar-width: none; }
.month-chip { 
    flex: 0 0 auto; width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; /* 圆形触摸目标 */
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    font-weight: 500; font-size: 0.9rem;
    transition: all 0.2s; cursor: pointer;
}
.month-chip.active { 
    background: var(--md-sys-color-primary); 
    color: var(--md-sys-color-on-primary); 
    font-weight: bold; transform: scale(1.1);
}

/* --- 其他通用样式保持不变 --- */
.news-card { display: flex; background: var(--md-sys-color-surface-container); border-radius: var(--shape-corner-l); margin-bottom: 16px; cursor: pointer; overflow: hidden; min-height: 130px; }
.news-img { width: 130px; object-fit: cover; }
.news-content { padding: 16px 20px; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.news-card.text-only .news-content { padding: 20px 24px; }
.news-tag { color: var(--md-sys-color-primary); font-size: 0.75rem; font-weight: 700; margin-bottom: 6px; }
.news-title { font-size: 1.05rem; font-weight: 600; line-height: 1.4; margin-bottom: 6px; }
.news-meta { font-size: 0.8rem; color: var(--md-sys-color-outline); }

.app-download-card { display: flex; align-items: center; justify-content: space-between; background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); padding: 16px 20px; border-radius: var(--shape-corner-xl); }
.dl-content { display: flex; align-items: center; gap: 16px; }
.dl-icon { font-size: 32px; }
.footer-text { text-align: center; margin-top: 16px; font-size: 0.75rem; color: var(--md-sys-color-outline); }

.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 300px; background: var(--md-sys-color-surface-container); z-index: 200; transform: translateX(-100%); transition: transform 0.4s var(--motion-easing-emphasized); padding: 16px; box-shadow: 1px 0 10px rgba(0,0,0,0.1); }
.drawer.open { transform: translateX(0); }
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 150; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.drawer.open + .drawer-scrim { opacity: 1; pointer-events: auto; }
.drawer-item { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: var(--shape-corner-m); text-decoration: none; color: var(--md-sys-color-on-surface); font-weight: 500; }
.drawer-item:active { background: rgba(0,0,0,0.05); }

.icon-btn { background:none; border:none; padding:8px; border-radius:50%; color:inherit; cursor:pointer; }
.icon-btn.on-primary { color: var(--md-sys-color-primary); background: var(--md-sys-color-on-primary); }
.text-btn { background:none; border:none; color:var(--md-sys-color-primary); font-weight:600; cursor:pointer; padding:4px 8px; }
.tonal-btn { background:var(--md-sys-color-secondary-container); color:var(--md-sys-color-on-surface); border:none; padding:10px 20px; border-radius:12px; font-weight:600; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: var(--md-sys-color-outline); border-radius: 34px; transition: .3s; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: var(--md-sys-color-primary); }
input:checked + .slider:before { transform: translateX(20px); }























/* =========================================================
   Settings Dialog
   ========================================================= */

/* 整个设置弹窗 */
#settings-dialog {
  padding: 0;
}

/* Header：*/
#settings-dialog .dialog-header {
  padding: 20px 24px;
  gap: 12px;
}

/* 内容区域：有呼吸感 + 小屏可滚动 */
#settings-dialog .dialog-content {
  padding: 24px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;                 /* 关键：行间距 */
  max-height: 60vh;          /* 防止小屏溢出 */
  overflow-y: auto;
}

/* 单个设置项 = 卡片 */
#settings-dialog .setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;

  min-height: 56px;          /* Material 推荐触控高度 */
  padding: 12px 16px;

  background: var(--md-sys-color-surface-container);
  border-radius: 16px;
}

/* 左侧文字 */
#settings-dialog .setting-label {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.1px;
}

/* select 下拉框 */
#settings-dialog .styled-select {
  min-width: 120px;
  height: 40px;
}

/* switch 微调（视觉更平衡） */
#settings-dialog .switch {
  transform: scale(1.05);
}

/* iOS 滚动更顺滑 */
#settings-dialog .dialog-content {
  -webkit-overflow-scrolling: touch;
}

.icon-btn { background:none; border:none; padding:8px; border-radius:50%; color:inherit; cursor:pointer; }
.icon-btn.on-primary { color: var(--md-sys-color-primary); background: var(--md-sys-color-on-primary); }
.text-btn { background:none; border:none; color:var(--md-sys-color-primary); font-weight:600; cursor:pointer; padding:4px 8px; }
.tonal-btn { background:var(--md-sys-color-secondary-container); color:var(--md-sys-color-on-surface); border:none; padding:10px 20px; border-radius:12px; font-weight:600; cursor: pointer; }

dialog {
    border: none; background: var(--md-sys-color-surface);
    margin: auto; padding: 0; box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }


/* --- 侧边栏 Drawer (修复版) --- */
.drawer {
    position: fixed; top: 0; left: 0; bottom: 0; width: 300px;
    background: var(--md-sys-color-surface-container);
    z-index: 200;
    transform: translateX(-100%); /* 默认移出屏幕 */
    transition: transform var(--motion-duration-medium) var(--motion-easing-emphasized);
    padding: 16px;
    box-shadow: 1px 0 10px rgba(0,0,0,0.1);
    display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; padding-top: var(--safe-top); }
.drawer-content { display: flex; flex-direction: column; gap: 8px; }
.drawer-item {
    display: flex; align-items: center; gap: 16px; padding: 16px;
    border-radius: var(--shape-corner-m);
    text-decoration: none; color: var(--md-sys-color-on-surface);
    font-weight: 500;
    transition: background 0.2s;
}
.drawer-item:active, .drawer-item:hover { background: rgba(0,0,0,0.05); }

.drawer-scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 150;
    opacity: 0; pointer-events: none; /* 默认不挡点击 */
    transition: opacity 0.3s;
}
.drawer.open + .drawer-scrim { opacity: 1; pointer-events: auto; }

/* --- 顶部栏 --- */
.top-app-bar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; background: var(--md-sys-color-surface); position: sticky; top: 0; z-index: 100; }
.logo-container { flex: 1; display: flex; justify-content: center; }
.app-logo { height: 28px; width: auto; }
@media (prefers-color-scheme: dark) { .app-logo { filter: brightness(0) invert(1); } }
.app-logo { height: 28px; width: auto; }
@media (prefers-color-scheme: dark) { .app-logo { filter: brightness(0) invert(1); } }
