/* ============================================================
   style.css - 全局样式
   风格：Material Design 风，纯 CSS，支持移动端适配
   ============================================================ */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --bg: #f3f4f6;
  --card: #ffffff;
  --border: #e5e7eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow: 0 4px 16px rgba(0, 0, 0, .08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .14);
  --header-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

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

html, body { height: 100%; }

/* 关键：确保 hidden 属性始终生效（优先级高于 .spinner/.state-box 等的 display） */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
}

.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* ---------------- 表单 ---------------- */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

/* ---------------- 登录页 ---------------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #ede9fe 100%);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 32px;
}
.auth-logo {
  font-size: 44px;
  text-align: center;
  line-height: 1;
  margin-bottom: 12px;
}
.auth-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}
.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin: 6px 0 26px;
}
.auth-footer {
  margin-top: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
}

.error-message {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------------- 顶栏 ---------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 980px;
  height: 100%;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 5px 12px;
}
.reader-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
  flex: 1;
  text-align: center;
}

/* ---------------- 主内容区 ---------------- */
.app-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 80px 20px;
  color: var(--text-secondary);
  text-align: center;
}
.state-box p { font-size: 14px; }

.empty-box {
  text-align: center;
  color: var(--text-light);
  padding: 60px 20px;
  font-size: 14px;
}

/* ---------------- 分组与文章列表 ---------------- */
.group {
  margin-bottom: 28px;
}
.group-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  padding: 8px 14px;
  margin-bottom: 10px;
  background: var(--card);
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.group-title::after {
  content: attr(data-count);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  background: var(--bg);
  border-radius: 999px;
  padding: 2px 10px;
}

.article-list {
  list-style: none;
}
.article-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.article-item:hover {
  box-shadow: var(--shadow);
  border-color: #c7d2fe;
  transform: translateY(-1px);
}
.article-info {
  min-width: 0; /* 允许子元素省略 */
  flex: 1;
}
.article-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.article-sub {
  font-size: 12px;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

/* ---------------- 阅读页 ---------------- */
.reader-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.reader-main {
  flex: 1;
  position: relative;
  background: var(--card);
}
.reader-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
/* 阅读页内的加载/错误浮层 */
.reader-main .state-box {
  position: absolute;
  inset: 0;
  background: var(--card);
  z-index: 10;
}

/* ---------------- 忙碌遮罩 ---------------- */
.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(255, 255, 255, .75);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ---------------- 加载动画 ---------------- */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
}
.btn .spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------- Toast ---------------- */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: #1f2937;
  color: #fff;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 1;
  transition: opacity .3s, transform .3s;
  animation: toast-in .25s ease;
}
.toast-error { background: var(--danger); }
.toast-success { background: var(--success); }
.toast-out { opacity: 0; transform: translateY(-8px); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 640px) {
  .app-main { padding: 16px 12px 40px; }
  .article-item { flex-direction: column; align-items: stretch; }
  .article-item .btn { align-self: flex-start; }
  .auth-card { padding: 32px 24px 26px; }
  .reader-title { max-width: 160px; }
  .user-chip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
